X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fmain%2FConfiguration.java;h=cf4bca526a8938a92b4238448f92ba99267193ef;hb=0123d73f009ae0bf018165f981eda16413129eae;hp=e4e0510424f7a29d7160d07ece5325100f8f1752;hpb=978a833ff2f68927ea0c376f9ad538069898f1e7;p=jSite.git diff --git a/src/de/todesbaum/jsite/main/Configuration.java b/src/de/todesbaum/jsite/main/Configuration.java index e4e0510..cf4bca5 100644 --- a/src/de/todesbaum/jsite/main/Configuration.java +++ b/src/de/todesbaum/jsite/main/Configuration.java @@ -34,17 +34,16 @@ import java.util.Locale; import java.util.Map; import java.util.Map.Entry; -import de.todesbaum.jsite.application.EditionProject; import de.todesbaum.jsite.application.FileOption; import de.todesbaum.jsite.application.Node; import de.todesbaum.jsite.application.Project; +import de.todesbaum.util.io.Closer; import de.todesbaum.util.io.StreamCopier; import de.todesbaum.util.xml.SimpleXML; import de.todesbaum.util.xml.XML; /** - * @author David Roden <droden@gmail.com> - * @version $Id$ + * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ public class Configuration { @@ -100,18 +99,8 @@ public class Configuration { } catch (FileNotFoundException e) { } catch (IOException e) { } finally { - if (fileInputStream != null) { - try { - fileInputStream.close(); - } catch (IOException ioe1) { - } - } - if (fileByteOutputStream != null) { - try { - fileByteOutputStream.close(); - } catch (IOException ioe1) { - } - } + Closer.close(fileInputStream); + Closer.close(fileByteOutputStream); } } rootNode = new SimpleXML("configuration"); @@ -135,18 +124,8 @@ public class Configuration { return true; } catch (IOException ioe1) { } finally { - if (configurationInputStream != null) { - try { - configurationInputStream.close(); - } catch (IOException ioe1) { - } - } - if (fileOutputStream != null) { - try { - fileOutputStream.close(); - } catch (IOException ioe1) { - } - } + Closer.close(configurationInputStream); + Closer.close(fileOutputStream); } return false; } @@ -234,13 +213,7 @@ public class Configuration { SimpleXML[] projectNodes = projectsNode.getNodes("project"); for (SimpleXML projectNode: projectNodes) { try { - Project project = null; - SimpleXML typeNode = projectNode.getNode("type"); - if ("edition".equals(typeNode.getValue())) { - EditionProject editionProject = new EditionProject(); - project = editionProject; - editionProject.setEdition(Integer.parseInt(projectNode.getNode("edition").getValue())); - } + Project project = new Project(); projects.add(project); project.setDescription(projectNode.getNode("description").getValue()); project.setIndexFile(projectNode.getNode("index-file").getValue()); @@ -248,6 +221,10 @@ public class Configuration { project.setLocalPath(projectNode.getNode("local-path").getValue()); project.setName(projectNode.getNode("name").getValue()); project.setPath(projectNode.getNode("path").getValue()); + if ((project.getPath() != null) && (project.getPath().indexOf("/") != -1)) { + project.setPath(project.getPath().replaceAll("/", "")); + } + project.setEdition(Integer.parseInt(projectNode.getNode("edition").getValue())); project.setInsertURI(projectNode.getNode("insert-uri").getValue()); project.setRequestURI(projectNode.getNode("request-uri").getValue()); SimpleXML fileOptionsNode = projectNode.getNode("file-options"); @@ -281,10 +258,7 @@ public class Configuration { SimpleXML projectsNode = new SimpleXML("project-list"); for (Project project: projects) { SimpleXML projectNode = projectsNode.append("project"); - if (project instanceof EditionProject) { - projectNode.append("type", "edition"); - projectNode.append("edition", String.valueOf(((EditionProject) project).getEdition())); - } + projectNode.append("edition", String.valueOf(project.getEdition())); projectNode.append("description", project.getDescription()); projectNode.append("index-file", project.getIndexFile()); projectNode.append("last-insertion-time", String.valueOf(project.getLastInsertionTime()));