KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > airsent > presentation > DeviceBasePO


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: DeviceBasePO.java,v 1.1 2004/08/16 09:33:16 slobodan Exp $
18  */

19
20 package com.lutris.airsent.presentation;
21
22 import com.lutris.airsent.presentation.*;
23 import com.lutris.appserver.server.httpPresentation.*;
24 import com.lutris.appserver.server.session.*;
25 import com.lutris.appserver.server.Enhydra;
26 //import com.lutris.xml.xmlc.*;
27
import com.lutris.logging.*;
28 import com.lutris.util.KeywordValueException;
29 import com.lutris.appserver.server.user.User;
30 import org.w3c.dom.*;
31 import org.enhydra.wireless.wml.dom.WMLGoElement;
32 import org.enhydra.xml.xmlc.XMLObject;
33 import java.lang.reflect.*;
34 import java.util.*;
35 import java.lang.Throwable JavaDoc;
36
37 /**
38  * This is the parent Presentaion object. All presentation objects
39  * should extend this class.
40  *
41  * The run method looks for an event parameter and then calls
42  * handle<EventName>. If the "event" Parameter is not defined then
43  * the handleDefault() method is called in your child class.
44  *
45  * @author
46  * @version
47  */

48 public abstract class DeviceBasePO extends BasePO {
49
50     /**
51      * Handles default events.
52      *
53      *
54      * @return
55      *
56      * @throws HttpPresentationException
57      *
58      */

59     public abstract XMLObject handleDefault()
60         throws HttpPresentationException;
61
62     /**
63      * This method should be implemented in the subclass so that it returns
64      * the authorization level necessary to access the po.
65      */

66     abstract protected int getRequiredAuthLevel();
67
68     /**
69      * This rerouteForContent overrides the parent method to avoid
70      * a continous loop senario of rerouting.
71      */

72     protected void rerouteForContent(HttpPresentationComms comms) {}
73
74     ;
75
76     /*
77      * Uses the xmlfactory and the request content
78      * type to determine the proper page type
79      * to generate.
80      * For example if the request type is wml and
81      * the PO is MessengerLogin, then
82      * using the
83      *
84      * XMLObject page =
85      * myComms.xmlcFactory.create(Class.forName("MessengerLogin" + "WML"));
86      *
87      * @param String poName
88      * @return XMLObject
89      *
90      * @throws AirSentPresentationException
91      */

92     public XMLObject create(String JavaDoc poName)
93         throws AirSentPresentationException {
94     XMLObject page = null;
95
96     try {
97         page =
98         getComms().xmlcFactory.create(DeviceUtils.getPageName(getComms(),
99             poName));
100     } catch (Exception JavaDoc ex) {
101         throw new AirSentPresentationException("Trouble getting current authorization level",
102                            ex);
103     }
104     return page;
105     }
106
107
108     /**
109      * This logs out a user from the session. it first grabs
110      * an instance of the sessionData associated with the request
111      * and then sets the user to null in the session data.
112      *
113      * @param HttpServletRequest request - this is the request that
114      * the session data is extracted from.
115      *
116      * @exception AirSentPresentationException when an error occurs or if
117      * the session data for the request is null.
118      */

119     public XMLObject handleLogout() throws AirSentPresentationException {
120     try {
121
122         mySessionData = null;
123             SessionManager sessionManager = myComms.session.getSessionManager();
124             sessionManager.deleteSession(myComms.session);
125                 
126         throw new ClientPageRedirectException(AirSentConstants.XML_PAGE);
127     } catch (Exception JavaDoc e) {
128         throw new AirSentPresentationException("Trouble logging out user",
129                            e);
130     }
131     }
132 }
133
134
Popular Tags