+ /**
+ * Creates a new project. The returned {@link Project} will contain a newly
+ * generated key pair.
+ *
+ * @return A newly created project
+ * @throws IOException
+ * if an I/O error occured communicating with the node
+ * @throws JSiteException
+ * if there is a problem with the node
+ */
+ public Project createProject() throws IOException, JSiteException {
+ Project project = new Project();
+ String[] keyPair = nodeManager.generateKeyPair();
+ project.setName("");
+ project.setDescription("");
+ project.setPrivateKey(keyPair[0]);
+ project.setPublicKey(keyPair[1]);
+ project.setBasePath("");
+ project.setDefaultFile("");
+ projects.add(project);
+ project.addPropertyChangeListener(this);
+ try {
+ save();
+ } catch (IOException ioe1) {
+ /* ignore. */
+ }
+ return project;
+ }
+
+ /**
+ * Clones the given project and returns the clone. The clone will be
+ * identical in all user-exposed fields, except for the project’s
+ * {@link Project#getId ID}.
+ *
+ * @param project
+ * The project to clone
+ * @return The cloned project
+ */
+ public Project cloneProject(Project project) {
+ Project projectClone = new Project(project);
+ projects.add(projectClone);
+ projectClone.addPropertyChangeListener(this);
+ try {
+ save();
+ } catch (IOException ioe1) {
+ /* ignore. */
+ }
+ return projectClone;
+ }
+
+ /**
+ * Removes the given project.
+ *
+ * @param project
+ * The project to remove
+ */
+ public void removeProject(Project project) {
+ projects.remove(project);
+ try {
+ save();
+ } catch (IOException ioe1) {
+ /* ignore. */
+ }
+ }
+
+ //
+ // INTERFACE PropertyChangeListener
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
+ try {
+ save();
+ } catch (IOException ioe1) {
+ /* ignore. */
+ }
+ }
+