File Source: WeblogPreviewResourceRequest.java
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.weblogger.ui.rendering.util;
20
21 import javax.servlet.http.HttpServletRequest;
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.roller.weblogger.WebloggerException;
25 import org.apache.roller.weblogger.business.themes.ThemeNotFoundException;
26 import org.apache.roller.weblogger.business.WebloggerFactory;
27 import org.apache.roller.weblogger.business.themes.ThemeManager;
28 import org.apache.roller.weblogger.pojos.Theme;
29
30
31 /**
32 *
33 */
34 public class WeblogPreviewResourceRequest extends WeblogResourceRequest {
35
/*
P/P * Method: org.apache.roller.weblogger.ui.rendering.util.WeblogPreviewResourceRequest__static_init
*
* Postconditions:
* init'ed(log)
*/
36 private static Log log = LogFactory.getLog(WeblogPreviewResourceRequest.class);
37
38 // lightweight attributes
39 private String themeName = null;
40
41 // heavyweight attributes
42 private Theme theme = null;
43
44
/*
P/P * Method: void org.apache.roller.weblogger.ui.rendering.util.WeblogPreviewResourceRequest()
*
* Postconditions:
* this.authenticUser == null
* this.locale == null
* this.localeInstance == null
* this.pathInfo == null
* this.request == null
* this.resourcePath == null
* this.theme == null
* this.themeName == null
* this.user == null
* this.weblog == null
* ...
*/
45 public WeblogPreviewResourceRequest() {}
46
47
48 public WeblogPreviewResourceRequest(HttpServletRequest request)
49 throws InvalidRequestException {
50
51 // let parent go first
/*
P/P * Method: void org.apache.roller.weblogger.ui.rendering.util.WeblogPreviewResourceRequest(HttpServletRequest)
*
* Preconditions:
* log != null
* org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.log != null
* org/apache/roller/weblogger/ui/rendering/util/WeblogResourceRequest.log != null
* request != null
*
* Postconditions:
* java.lang.String:substring(...)._tainted == 0
* init'ed(this.authenticUser)
* init'ed(this.locale)
* this.localeInstance == null
* this.theme == null
* this.user == null
* this.weblog == null
* this.pathInfo != null
* this.request == request
* this.request != null
* ...
*
* Test Vectors:
* javax.servlet.http.HttpServletRequest:getParameter(...)@56: Addr_Set{null}, Inverse{null}
* org.apache.commons.logging.Log:isDebugEnabled(...)@60: {0}, {1}
*/
52 super(request);
53
54 // all we need to worry about is the query params
55 // the only param we expect is "theme"
56 if(request.getParameter("theme") != null) {
57 this.themeName = request.getParameter("theme");
58 }
59
60 if(log.isDebugEnabled()) {
61 log.debug("theme = "+this.themeName);
62 }
63 }
64
65 public String getThemeName() {
/*
P/P * Method: String getThemeName()
*
* Preconditions:
* init'ed(this.themeName)
*
* Postconditions:
* return_value == this.themeName
* init'ed(return_value)
*/
66 return themeName;
67 }
68
69 public void setThemeName(String theme) {
/*
P/P * Method: void setThemeName(String)
*
* Postconditions:
* this.themeName == theme
* init'ed(this.themeName)
*/
70 this.themeName = theme;
71 }
72
73 // override so that previews never show login status
74 public String getAuthenticUser() {
/*
P/P * Method: String getAuthenticUser()
*
* Postconditions:
* return_value == null
*/
75 return null;
76 }
77
78 // override so that previews never show login status
79 public boolean isLoggedIn() {
/*
P/P * Method: bool isLoggedIn()
*
* Postconditions:
* return_value == 0
*/
80 return false;
81 }
82
83 public Theme getTheme() {
84
/*
P/P * Method: Theme getTheme()
*
* Preconditions:
* init'ed(this.theme)
* (soft) log != null
* (soft) init'ed(this.themeName)
*
* Presumptions:
* org.apache.roller.weblogger.business.Weblogger:getThemeManager(...)@87 != null
* org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@87 != null
*
* Postconditions:
* init'ed(return_value)
* this.theme == return_value
*
* Test Vectors:
* this.theme: Inverse{null}, Addr_Set{null}
* this.themeName: Addr_Set{null}, Inverse{null}
*/
85 if(theme == null && themeName != null) {
86 try {
87 ThemeManager themeMgr = WebloggerFactory.getWeblogger().getThemeManager();
88 theme = themeMgr.getTheme(themeName);
89 } catch(ThemeNotFoundException tnfe) {
90 // bogus theme specified ... don't worry about it
91 } catch(WebloggerException re) {
92 log.error("Error looking up theme "+themeName, re);
93 }
94 }
95
96 return theme;
97 }
98
99 public void setTheme(Theme theme) {
/*
P/P * Method: void setTheme(Theme)
*
* Postconditions:
* this.theme == theme
* init'ed(this.theme)
*/
100 this.theme = theme;
101 }
102 }
SofCheck Inspector Build Version : 2.18479
| WeblogPreviewResourceRequest.java |
2009-Jan-02 14:25:20 |
| WeblogPreviewResourceRequest.class |
2009-Sep-04 03:12:46 |