1 23 24 package transactionsDiscRack.presentation.personMgmt; 25 26 import transactionsDiscRack.spec.*; 27 import transactionsDiscRack.presentation.BasePO; 28 import transactionsDiscRack.presentation.TransactionsDiscRackPresentationException; 29 30 import com.lutris.appserver.server.httpPresentation.*; 31 import com.lutris.appserver.server.session.*; 32 import com.lutris.util.*; 33 import org.w3c.dom.*; 36 import org.w3c.dom.html.*; 37 import org.enhydra.xml.xmlc.XMLObject; 38 39 43 public class Login extends BasePO { 44 45 48 private static String SUBMIT_NAME = "submit"; 49 private static String LOGIN_NAME = "login"; 50 private static String PASSWORD_NAME = "password"; 51 private static String ERROR_NAME = "ERROR_NAME"; 52 53 56 public boolean loggedInUserRequired() { 57 return false; 58 } 59 60 63 public XMLObject handleDefault() 64 throws HttpPresentationException { 65 return showPage(null); 66 } 67 68 74 public XMLObject handleLogin() 75 throws HttpPresentationException { 76 String login = this.getComms().request.getParameter(LOGIN_NAME); 77 String password = this.getComms().request.getParameter(PASSWORD_NAME); 78 79 80 Person user = null; 81 82 87 try { 88 89 user =((PersonGenerator)PersonGeneratorFactory.getPersonGenerator("transactionsDiscRack.business.person.PersonGeneratorImpl")).findPerson(login); 90 if(null == user || !user.getPassword().equals(password)) { 91 return showPage("Invalid username or password"); 92 } else { 94 this.setUser(user); 95 user.dbtRelease(); 96 throw new ClientPageRedirectException(getComms().request.getApplicationPath()+DISC_CATALOG_PAGE); 97 98 } 99 }catch(NullPointerException ex){ 100 101 throw new ClientPageRedirectException(getComms().request.getApplicationPath()+DISC_CATALOG_PAGE); 102 103 104 } catch(TransactionsDiscRackException ex) { 105 if (user != null) 106 user.dbtRelease(); 107 this.writeDebugMsg("System error finding user: " + ex.getMessage()); 108 throw new TransactionsDiscRackPresentationException("System error finding user", ex); 109 } 110 } 111 112 118 public XMLObject handleLogout() 119 throws HttpPresentationException { 120 this.removeUserFromSession(); 121 return (ExitHTML)myComms.xmlcFactory.create(ExitHTML.class); 122 } 124 125 131 public XMLObject handleThrowException() 132 throws Exception { 133 throw new Exception ("This is a test exception thrown from Login.java handleThrowException()"); 134 } 135 136 142 public XMLObject showPage(String errorMsg) { 143 144 LoginHTML page = (LoginHTML)myComms.xmlcFactory.create(LoginHTML.class); 145 146 if(null != errorMsg || 147 null != (errorMsg = this.getSessionData().getAndClearUserMessage())) { 148 page.setTextErrorText(errorMsg); 149 } else { 150 page.getElementErrorText().getParentNode().removeChild(page.getElementErrorText()); 151 } 152 153 return page; 154 } 155 } 156 157 158 | Popular Tags |