NIHVIVO-2279 Add more functions to the UserAccount controller.
This commit is contained in:
parent
4d1443a40d
commit
fabf46d1e7
6 changed files with 144 additions and 10 deletions
|
@ -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.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
@ -21,7 +23,8 @@ public class UserAccountsDeleter extends UserAccountsPage {
|
|||
*/
|
||||
public Collection<String> delete() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new RuntimeException("UserAccountsDeleter.delete() not implemented.");
|
||||
throw new RuntimeException(
|
||||
"UserAccountsDeleter.delete() not implemented.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String, Object> 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.
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue