1 5 package org.enhydra.pim.presentation.enhydrapim; 6 7 import org.enhydra.pim.business.UserManagerI; 8 import org.enhydra.pim.business.api.OwnerI; 9 import org.enhydra.pim.presentation.BasePO; 10 import org.enhydra.pim.spec.UserManagerFactory; 11 import org.enhydra.xml.xmlc.XMLObject; 12 13 import com.lutris.appserver.server.httpPresentation.ClientPageRedirectException; 14 import com.lutris.appserver.server.httpPresentation.HttpPresentationException; 15 16 21 public class Register extends BasePO { 22 23 private static final String PASSWORD2 = "password2"; 24 25 private static final String PASSWORD1 = "password1"; 26 27 private static final String USERNAME = "userName"; 28 29 34 public XMLObject handleDefault() throws HttpPresentationException { 35 return showPage(); 36 } 37 38 43 protected boolean loggedInUserRequired() { 44 return false; 46 } 47 48 55 public XMLObject handleRegister() throws HttpPresentationException { 56 57 String userName = this.getComms().request.getParameter(USERNAME); 58 String password1 = this.getComms().request.getParameter(PASSWORD1); 59 String password2 = this.getComms().request.getParameter(PASSWORD2); 60 61 if (userName.length() == 0 || password1.length() == 0 || password1.length() == 0) { 64 return showErrorPage("Missing information. Please make sure all fields are filled out exactly"); 65 } 66 67 if (!password1.equals(password2)) { 69 return showErrorPage("Please make sure your password and password confirmation match exactly"); 70 } 71 72 78 79 try { 80 UserManagerI uMan = UserManagerFactory.getUserManager(); 81 OwnerI user = uMan.checkOwner(userName, password1); 82 if (user == null) { 84 uMan.registerOwner(userName, password1); 85 this.getSessionData().setUserMessage("You are registered, " + userName + ", please log in"); 86 throw new ClientPageRedirectException(LOGIN_PAGE); 87 } else { 91 return showErrorPage("The login name " + userName + " is already taken. Please try another."); 92 } 93 } catch (Exception ex) { 94 return showErrorPage("Exception during login operation"); 95 } 96 97 } 98 99 105 public XMLObject showPage() throws HttpPresentationException { 106 RegisterHTML page = (RegisterHTML) myComms.xmlcFactory.create(RegisterHTML.class); 107 return page; 108 } 109 110 } | Popular Tags |