001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018:
019: package org.apache.roller.business;
020:
021: import java.io.InputStream;
022: import org.apache.roller.pojos.WeblogResource;
023: import org.apache.roller.pojos.WebsiteData;
024:
025: /**
026: * Interface for managing files uploaded to Roller.
027: */
028: public interface FileManager {
029:
030: /**
031: * Get a reference to a specific file in a weblog's uploads area.
032: *
033: * This method always returns a valid file or will throw an exception
034: * if the specificed path doesn't exist, is a directory, or can't be read.
035: *
036: * @param weblog The weblog we are working on.
037: * @param path The relative path to the desired resource within
038: * the weblog's uploads area.
039: *
040: * @throws FileNotFoundException If path does not exist.
041: * @throws FilePathException If path is invalid, is a directory, or can't be read.
042: *
043: * @return WeblogResource representing the real file resource.
044: */
045: public WeblogResource getFile(WebsiteData weblog, String path)
046: throws FileNotFoundException, FilePathException;
047:
048: /**
049: * Get list of files from a specific path of the weblog's uploads area.
050: *
051: * This method will return a WeblogResource[] array of all files at the
052: * given path if it exists, otherwise it will throw an exception.
053: *
054: * This method should return the files at the root of the weblog's uploads
055: * area given a path value of null, "" (empty string), or "/"
056: *
057: * This method should NOT return any resources which represent directories.
058: *
059: * @param weblog The weblog we are working on.
060: * @param path The relative path to the desired resource within
061: * the weblog's uploads area.
062: *
063: * @throws FileNotFoundException If path does not exist.
064: * @throws FilePathException If path is invalid, is not a directory, or can't be read.
065: *
066: * @return WeblogResource[] of files in website's uploads area at given path.
067: */
068: public WeblogResource[] getFiles(WebsiteData weblog, String path)
069: throws FileNotFoundException, FilePathException;
070:
071: /**
072: * Get list of directories from a weblog's uploads area.
073: *
074: * This method will return an array of all dirs in the weblogs' uploads
075: * area, otherwise it will throw an exception.
076: *
077: * @param weblog The weblog we are working on.
078: *
079: * @throws FileNotFoundException If path does not exist.
080: * @throws FilePathException If path is invalid, or can't be read.
081: *
082: * @return WeblogResource[] of directories in website's uploads area.
083: */
084: public WeblogResource[] getDirectories(WebsiteData weblog)
085: throws FileNotFoundException, FilePathException;
086:
087: /**
088: * Save a file to weblog's uploads area.
089: *
090: * @param weblog The weblog we are working on.
091: * @param path The relative path to the desired location within
092: * the weblog's uploads area where the file should be saved.
093: * @param contentType Content type of the file.
094: * @param size Size of file to be saved.
095: * @param is InputStream to read the file from.
096: *
097: * @throws FileNotFoundException If path to save location does not exist.
098: * @throws FilePathException If path is invalid, is not a directory, or can't be read.
099: * @throws FileIOException If there is an unexpected error during the save.
100: */
101: public void saveFile(WebsiteData weblog, String path,
102: String contentType, long size, InputStream is)
103: throws FileNotFoundException, FilePathException,
104: FileIOException;
105:
106: /**
107: * Create an empty subdirectory in the weblog's uploads area.
108: *
109: * @param weblog The weblog we are working on.
110: * @param path The relative path to the desired location within
111: * the weblog's uploads area where the directory should be created.
112: *
113: * @throws FileNotFoundException If path to create location does not exist.
114: * @throws FilePathException If path is invalid, is not a directory, or can't be read.
115: * @throws FileIOException If there is an unexpected error during the create.
116: */
117: public void createDirectory(WebsiteData weblog, String path)
118: throws FileNotFoundException, FilePathException,
119: FileIOException;
120:
121: /**
122: * Delete file or directory from weblog's uploads area.
123: *
124: * @param weblog The weblog we are working on.
125: * @param path The relative path to the file within the weblog's uploads
126: * area that should be deleted.
127: *
128: * @throws FileNotFoundException If path does not exist.
129: * @throws FilePathException If path is invalid, or can't be read.
130: * @throws FileIOException If there is an unexpected error during the delete.
131: */
132: public void deleteFile(WebsiteData weblog, String path)
133: throws FileNotFoundException, FilePathException,
134: FileIOException;
135:
136: /**
137: * Is the given weblog over the file-upload quota limit?
138: *
139: * @param weblog The weblog we are working on.
140: *
141: * @return True if weblog is over set quota, False otherwise.
142: */
143: public boolean overQuota(WebsiteData weblog);
144:
145: /**
146: * Release all resources associated with Roller session.
147: */
148: public void release();
149:
150: }
|