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
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);
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");
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<String, FileOverride> overrideEntry : project.getFileOverrides().entrySet()) {
projectProperties.setProperty(projectPrefix + ".overrides." + overrideIndex + ".filePath", overrideEntry.getKey());
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]);
public Project cloneProject(Project project) {
Project projectClone = new Project(project);
projects.add(projectClone);
- projectClone.setId(Hex.toHex(IdGenerator.generateId()));
projectClone.addPropertyChangeListener(this);
try {
save();