From ceba2763ae5c5b11a928a331438fb49be0a84e1d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 3 Jun 2008 08:53:16 +0200 Subject: [PATCH] load and save nodes in projects don't create ids for new projects --- src/net/pterodactylus/jsite/core/ProjectManager.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/net/pterodactylus/jsite/core/ProjectManager.java b/src/net/pterodactylus/jsite/core/ProjectManager.java index 782a5d6..2619650 100644 --- a/src/net/pterodactylus/jsite/core/ProjectManager.java +++ b/src/net/pterodactylus/jsite/core/ProjectManager.java @@ -35,10 +35,8 @@ import java.util.Map.Entry; import java.util.logging.Level; import java.util.logging.Logger; -import net.pterodactylus.jsite.util.IdGenerator; import net.pterodactylus.util.io.Closer; import net.pterodactylus.util.logging.Logging; -import net.pterodactylus.util.number.Hex; /** * Manages projects, taking care of persistence, lifetime statistics, and other @@ -137,6 +135,7 @@ public class ProjectManager implements PropertyChangeListener { String projectPublicKey = projectProperties.getProperty(projectPrefix + ".publicKey"); String projectBasePath = projectProperties.getProperty(projectPrefix + ".basePath"); String projectDefaultFile = projectProperties.getProperty(projectPrefix + ".defaultFile"); + String projectNode = projectProperties.getProperty(projectPrefix + ".node"); Project project = new Project(); project.setId(projectId); project.setName(projectName); @@ -145,6 +144,10 @@ public class ProjectManager implements PropertyChangeListener { project.setPublicKey(projectPublicKey); project.setBasePath(projectBasePath); project.setDefaultFile(projectDefaultFile); + if (projectNode != null) { + Node node = nodeManager.getNode(projectNode); + project.setNode(node); + } int overrideIndex = 0; while (projectProperties.containsKey(projectPrefix + ".overrides." + overrideIndex + ".override")) { String filePath = projectProperties.getProperty(projectPrefix + ".overrides." + overrideIndex + ".filePath"); @@ -183,6 +186,9 @@ public class ProjectManager implements PropertyChangeListener { projectProperties.setProperty(projectPrefix + ".publicKey", project.getPublicKey()); projectProperties.setProperty(projectPrefix + ".basePath", project.getBasePath()); projectProperties.setProperty(projectPrefix + ".defaultFile", project.getDefaultFile()); + if (project.getNode() != null) { + projectProperties.setProperty(projectPrefix + ".node", project.getNode().getId()); + } int overrideIndex = 0; for (Entry overrideEntry : project.getFileOverrides().entrySet()) { projectProperties.setProperty(projectPrefix + ".overrides." + overrideIndex + ".filePath", overrideEntry.getKey()); @@ -214,7 +220,6 @@ public class ProjectManager implements PropertyChangeListener { public Project createProject() throws IOException, JSiteException { Project project = new Project(); String[] keyPair = nodeManager.generateKeyPair(); - project.setId(Hex.toHex(IdGenerator.generateId())); project.setName(""); project.setDescription(""); project.setPrivateKey(keyPair[0]); @@ -243,7 +248,6 @@ public class ProjectManager implements PropertyChangeListener { public Project cloneProject(Project project) { Project projectClone = new Project(project); projects.add(projectClone); - projectClone.setId(Hex.toHex(IdGenerator.generateId())); projectClone.addPropertyChangeListener(this); try { save(); -- 2.7.4