implement project cloning
[jSite2.git] / src / net / pterodactylus / jsite / project / Project.java
index 1d1de85..c54f211 100644 (file)
@@ -31,7 +31,6 @@ import net.pterodactylus.util.beans.AbstractBean;
  * {@link PropertyChangeListener}s if any of the contained properties change.
  * 
  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
- * @version $Id$
  */
 public class Project extends AbstractBean {
 
@@ -74,6 +73,31 @@ public class Project extends AbstractBean {
        /** The list of files from the base path. */
        private List<Entry> basePathEntries = new ArrayList<Entry>();
 
+       /** The list of virtual files. */
+       private List<Entry> virtualEntries = new ArrayList<Entry>();
+
+       /**
+        * Creates a new project.
+        */
+       public Project() {
+               /* do nothing. */
+       }
+
+       /**
+        * Clones the given project.
+        * 
+        * @param project
+        */
+       Project(Project project) {
+               this.name = project.name;
+               this.description = project.description;
+               this.publicKey = project.publicKey;
+               this.privateKey = project.privateKey;
+               this.basePath = project.basePath;
+               this.basePathEntries.addAll(project.basePathEntries);
+               this.virtualEntries.addAll(project.virtualEntries);
+       }
+
        /**
         * Returns the internal ID.
         * 
@@ -218,6 +242,34 @@ public class Project extends AbstractBean {
                return basePathEntries;
        }
 
+       /**
+        * Returns the list of visual entries.
+        * 
+        * @return The visual entries
+        */
+       public List<Entry> getVirtualEntries() {
+               return virtualEntries;
+       }
+
+       /**
+        * Adds a virtual entry that redirects to the given target.
+        * 
+        * @param name
+        *            The name of the entry
+        * @param contentType
+        *            The content type of the entry, or <code>null</code> for
+        *            auto-detection
+        * @param target
+        *            The target URI of the redirect
+        */
+       public void addVirtualEntry(String name, String contentType, String target) {
+               RedirectEntry redirectEntry = new RedirectEntry();
+               redirectEntry.setName(name);
+               redirectEntry.setContentType(contentType);
+               redirectEntry.setTarget(target);
+               redirectEntry.setInsert(true);
+       }
+
        //
        // PRIVATE METHODS
        //