From a3561508e6b6ab321df336c32e94ea25a1c2983e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 17 Mar 2012 03:06:56 +0100 Subject: [PATCH] Load and save last insert hashes. --- src/de/todesbaum/jsite/main/Configuration.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/de/todesbaum/jsite/main/Configuration.java b/src/de/todesbaum/jsite/main/Configuration.java index 6a12a65..1eb4b92 100644 --- a/src/de/todesbaum/jsite/main/Configuration.java +++ b/src/de/todesbaum/jsite/main/Configuration.java @@ -335,6 +335,17 @@ public class Configuration { } else { project.setIgnoreHiddenFiles(true); } + + /* load last insert hashes. */ + 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(); + project.getFileOption(filename).setLastInsertHash(lastInsertHash); + } + } + SimpleXML fileOptionsNode = projectNode.getNode("file-options"); Map fileOptions = new HashMap(); if (fileOptionsNode != null) { @@ -383,6 +394,18 @@ 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()); + } + SimpleXML fileOptionsNode = projectNode.append("file-options"); Iterator> entries = project.getFileOptions().entrySet().iterator(); while (entries.hasNext()) { -- 2.7.4