Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
../../../img/srcFileCovDistChart5.png 38% of files have more coverage
44   213   35   1,76
10   120   0,8   25
25     1,4  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  Configuration       Line # 45 44 0% 35 40 49,4% 0.49367088
 
  (216)
 
1    /*
2    * Copyright (c) 2003-2006, Simon Brown
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions are met:
7    *
8    * - Redistributions of source code must retain the above copyright
9    * notice, this list of conditions and the following disclaimer.
10    *
11    * - Redistributions in binary form must reproduce the above copyright
12    * notice, this list of conditions and the following disclaimer in
13    * the documentation and/or other materials provided with the
14    * distribution.
15    *
16    * - Neither the name of Pebble nor the names of its contributors may
17    * be used to endorse or promote products derived from this software
18    * without specific prior written permission.
19    *
20    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23    * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30    * POSSIBILITY OF SUCH DAMAGE.
31    */
32    package net.sourceforge.pebble;
33   
34    import net.sourceforge.pebble.dao.DAOFactory;
35    import net.sourceforge.pebble.dao.file.FileDAOFactory;
36    import net.sourceforge.pebble.security.SecurityRealm;
37    import org.apache.commons.logging.Log;
38    import org.apache.commons.logging.LogFactory;
39   
40    /**
41    * A bean representing configurable properties for Pebble.
42    *
43    * @author Simon Brown
44    */
 
45    public class Configuration {
46   
47    /** the log used by this class */
48    private static Log log = LogFactory.getLog(Configuration.class);
49   
50    private String dataDirectory = "${user.home}/pebble";
51    private String url;
52    private String secureUrl;
53    private boolean multiBlog = false;
54    private boolean virtualHostingEnabled = false;
55    private boolean userThemesEnabled = true;
56    private String smtpHost = "java:comp/env/mail/Session";
57    private long fileUploadSize = 2048;
58    private long fileUploadQuota = -1;
59    private DAOFactory daoFactory = new FileDAOFactory();
60    private SecurityRealm securityRealm;
61   
 
62  2432 toggle public Configuration() {
63    }
64   
 
65  598 toggle public String getUrl() {
66  598 return url;
67    }
68   
 
69  2506 toggle public void setUrl(String s) {
70  2506 this.url = s;
71   
72  2506 if (url != null && !(url.length() == 0) && !url.endsWith("/")) {
73  4 url += "/";
74    }
75    }
76   
 
77  4 toggle public String getDomainName() {
78    // and set the domain name
79  4 String url = PebbleContext.getInstance().getConfiguration().getUrl();
80  4 int index = url.indexOf("://");
81  4 String domainName = url.substring(index+3);
82  4 index = domainName.indexOf("/");
83  4 domainName = domainName.substring(0, index);
84   
85  4 if (domainName.indexOf(":") > -1) {
86    // the domain name still has a port number so remove it
87  2 domainName = domainName.substring(0, domainName.indexOf(":"));
88    }
89   
90  4 return domainName;
91    }
92   
 
93  0 toggle public String getSecureUrl() {
94  0 if (secureUrl != null && secureUrl.length() > 0) {
95  0 return secureUrl;
96    } else {
97  0 return url;
98    }
99    }
100   
 
101  0 toggle public void setSecureUrl(String s) {
102  0 this.secureUrl = s;
103   
104  0 if (secureUrl != null && !(secureUrl.length() == 0) && !secureUrl.endsWith("/")) {
105  0 secureUrl += "/";
106    }
107    }
108   
 
109  14 toggle public String getSmtpHost() {
110  14 return smtpHost;
111    }
112   
 
113  0 toggle public void setSmtpHost(String smtpHost) {
114  0 this.smtpHost = smtpHost;
115    }
116   
 
117  0 toggle public long getFileUploadSize() {
118  0 return fileUploadSize;
119    }
120   
 
121  0 toggle public void setFileUploadSize(long fileUploadSize) {
122  0 this.fileUploadSize = fileUploadSize;
123    }
124   
 
125  16 toggle public long getFileUploadQuota() {
126  16 return fileUploadQuota;
127    }
128   
 
129  0 toggle public void setFileUploadQuota(long fileUploadQuota) {
130  0 this.fileUploadQuota = fileUploadQuota;
131    }
132   
 
133  0 toggle public DAOFactory getDaoFactory() {
134  0 return daoFactory;
135    }
136   
 
137  0 toggle public void setDaoFactory(DAOFactory daoFactory) {
138  0 this.daoFactory = daoFactory;
139    }
140   
 
141  88 toggle public String getDataDirectory() {
142  88 return dataDirectory;
143    }
144   
 
145  2432 toggle public void setDataDirectory(String dataDirectory) {
146  2432 this.dataDirectory = evaluateDirectory(dataDirectory);
147    }
148   
 
149  0 toggle public boolean isMultiBlog() {
150  0 return multiBlog;
151    }
152   
 
153  0 toggle public void setMultiBlog(boolean multiBlog) {
154  0 this.multiBlog = multiBlog;
155    }
156   
157   
 
158  70 toggle public boolean isVirtualHostingEnabled() {
159  70 return virtualHostingEnabled;
160    }
161   
 
162  0 toggle public void setVirtualHostingEnabled(boolean virtualHostingEnabled) {
163  0 this.virtualHostingEnabled = virtualHostingEnabled;
164    }
165   
 
166  24 toggle public SecurityRealm getSecurityRealm() {
167  24 return securityRealm;
168    }
169   
 
170  1250 toggle public void setSecurityRealm(SecurityRealm securityRealm) {
171  1250 this.securityRealm = securityRealm;
172    }
173   
174    /**
175    * Replaces ${some.property} at the start of the string with the value
176    * from System.getProperty(some.property).
177    *
178    * @param s the String to transform
179    * @return a new String, or the same String if it doesn't start with a
180    * property name delimited by ${...}
181    */
 
182  2432 toggle private String evaluateDirectory(String s) {
183  2432 log.debug("Raw string is " + s);
184  2432 if (s.startsWith("${")) {
185  0 int index = s.indexOf("}");
186  0 String propertyName = s.substring(2, index);
187  0 String propertyValue = System.getProperty(propertyName);
188  0 log.debug(propertyName + " = " + propertyValue);
189  0 return propertyValue + s.substring(index+1);
190    } else {
191  2432 return s;
192    }
193    }
194   
195    /**
196    * Determines whether user themes are enabled.
197    *
198    * @return true if user themes are enabled, false otherwise
199    */
 
200  0 toggle public boolean isUserThemesEnabled() {
201  0 return userThemesEnabled;
202    }
203   
204    /**
205    * Sets whether user themes are enabled.
206    *
207    * @param userThemesEnabled true if user themes are enabled,
208    * false otherwise
209    */
 
210  0 toggle public void setUserThemesEnabled(boolean userThemesEnabled) {
211  0 this.userThemesEnabled = userThemesEnabled;
212    }
213    }