/*
- * jSite - Configuration.java - Copyright © 2006–2012 David Roden
+ * jSite - Configuration.java - Copyright © 2006–2014 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
import de.todesbaum.jsite.application.Node;
import de.todesbaum.jsite.application.Project;
import de.todesbaum.jsite.main.ConfigurationLocator.ConfigurationLocation;
-import de.todesbaum.util.freenet.fcp2.ClientPutDir.ManifestPutter;
import de.todesbaum.util.freenet.fcp2.PriorityClass;
+import org.w3c.dom.Document;
/**
* The configuration.
StreamCopier.copy(fileInputStream, fileByteOutputStream, configurationFile.length());
fileByteOutputStream.close();
byte[] fileBytes = fileByteOutputStream.toByteArray();
- rootNode = SimpleXML.fromDocument(XML.transformToDocument(fileBytes));
+ Document document = XML.transformToDocument(fileBytes);
+ if (document != null) {
+ rootNode = SimpleXML.fromDocument(document);
+ }
return;
} catch (FileNotFoundException e) {
/* ignore. */
*
* @return A list of all projects
*/
- public Project[] getProjects() {
+ public List<Project> getProjects() {
List<Project> projects = new ArrayList<Project>();
SimpleXML projectsNode = rootNode.getNode("project-list");
if (projectsNode != null) {
}
}
}
- return projects.toArray(new Project[projects.size()]);
+ return projects;
}
/**
* @param projects
* The list of all projects
*/
- public void setProjects(Project[] projects) {
+ public void setProjects(List<Project> projects) {
SimpleXML projectsNode = new SimpleXML("project-list");
for (Project project : projects) {
SimpleXML projectNode = projectsNode.append("project");
fileOptionNode.append("insert", String.valueOf(fileOption.isInsert()));
fileOptionNode.append("insert-redirect", String.valueOf(fileOption.isInsertRedirect()));
fileOptionNode.append("custom-key", fileOption.getCustomKey());
- fileOptionNode.append("changed-name", fileOption.getChangedName());
+ fileOptionNode.append("changed-name", fileOption.getChangedName().orElse(null));
fileOptionNode.append("mime-type", fileOption.getMimeType());
}
}
return this;
}
- /**
- * Returns the manifest putter.
- *
- * @return The manifest putter
- */
- public ManifestPutter getManifestPutter() {
- return ManifestPutter.valueOf(getNodeValue(new String[] { "manifest-putter" }, "simple").toUpperCase());
- }
-
- /**
- * Sets the manifest putter.
- *
- * @param manifestPutter
- * The manifest putter
- * @return This configuration
- */
- public Configuration setManifestPutter(ManifestPutter manifestPutter) {
- rootNode.replace("manifest-putter", manifestPutter.name().toLowerCase());
- return this;
- }
-
}