public class FilesystemConnector extends Object implements MetadataRepositoryConnector
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_FILESYSTEM_CONNECTOR
Id for default file system connector.
|
Constructor and Description |
---|
FilesystemConnector(RepositoryConnectorConfiguration connectorConfiguration)
Constructor for a new FilesystemConnector, based on the given FilesystemConfiguration.
|
Modifier and Type | Method and Description |
---|---|
void |
clearContent()
Deletes all files from the repository.
|
void |
deleteContent(ContentId contentId)
Delete the content with the given ContentId.
|
RepositoryConnectorConfiguration |
getConfiguration() |
AttachmentTO |
getContent(ExtendedContentId contentId)
Returns a ContentTO that is associated with the given ContentId.
|
ContentMetadata |
getMetadata(ContentId contentId)
Return the ContentMetadata that is associated with the given ContentId.
|
protected String |
getPath() |
long |
getRepositorySize() |
long |
getRepositorySizeLimit() |
float |
getRepositorySizeLimitRatio()
Gets the ratio of the current repository size to the repository size limit.
|
float |
getRepositorySizeLimitRatio(long sizeOfNewDataToStore)
Gets the ratio of the current repository size plus sizeOfNewDataToStore to the repository
size limit.
|
protected void |
prepareStorageDirectory()
Create the directory returned by
getPath() if it does not yet exist. |
void |
removeConnector()
Callback that is invoked if a connector is removed.
|
ContentId |
storeContent(AttachmentTO contentTo)
Store the given ContentTO and return a ContentId for it.
|
void |
updateMetadata(ContentMetadata metadata)
Update the metadata of existing content with the provided metadata.
|
public static final String DEFAULT_FILESYSTEM_CONNECTOR
public FilesystemConnector(RepositoryConnectorConfiguration connectorConfiguration) throws IOException
connectorConfiguration
- The configuration for this connector.IOException
- in case the the directory for storing the content cannot be created or exists and
is not a directory or cannot be accessedpublic void clearContent() throws ContentRepositoryException
clearContent
in interface RepositoryConnector
ContentRepositoryException
- Exception.public void deleteContent(ContentId contentId) throws ContentRepositoryException
deleteContent
in interface RepositoryConnector
contentId
- The ContentId for the content to delete.ContentRepositoryException
- in case deleting the content failedpublic RepositoryConnectorConfiguration getConfiguration()
getConfiguration
in interface RepositoryConnector
public AttachmentTO getContent(ExtendedContentId contentId) throws ContentRepositoryException
getContent
in interface RepositoryConnector
contentId
- The ContentId for the ContentTO to be read.ContentRepositoryException
- in case reading the content failedpublic ContentMetadata getMetadata(ContentId contentId)
getMetadata
in interface MetadataRepositoryConnector
contentId
- The ContentId for the ContentTO to be read.protected String getPath()
public long getRepositorySize()
getRepositorySize
in interface RepositoryConnector
public long getRepositorySizeLimit()
getRepositorySizeLimit
in interface RepositoryConnector
public float getRepositorySizeLimitRatio()
RepositoryConnector
getRepositorySizeLimitRatio
in interface RepositoryConnector
public float getRepositorySizeLimitRatio(long sizeOfNewDataToStore)
RepositoryConnector
getRepositorySizeLimitRatio
in interface RepositoryConnector
sizeOfNewDataToStore
- size of data in bytesprotected void prepareStorageDirectory() throws IOException
getPath()
if it does not yet exist.IOException
- in case the directory cannot be created or exists and is not a directory or
cannot be accessedpublic void removeConnector()
removeConnector
in interface RepositoryConnector
public ContentId storeContent(AttachmentTO contentTo) throws ContentRepositoryException
storeContent
in interface RepositoryConnector
ContentRepositoryException
- in case storing the content failedpublic void updateMetadata(ContentMetadata metadata) throws ContentRepositoryException
updateMetadata
in interface MetadataRepositoryConnector
metadata
- The ContentMetadata to update.ContentRepositoryException
- in case the metadata cannot be updated.Copyright © 2019 Communote team. All rights reserved.