X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fmain%2FConfiguration.java;h=e4e0510424f7a29d7160d07ece5325100f8f1752;hb=978a833ff2f68927ea0c376f9ad538069898f1e7;hp=1a06f374c62a154d8c4f4f504ea7b8690fd2f621;hpb=09fa4bb91cf4e7f4e29136232a9daac37ef48529;p=jSite.git diff --git a/src/de/todesbaum/jsite/main/Configuration.java b/src/de/todesbaum/jsite/main/Configuration.java index 1a06f37..e4e0510 100644 --- a/src/de/todesbaum/jsite/main/Configuration.java +++ b/src/de/todesbaum/jsite/main/Configuration.java @@ -44,7 +44,7 @@ import de.todesbaum.util.xml.XML; /** * @author David Roden <droden@gmail.com> - * @version $Id: Configuration.java 418 2006-03-29 17:49:16Z bombe $ + * @version $Id$ */ public class Configuration { @@ -53,13 +53,21 @@ public class Configuration { private SimpleXML rootNode; public Configuration() { - filename = System.getProperty("user.home") + "/.jSite/config7"; - lockFilename = System.getProperty("user.home") + "/.jSite/lock7"; + this(System.getProperty("user.home") + "/.jSite/config7"); + } + + public Configuration(String filename) { + this(filename, filename + ".lock"); + } + + public Configuration(String filename, String lockFilename) { + this.filename = filename; + this.lockFilename = lockFilename; readConfiguration(); } private boolean createConfigDirectory() { - File configDirectory = new File(System.getProperty("user.home"), ".jSite"); + File configDirectory = new File(filename).getAbsoluteFile().getParentFile(); return (configDirectory.exists() && configDirectory.isDirectory()) || configDirectory.mkdirs(); } @@ -112,7 +120,7 @@ public class Configuration { public boolean save() { File configurationFile = new File(filename); if (!configurationFile.exists()) { - File configurationFilePath = configurationFile.getParentFile(); + File configurationFilePath = configurationFile.getAbsoluteFile().getParentFile(); if (!configurationFilePath.exists() && !configurationFilePath.mkdirs()) { return false; } @@ -176,6 +184,7 @@ public class Configuration { * @return The hostname of the node * @deprecated Use {@link #getSelectedNode()} instead */ + @Deprecated public String getNodeAddress() { return getNodeValue(new String[] { "node-address" }, "localhost"); } @@ -185,6 +194,7 @@ public class Configuration { * @param nodeAddress The hostname of the node * @deprecated Use {@link #setSelectedNode(Node)} instead */ + @Deprecated public void setNodeAddress(String nodeAddress) { rootNode.replace("node-address", nodeAddress); } @@ -194,6 +204,7 @@ public class Configuration { * @return The port number of the node * @deprecated Use {@link #getSelectedNode()} instead. */ + @Deprecated public int getNodePort() { return getNodeIntValue(new String[] { "node-port" }, 9481); } @@ -203,6 +214,7 @@ public class Configuration { * @param nodePort The port number of the node * @deprecated Use {@link #setSelectedNode(Node)} instead */ + @Deprecated public void setNodePort(int nodePort) { rootNode.replace("node-port", String.valueOf(nodePort)); }