/*
- * jSite - a tool for uploading websites into Freenet
- * Copyright (C) 2006 David Roden
+ * jSite - a tool for uploading websites into Freenet Copyright (C) 2006 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * 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 the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package de.todesbaum.jsite.application;
*/
public void setCustomKey(String customKey) {
if (customKey == null) {
- customKey = "";
+ this.customKey = "";
+ } else {
+ this.customKey = customKey;
}
- this.customKey = customKey;
}
/**
*/
public void setMimeType(String mimeType) {
if (mimeType == null) {
- mimeType = defaultMimeType;
+ this.mimeType = defaultMimeType;
+ } else {
+ this.mimeType = mimeType;
}
- this.mimeType = mimeType;
}
/**
*/
public void setContainer(String container) {
if (container == null) {
- container = DEFAULT_CONTAINER;
+ this.container = DEFAULT_CONTAINER;
+ } else {
+ this.container = container;
}
- this.container = container;
}
/**
* Sets whether the file should have “$[EDITION+<i>n</i>]” tags replaced.
*
* @param replaceEdition
- * <code>true</code> to replace tags, <code>false</code> not
- * to replace
+ * <code>true</code> to replace tags, <code>false</code> not to
+ * replace
*/
public void setReplaceEdition(boolean replaceEdition) {
this.replaceEdition = replaceEdition;
}
/**
- * Returns whether the file should have “$[EDITION+<i>n</i>]” tags
- * replaced.
+ * Returns whether the file should have “$[EDITION+<i>n</i>]” tags replaced.
*
- * @return <code>true</code> if tags should be replaced,
- * <code>false</code> otherwise
+ * @return <code>true</code> if tags should be replaced, <code>false</code>
+ * otherwise
*/
public boolean getReplaceEdition() {
return replaceEdition;
return false;
}
-}
\ No newline at end of file
+}
/*
- * jSite - a tool for uploading websites into Freenet
- * Copyright (C) 2006 David Roden
+ * jSite - a tool for uploading websites into Freenet Copyright (C) 2006 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * 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 the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package de.todesbaum.jsite.application;
/**
* Container for project information.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class Project implements Comparable<Project> {
/**
* Creates a new project from an existing one.
- *
+ *
* @param project
* The project to clone
*/
/**
* Returns the name of the project.
- *
+ *
* @return The name of the project
*/
public String getName() {
/**
* Sets the name of the project.
- *
+ *
* @param name
* The name of the project
*/
/**
* Returns the description of the project.
- *
+ *
* @return The description of the project
*/
public String getDescription() {
/**
* Sets the description of the project.
- *
+ *
* @param description
* The description of the project
*/
/**
* Returns the local path of the project.
- *
+ *
* @return The local path of the project
*/
public String getLocalPath() {
/**
* Sets the local path of the project.
- *
+ *
* @param localPath
* The local path of the project
*/
/**
* Returns the name of the index file of the project, relative to the
* project’s local path.
- *
+ *
* @return The name of the index file of the project
*/
public String getIndexFile() {
/**
* Sets the name of the index file of the project, relative to the project’s
* local path.
- *
+ *
* @param indexFile
* The name of the index file of the project
*/
/**
* Returns the time the project was last inserted, in milliseconds since the
* epoch.
- *
+ *
* @return The time of the last insertion
*/
public long getLastInsertionTime() {
/**
* Sets the time the project was last inserted, in milliseconds since the
* last epoch.
- *
+ *
* @param lastInserted
* The time of the last insertion
*/
/**
* Returns the remote path of the project. The remote path is the path that
* directly follows the request URI of the project.
- *
+ *
* @return The remote path of the project
*/
public String getPath() {
/**
* Sets the remote path of the project. The remote path is the path that
* directly follows the request URI of the project.
- *
+ *
* @param path
* The remote path of the project
*/
/**
* Returns the insert URI of the project.
- *
+ *
* @return The insert URI of the project
*/
public String getInsertURI() {
/**
* Sets the insert URI of the project.
- *
+ *
* @param insertURI
* The insert URI of the project
*/
/**
* Returns the request URI of the project.
- *
+ *
* @return The request URI of the project
*/
public String getRequestURI() {
/**
* Sets the request URI of the project.
- *
+ *
* @param requestURI
* The request URI of the project
*/
/**
* Shortens the given URI by removing scheme and key-type prefixes.
- *
+ *
* @param uri
* The URI to shorten
* @return The shortened URI
*/
private String shortenURI(String uri) {
- if (uri.startsWith("freenet:")) {
- uri = uri.substring("freenet:".length());
+ String shortUri = uri;
+ if (shortUri.startsWith("freenet:")) {
+ shortUri = shortUri.substring("freenet:".length());
}
- if (uri.startsWith("SSK@")) {
- uri = uri.substring("SSK@".length());
+ if (shortUri.startsWith("SSK@")) {
+ shortUri = shortUri.substring("SSK@".length());
}
- if (uri.startsWith("USK@")) {
- uri = uri.substring("USK@".length());
+ if (shortUri.startsWith("USK@")) {
+ shortUri = shortUri.substring("USK@".length());
}
- if (uri.endsWith("/")) {
- uri = uri.substring(0, uri.length() - 1);
+ if (shortUri.endsWith("/")) {
+ shortUri = shortUri.substring(0, shortUri.length() - 1);
}
- return uri;
+ return shortUri;
}
/**
* Shortens the name of the given file by removing the local path of the
* project and leading file separators.
- *
+ *
* @param file
* The file whose name should be shortened
* @return The shortened name of the file
* Returns the options for the file with the given name. If the file does
* not yet have any options, a new set of default options is created and
* returned.
- *
+ *
* @param filename
* The name of the file, relative to the project root
* @return The options for the file
/**
* Sets options for a file.
- *
+ *
* @param filename
* The filename to set the options for, relative to the project
* root
/**
* Returns all file options.
- *
+ *
* @return All file options
*/
public Map<String, FileOption> getFileOptions() {
/**
* Sets all file options.
- *
+ *
* @param fileOptions
* The file options
*/
/**
* Returns the edition of the project.
- *
+ *
* @return The edition of the project
*/
public int getEdition() {
/**
* Sets the edition of the project.
- *
+ *
* @param edition
* The edition to set
*/
/**
* Constructs the final request URI including the edition number.
- *
+ *
* @param offset
* The offset for the edition number
* @return The final request URI