KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > ui > rendering > model > ConfigModel


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.model;
20
21 import java.net.MalformedURLException JavaDoc;
22 import java.util.Arrays JavaDoc;
23 import java.util.HashMap JavaDoc;
24 import java.util.List JavaDoc;
25 import java.util.Map JavaDoc;
26 import javax.servlet.jsp.PageContext JavaDoc;
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29 import org.apache.roller.RollerException;
30 import org.apache.roller.config.RollerRuntimeConfig;
31 import org.apache.roller.pojos.wrapper.WeblogEntryDataWrapper;
32 import org.apache.roller.pojos.wrapper.WebsiteDataWrapper;
33 import org.apache.roller.ui.core.RequestConstants;
34 import org.apache.roller.ui.core.RollerContext;
35 import org.apache.struts.util.RequestUtils;
36
37
38 /**
39  * Model which provides access to application config data like site
40  * config properties.
41  */

42 public class ConfigModel implements Model {
43     
44     private static Log log = LogFactory.getLog(ConfigModel.class);
45     
46     
47     /** Template context name to be used for model */
48     public String JavaDoc getModelName() {
49         return "config";
50     }
51     
52     
53     /** Init model */
54     public void init(Map JavaDoc map) throws RollerException {
55         // no-op
56
}
57     
58     
59     public String JavaDoc getSiteName() {
60         return getProperty("site.name");
61     }
62     
63     public String JavaDoc getSiteShortName() {
64         return getProperty("site.shortName");
65     }
66     
67     public String JavaDoc getSiteDescription() {
68         return getProperty("site.description");
69     }
70     
71     public String JavaDoc getSiteEmail() {
72         return getProperty("site.adminemail");
73     }
74     
75     public boolean getRegistrationEnabled() {
76         return getBooleanProperty("users.registration.enabled");
77     }
78     
79     public String JavaDoc getRegistrationURL() {
80         return getProperty("users.registration.url");
81     }
82     
83     public int getFeedSize() {
84         return getIntProperty("site.newsfeeds.defaultEntries");
85     }
86     
87     public int getFeedMaxSize() {
88         return getIntProperty("site.newsfeeds.maxEntries");
89     }
90     
91     public boolean getFeedStyle() {
92         return getBooleanProperty("site.newsfeeds.styledFeeds");
93     }
94             
95     public boolean getCommentAutoFormat() {
96         return getBooleanProperty("users.comments.autoformat");
97     }
98     
99     public boolean getCommentEscapeHtml() {
100         return getBooleanProperty("users.comments.escapehtml");
101     }
102     
103     public boolean getCommentEmailNotify() {
104         return getBooleanProperty("users.comments.emailnotify");
105     }
106     
107     public boolean getTrackbacksEnabled() {
108         return getBooleanProperty("users.trackbacks.enabled");
109     }
110     
111     
112     /** Get Roller version string */
113     public String JavaDoc getRollerVersion() {
114         return RollerContext.getRollerContext().getRollerVersion();
115     }
116     
117     
118     /** Get timestamp of Roller build */
119     public String JavaDoc getRollerBuildTimestamp() {
120         return RollerContext.getRollerContext().getRollerBuildTime();
121     }
122     
123     
124     /** Get username who created Roller build */
125     public String JavaDoc getRollerBuildUser() {
126         return RollerContext.getRollerContext().getRollerBuildUser();
127     }
128     
129     
130     private String JavaDoc getProperty(String JavaDoc name) {
131         return RollerRuntimeConfig.getProperty(name);
132     }
133     
134     
135     private int getIntProperty(String JavaDoc name) {
136         return RollerRuntimeConfig.getIntProperty(name);
137     }
138     
139     
140     private boolean getBooleanProperty(String JavaDoc name) {
141         return RollerRuntimeConfig.getBooleanProperty(name);
142     }
143     
144 }
145
146
Popular Tags