public class WorkspaceFileSystem extends Object implements WorkspaceContentAddressableStorage
Constructor and Description |
---|
WorkspaceFileSystem(StorageConfiguration configuration)
Default constructor Define the root of workspace with the storagePath property from configuration
|
Modifier and Type | Method and Description |
---|---|
void |
compress(String containerName,
List<String> folderNames,
String zipName) |
String |
computeObjectDigest(String containerName,
String objectName,
DigestType algo)
compute Object Digest using a defined algorithm
|
long |
countObjects(String containerName)
Determines if a container exists
|
void |
createContainer(String containerName)
Creates a container
|
void |
createFolder(String containerName,
String folderName)
Creates a folder (or a directory) marker depending on the service
|
void |
deleteContainer(String containerName,
boolean recursive)
Deletes everything inside a container recursively.
|
void |
deleteFolder(String containerName,
String folderName)
Deletes a folder (or a directory) marker depending on the service
|
void |
deleteObject(String containerName,
String objectName)
Deletes a object representing the data at location
containerName/objectName
|
ContainerInformation |
getContainerInformation(String containerName)
Get container information like capacity
|
List<URI> |
getListUriDigitalObjectFromFolder(String containerName,
String folderName)
Retrieves recursively the uri list of object inside a folder rootFolder/subfolder/
|
javax.ws.rs.core.Response |
getObject(String containerName,
String objectName)
Retrieves an object representing the data at location
containerName/objectName
|
com.fasterxml.jackson.databind.JsonNode |
getObjectInformation(String containerName,
String objectName)
Retrieves information about an object at location
containerName/objectName
|
boolean |
isExistingContainer(String containerName)
Determines if a container exists
|
boolean |
isExistingFolder(String containerName,
String folderName)
Determines if a folder (or a directory) exists
|
boolean |
isExistingObject(String containerName,
String objectName)
Determines if an object exists
|
void |
purgeContainer(String containerName)
Deletes the contents of a container at its root path without deleting the container
|
void |
putObject(String containerName,
String objectName,
InputStream stream)
Adds an object representing the data at location containerName/objectName
|
void |
uncompressObject(String containerName,
String folderName,
String archiveMimeType,
InputStream inputStreamObject)
create container: will be identified by GUID and extract objects and push it on the container
|
public WorkspaceFileSystem(StorageConfiguration configuration) throws IOException
configuration
- the configuration, just StoragePath property is requiredIOException
- when error occurs to create root directorypublic void createContainer(String containerName) throws ContentAddressableStorageAlreadyExistException, ContentAddressableStorageServerException
WorkspaceContentAddressableStorage
createContainer
in interface WorkspaceContentAddressableStorage
containerName
- name of container to createContentAddressableStorageAlreadyExistException
- Thrown when creating a container while it (containerName)
already existsContentAddressableStorageServerException
- Thrown when internal server error happenspublic void purgeContainer(String containerName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
WorkspaceContentAddressableStorage
Note: this function will delete everything inside a container recursively.
purgeContainer
in interface WorkspaceContentAddressableStorage
containerName
- name of container to purgeContentAddressableStorageNotFoundException
- Thrown when the container cannot be located.ContentAddressableStorageServerException
- Thrown when internal server error happenspublic void deleteContainer(String containerName, boolean recursive) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
WorkspaceContentAddressableStorage
deleteContainer
in interface WorkspaceContentAddressableStorage
containerName
- name of the container to deleterecursive
- false : deletes a container if it is empty, true : deletes everything recursivelyContentAddressableStorageNotFoundException
- Thrown when the container cannot be located.ContentAddressableStorageServerException
- Thrown when internal server error happenspublic boolean isExistingContainer(String containerName)
WorkspaceContentAddressableStorage
isExistingContainer
in interface WorkspaceContentAddressableStorage
containerName
- name of containerpublic void createFolder(String containerName, String folderName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageAlreadyExistException, ContentAddressableStorageServerException
WorkspaceContentAddressableStorage
createFolder
in interface WorkspaceContentAddressableStorage
containerName
- container to create the directory infolderName
- full path to the folder (or directory)ContentAddressableStorageNotFoundException
- Thrown when the container cannot be located.ContentAddressableStorageAlreadyExistException
- Thrown when creating a directory while it already existsContentAddressableStorageServerException
- Thrown when internal server error happenspublic void deleteFolder(String containerName, String folderName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
WorkspaceContentAddressableStorage
deleteFolder
in interface WorkspaceContentAddressableStorage
containerName
- container to delete the folder fromfolderName
- full path to the folder to deleteContentAddressableStorageNotFoundException
- Thrown when the directory cannot be located.ContentAddressableStorageServerException
- Thrown when internal server error happenspublic boolean isExistingFolder(String containerName, String folderName)
WorkspaceContentAddressableStorage
isExistingFolder
in interface WorkspaceContentAddressableStorage
containerName
- container where the folder residesfolderName
- full path to the folderpublic List<URI> getListUriDigitalObjectFromFolder(String containerName, String folderName) throws ContentAddressableStorageException
WorkspaceContentAddressableStorage
getListUriDigitalObjectFromFolder
in interface WorkspaceContentAddressableStorage
containerName
- not null allowed container where this exists.folderName
- not null allowed fully qualified folder name relative to the container.ContentAddressableStorageNotFoundException
- Thrown when the container cannot be located.ContentAddressableStorageException
- Thrown when get action failed due some other failurepublic void uncompressObject(String containerName, String folderName, String archiveMimeType, InputStream inputStreamObject) throws ContentAddressableStorageException
WorkspaceContentAddressableStorage
uncompressObject
in interface WorkspaceContentAddressableStorage
containerName
- : the container name (will be Guid created in ingest module)folderName
- : the folder namearchiveMimeType
- : the archive type (zip, tar, tar.gz, tar.bz2)inputStreamObject
- : SIP input streamContentAddressableStorageNotFoundException
- Thrown when the container cannot be locatedContentAddressableStorageAlreadyExistException
- Thrown when folder existsContentAddressableStorageServerException
- Thrown when internal server error happensContentAddressableStorageException
- Thrown when get action failed due some other failureContentAddressableStorageCompressedFileException
- Thrown when the file is not a zip or an empty zippublic void putObject(String containerName, String objectName, InputStream stream) throws ContentAddressableStorageException
WorkspaceContentAddressableStorage
putObject
in interface WorkspaceContentAddressableStorage
containerName
- container to place the object.objectName
- fully qualified object name relative to the container.stream
- the dataContentAddressableStorageNotFoundException
- Thrown when the container cannot be located.ContentAddressableStorageException
- Thrown when put action failed due some other failureContentAddressableStorageAlreadyExistException
- Thrown when object creating existspublic javax.ws.rs.core.Response getObject(String containerName, String objectName) throws ContentAddressableStorageException
WorkspaceContentAddressableStorage
WARNING : use this method only if the response has to be consumed right away.
getObject
in interface WorkspaceContentAddressableStorage
containerName
- container where this exists.objectName
- fully qualified name relative to the container.ContentAddressableStorageNotFoundException
- Thrown when the container cannot be located.ContentAddressableStorageException
- Thrown when get action failed due some other failureContentAddressableStorageAlreadyExistException
- Thrown when object creating existspublic void deleteObject(String containerName, String objectName) throws ContentAddressableStorageException
WorkspaceContentAddressableStorage
deleteObject
in interface WorkspaceContentAddressableStorage
containerName
- container where this exists.objectName
- fully qualified name relative to the container.ContentAddressableStorageNotFoundException
- Thrown when the container cannot be located or the blob
cannot be located in the container.ContentAddressableStorageException
- Thrown when get action failed due some other failurepublic boolean isExistingObject(String containerName, String objectName)
WorkspaceContentAddressableStorage
isExistingObject
in interface WorkspaceContentAddressableStorage
containerName
- container where the object residesobjectName
- fully qualified name relative to the container.public String computeObjectDigest(String containerName, String objectName, DigestType algo) throws ContentAddressableStorageException
WorkspaceContentAddressableStorage
computeObjectDigest
in interface WorkspaceContentAddressableStorage
containerName
- container where this exists.objectName
- fully qualified name relative to the container.algo
- Digest algoContentAddressableStorageNotFoundException
- Thrown when the container or the object cannot be locatedContentAddressableStorageServerException
- Thrown when internal server error happensContentAddressableStorageException
- Thrown when put action failed due some other failurepublic ContainerInformation getContainerInformation(String containerName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
WorkspaceContentAddressableStorage
getContainerInformation
in interface WorkspaceContentAddressableStorage
containerName
- the container nameContentAddressableStorageNotFoundException
- thrown when storage is not available or container does not
existContentAddressableStorageServerException
public com.fasterxml.jackson.databind.JsonNode getObjectInformation(String containerName, String objectName) throws ContentAddressableStorageException
WorkspaceContentAddressableStorage
getObjectInformation
in interface WorkspaceContentAddressableStorage
containerName
- container where the object is.objectName
- fully qualified name relative to the container.ContentAddressableStorageNotFoundException
- Thrown when the container cannot be located.ContentAddressableStorageException
- Thrown when get action failed due some other failurepublic long countObjects(String containerName) throws ContentAddressableStorageException
WorkspaceContentAddressableStorage
countObjects
in interface WorkspaceContentAddressableStorage
containerName
- name of containerContentAddressableStorageNotFoundException
- Thrown when the container cannot be located.ContentAddressableStorageException
- Thrown when get action failed due some other failurepublic void compress(String containerName, List<String> folderNames, String zipName) throws IOException, org.apache.commons.compress.archivers.ArchiveException
containerName
- name of the containerfolderNames
- list of file or directory to archivezipName
- name of the archive fileIOException
org.apache.commons.compress.archivers.ArchiveException
Copyright © 2018 Vitam. All rights reserved.