2 * jSite - a tool for uploading websites into Freenet
3 * Copyright (C) 2006 David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package de.todesbaum.jsite.application;
23 import java.util.Collections;
24 import java.util.HashMap;
27 import de.todesbaum.util.mime.DefaultMIMETypes;
30 * @author David Roden <dr@todesbaum.dyndns.org>
31 * @version $Id: Project.java 357 2006-03-24 15:46:03Z bombe $
33 public abstract class Project implements Comparable {
35 protected String name;
36 protected String description;
38 protected String insertURI;
39 protected String requestURI;
41 protected String indexFile;
42 protected String localPath;
43 protected String path;
44 protected long lastInsertionTime;
46 protected Map<String, FileOption> fileOptions = new HashMap<String, FileOption>();
56 public Project(Project project) {
58 description = project.description;
59 insertURI = project.insertURI;
60 requestURI = project.requestURI;
62 localPath = project.localPath;
63 indexFile = project.indexFile;
64 lastInsertionTime = project.lastInsertionTime;
65 fileOptions = new HashMap<String, FileOption>(project.fileOptions);
69 * @return Returns the title.
71 public String getName() {
79 public void setName(String title) {
84 * @return Returns the description.
86 public String getDescription() {
92 * The description to set.
94 public void setDescription(String description) {
95 this.description = description;
99 * @return Returns the localPath.
101 public String getLocalPath() {
107 * The localPath to set.
109 public void setLocalPath(String localPath) {
110 this.localPath = localPath;
114 * @return Returns the indexFile.
116 public String getIndexFile() {
122 * The indexFile to set.
124 public void setIndexFile(String indexFile) {
125 this.indexFile = indexFile;
129 * @return Returns the lastInserted.
131 public long getLastInsertionTime() {
132 return lastInsertionTime;
136 * @param lastInserted
137 * The lastInserted to set.
139 public void setLastInsertionTime(long lastInserted) {
140 this.lastInsertionTime = lastInserted;
144 * @return Returns the name.
146 public String getPath() {
154 public void setPath(String name) {
159 * @return Returns the insertURI.
161 public String getInsertURI() {
167 * The insertURI to set.
169 public void setInsertURI(String insertURI) {
170 this.insertURI = insertURI;
174 * @return Returns the requestURI.
176 public String getRequestURI() {
182 * The requestURI to set.
184 public void setRequestURI(String requestURI) {
185 this.requestURI = requestURI;
188 public String toString() {
192 public String shortenFilename(File file) {
193 String filename = file.getPath();
194 if (filename.startsWith(localPath)) {
195 filename = filename.substring(localPath.length());
196 if (filename.startsWith(File.separator)) {
197 filename = filename.substring(1);
203 public FileOption getFileOption(String filename) {
204 FileOption fileOption = fileOptions.get(filename);
205 if (fileOption == null) {
206 fileOption = new FileOption(DefaultMIMETypes.guessMIMEType(filename));
207 fileOptions.put(filename, fileOption);
212 public void setFileOption(String filename, FileOption fileOption) {
213 fileOptions.put(filename, fileOption);
217 * @return Returns the fileOptions.
219 public Map<String, FileOption> getFileOptions() {
220 return Collections.unmodifiableMap(fileOptions);
225 * The fileOptions to set.
227 public void setFileOptions(Map<String, FileOption> fileOptions) {
228 this.fileOptions.clear();
229 this.fileOptions.putAll(fileOptions);
232 public String getFinalURI(int editionOffset) {
233 return requestURI + path + "/";
239 public int compareTo(Object o) {
240 return name.compareToIgnoreCase(((Project) o).name);