/**
* @author David Roden <dr@todesbaum.dyndns.org>
- * @version $Id: Project.java 357 2006-03-24 15:46:03Z bombe $
+ * @version $Id$
*/
-public abstract class Project implements Comparable {
+public class Project implements Comparable {
protected String name;
protected String description;
protected String localPath;
protected String path;
protected long lastInsertionTime;
+ /** The edition to insert to. */
+ protected int edition;
protected Map<String, FileOption> fileOptions = new HashMap<String, FileOption>();
insertURI = project.insertURI;
requestURI = project.requestURI;
path = project.path;
+ edition = project.edition;
localPath = project.localPath;
indexFile = project.indexFile;
lastInsertionTime = project.lastInsertionTime;
* The title to set.
*/
public void setName(String title) {
- this.name = title;
+ name = title;
}
/**
* The lastInserted to set.
*/
public void setLastInsertionTime(long lastInserted) {
- this.lastInsertionTime = lastInserted;
+ lastInsertionTime = lastInserted;
}
/**
* The name to set.
*/
public void setPath(String name) {
- this.path = name;
+ path = name;
}
/**
* The insertURI to set.
*/
public void setInsertURI(String insertURI) {
- this.insertURI = insertURI;
+ this.insertURI = shortenURI(insertURI);
}
/**
* The requestURI to set.
*/
public void setRequestURI(String requestURI) {
- this.requestURI = requestURI;
+ this.requestURI = shortenURI(requestURI);
}
+ @Override
public String toString() {
return name;
}
+
+ private String shortenURI(String uri) {
+ if (uri.startsWith("freenet:")) {
+ uri = uri.substring("freenet:".length());
+ }
+ if (uri.startsWith("SSK@")) {
+ uri = uri.substring("SSK@".length());
+ }
+ if (uri.startsWith("USK@")) {
+ uri = uri.substring("USK@".length());
+ }
+ if (uri.endsWith("/")) {
+ uri = uri.substring(0, uri.length() - 1);
+ }
+ return uri;
+ }
public String shortenFilename(File file) {
String filename = file.getPath();
}
public void setFileOption(String filename, FileOption fileOption) {
- fileOptions.put(filename, fileOption);
+ if (fileOption != null) {
+ fileOptions.put(filename, fileOption);
+ } else {
+ fileOptions.remove(filename);
+ }
}
/**
* @return Returns the fileOptions.
*/
public Map<String, FileOption> getFileOptions() {
- return Collections.unmodifiableMap(fileOptions);
+ return Collections.unmodifiableMap(new HashMap<String, FileOption>(fileOptions));
}
/**
this.fileOptions.clear();
this.fileOptions.putAll(fileOptions);
}
-
- public String getFinalURI(int editionOffset) {
- return requestURI + path + "/";
- }
-
+
/**
* {@inheritDoc}
*/
return name.compareToIgnoreCase(((Project) o).name);
}
+ /**
+ * Returns the edition of the project.
+ *
+ * @return The edition of the project
+ */
+ public int getEdition() {
+ return edition;
+ }
+
+ /**
+ * Sets the edition of the project.
+ *
+ * @param edition
+ * The edition to set
+ */
+ public void setEdition(int edition) {
+ this.edition = edition;
+ }
+
+ /**
+ * Constructs the final request URI including the edition number.
+ *
+ * @return The final request URI
+ */
+ public String getFinalRequestURI(int offset) {
+ return "freenet:USK@" + requestURI + "/" + path + "/" + (edition + offset) + "/";
+ }
+
}