diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsAddPage.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsAddPage.java index 3f0513735..c6d77d99b 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsAddPage.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsAddPage.java @@ -13,7 +13,14 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Res import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; /** - * TODO + * Handle the "Add new account" form display and submission. + * + * TODO Associate a profile from this account + * + * TODO Handle sending of email. + * + * TODO Handle initial password set if email isn't available. Set password + * fields, change-required flag, account is active. */ public class UserAccountsAddPage extends UserAccountsPage { private static final String PARAMETER_SUBMIT = "submitAdd"; @@ -145,4 +152,20 @@ public class UserAccountsAddPage extends UserAccountsPage { return new TemplateResponseValues(TEMPLATE_NAME, body); } + /** + * @return + */ + public UserAccount getAddedAccount() { + // TODO Auto-generated method stub + throw new RuntimeException("UserAccountsAddPage.getAddedAccount() not implemented."); + } + + /** + * @return + */ + public boolean wasPasswordEmailSent() { + // TODO Auto-generated method stub + throw new RuntimeException("UserAccountsAddPage.wasPasswordEmailSent() not implemented."); + } + } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsController.java index fd01a956b..c70992c47 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsController.java @@ -9,7 +9,6 @@ import org.apache.commons.logging.LogFactory; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.ManageUserAccounts; -import edu.cornell.mannlib.vitro.webapp.beans.UserAccount; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; @@ -49,7 +48,13 @@ public class UserAccountsController extends FreemarkerHttpServlet { } } else if (ACTION_EDIT.equals(action)) { - return new UserAccountsEditPage(vreq).showPage(); + UserAccountsEditPage page = new UserAccountsEditPage(vreq); + page.parseParametersAndValidate(); + if (page.isSubmit() && page.isValid()) { + return editAccountAndShowList(vreq, page); + } else { + return page.showPage(); + } } else if (ACTION_DELETE.equals(action)) { UserAccountsDeleter deleter = new UserAccountsDeleter(vreq); @@ -66,10 +71,18 @@ public class UserAccountsController extends FreemarkerHttpServlet { private ResponseValues addAccountAndShowList(VitroRequest vreq, UserAccountsAddPage addPage) { - UserAccount userAccount = addPage.createNewAccount(); + addPage.createNewAccount(); UserAccountsListPage listPage = new UserAccountsListPage(vreq); - return listPage.showPageWithNewAccount(userAccount); + return listPage.showPageWithNewAccount(addPage.getAddedAccount(), + addPage.wasPasswordEmailSent()); } + private ResponseValues editAccountAndShowList(VitroRequest vreq, + UserAccountsEditPage editPage) { + editPage.updateAccount(); + UserAccountsListPage listPage = new UserAccountsListPage(vreq); + return listPage.showPageWithUpdatedAccount( + editPage.getUpdatedAccount(), editPage.wasPasswordEmailSent()); + } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsDeleter.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsDeleter.java index 02d5b5931..834d2a60f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsDeleter.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsDeleter.java @@ -7,7 +7,9 @@ import java.util.Collection; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; /** - * TODO + * TODO delete and kick to Accounts list with message, telling how many were + * deleted. If there was a problem, the user will need to infer it from the + * count?? */ public class UserAccountsDeleter extends UserAccountsPage { @@ -16,12 +18,13 @@ public class UserAccountsDeleter extends UserAccountsPage { } /** - * @return + * @return * */ public Collection delete() { // TODO Auto-generated method stub - throw new RuntimeException("UserAccountsDeleter.delete() not implemented."); + throw new RuntimeException( + "UserAccountsDeleter.delete() not implemented."); } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsEditPage.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsEditPage.java index f1e7d637b..f9bd23c64 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsEditPage.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsEditPage.java @@ -2,12 +2,23 @@ package edu.cornell.mannlib.vitro.webapp.controller.accounts; +import edu.cornell.mannlib.vitro.webapp.beans.UserAccount; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; /** - * TODO + * TODO present the form. Get the submission. + * + * TODO If email is available, present the reset flag with message templage, and send email + * + * TODO if email is not available, allow password change with checks for validity + * + * TODO If successful, go to AccountsList with message and optional password message. + * + * TODO if unsuccessful, go back to the page, with errors. + * + * TODO How much of this can be shared with AddPage? Email templates? */ public class UserAccountsEditPage extends UserAccountsPage { private static final String TEMPLATE_NAME = "userAccounts-edit.ftl"; @@ -20,5 +31,53 @@ public class UserAccountsEditPage extends UserAccountsPage { return new TemplateResponseValues(TEMPLATE_NAME); } + /** + * @return + */ + public UserAccount updateAccount() { + // TODO Auto-generated method stub + throw new RuntimeException("UserAccountsEditPage.updateAccount() not implemented."); + } + + /** + * @return + */ + public boolean wasPasswordEmailSent() { + // TODO Auto-generated method stub + throw new RuntimeException("UserAccountsEditPage.wasPasswordEmailSent() not implemented."); + } + + /** + * @return + */ + public UserAccount getUpdatedAccount() { + // TODO Auto-generated method stub + throw new RuntimeException("UserAccountsEditPage.getUpdatedAccount() not implemented."); + } + + /** + * + */ + public void parseParametersAndValidate() { + // TODO Auto-generated method stub + throw new RuntimeException("UserAccountsEditPage.parseParametersAndValidate() not implemented."); + } + + /** + * @return + */ + public boolean isValid() { + // TODO Auto-generated method stub + throw new RuntimeException("UserAccountsEditPage.isValid() not implemented."); + } + + /** + * @return + */ + public boolean isSubmit() { + // TODO Auto-generated method stub + throw new RuntimeException("UserAccountsEditPage.isSubmit() not implemented."); + } + } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsListPage.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsListPage.java index d65f7b72e..866a77e60 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsListPage.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsListPage.java @@ -27,6 +27,11 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem /** * Handle the List page. + * + * TODO: agree with Manolo how to do the column heads as links that change the + * sort order + * + * TODO: auto-complete */ public class UserAccountsListPage extends UserAccountsPage { private static final Log log = LogFactory @@ -87,7 +92,8 @@ public class UserAccountsListPage extends UserAccountsPage { /** * We just came from adding a new account. Show the list with a message. */ - public ResponseValues showPageWithNewAccount(UserAccount userAccount) { + public ResponseValues showPageWithNewAccount(UserAccount userAccount, + boolean emailWasSent) { UserAccountsSelection selection = UserAccountsSelector.select( userAccountsModel, criteria); Map body = buildTemplateBodyMap(selection); @@ -98,6 +104,15 @@ public class UserAccountsListPage extends UserAccountsPage { return new TemplateResponseValues(TEMPLATE_NAME, body); } + /** + * We just came from editing an account. Show the list with a message. + */ + public ResponseValues showPageWithUpdatedAccount(UserAccount userAccount, + boolean emailWasSent) { + throw new RuntimeException( + "UserAccountsListPage.showPageWithUpdatedAccount not implemented."); + } + /** * We just came from deleting accounts. Show the list with a message. */ diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsSetPasswordPage.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsSetPasswordPage.java new file mode 100644 index 000000000..1c93807de --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/UserAccountsSetPasswordPage.java @@ -0,0 +1,21 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.accounts; + +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; + +/** + * TODO If hash is not valid display bogus message. + * + * TODO Set the password fields, reset the expire time, set account active, kick + * to home page with message. Send confirmation email. + * + * TODO How do we know "createPassword" from "setPassword"? a parameter? or just by account status? + */ +public class UserAccountsSetPasswordPage extends UserAccountsPage { + + protected UserAccountsSetPasswordPage(VitroRequest vreq) { + super(vreq); + } + +}