KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > ui > rendering > util > ParsedRequest


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. The ASF licenses this file to You
4  * under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License. For additional information regarding
15  * copyright in this work, please see the NOTICE file in the top level
16  * directory of this distribution.
17  */

18
19 package org.apache.roller.ui.rendering.util;
20
21 import java.util.Locale JavaDoc;
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23
24
25 /**
26  * An abstract class representing any request made to Roller that has been
27  * parsed in order to extract relevant pieces of information from the url.
28  *
29  * NOTE: It is extremely important to mention that this class and all of its
30  * subclasses are meant to be extremely light weight. Meaning they should
31  * avoid any time consuming operations at all costs, especially operations
32  * which require a trip to the db. Those operations should be used very, very
33  * sparingly and should only be triggered when it's guaranteed that they are
34  * needed.
35  */

36 public abstract class ParsedRequest {
37     
38     HttpServletRequest JavaDoc request = null;
39     
40     private String JavaDoc language = null;
41     private String JavaDoc authenticUser = null;
42     
43     
44     ParsedRequest() {}
45     
46     
47     /**
48      * Parse the given http request and extract any information we can.
49      *
50      * This abstract version of the constructor gathers info likely to be
51      * relevant to all requests to Roller.
52      */

53     public ParsedRequest(HttpServletRequest JavaDoc request) throws InvalidRequestException {
54         
55         // keep a reference to the original request
56
this.request = request;
57         
58         // login status
59
java.security.Principal JavaDoc prince = request.getUserPrincipal();
60         if(prince != null) {
61             this.authenticUser = prince.getName();
62         }
63         
64     }
65     
66     
67     public String JavaDoc getAuthenticUser() {
68         return this.authenticUser;
69     }
70     
71     
72     public boolean isLoggedIn() {
73         return (this.authenticUser != null);
74     }
75     
76 }
77
Popular Tags