Class FileStorageImplWrapper
- java.lang.Object
-
- edu.cornell.mannlib.vitro.webapp.filestorage.impl.FileStorageImplWrapper
-
- All Implemented Interfaces:
Application.Component,Application.Module,FileStorage
public class FileStorageImplWrapper extends Object implements FileStorage
A thin wrapper around the existing FileStorageImpl. Handles the setup.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface edu.cornell.mannlib.vitro.webapp.modules.Application.Component
Application.Component.LifecycleState
-
-
Field Summary
Fields Modifier and Type Field Description static StringFILE_STORAGE_SUBDIRECTORYstatic StringPROPERTY_DEFAULT_NAMESPACE
-
Constructor Summary
Constructors Constructor Description FileStorageImplWrapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateFile(String id, String filename, InputStream bytes)Store the bytes from this stream as a file with the specified ID and filename.booleandeleteFile(String id)If a file exists with this ID, it will be deleted, regardless of the file name.StringgetFilename(String id)If a file exists with this ID, get its name.InputStreamgetInputStream(String id, String filename)Get a stream that will provide the contents of the file that was stored with this ID and this filename.voidshutdown(Application application)This should be called only once, and should be the last call on this Component.voidstartup(Application application, ComponentStartupStatus ss)Create an instance of FileStorageImpl, based on the values in runtime.properties.
-
-
-
Field Detail
-
PROPERTY_DEFAULT_NAMESPACE
public static final String PROPERTY_DEFAULT_NAMESPACE
- See Also:
- Constant Field Values
-
FILE_STORAGE_SUBDIRECTORY
public static final String FILE_STORAGE_SUBDIRECTORY
- See Also:
- Constant Field Values
-
-
Method Detail
-
startup
public void startup(Application application, ComponentStartupStatus ss)
Create an instance of FileStorageImpl, based on the values in runtime.properties.- Specified by:
startupin interfaceApplication.Component
-
shutdown
public void shutdown(Application application)
Description copied from interface:Application.ComponentThis should be called only once, and should be the last call on this Component.- Specified by:
shutdownin interfaceApplication.Component
-
createFile
public void createFile(String id, String filename, InputStream bytes) throws FileAlreadyExistsException, IOException
Description copied from interface:FileStorageStore the bytes from this stream as a file with the specified ID and filename. If the file already exists, it is over-written.- Specified by:
createFilein interfaceFileStorage- Throws:
FileAlreadyExistsException- if a file already exists with this ID but with a different filename.IOException
-
getFilename
public String getFilename(String id) throws IOException
Description copied from interface:FileStorageIf a file exists with this ID, get its name.- Specified by:
getFilenamein interfaceFileStorage- Returns:
- The name of the file (un-encoded) if it exists, or
nullif it does not. - Throws:
IOException
-
getInputStream
public InputStream getInputStream(String id, String filename) throws FileNotFoundException, IOException
Description copied from interface:FileStorageGet a stream that will provide the contents of the file that was stored with this ID and this filename. Close the stream when you're finished with it.- Specified by:
getInputStreamin interfaceFileStorage- Throws:
FileNotFoundException- if there is no file that matches this ID and filename.IOException
-
deleteFile
public boolean deleteFile(String id) throws IOException
Description copied from interface:FileStorageIf a file exists with this ID, it will be deleted, regardless of the file name. If no such file exists, no action is taken, no exception is thrown.- Specified by:
deleteFilein interfaceFileStorage- Returns:
trueif a file existed,falseotherwise.- Throws:
IOException
-
-