//# 0 errors, 363 messages
//#
/*
    //#theme.java:1:1: class: net.sourceforge.pebble.domain.Theme
 * Copyright (c) 2003-2006, Simon Brown
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 *   - Neither the name of Pebble nor the names of its contributors may
 *     be used to endorse or promote products derived from this software
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package net.sourceforge.pebble.domain;

import net.sourceforge.pebble.util.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

/**
 * Represents the user's editable theme.
 *
 * @author    Simon Brown
 */
public class Theme {

  /** the log used by this class */
  private static Log log = LogFactory.getLog(Theme.class);
    //#theme.java:52: method: net.sourceforge.pebble.domain.Theme.net.sourceforge.pebble.domain.Theme__static_init
    //#theme.java:52: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.domain.Theme
    //#    method: net.sourceforge.pebble.domain.Theme__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(net.sourceforge.pebble.domain.Theme__static_init): __Descendant_Table[net/sourceforge/pebble/domain/Theme]
    //#output(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.backup()V
    //#output(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.backup(Ljava/lang/String;)V
    //#output(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.copy(Ljava/io/File;Ljava/io/File;)V
    //#output(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.copy(Ljava/lang/String;)V
    //#output(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.getBackupThemeDirectory()Ljava/lang/String;
    //#output(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.getName()Ljava/lang/String;
    //#output(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.getPathToLiveTheme()Ljava/io/File;
    //#output(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.restore()V
    //#output(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.restore(Ljava/lang/String;)V
    //#output(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.restoreToSpecifiedTheme(Ljava/lang/String;)V
    //#output(net.sourceforge.pebble.domain.Theme__static_init): log
    //#post(net.sourceforge.pebble.domain.Theme__static_init): __Descendant_Table[net/sourceforge/pebble/domain/Theme] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.backup()V == &backup
    //#post(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.backup(Ljava/lang/String;)V == &backup
    //#post(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.copy(Ljava/io/File;Ljava/io/File;)V == &copy
    //#post(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.copy(Ljava/lang/String;)V == &copy
    //#post(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.getBackupThemeDirectory()Ljava/lang/String; == &getBackupThemeDirectory
    //#post(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.getName()Ljava/lang/String; == &getName
    //#post(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.getPathToLiveTheme()Ljava/io/File; == &getPathToLiveTheme
    //#post(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.restore()V == &restore
    //#post(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.restore(Ljava/lang/String;)V == &restore
    //#post(net.sourceforge.pebble.domain.Theme__static_init): __Dispatch_Table.restoreToSpecifiedTheme(Ljava/lang/String;)V == &restoreToSpecifiedTheme
    //#post(net.sourceforge.pebble.domain.Theme__static_init): init'ed(log)
    //#theme.java:52: end of method: net.sourceforge.pebble.domain.Theme.net.sourceforge.pebble.domain.Theme__static_init

  /** the name of the theme that should be used as a default */
  public static final String DEFAULT_THEME_NAME = "default";

  /** the blog to which this theme belongs */
  private Blog blog;

  /** the name of the theme */
  private String name;

  /** the path of the live theme (under the webapp root) */
  private String pathToLiveThemes;

  /**
   * Creates a new Theme instance with the specified details.
   *
   * @param blog                the owning Blog instance
   * @param name                the name of the theme
   * @param pathToLiveThemes    the path to the live themes
   */
  public Theme(Blog blog, String name, String pathToLiveThemes) {
    //#theme.java:73: method: void net.sourceforge.pebble.domain.Theme.net.sourceforge.pebble.domain.Theme(Blog, String, String)
    //#input(void net.sourceforge.pebble.domain.Theme(Blog, String, String)): blog
    //#input(void net.sourceforge.pebble.domain.Theme(Blog, String, String)): name
    //#input(void net.sourceforge.pebble.domain.Theme(Blog, String, String)): pathToLiveThemes
    //#input(void net.sourceforge.pebble.domain.Theme(Blog, String, String)): this
    //#output(void net.sourceforge.pebble.domain.Theme(Blog, String, String)): this.blog
    //#output(void net.sourceforge.pebble.domain.Theme(Blog, String, String)): this.name
    //#output(void net.sourceforge.pebble.domain.Theme(Blog, String, String)): this.pathToLiveThemes
    //#post(void net.sourceforge.pebble.domain.Theme(Blog, String, String)): this.blog == blog
    //#post(void net.sourceforge.pebble.domain.Theme(Blog, String, String)): init'ed(this.blog)
    //#post(void net.sourceforge.pebble.domain.Theme(Blog, String, String)): this.name == name
    //#post(void net.sourceforge.pebble.domain.Theme(Blog, String, String)): init'ed(this.name)
    //#post(void net.sourceforge.pebble.domain.Theme(Blog, String, String)): this.pathToLiveThemes == pathToLiveThemes
    //#post(void net.sourceforge.pebble.domain.Theme(Blog, String, String)): init'ed(this.pathToLiveThemes)
    this.blog = blog;
    this.name = name;
    this.pathToLiveThemes = pathToLiveThemes;
  }
    //#theme.java:77: end of method: void net.sourceforge.pebble.domain.Theme.net.sourceforge.pebble.domain.Theme(Blog, String, String)

  /**
   * Gets the location where the backup version of the blog theme is stored -
   * under the blog.dir directory, in a sub-directory called "theme".
   *
   * @return    an absolute, local path on the filing system
   */
  String getBackupThemeDirectory() {
    return blog.getRoot() + File.separator + "theme";
    //#theme.java:86: method: String net.sourceforge.pebble.domain.Theme.getBackupThemeDirectory()
    //#theme.java:86: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.domain.Blog:getRoot()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.domain.Theme
    //#    method: String getBackupThemeDirectory()
    //#    unanalyzed callee: String net.sourceforge.pebble.domain.Blog:getRoot()
    //#input(String getBackupThemeDirectory()): java.io.File.separator
    //#input(String getBackupThemeDirectory()): this
    //#input(String getBackupThemeDirectory()): this.blog
    //#output(String getBackupThemeDirectory()): return_value
    //#pre[2] (String getBackupThemeDirectory()): this.blog != null
    //#presumption(String getBackupThemeDirectory()): init'ed(java.io.File.separator)
    //#post(String getBackupThemeDirectory()): return_value != null
    //#theme.java:86: end of method: String net.sourceforge.pebble.domain.Theme.getBackupThemeDirectory()
  }

  public File getPathToLiveTheme() {
    return new File(pathToLiveThemes, name);
    //#theme.java:90: method: File net.sourceforge.pebble.domain.Theme.getPathToLiveTheme()
    //#input(File getPathToLiveTheme()): this
    //#input(File getPathToLiveTheme()): this.name
    //#input(File getPathToLiveTheme()): this.pathToLiveThemes
    //#output(File getPathToLiveTheme()): new File(getPathToLiveTheme#1) num objects
    //#output(File getPathToLiveTheme()): return_value
    //#new obj(File getPathToLiveTheme()): new File(getPathToLiveTheme#1)
    //#pre[2] (File getPathToLiveTheme()): init'ed(this.name)
    //#pre[3] (File getPathToLiveTheme()): init'ed(this.pathToLiveThemes)
    //#post(File getPathToLiveTheme()): return_value == &new File(getPathToLiveTheme#1)
    //#post(File getPathToLiveTheme()): new File(getPathToLiveTheme#1) num objects == 1
    //#theme.java:90: end of method: File net.sourceforge.pebble.domain.Theme.getPathToLiveTheme()
  }

  /**
   * Restores the theme from the blog.dir to the webapp.
   */
  public void restore() {
    restore(DEFAULT_THEME_NAME);
    //#theme.java:97: method: void net.sourceforge.pebble.domain.Theme.restore()
    //#input(void restore()): __Descendant_Table[net/sourceforge/pebble/domain/Theme]
    //#input(void restore()): __Descendant_Table[others]
    //#input(void restore()): __Dispatch_Table.getBackupThemeDirectory()Ljava/lang/String;
    //#input(void restore()): __Dispatch_Table.getPathToLiveTheme()Ljava/io/File;
    //#input(void restore()): __Dispatch_Table.restore(Ljava/lang/String;)V
    //#input(void restore()): log
    //#input(void restore()): this
    //#input(void restore()): this.__Tag
    //#input(void restore()): this.blog
    //#input(void restore()): this.name
    //#input(void restore()): this.pathToLiveThemes
    //#pre[1] (void restore()): log != null
    //#pre[3] (void restore()): this.__Tag == net/sourceforge/pebble/domain/Theme
    //#pre[4] (void restore()): this.blog != null
    //#pre[5] (void restore()): init'ed(this.name)
    //#pre[6] (void restore()): init'ed(this.pathToLiveThemes)
    //#unanalyzed(void restore()): Effects-of-calling:net.sourceforge.pebble.domain.Blog:getRoot
    //#unanalyzed(void restore()): Effects-of-calling:java.lang.String:valueOf
    //#unanalyzed(void restore()): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void restore()): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void restore()): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void restore()): Effects-of-calling:java.io.File
    //#unanalyzed(void restore()): Effects-of-calling:java.io.File:exists
    //#unanalyzed(void restore()): Effects-of-calling:java.io.File:mkdir
    //#unanalyzed(void restore()): Effects-of-calling:java.io.File:listFiles
    //#unanalyzed(void restore()): Effects-of-calling:java.io.File:isDirectory
    //#unanalyzed(void restore()): Effects-of-calling:java.io.File:getName
    //#unanalyzed(void restore()): Effects-of-calling:copy
    //#unanalyzed(void restore()): Effects-of-calling:java.io.FileInputStream
    //#unanalyzed(void restore()): Effects-of-calling:java.io.FileInputStream:getChannel
    //#unanalyzed(void restore()): Effects-of-calling:java.io.FileOutputStream
    //#unanalyzed(void restore()): Effects-of-calling:java.io.FileOutputStream:getChannel
    //#unanalyzed(void restore()): Effects-of-calling:java.nio.channels.FileChannel:size
    //#unanalyzed(void restore()): Effects-of-calling:java.nio.channels.FileChannel:transferFrom
    //#unanalyzed(void restore()): Effects-of-calling:java.nio.channels.FileChannel:close
    //#unanalyzed(void restore()): Effects-of-calling:java.io.File:getAbsolutePath
    //#unanalyzed(void restore()): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(void restore()): Effects-of-calling:net.sourceforge.pebble.util.FileUtils:deleteFile
    //#unanalyzed(void restore()): Effects-of-calling:org.apache.commons.logging.Log:debug
    //#unanalyzed(void restore()): Effects-of-calling:java.io.File:renameTo
    //#unanalyzed(void restore()): Effects-of-calling:org.apache.commons.logging.Log:info
  }
    //#theme.java:98: end of method: void net.sourceforge.pebble.domain.Theme.restore()

  /**
   * Restores the theme from the blog.dir to the webapp.
   */
  public void restore(String themeName) {
    File blogTheme = new File(getBackupThemeDirectory());
    //#theme.java:104: method: void net.sourceforge.pebble.domain.Theme.restore(String)
    //#input(void restore(String)): __Descendant_Table[net/sourceforge/pebble/domain/Theme]
    //#input(void restore(String)): __Descendant_Table[others]
    //#input(void restore(String)): __Dispatch_Table.getBackupThemeDirectory()Ljava/lang/String;
    //#input(void restore(String)): __Dispatch_Table.getPathToLiveTheme()Ljava/io/File;
    //#input(void restore(String)): log
    //#input(void restore(String)): themeName
    //#input(void restore(String)): this
    //#input(void restore(String)): this.__Tag
    //#input(void restore(String)): this.blog
    //#input(void restore(String)): this.name
    //#input(void restore(String)): this.pathToLiveThemes
    //#pre[1] (void restore(String)): log != null
    //#pre[4] (void restore(String)): this.__Tag == net/sourceforge/pebble/domain/Theme
    //#pre[5] (void restore(String)): this.blog != null
    //#pre[6] (void restore(String)): init'ed(this.name)
    //#pre[7] (void restore(String)): init'ed(this.pathToLiveThemes)
    //#presumption(void restore(String)): java.io.File:listFiles(...)@105 != null
    //#unanalyzed(void restore(String)): Effects-of-calling:net.sourceforge.pebble.domain.Blog:getRoot
    //#unanalyzed(void restore(String)): Effects-of-calling:java.lang.String:valueOf
    //#unanalyzed(void restore(String)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void restore(String)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void restore(String)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void restore(String)): Effects-of-calling:java.io.File
    //#unanalyzed(void restore(String)): Effects-of-calling:java.io.File:exists
    //#unanalyzed(void restore(String)): Effects-of-calling:java.io.File:mkdir
    //#unanalyzed(void restore(String)): Effects-of-calling:java.io.File:listFiles
    //#unanalyzed(void restore(String)): Effects-of-calling:java.io.File:isDirectory
    //#unanalyzed(void restore(String)): Effects-of-calling:java.io.File:getName
    //#unanalyzed(void restore(String)): Effects-of-calling:copy
    //#unanalyzed(void restore(String)): Effects-of-calling:java.io.FileInputStream
    //#unanalyzed(void restore(String)): Effects-of-calling:java.io.FileInputStream:getChannel
    //#unanalyzed(void restore(String)): Effects-of-calling:java.io.FileOutputStream
    //#unanalyzed(void restore(String)): Effects-of-calling:java.io.FileOutputStream:getChannel
    //#unanalyzed(void restore(String)): Effects-of-calling:java.nio.channels.FileChannel:size
    //#unanalyzed(void restore(String)): Effects-of-calling:java.nio.channels.FileChannel:transferFrom
    //#unanalyzed(void restore(String)): Effects-of-calling:java.nio.channels.FileChannel:close
    //#unanalyzed(void restore(String)): Effects-of-calling:java.io.File:getAbsolutePath
    //#unanalyzed(void restore(String)): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(void restore(String)): Effects-of-calling:net.sourceforge.pebble.util.FileUtils:deleteFile
    //#unanalyzed(void restore(String)): Effects-of-calling:java.io.File:renameTo
    //#unanalyzed(void restore(String)): Effects-of-calling:org.apache.commons.logging.Log:info
    //#test_vector(void restore(String)): java.io.File:exists(...)@105: {0}, {1}
    //#test_vector(void restore(String)): java.io.File:listFiles(...).length@105: {1..+Inf}, {0}
    if (!blogTheme.exists() || blogTheme.listFiles().length == 0) {
      copy(themeName);
    }

    log.debug("Restoring " + name + " theme from " + getBackupThemeDirectory());
    //#theme.java:109: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.domain.Theme
    //#    method: void restore(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    copy(blogTheme, getPathToLiveTheme());
  }
    //#theme.java:111: end of method: void net.sourceforge.pebble.domain.Theme.restore(String)

  /**
   * Restores the theme from the blog.dir to the webapp.
   */
  public void restoreToSpecifiedTheme(String themeName) {
    File blogTheme = new File(getBackupThemeDirectory());
    //#theme.java:117: method: void net.sourceforge.pebble.domain.Theme.restoreToSpecifiedTheme(String)
    //#input(void restoreToSpecifiedTheme(String)): __Descendant_Table[net/sourceforge/pebble/domain/Theme]
    //#input(void restoreToSpecifiedTheme(String)): __Descendant_Table[others]
    //#input(void restoreToSpecifiedTheme(String)): __Dispatch_Table.getBackupThemeDirectory()Ljava/lang/String;
    //#input(void restoreToSpecifiedTheme(String)): __Dispatch_Table.getPathToLiveTheme()Ljava/io/File;
    //#input(void restoreToSpecifiedTheme(String)): __Dispatch_Table.restore(Ljava/lang/String;)V
    //#input(void restoreToSpecifiedTheme(String)): log
    //#input(void restoreToSpecifiedTheme(String)): themeName
    //#input(void restoreToSpecifiedTheme(String)): this
    //#input(void restoreToSpecifiedTheme(String)): this.__Tag
    //#input(void restoreToSpecifiedTheme(String)): this.blog
    //#input(void restoreToSpecifiedTheme(String)): this.name
    //#input(void restoreToSpecifiedTheme(String)): this.pathToLiveThemes
    //#pre[1] (void restoreToSpecifiedTheme(String)): log != null
    //#pre[4] (void restoreToSpecifiedTheme(String)): this.__Tag == net/sourceforge/pebble/domain/Theme
    //#pre[5] (void restoreToSpecifiedTheme(String)): this.blog != null
    //#pre[6] (void restoreToSpecifiedTheme(String)): init'ed(this.name)
    //#pre[7] (void restoreToSpecifiedTheme(String)): init'ed(this.pathToLiveThemes)
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:net.sourceforge.pebble.domain.Blog:getRoot
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.lang.String:valueOf
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.io.File
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.io.File:exists
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.io.File:mkdir
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.io.File:listFiles
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.io.File:isDirectory
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.io.File:getName
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:copy
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.io.FileInputStream
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.io.FileInputStream:getChannel
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.io.FileOutputStream
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.io.FileOutputStream:getChannel
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.nio.channels.FileChannel:size
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.nio.channels.FileChannel:transferFrom
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.nio.channels.FileChannel:close
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.io.File:getAbsolutePath
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:net.sourceforge.pebble.util.FileUtils:deleteFile
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:org.apache.commons.logging.Log:debug
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:java.io.File:renameTo
    //#unanalyzed(void restoreToSpecifiedTheme(String)): Effects-of-calling:org.apache.commons.logging.Log:info
    FileUtils.deleteFile(blogTheme);
    //#theme.java:118: Warning: method not available
    //#    -- call on void net.sourceforge.pebble.util.FileUtils:deleteFile(File)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.domain.Theme
    //#    method: void restoreToSpecifiedTheme(String)
    //#    unanalyzed callee: void net.sourceforge.pebble.util.FileUtils:deleteFile(File)
    FileUtils.deleteFile(getPathToLiveTheme());
    //#theme.java:119: Warning: method not available
    //#    -- call on void net.sourceforge.pebble.util.FileUtils:deleteFile(File)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.domain.Theme
    //#    method: void restoreToSpecifiedTheme(String)
    //#    unanalyzed callee: void net.sourceforge.pebble.util.FileUtils:deleteFile(File)
    restore(themeName);
  }
    //#theme.java:121: end of method: void net.sourceforge.pebble.domain.Theme.restoreToSpecifiedTheme(String)

  /**
   * Backs up the theme from the webapp to the blog.dir.
   */
  public void backup() {
    backup(name);
    //#theme.java:127: method: void net.sourceforge.pebble.domain.Theme.backup()
    //#input(void backup()): __Descendant_Table[net/sourceforge/pebble/domain/Theme]
    //#input(void backup()): __Descendant_Table[others]
    //#input(void backup()): __Dispatch_Table.getBackupThemeDirectory()Ljava/lang/String;
    //#input(void backup()): log
    //#input(void backup()): this
    //#input(void backup()): this.__Tag
    //#input(void backup()): this.blog
    //#input(void backup()): this.name
    //#input(void backup()): this.pathToLiveThemes
    //#pre[1] (void backup()): log != null
    //#pre[3] (void backup()): this.__Tag == net/sourceforge/pebble/domain/Theme
    //#pre[4] (void backup()): this.blog != null
    //#pre[5] (void backup()): init'ed(this.name)
    //#pre[6] (void backup()): init'ed(this.pathToLiveThemes)
    //#unanalyzed(void backup()): Effects-of-calling:net.sourceforge.pebble.domain.Blog:getRoot
    //#unanalyzed(void backup()): Effects-of-calling:java.lang.String:valueOf
    //#unanalyzed(void backup()): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void backup()): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void backup()): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void backup()): Effects-of-calling:java.io.File
    //#unanalyzed(void backup()): Effects-of-calling:java.io.File:exists
    //#unanalyzed(void backup()): Effects-of-calling:java.io.File:mkdir
    //#unanalyzed(void backup()): Effects-of-calling:java.io.File:listFiles
    //#unanalyzed(void backup()): Effects-of-calling:java.io.File:isDirectory
    //#unanalyzed(void backup()): Effects-of-calling:java.io.File:getName
    //#unanalyzed(void backup()): Effects-of-calling:copy
    //#unanalyzed(void backup()): Effects-of-calling:java.io.FileInputStream
    //#unanalyzed(void backup()): Effects-of-calling:java.io.FileInputStream:getChannel
    //#unanalyzed(void backup()): Effects-of-calling:java.io.FileOutputStream
    //#unanalyzed(void backup()): Effects-of-calling:java.io.FileOutputStream:getChannel
    //#unanalyzed(void backup()): Effects-of-calling:java.nio.channels.FileChannel:size
    //#unanalyzed(void backup()): Effects-of-calling:java.nio.channels.FileChannel:transferFrom
    //#unanalyzed(void backup()): Effects-of-calling:java.nio.channels.FileChannel:close
    //#unanalyzed(void backup()): Effects-of-calling:java.io.File:getAbsolutePath
    //#unanalyzed(void backup()): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(void backup()): Effects-of-calling:net.sourceforge.pebble.util.FileUtils:deleteFile
    //#unanalyzed(void backup()): Effects-of-calling:org.apache.commons.logging.Log:debug
    //#unanalyzed(void backup()): Effects-of-calling:java.io.File:renameTo
  }
    //#theme.java:128: end of method: void net.sourceforge.pebble.domain.Theme.backup()

  /**
   * Backs up the named theme from the webapp to the blog.dir.
   *
   * @param themeName   the name of the theme to backup
   */
  private void backup(String themeName) {
    log.debug("Backing up " + themeName + " theme to " + getBackupThemeDirectory());
    //#theme.java:136: method: void net.sourceforge.pebble.domain.Theme.backup(String)
    //#theme.java:136: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.domain.Theme
    //#    method: void backup(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    //#input(void backup(String)): __Descendant_Table[net/sourceforge/pebble/domain/Theme]
    //#input(void backup(String)): __Descendant_Table[others]
    //#input(void backup(String)): __Dispatch_Table.getBackupThemeDirectory()Ljava/lang/String;
    //#input(void backup(String)): log
    //#input(void backup(String)): themeName
    //#input(void backup(String)): this
    //#input(void backup(String)): this.__Tag
    //#input(void backup(String)): this.blog
    //#input(void backup(String)): this.pathToLiveThemes
    //#pre[1] (void backup(String)): log != null
    //#pre[4] (void backup(String)): this.__Tag == net/sourceforge/pebble/domain/Theme
    //#pre[5] (void backup(String)): this.blog != null
    //#pre[6] (void backup(String)): init'ed(this.pathToLiveThemes)
    //#unanalyzed(void backup(String)): Effects-of-calling:net.sourceforge.pebble.domain.Blog:getRoot
    //#unanalyzed(void backup(String)): Effects-of-calling:java.lang.String:valueOf
    //#unanalyzed(void backup(String)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void backup(String)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void backup(String)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void backup(String)): Effects-of-calling:java.io.File:exists
    //#unanalyzed(void backup(String)): Effects-of-calling:java.io.File:mkdir
    //#unanalyzed(void backup(String)): Effects-of-calling:java.io.File:listFiles
    //#unanalyzed(void backup(String)): Effects-of-calling:java.io.File:isDirectory
    //#unanalyzed(void backup(String)): Effects-of-calling:java.io.File:getName
    //#unanalyzed(void backup(String)): Effects-of-calling:java.io.File
    //#unanalyzed(void backup(String)): Effects-of-calling:copy
    //#unanalyzed(void backup(String)): Effects-of-calling:java.io.FileInputStream
    //#unanalyzed(void backup(String)): Effects-of-calling:java.io.FileInputStream:getChannel
    //#unanalyzed(void backup(String)): Effects-of-calling:java.io.FileOutputStream
    //#unanalyzed(void backup(String)): Effects-of-calling:java.io.FileOutputStream:getChannel
    //#unanalyzed(void backup(String)): Effects-of-calling:java.nio.channels.FileChannel:size
    //#unanalyzed(void backup(String)): Effects-of-calling:java.nio.channels.FileChannel:transferFrom
    //#unanalyzed(void backup(String)): Effects-of-calling:java.nio.channels.FileChannel:close
    //#unanalyzed(void backup(String)): Effects-of-calling:java.io.File:getAbsolutePath
    //#unanalyzed(void backup(String)): Effects-of-calling:org.apache.commons.logging.Log:error
    //#test_vector(void backup(String)): java.io.File:exists(...)@141: {0}, {1}
    File liveTheme = new File(pathToLiveThemes, themeName);
    File blogTheme = new File(getBackupThemeDirectory());
    File blogThemeBackup = new File(getBackupThemeDirectory() + ".bak");

    if (blogTheme.exists()) {
      blogTheme.renameTo(blogThemeBackup);
    }
    copy(liveTheme, blogTheme);
    FileUtils.deleteFile(blogThemeBackup);
    //#theme.java:145: Warning: method not available
    //#    -- call on void net.sourceforge.pebble.util.FileUtils:deleteFile(File)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.domain.Theme
    //#    method: void backup(String)
    //#    unanalyzed callee: void net.sourceforge.pebble.util.FileUtils:deleteFile(File)
  }
    //#theme.java:146: end of method: void net.sourceforge.pebble.domain.Theme.backup(String)

  /**
   * Copies the named theme from the webapp to blog.dir/theme.
   *
   * @param themeName   the name of the theme to backup
   */
  private void copy(String themeName) {
    log.info("Copying " + themeName + " theme to " + getBackupThemeDirectory());
    //#theme.java:154: method: void net.sourceforge.pebble.domain.Theme.copy(String)
    //#theme.java:154: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.domain.Theme
    //#    method: void copy(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
    //#input(void copy(String)): __Descendant_Table[net/sourceforge/pebble/domain/Theme]
    //#input(void copy(String)): __Descendant_Table[others]
    //#input(void copy(String)): __Dispatch_Table.getBackupThemeDirectory()Ljava/lang/String;
    //#input(void copy(String)): log
    //#input(void copy(String)): themeName
    //#input(void copy(String)): this
    //#input(void copy(String)): this.__Tag
    //#input(void copy(String)): this.blog
    //#input(void copy(String)): this.pathToLiveThemes
    //#pre[1] (void copy(String)): log != null
    //#pre[4] (void copy(String)): this.__Tag == net/sourceforge/pebble/domain/Theme
    //#pre[5] (void copy(String)): this.blog != null
    //#pre[6] (void copy(String)): init'ed(this.pathToLiveThemes)
    //#unanalyzed(void copy(String)): Effects-of-calling:net.sourceforge.pebble.domain.Blog:getRoot
    //#unanalyzed(void copy(String)): Effects-of-calling:java.lang.String:valueOf
    //#unanalyzed(void copy(String)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void copy(String)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void copy(String)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void copy(String)): Effects-of-calling:java.io.File:exists
    //#unanalyzed(void copy(String)): Effects-of-calling:java.io.File:mkdir
    //#unanalyzed(void copy(String)): Effects-of-calling:java.io.File:listFiles
    //#unanalyzed(void copy(String)): Effects-of-calling:java.io.File:isDirectory
    //#unanalyzed(void copy(String)): Effects-of-calling:java.io.File:getName
    //#unanalyzed(void copy(String)): Effects-of-calling:java.io.File
    //#unanalyzed(void copy(String)): Effects-of-calling:copy
    //#unanalyzed(void copy(String)): Effects-of-calling:java.io.FileInputStream
    //#unanalyzed(void copy(String)): Effects-of-calling:java.io.FileInputStream:getChannel
    //#unanalyzed(void copy(String)): Effects-of-calling:java.io.FileOutputStream
    //#unanalyzed(void copy(String)): Effects-of-calling:java.io.FileOutputStream:getChannel
    //#unanalyzed(void copy(String)): Effects-of-calling:java.nio.channels.FileChannel:size
    //#unanalyzed(void copy(String)): Effects-of-calling:java.nio.channels.FileChannel:transferFrom
    //#unanalyzed(void copy(String)): Effects-of-calling:java.nio.channels.FileChannel:close
    //#unanalyzed(void copy(String)): Effects-of-calling:java.io.File:getAbsolutePath
    //#unanalyzed(void copy(String)): Effects-of-calling:org.apache.commons.logging.Log:error
    //#test_vector(void copy(String)): java.io.File:exists(...)@159: {0}, {1}
    File liveTheme = new File(pathToLiveThemes, themeName);
    File blogTheme = new File(getBackupThemeDirectory());
    File blogThemeBackup = new File(getBackupThemeDirectory() + ".bak");

    if (blogTheme.exists()) {
      blogTheme.renameTo(blogThemeBackup);
    }
    copy(liveTheme, blogTheme);
    FileUtils.deleteFile(blogThemeBackup);
    //#theme.java:163: Warning: method not available
    //#    -- call on void net.sourceforge.pebble.util.FileUtils:deleteFile(File)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.domain.Theme
    //#    method: void copy(String)
    //#    unanalyzed callee: void net.sourceforge.pebble.util.FileUtils:deleteFile(File)
  }
    //#theme.java:164: end of method: void net.sourceforge.pebble.domain.Theme.copy(String)

  /**
   * Copies one file to another.
   *
   * @param source        the source
   * @param destination   the destination
   */
  private void copy(File source, File destination) {
    if (!destination.exists()) {
    //#theme.java:173: method: void net.sourceforge.pebble.domain.Theme.copy(File, File)
    //#input(void copy(File, File)): destination
    //#input(void copy(File, File)): log
    //#input(void copy(File, File)): source
    //#input(void copy(File, File)): this
    //#pre[1] (void copy(File, File)): destination != null
    //#pre[3] (void copy(File, File)): source != null
    //#pre[2] (void copy(File, File)): (soft) log != null
    //#presumption(void copy(File, File)): files.length@177 <= 4_294_967_295
    //#presumption(void copy(File, File)): files[i]@177 != null
    //#presumption(void copy(File, File)): java.io.FileInputStream:getChannel(...)@184 != null
    //#presumption(void copy(File, File)): java.io.FileOutputStream:getChannel(...)@185 != null
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.io.File:exists
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.io.File:mkdir
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.io.File:listFiles
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.io.File:isDirectory
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.io.File:getName
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.io.File
    //#unanalyzed(void copy(File, File)): Effects-of-calling:copy
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.io.FileInputStream
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.io.FileInputStream:getChannel
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.io.FileOutputStream
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.io.FileOutputStream:getChannel
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.nio.channels.FileChannel:size
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.nio.channels.FileChannel:transferFrom
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.nio.channels.FileChannel:close
    //#unanalyzed(void copy(File, File)): Effects-of-calling:java.io.File:getAbsolutePath
    //#unanalyzed(void copy(File, File)): Effects-of-calling:org.apache.commons.logging.Log:error
    //#test_vector(void copy(File, File)): java.io.File:exists(...)@173: {1}, {0}
    //#test_vector(void copy(File, File)): java.io.File:isDirectory(...)@180: {0}, {1}
    //#test_vector(void copy(File, File)): java.io.File:listFiles(...)@177: Addr_Set{null}, Inverse{null}
      destination.mkdir();
    }

    File files[] = source.listFiles();
    if (files != null) {
      for (int i = 0; i < files.length; i++) {
        if (files[i].isDirectory()) {
          copy(files[i], new File(destination, files[i].getName()));
        } else {
          try {
              FileChannel srcChannel = new FileInputStream(files[i]).getChannel();
              FileChannel dstChannel = new FileOutputStream(new File(destination, files[i].getName())).getChannel();
              dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
              srcChannel.close();
              dstChannel.close();
          } catch (IOException ioe) {
            log.error("Could not write to " + destination.getAbsolutePath(), ioe);
    //#theme.java:190: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:error(Object, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.domain.Theme
    //#    method: void copy(File, File)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:error(Object, Throwable)
          }
        }
      }
    }
  }
    //#theme.java:195: end of method: void net.sourceforge.pebble.domain.Theme.copy(File, File)

  /**
   * Gets the name of this theme.
   *
   * @return    the name
   */
  public String getName() {
    return name;
    //#theme.java:203: method: String net.sourceforge.pebble.domain.Theme.getName()
    //#input(String getName()): this
    //#input(String getName()): this.name
    //#output(String getName()): return_value
    //#pre[2] (String getName()): init'ed(this.name)
    //#post(String getName()): return_value == this.name
    //#post(String getName()): init'ed(return_value)
    //#theme.java:203: end of method: String net.sourceforge.pebble.domain.Theme.getName()
  }

}    //#theme.java:: end of class: net.sourceforge.pebble.domain.Theme
