KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > airsent > presentation > customer > Login


1 /*
2  * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
3  * Reserved.
4  *
5  * This source code file is distributed by Lutris Technologies, Inc. for
6  * use only by licensed users of product(s) that include this source
7  * file. Use of this source file or the software that uses it is covered
8  * by the terms and conditions of the Lutris Enhydra Development License
9  * Agreement included with this product.
10  *
11  * This Software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
12  * ANY KIND, either express or implied. See the License for the specific terms
13  * governing rights and limitations under the License.
14  *
15  * Contributor(s):
16  *
17  * $Id: Login.java,v 1.1 2004/08/16 09:33:18 slobodan Exp $
18  */

19
20 package com.lutris.airsent.presentation.customer;
21
22 import com.lutris.airsent.presentation.BasePO;
23 import com.lutris.appserver.server.httpPresentation.*;
24 import com.lutris.appserver.server.session.*;
25 import com.lutris.util.*;
26 //import com.lutris.xml.xmlc.*;
27
//import com.lutris.xml.xmlc.html.*;
28
import org.w3c.dom.*;
29 import org.w3c.dom.html.*;
30 import org.enhydra.xml.xmlc.XMLObject;
31 import com.lutris.airsent.spec.AirSentException;
32
33 import com.lutris.airsent.presentation.AirSentPresentationException;
34 import com.lutris.airsent.presentation.AirSentConstants;
35 import java.util.*;
36 import com.lutris.airsent.spec.customer.Customer;
37
38 /**
39  * The login page of the AirSent app
40  *
41  */

42 public class Login extends BasePO {
43
44     /**
45      * Constants
46      */

47     private static final int AUTH_LEVEL = AirSentConstants.UNAUTH_USER;
48
49     /**
50      * Superclass method override.
51      * returns the authorization level necessary to access this po.
52      *
53      * @return int required authorization level
54      */

55     public int getRequiredAuthLevel() {
56     return AUTH_LEVEL;
57     }
58
59     /**
60      * Default event. Just show the page.
61      */

62     public XMLObject handleDefault() throws HttpPresentationException {
63     return showPage(null);
64     }
65
66     /**
67      *
68      * @param error messages
69      * @return page as XMLObject.
70      */

71     public XMLObject showPage(String JavaDoc errorMsg)
72         throws AirSentPresentationException {
73     LoginHTML page =
74         (LoginHTML) myComms.xmlcFactory.create(LoginHTML.class);
75
76     try {
77         if (null != errorMsg
78         || null
79         != (errorMsg =
80             getSessionData().getAndClearUserMessage())) {
81         page.setTextErrorText(errorMsg);
82         } else {
83         page.getElementErrorText().getParentNode().removeChild(page.getElementErrorText());
84         }
85     } catch (Exception JavaDoc e) {
86         throw new AirSentPresentationException("Trouble showing page", e);
87     }
88
89     return page;
90     }
91
92     /**
93      * Process login data
94      *
95      * @return error String
96      */

97     public XMLObject handleLogin() throws HttpPresentationException {
98     String JavaDoc login =
99         getComms().request.getParameter(AirSentConstants.LOGIN_NAME);
100     String JavaDoc password =
101         getComms().request.getParameter(AirSentConstants.PASSWORD_NAME);
102     Customer customer = null;
103
104     try {
105         if ((customer =
106             getApplication().getHomeManager().getCustomerManager().validatePassword(login,
107             password)) == null) {
108         return showPage("Invalid username or password.");
109         } else {
110         getSessionData().setCustomer(customer);
111         getSessionData().setUserAuth(AirSentConstants.CUSTOMER_USER);
112         
113         this.getSessionData().setUserMessage("Welcome, " + customer.getFirstName());
114         //throw new ServerPageRedirectException(AirSentConstants.ORDERSTEP1_PO);
115
throw new ClientPageRedirectException(AirSentConstants.ORDERSTEP1_PO);
116         }
117 /*
118  * Catch Null pointer exception ( we canot make a instances of classes from business layer when we run AirSent_pres )
119  * We need to allow AirSent_pres to be functional , response
120  * will be default HTML page
121  *
122  */

123     }catch(NullPointerException JavaDoc ex){
124         throw new ClientPageRedirectException(AirSentConstants.ORDERSTEP1_PO);
125          
126     
127     } catch (Exception JavaDoc ex) {
128         throw new AirSentPresentationException("System error finding user",
129                            ex);
130     }
131     }
132
133 }
134
135
Popular Tags