Add accessors for the configuration file location.
[jSite.git] / src / de / todesbaum / jsite / main / Configuration.java
index e98a18d..ca5a1af 100644 (file)
@@ -49,6 +49,27 @@ import de.todesbaum.util.xml.XML;
  */
 public class Configuration {
 
+       /**
+        * The location of the configuration directory.
+        *
+        * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
+        */
+       public enum ConfigurationDirectory {
+
+               /** The configuration is in the same directory as the JAR file. */
+               NEXT_TO_JAR_FILE,
+
+               /**
+                * The configuration is in the user’s home directory. This is the
+                * pre-0.9.3 default.
+                */
+               HOME_DIRECTORY;
+
+       }
+
+       /** The configuration directory. */
+       private ConfigurationDirectory configurationDirectory = ConfigurationDirectory.HOME_DIRECTORY;
+
        /** The name of the file the configuration is stored to. */
        private String filename;
 
@@ -92,6 +113,25 @@ public class Configuration {
        }
 
        /**
+        * Returns the configuration directory.
+        *
+        * @return The configuration directory
+        */
+       public ConfigurationDirectory getConfigurationDirectory() {
+               return configurationDirectory;
+       }
+
+       /**
+        * Sets the configuration directory.
+        *
+        * @param configurationDirectory
+        *            The configuration directory
+        */
+       public void setConfigurationDirectory(ConfigurationDirectory configurationDirectory) {
+               this.configurationDirectory = configurationDirectory;
+       }
+
+       /**
         * Creates the directory of the configuration file.
         *
         * @return <code>true</code> if the directory exists, or if it could be
@@ -332,7 +372,11 @@ public class Configuration {
                                        Project project = new Project();
                                        projects.add(project);
                                        project.setDescription(projectNode.getNode("description").getValue(""));
-                                       project.setIndexFile(projectNode.getNode("index-file").getValue(""));
+                                       String indexFile = projectNode.getNode("index-file").getValue("");
+                                       if (indexFile.indexOf('/') > -1) {
+                                               indexFile = "";
+                                       }
+                                       project.setIndexFile(indexFile);
                                        project.setLastInsertionTime(Long.parseLong(projectNode.getNode("last-insertion-time").getValue("0")));
                                        project.setLocalPath(projectNode.getNode("local-path").getValue(""));
                                        project.setName(projectNode.getNode("name").getValue(""));