X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fmain%2FConfiguration.java;h=53bfb4daa54320632d2295c7d04df782f0955beb;hb=e813a9b8c976b7c24af33df253ce40ee1ec4c1d5;hp=75f2204849562c605be69fa188c16fe1a6e084ee;hpb=a7d2ac9e58d1fffbb8a9c63c7d4081e8717a6f7f;p=jSite.git diff --git a/src/de/todesbaum/jsite/main/Configuration.java b/src/de/todesbaum/jsite/main/Configuration.java index 75f2204..53bfb4d 100644 --- a/src/de/todesbaum/jsite/main/Configuration.java +++ b/src/de/todesbaum/jsite/main/Configuration.java @@ -1,6 +1,5 @@ /* - * jSite - a tool for uploading websites into Freenet - * Copyright (C) 2006 David Roden + * jSite - Configuration.java - Copyright © 2006–2011 David Roden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -336,8 +335,22 @@ public class Configuration { } else { project.setIgnoreHiddenFiles(true); } - SimpleXML fileOptionsNode = projectNode.getNode("file-options"); + + /* load last insert hashes. */ Map fileOptions = new HashMap(); + SimpleXML lastInsertHashesNode = projectNode.getNode("last-insert-hashes"); + if (lastInsertHashesNode != null) { + for (SimpleXML fileNode : lastInsertHashesNode.getNodes("file")) { + String filename = fileNode.getNode("filename").getValue(); + String lastInsertHash = fileNode.getNode("last-insert-hash").getValue(); + int lastInsertEdition = Integer.valueOf(fileNode.getNode("last-insert-edition").getValue()); + FileOption fileOption = project.getFileOption(filename); + fileOption.setLastInsertHash(lastInsertHash).setLastInsertEdition(lastInsertEdition); + fileOptions.put(filename, fileOption); + } + } + + SimpleXML fileOptionsNode = projectNode.getNode("file-options"); if (fileOptionsNode != null) { SimpleXML[] fileOptionNodes = fileOptionsNode.getNodes("file-option"); for (SimpleXML fileOptionNode : fileOptionNodes) { @@ -352,11 +365,6 @@ public class Configuration { fileOption.setChangedName(fileOptionNode.getNode("changed-name").getValue()); } fileOption.setMimeType(fileOptionNode.getNode("mime-type").getValue("")); - fileOption.setContainer(fileOptionNode.getNode("container").getValue()); - if (fileOptionNode.getNode("replace-edition") != null) { - fileOption.setReplaceEdition(Boolean.parseBoolean(fileOptionNode.getNode("replace-edition").getValue())); - fileOption.setEditionRange(Integer.parseInt(fileOptionNode.getNode("edition-range").getValue())); - } fileOptions.put(filename, fileOption); } } @@ -389,6 +397,19 @@ public class Configuration { projectNode.append("insert-uri", project.getInsertURI()); projectNode.append("request-uri", project.getRequestURI()); projectNode.append("ignore-hidden-files", String.valueOf(project.isIgnoreHiddenFiles())); + + /* store last insert hashes. */ + SimpleXML lastInsertHashesNode = projectNode.append("last-insert-hashes"); + for (Entry fileOption : project.getFileOptions().entrySet()) { + if ((fileOption.getValue().getLastInsertHash() == null) || (fileOption.getValue().getLastInsertHash().length() == 0)) { + continue; + } + SimpleXML fileNode = lastInsertHashesNode.append("file"); + fileNode.append("filename", fileOption.getKey()); + fileNode.append("last-insert-hash", fileOption.getValue().getLastInsertHash()); + fileNode.append("last-insert-edition", String.valueOf(fileOption.getValue().getLastInsertEdition())); + } + SimpleXML fileOptionsNode = projectNode.append("file-options"); Iterator> entries = project.getFileOptions().entrySet().iterator(); while (entries.hasNext()) { @@ -402,9 +423,6 @@ public class Configuration { fileOptionNode.append("custom-key", fileOption.getCustomKey()); fileOptionNode.append("changed-name", fileOption.getChangedName()); fileOptionNode.append("mime-type", fileOption.getMimeType()); - fileOptionNode.append("container", fileOption.getContainer()); - fileOptionNode.append("replace-edition", String.valueOf(fileOption.getReplaceEdition())); - fileOptionNode.append("edition-range", String.valueOf(fileOption.getEditionRange())); } } }