public class FileTransferCacheManager extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ATTACHMENT_FOLDER
Attachment folder for uploads and downloads.
|
static String |
FILE_NAME_DELIMITER
The delimiter that separates file attachment id, file version and file
name in an uploaded file.
|
static String |
PROJECT_FOLDER_PREFIX
project folder prefix.
|
static String |
TEMP_FOLDER
Temporary folder for file uploads to server.
|
| Constructor and Description |
|---|
FileTransferCacheManager()
Default constructor for uploads without an available project space.
|
FileTransferCacheManager(ProjectSpace projectSpaceImpl)
Default constructor for a specific project space.
|
| Modifier and Type | Method and Description |
|---|---|
File |
cacheFile(File input,
FileIdentifier id)
Adds a file to the cache using a given id.
|
File |
createTempFile(FileIdentifier id)
Creates a file in the temporary cache folder for a specified file id and
returns it.
|
File |
getCachedFile(FileIdentifier identifier)
Returns a cached file with a given identifier.
|
static String |
getCacheFolder(ProjectSpace projectSpace)
Returns the default file cache folder of a given projectspace.
|
boolean |
hasCachedFile(FileIdentifier identifier)
Returns true iff a file with this identifier is present in the cache.
|
File |
moveTempFileToCache(FileIdentifier id)
This method moves a file from the temporary folder into the cache.
|
File |
moveTempFileToCache(FileIdentifier id,
boolean overwrite)
This method moves a file from the temporary folder into the cache.
|
boolean |
removeCachedFile(FileIdentifier fileIdentifier)
Removes a file from the cache.
|
public static final String TEMP_FOLDER
public static final String PROJECT_FOLDER_PREFIX
public static final String ATTACHMENT_FOLDER
public static final String FILE_NAME_DELIMITER
public FileTransferCacheManager(ProjectSpace projectSpaceImpl)
projectSpaceImpl - the project space to which this cache belongs.public FileTransferCacheManager()
public static String getCacheFolder(ProjectSpace projectSpace)
projectSpace - the projectSpacepublic boolean hasCachedFile(FileIdentifier identifier)
identifier - the identifier of the filepublic File getCachedFile(FileIdentifier identifier) throws FileTransferException
identifier - the identifier of the fileFileTransferException - if the file is not present in the cachepublic File cacheFile(File input, FileIdentifier id) throws IOException
input - the file to be cachedid - the id to be used for the file.IOException - any IO Exception that can occur during copying a filepublic File createTempFile(FileIdentifier id) throws FileTransferException
id - the file id for which to create a temporary fileFileTransferException - if an IO exception occurred during the creation of a new filepublic File moveTempFileToCache(FileIdentifier id) throws FileTransferException
id - the id of the file which is to be movedFileTransferException - thrown if the temporary file does not exist, the final file
already exists, or if the rename operation which moves the
file failspublic File moveTempFileToCache(FileIdentifier id, boolean overwrite) throws FileTransferException
id - the id of the file which is to be movedoverwrite - whether to overwrite an existing file, if one with the given id is foundFileTransferException - thrown if the temporary file does not exist, the final file
already exists, or if the rename operation which moves the
file failspublic boolean removeCachedFile(FileIdentifier fileIdentifier)
fileIdentifier - the identifier of the file to be removedCopyright © 2017. All rights reserved.