File Source: WeblogCustomTheme.java

         /* 
    P/P   *  Method: org.apache.roller.weblogger.business.themes.WeblogCustomTheme__static_init
          */
     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.business.themes;
    20  
    21  import java.util.Date;
    22  import java.util.List;
    23  import org.apache.roller.weblogger.WebloggerException;
    24  import org.apache.roller.weblogger.business.FileManager;
    25  import org.apache.roller.weblogger.business.FileNotFoundException;
    26  import org.apache.roller.weblogger.business.FilePathException;
    27  import org.apache.roller.weblogger.business.WebloggerFactory;
    28  import org.apache.roller.weblogger.business.UserManager;
    29  import org.apache.roller.weblogger.pojos.ThemeResource;
    30  import org.apache.roller.weblogger.pojos.ThemeTemplate;
    31  import org.apache.roller.weblogger.pojos.WeblogTheme;
    32  import org.apache.roller.weblogger.pojos.Weblog;
    33  
    34  
    35  /**
    36   * A WeblogTheme custom defined by the weblog owner.
    37   */
    38  public class WeblogCustomTheme extends WeblogTheme {
    39      
    40      
    41      public WeblogCustomTheme(Weblog weblog) {
                 /* 
    P/P           *  Method: void org.apache.roller.weblogger.business.themes.WeblogCustomTheme(Weblog)
                  */
    42          super(weblog);
    43      }
    44      
    45      
    46      public String getId() {
                 /* 
    P/P           *  Method: String getId()
                  * 
                  *  Postconditions:
                  *    return_value == &"custom"
                  */
    47          return CUSTOM;
    48      }
    49      
    50      public String getName() {
                 /* 
    P/P           *  Method: String getName()
                  * 
                  *  Postconditions:
                  *    return_value == &"custom"
                  */
    51          return CUSTOM;
    52      }
    53      
    54      public String getDescription() {
                 /* 
    P/P           *  Method: String getDescription()
                  * 
                  *  Postconditions:
                  *    return_value == &"custom"
                  */
    55          return CUSTOM;
    56      }
    57  
    58      public String getAuthor() {
                 /* 
    P/P           *  Method: String getAuthor()
                  * 
                  *  Postconditions:
                  *    return_value == &"N.A"
                  */
    59          return "N/A";
    60      }
    61      
    62      public Date getLastModified() {
                 /* 
    P/P           *  Method: Date getLastModified()
                  * 
                  *  Preconditions:
                  *    this.weblog != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    63          return this.weblog.getLastModified();
    64      }
    65      
    66      public boolean isEnabled() {
                 /* 
    P/P           *  Method: bool isEnabled()
                  * 
                  *  Postconditions:
                  *    return_value == 1
                  */
    67          return true;
    68      }
    69      
    70      
    71      /**
    72       * Get the collection of all templates associated with this Theme.
    73       */
    74      public List getTemplates() throws WebloggerException {
                 /* 
    P/P           *  Method: List getTemplates()
                  * 
                  *  Preconditions:
                  *    org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider != null
                  *    org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance != null
                  *    this.weblog != null
                  * 
                  *  Presumptions:
                  *    getWeblogger(...).userManager != null
                  *    userMgr.strategy != null
                  *    userMgr.strategy.emf != null
                  *    userMgr.strategy.threadLocalEntityManager != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    75          UserManager userMgr = WebloggerFactory.getWeblogger().getUserManager();
    76          return userMgr.getPages(this.weblog);
    77      }
    78      
    79      
    80      /**
    81       * Lookup the stylesheet template for this theme.
    82       * Returns null if no stylesheet can be found.
    83       */
    84      public ThemeTemplate getStylesheet() throws WebloggerException {
                 /* 
    P/P           *  Method: ThemeTemplate getStylesheet()
                  * 
                  *  Preconditions:
                  *    this.weblog != null
                  *    (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider != null
                  *    (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    85          return getTemplateByLink(this.weblog.getCustomStylesheetPath());
    86      }
    87      
    88      
    89      /**
    90       * Lookup the default template.
    91       * Returns null if the template cannot be found.
    92       */
    93      public ThemeTemplate getDefaultTemplate() throws WebloggerException {
                 /* 
    P/P           *  Method: ThemeTemplate getDefaultTemplate()
                  * 
                  *  Preconditions:
                  *    org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider != null
                  *    org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance != null
                  *    this.weblog != null
                  * 
                  *  Presumptions:
                  *    getWeblogger(...).userManager != null
                  *    userMgr.strategy != null
                  *    userMgr.strategy.emf != null
                  *    userMgr.strategy.threadLocalEntityManager != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    94          UserManager userMgr = WebloggerFactory.getWeblogger().getUserManager();
    95          return userMgr.getPageByAction(this.weblog, ThemeTemplate.ACTION_WEBLOG);
    96      }
    97      
    98      
    99      /**
   100       * Lookup the specified template by action.
   101       * Returns null if the template cannot be found.
   102       */
   103      public ThemeTemplate getTemplateByAction(String action) throws WebloggerException {
                 /* 
    P/P           *  Method: ThemeTemplate getTemplateByAction(String)
                  * 
                  *  Preconditions:
                  *    (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider != null
                  *    (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance != null
                  *    (soft) this.weblog != null
                  * 
                  *  Presumptions:
                  *    getWeblogger(...).userManager != null
                  *    userMgr.strategy != null
                  *    userMgr.strategy.emf != null
                  *    userMgr.strategy.threadLocalEntityManager != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    action: Inverse{null}, Addr_Set{null}
                  */
   104          if(action == null)
   105              return null;
   106          
   107          UserManager userMgr = WebloggerFactory.getWeblogger().getUserManager();
   108          return userMgr.getPageByAction(this.weblog, action);
   109      }
   110      
   111      
   112      /**
   113       * Lookup the specified template by name.
   114       * Returns null if the template cannot be found.
   115       */
   116      public ThemeTemplate getTemplateByName(String name) throws WebloggerException {
                 /* 
    P/P           *  Method: ThemeTemplate getTemplateByName(String)
                  * 
                  *  Preconditions:
                  *    (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider != null
                  *    (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance != null
                  *    (soft) this.weblog != null
                  * 
                  *  Presumptions:
                  *    getWeblogger(...).userManager != null
                  *    userMgr.strategy != null
                  *    userMgr.strategy.emf != null
                  *    userMgr.strategy.threadLocalEntityManager != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    name: Inverse{null}, Addr_Set{null}
                  */
   117          if(name == null)
   118              return null;
   119          
   120          UserManager userMgr = WebloggerFactory.getWeblogger().getUserManager();
   121          return userMgr.getPageByName(this.weblog, name);
   122      }
   123      
   124      
   125      /**
   126       * Lookup the specified template by link.
   127       * Returns null if the template cannot be found.
   128       */
   129      public ThemeTemplate getTemplateByLink(String link) throws WebloggerException {
                 /* 
    P/P           *  Method: ThemeTemplate getTemplateByLink(String)
                  * 
                  *  Preconditions:
                  *    (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider != null
                  *    (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance != null
                  *    (soft) this.weblog != null
                  * 
                  *  Presumptions:
                  *    getWeblogger(...).userManager != null
                  *    userMgr.strategy != null
                  *    userMgr.strategy.emf != null
                  *    userMgr.strategy.threadLocalEntityManager != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    link: Inverse{null}, Addr_Set{null}
                  */
   130          if(link == null)
   131              return null;
   132          
   133          UserManager userMgr = WebloggerFactory.getWeblogger().getUserManager();
   134          return userMgr.getPageByLink(this.weblog, link);
   135      }
   136      
   137      
   138      /**
   139       * Lookup the specified resource by path.
   140       * Returns null if the resource cannot be found.
   141       */
   142      public ThemeResource getResource(String path) {
   143          
                 /* 
    P/P           *  Method: ThemeResource getResource(String)
                  * 
                  *  Preconditions:
                  *    (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider != null
                  *    (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance != null
                  * 
                  *  Postconditions:
                  *    return_value == One-of{&new FileManagerImpl$WeblogResourceFile(getFile#3), null}
                  *    return_value in Addr_Set{null,&new FileManagerImpl$WeblogResourceFile(getFile#3)}
                  *    new File(getRealFile#6) num objects <= 1
                  *    new FileManagerImpl$WeblogResourceFile(getFile#3) num objects <= 1
                  *    new FileManagerImpl$WeblogResourceFile(getFile#3).relativePath == path
                  *    init'ed(new FileManagerImpl$WeblogResourceFile(getFile#3).relativePath)
                  *    new FileManagerImpl$WeblogResourceFile(getFile#3).resourceFile == &new File(getRealFile#6)
                  *    new FileManagerImpl$WeblogResourceFile(getFile#3).weblog == this.weblog
                  *    new FileManagerImpl$WeblogResourceFile(getFile#3).weblog != null
                  */
   144          ThemeResource resource = null;
   145          
   146          try {
   147              FileManager fileMgr = WebloggerFactory.getWeblogger().getFileManager();
+  148              resource = fileMgr.getFile(this.weblog, path);
   149          } catch (WebloggerException ex) {
   150              // ignored, resource considered not found
   151          }
   152          
   153          return resource;
   154      }
   155      
   156  }








SofCheck Inspector Build Version : 2.18479
WeblogCustomTheme.java 2009-Jan-02 14:25:12
WeblogCustomTheme.class 2009-Sep-04 03:12:32