upgradeutilities.java

### File Source: upgradeutilities.java

         1  package net.sourceforge.pebble.util;
         2
         3  import net.sourceforge.pebble.domain.Blog;
         4  import org.apache.commons.logging.Log;
         5  import org.apache.commons.logging.LogFactory;
         6
         7  /**
         8   * Utilities for upgrading blogs.
         9   *
        10   * @author    Simon Brown
        11   */
             /*
        P/P   *  Method: void net.sourceforge.pebble.util.UpgradeUtilities()
              */
        12  public class UpgradeUtilities {
        13
        14    /** the logger used by this action */
               /*
        P/P     *  Method: net.sourceforge.pebble.util.UpgradeUtilities__static_init
                *
                *  Postconditions:
                *    init'ed(log)
                */
        15    private static final Log log = LogFactory.getLog(UpgradeUtilities.class);
        16
        17    public static void upgradeBlog(Blog blog, String fromVersion, String toVersion) throws Exception {
                 /*
        P/P       *  Method: void upgradeBlog(Blog, String, String)
                  *
                  *  Preconditions:
                  *    (soft) blog != null
                  *
                  *  Presumptions:
                  *    org.apache.commons.logging.LogFactory:getLog(...)@15 != null
                  *
                  *  Test Vectors:
                  *    fromVersion: Addr_Set{null}, Inverse{null}
                  *    java.lang.String:startsWith(...)@20: {1}, {0}
                  *    java.lang.String:startsWith(...)@21: {1}, {0}
                  *    java.lang.String:startsWith(...)@22: {1}, {0}
                  *    java.lang.String:startsWith(...)@23: {0}, {1}
                  */
        18      log.info("Upgrading blog from " + fromVersion + " to " + toVersion);
        19      if (fromVersion == null
        20          || fromVersion.startsWith("2.3")
        21          || fromVersion.startsWith("2.2")
        22          || fromVersion.startsWith("2.1")
        23          || fromVersion.startsWith("2.0")) {
        24        log.info("restructuring static pages");
        25        Utilities.restructureStaticPages(blog);
        26        log.info("building indizes");
        27        Utilities.buildIndexes(blog);
        28        log.info("upgrade done");
        29      } else {
        30        log.info("No upgrade required");
        31      }
        32    }
        33
        34  }

SofCheck Inspector Build Version : 2.22510

upgradeutilities.java | 2010-Jun-25 19:40:32
upgradeutilities.class | 2010-Jul-19 20:23:38