X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fproject%2FProject.java;h=b80c29322396953feb3ef45d1ecc9df92da04734;hb=dc77498d76f44c218603e026b825b389865bba73;hp=c54f211de9de171636fc569c88889c1a14261561;hpb=1b87930e43eb7d14068a21ed0b488f28cc6ce49b;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/project/Project.java b/src/net/pterodactylus/jsite/project/Project.java index c54f211..b80c293 100644 --- a/src/net/pterodactylus/jsite/project/Project.java +++ b/src/net/pterodactylus/jsite/project/Project.java @@ -20,16 +20,15 @@ package net.pterodactylus.jsite.project; import java.beans.PropertyChangeListener; -import java.io.File; -import java.util.ArrayList; -import java.util.List; +import java.util.HashMap; +import java.util.Map; import net.pterodactylus.util.beans.AbstractBean; /** * Container for project information. A Project is capable of notifying * {@link PropertyChangeListener}s if any of the contained properties change. - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ public class Project extends AbstractBean { @@ -49,9 +48,6 @@ public class Project extends AbstractBean { /** Name of the “base path” property. */ public static final String PROPERTY_BASE_PATH = "basePath"; - /** Name of the “base path entries” property. */ - public static final String PROPERTY_BASE_PATH_ENTRIES = "basePathEntries"; - /** Internal ID. */ private String id; @@ -70,11 +66,8 @@ public class Project extends AbstractBean { /** The base path of the project. */ private String basePath; - /** The list of files from the base path. */ - private List basePathEntries = new ArrayList(); - - /** The list of virtual files. */ - private List virtualEntries = new ArrayList(); + /** The overrides. */ + private final Map overrides = new HashMap(); /** * Creates a new project. @@ -85,7 +78,7 @@ public class Project extends AbstractBean { /** * Clones the given project. - * + * * @param project */ Project(Project project) { @@ -94,13 +87,11 @@ public class Project extends AbstractBean { 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. - * + * * @return The internal ID */ String getId() { @@ -109,7 +100,7 @@ public class Project extends AbstractBean { /** * Sets the internal ID. - * + * * @param id * The internal ID */ @@ -119,7 +110,7 @@ public class Project extends AbstractBean { /** * Returns the name of the project. - * + * * @return The name of the project */ public String getName() { @@ -128,7 +119,7 @@ public class Project extends AbstractBean { /** * Sets the name of the project. - * + * * @param name * The name of the project */ @@ -140,7 +131,7 @@ public class Project extends AbstractBean { /** * Returns the description of the project. - * + * * @return The description of the project */ public String getDescription() { @@ -149,7 +140,7 @@ public class Project extends AbstractBean { /** * Sets the description of the project - * + * * @param description * The description of the project */ @@ -161,7 +152,7 @@ public class Project extends AbstractBean { /** * Returns the public key of the project. - * + * * @return The public key of the project */ public String getPublicKey() { @@ -170,7 +161,7 @@ public class Project extends AbstractBean { /** * Sets the public key of the project. - * + * * @param publicKey * The public key of the project */ @@ -182,7 +173,7 @@ public class Project extends AbstractBean { /** * Returns the private key of the project. - * + * * @return The private key of the project */ public String getPrivateKey() { @@ -191,7 +182,7 @@ public class Project extends AbstractBean { /** * Sets the private key of the project. - * + * * @param privateKey * The private key of the project */ @@ -203,7 +194,7 @@ public class Project extends AbstractBean { /** * Returns the base path of the project. - * + * * @return The base path of the project */ public String getBasePath() { @@ -212,7 +203,7 @@ public class Project extends AbstractBean { /** * Sets the base path of the project. - * + * * @param basePath * The base path of the project */ @@ -223,83 +214,34 @@ public class Project extends AbstractBean { } /** - * Rescans the base path for new or changed files. - */ - public void rescanBasePath() { - List entries = new ArrayList(); - scanPath("", entries); - basePathEntries.clear(); - basePathEntries.addAll(entries); - firePropertyChange(PROPERTY_BASE_PATH_ENTRIES, null, null); - } - - /** - * Returns the list of files from the base path. - * - * @return The list of files from the base path + * Adds an override for the given file. + * + * @param filePath + * The file path + * @param override + * The override for the file */ - public List getBasePathEntries() { - return basePathEntries; + public void addOverride(String filePath, Override override) { + overrides.put(filePath, override); } /** - * Returns the list of visual entries. - * - * @return The visual entries + * Removes the override for the given file. + * + * @param filePath + * The file path for which to remove the override */ - public List getVirtualEntries() { - return virtualEntries; + public void removeOverride(String filePath) { + overrides.remove(filePath); } /** - * 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 null 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 - // - - /** - * Scans the given path relative to {@link #basePath} for files and adds - * them to the given list of entries. - * - * @param currentPath - * The current path, relative to the base path - * @param entries - * The list of entries + * Returns the list of {@link Override}s. + * + * @return All overrides */ - private void scanPath(String currentPath, List entries) { - File currentDirectory = new File(basePath + File.separatorChar + currentPath); - if (!currentDirectory.isDirectory()) { - return; - } - for (File file: currentDirectory.listFiles()) { - String fileName = currentPath + file.getName(); - if (file.isDirectory()) { - scanPath(fileName + File.separatorChar, entries); - continue; - } - PhysicalEntry entry = new PhysicalEntry(); - entry.setName(fileName); - entry.setPath(file.getPath()); - entry.setInsert(!file.isHidden()); - entries.add(entry); - } + public Map getOverrides() { + return overrides; } }