File Source: ConfigModel.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.model;
    20  
    21  import java.util.Map;
    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.WebloggerFactory;
    26  import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
    27  
    28  /**
    29   * Model which provides access to application config data like site
    30   * config properties.
    31   */
         /* 
    P/P   *  Method: void org.apache.roller.weblogger.ui.rendering.model.ConfigModel()
          */
    32  public class ConfigModel implements Model {
    33      
             /* 
    P/P       *  Method: org.apache.roller.weblogger.ui.rendering.model.ConfigModel__static_init
              * 
              *  Postconditions:
              *    init'ed(log)
              */
    34      private static Log log = LogFactory.getLog(ConfigModel.class);
    35      
    36      
    37      /** Template context name to be used for model */
    38      public String getModelName() {
                 /* 
    P/P           *  Method: String getModelName()
                  * 
                  *  Postconditions:
                  *    return_value == &"config"
                  */
    39          return "config";
    40      }
    41      
    42      
    43      /** Init model */
    44      public void init(Map map) throws WebloggerException {
    45          // no-op
             /* 
    P/P       *  Method: void init(Map)
              */
    46      }
    47      
    48      
    49      public String getSiteName() {
                 /* 
    P/P           *  Method: String getSiteName()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    50          return getProperty("site.name");
    51      }
    52      
    53      public String getSiteShortName() {
                 /* 
    P/P           *  Method: String getSiteShortName()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    54          return getProperty("site.shortName");
    55      }
    56      
    57      public String getSiteDescription() {
                 /* 
    P/P           *  Method: String getSiteDescription()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    58          return getProperty("site.description");
    59      }
    60      
    61      public String getSiteEmail() {
                 /* 
    P/P           *  Method: String getSiteEmail()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    62          return getProperty("site.adminemail");
    63      }
    64      
    65      public boolean getRegistrationEnabled() {
                 /* 
    P/P           *  Method: bool getRegistrationEnabled()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    66          return getBooleanProperty("users.registration.enabled");
    67      }
    68      
    69      public String getRegistrationURL() {
                 /* 
    P/P           *  Method: String getRegistrationURL()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    70          return getProperty("users.registration.url");
    71      }
    72      
    73      public boolean getFeedHistoryEnabled() {
                 /* 
    P/P           *  Method: bool getFeedHistoryEnabled()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    74          return getBooleanProperty("site.newsfeeds.history.enabled");
    75      }
    76      
    77      public int getFeedSize() {
                 /* 
    P/P           *  Method: int getFeedSize()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    78          return getIntProperty("site.newsfeeds.defaultEntries");
    79      }
    80      
    81      public int getFeedMaxSize() {
                 /* 
    P/P           *  Method: int getFeedMaxSize()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    82          return getIntProperty("site.newsfeeds.defaultEntries");
    83      }
    84      
    85      public boolean getFeedStyle() {
                 /* 
    P/P           *  Method: bool getFeedStyle()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    86          return getBooleanProperty("site.newsfeeds.styledFeeds");
    87      }
    88      
    89      public boolean getCommentHtmlAllowed() {
                 /* 
    P/P           *  Method: bool getCommentHtmlAllowed()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    90          return getBooleanProperty("users.comments.htmlenabled");
    91      }
    92      
    93      public boolean getCommentAutoFormat() {
    94          // this prop was removed in 4.0
                 /* 
    P/P           *  Method: bool getCommentAutoFormat()
                  * 
                  *  Postconditions:
                  *    return_value == 0
                  */
    95          return false;
    96      }
    97      
    98      public boolean getCommentEscapeHtml() {
    99          // replaced by new htmlallowed property in 4.0
                 /* 
    P/P           *  Method: bool getCommentEscapeHtml()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   100          return !getCommentHtmlAllowed();
   101      }
   102      
   103      public boolean getCommentEmailNotify() {
                 /* 
    P/P           *  Method: bool getCommentEmailNotify()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   104          return getBooleanProperty("users.comments.emailnotify");
   105      }
   106      
   107      public boolean getTrackbacksEnabled() {
                 /* 
    P/P           *  Method: bool getTrackbacksEnabled()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   108          return getBooleanProperty("users.trackbacks.enabled");
   109      }
   110      
   111      
   112      /** Get Roller version string */
   113      public String getRollerVersion() {
                 /* 
    P/P           *  Method: String getRollerVersion()
                  * 
                  *  Presumptions:
                  *    org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@114 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   114          return WebloggerFactory.getWeblogger().getVersion();
   115      }
   116      
   117      
   118      /** Get timestamp of Roller build */
   119      public String getRollerBuildTimestamp() {
                 /* 
    P/P           *  Method: String getRollerBuildTimestamp()
                  * 
                  *  Presumptions:
                  *    org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@120 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   120          return WebloggerFactory.getWeblogger().getBuildTime();
   121      }
   122      
   123      
   124      /** Get username who created Roller build */
   125      public String getRollerBuildUser() {
                 /* 
    P/P           *  Method: String getRollerBuildUser()
                  * 
                  *  Presumptions:
                  *    org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@126 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   126          return WebloggerFactory.getWeblogger().getBuildUser();
   127      }
   128      
   129      
   130      private String getProperty(String name) {
                 /* 
    P/P           *  Method: String getProperty(String)
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   131          return WebloggerRuntimeConfig.getProperty(name);
   132      }
   133      
   134      
   135      private int getIntProperty(String name) {
                 /* 
    P/P           *  Method: int getIntProperty(String)
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   136          return WebloggerRuntimeConfig.getIntProperty(name);
   137      }
   138      
   139      
   140      private boolean getBooleanProperty(String name) {
                 /* 
    P/P           *  Method: bool getBooleanProperty(String)
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   141          return WebloggerRuntimeConfig.getBooleanProperty(name);
   142      }
   143      
   144  }
   145  








SofCheck Inspector Build Version : 2.18479
ConfigModel.java 2009-Jan-02 14:24:56
ConfigModel.class 2009-Sep-04 03:12:44