Package fr.gouv.vitam.workspace.common
Class WorkspaceFileSystem
java.lang.Object
fr.gouv.vitam.workspace.common.WorkspaceFileSystem
- All Implemented Interfaces:
WorkspaceContentAddressableStorage
Workspace Filesystem implementation
-
Constructor Summary
ConstructorsConstructorDescriptionWorkspaceFileSystem(StorageConfiguration configuration) Default constructor Define the root of workspace with the storagePath property from configuration -
Method Summary
Modifier and TypeMethodDescriptioncheckWorkspaceContainerSanity(String container) checkWorkspaceDirSanity(String container, String directory) voidcheckWorkspaceFileSanity(String containerName, String relativeObjectName) voidcomputeObjectDigest(String containerName, String objectName, DigestType algo) compute Object Digest using a defined algorithmvoidcreateContainer(String containerName) Creates a containervoidcreateFolder(String containerName, String folderName) Creates a folder (or a directory) marker depending on the servicevoiddeleteContainer(String containerName, boolean recursive) Deletes everything inside a container recursively.voiddeleteFolder(String containerName, String folderName) Deletes a folder (or a directory) marker depending on the servicevoiddeleteObject(String containerName, String objectName) Deletes a object representing the data at location containerName/objectNamegetContainerInformation(String containerName) Get container information like capacitygetFilesWithParamsFromFolder(String containerName, String folderName) This method get all files in folder and return a map with the uri as a key and the value is a FileParams that contains whatever it needs.getListUriDigitalObjectFromFolder(String containerName, String folderName) Retrieves recursively the uri list of object inside a folder rootFolder/subfolder/javax.ws.rs.core.ResponseRetrieves an object representing the data at location containerName/objectNamecom.fasterxml.jackson.databind.JsonNodegetObjectInformation(String containerName, String objectName) Retrieves information about an object at location containerName/objectNameintbooleanisExistingContainer(String containerName) Determines if a container existsbooleanisExistingFolder(String containerName, String folderName) Determines if a folder (or a directory) existsbooleanisExistingObject(String containerName, String objectName) Determines if an object existsvoidpurgeContainer(String containerName) Deletes the contents of a container at its root path without deleting the containervoidpurgeOldFilesInContainer(String containerName, TimeToLive timeToLive) voidputAtomicObject(String containerName, String objectName, InputStream stream, long size) voidputObject(String containerName, String objectName, InputStream stream) Adds an object representing the data at location containerName/objectNamevoiduncompressObject(String containerName, String folderName, String archiveMimeType, InputStream inputStreamObject) create container: will be identified by GUID and extract objects and push it on the container
-
Constructor Details
-
WorkspaceFileSystem
Default constructor Define the root of workspace with the storagePath property from configuration- Parameters:
configuration- the configuration, just StoragePath property is required- Throws:
IOException- when error occurs to create root directory
-
-
Method Details
-
checkWorkspaceContainerSanity
- Throws:
IllegalPathException
-
checkWorkspaceDirSanity
- Throws:
IllegalPathException
-
checkWorkspaceFileSanity
public void checkWorkspaceFileSanity(String containerName, String relativeObjectName) throws IllegalPathException - Throws:
IllegalPathException
-
createContainer
public void createContainer(String containerName) throws ContentAddressableStorageAlreadyExistException, ContentAddressableStorageServerException Description copied from interface:WorkspaceContentAddressableStorageCreates a container- Specified by:
createContainerin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- name of container to create- Throws:
ContentAddressableStorageAlreadyExistException- Thrown when creating a container while it (containerName) already existsContentAddressableStorageServerException- Thrown when internal server error happens
-
purgeContainer
public void purgeContainer(String containerName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException Description copied from interface:WorkspaceContentAddressableStorageDeletes the contents of a container at its root path without deleting the containerNote: this function will delete everything inside a container recursively.
- Specified by:
purgeContainerin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- name of container to purge- Throws:
ContentAddressableStorageNotFoundException- Thrown when the container cannot be located.ContentAddressableStorageServerException- Thrown when internal server error happens
-
purgeOldFilesInContainer
public void purgeOldFilesInContainer(String containerName, TimeToLive timeToLive) throws ContentAddressableStorageException - Specified by:
purgeOldFilesInContainerin interfaceWorkspaceContentAddressableStorage- Throws:
ContentAddressableStorageException
-
deleteContainer
public void deleteContainer(String containerName, boolean recursive) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException Description copied from interface:WorkspaceContentAddressableStorageDeletes everything inside a container recursively.- Specified by:
deleteContainerin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- name of the container to deleterecursive- false : deletes a container if it is empty, true : deletes everything recursively- Throws:
ContentAddressableStorageNotFoundException- Thrown when the container cannot be located.ContentAddressableStorageServerException- Thrown when internal server error happens
-
isExistingContainer
Description copied from interface:WorkspaceContentAddressableStorageDetermines if a container exists- Specified by:
isExistingContainerin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- name of container- Returns:
- boolean type
-
createFolder
public void createFolder(String containerName, String folderName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageAlreadyExistException, ContentAddressableStorageServerException Description copied from interface:WorkspaceContentAddressableStorageCreates a folder (or a directory) marker depending on the service- Specified by:
createFolderin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- container to create the directory infolderName- full path to the folder (or directory)- Throws:
ContentAddressableStorageNotFoundException- Thrown when the container cannot be located.ContentAddressableStorageAlreadyExistException- Thrown when creating a directory while it already existsContentAddressableStorageServerException- Thrown when internal server error happens
-
deleteFolder
public void deleteFolder(String containerName, String folderName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException Description copied from interface:WorkspaceContentAddressableStorageDeletes a folder (or a directory) marker depending on the service- Specified by:
deleteFolderin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- container to delete the folder fromfolderName- full path to the folder to delete- Throws:
ContentAddressableStorageNotFoundException- Thrown when the directory cannot be located.ContentAddressableStorageServerException- Thrown when internal server error happens
-
isExistingFolder
Description copied from interface:WorkspaceContentAddressableStorageDetermines if a folder (or a directory) exists- Specified by:
isExistingFolderin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- container where the folder residesfolderName- full path to the folder- Returns:
- boolean type
-
getListUriDigitalObjectFromFolder
public List<URI> getListUriDigitalObjectFromFolder(String containerName, String folderName) throws ContentAddressableStorageException Description copied from interface:WorkspaceContentAddressableStorageRetrieves recursively the uri list of object inside a folder rootFolder/subfolder/- Specified by:
getListUriDigitalObjectFromFolderin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- not null allowed container where this exists.folderName- not null allowed fully qualified folder name relative to the container.- Returns:
- a list of URI
- Throws:
ContentAddressableStorageNotFoundException- Thrown when the container cannot be located.ContentAddressableStorageException- Thrown when get action failed due some other failure
-
uncompressObject
public void uncompressObject(String containerName, String folderName, String archiveMimeType, InputStream inputStreamObject) throws ContentAddressableStorageException Description copied from interface:WorkspaceContentAddressableStoragecreate container: will be identified by GUID and extract objects and push it on the container- Specified by:
uncompressObjectin interfaceWorkspaceContentAddressableStorage- Parameters:
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 stream- Throws:
ContentAddressableStorageNotFoundException- 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 zip
-
putObject
public void putObject(String containerName, String objectName, InputStream stream) throws ContentAddressableStorageException Description copied from interface:WorkspaceContentAddressableStorageAdds an object representing the data at location containerName/objectName- Specified by:
putObjectin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- container to place the object.objectName- fully qualified object name relative to the container.stream- the data- Throws:
ContentAddressableStorageNotFoundException- Thrown when the container cannot be located.ContentAddressableStorageException- Thrown when put action failed due some other failureContentAddressableStorageAlreadyExistException- Thrown when object creating exists
-
putAtomicObject
public void putAtomicObject(String containerName, String objectName, InputStream stream, long size) throws ContentAddressableStorageException - Specified by:
putAtomicObjectin interfaceWorkspaceContentAddressableStorage- Throws:
ContentAddressableStorageException
-
getObject
public javax.ws.rs.core.Response getObject(String containerName, String objectName, Long chunkOffset, Long maxChunkSize) throws ContentAddressableStorageException Description copied from interface:WorkspaceContentAddressableStorageRetrieves an object representing the data at location containerName/objectNameWARNING : use this method only if the response has to be consumed right away.
- Specified by:
getObjectin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- container where this exists.objectName- fully qualified name relative to the container.- Returns:
- the object you intended to receive
- Throws:
ContentAddressableStorageNotFoundException- Thrown when the container cannot be located.ContentAddressableStorageException- Thrown when get action failed due some other failureContentAddressableStorageAlreadyExistException- Thrown when object creating exists
-
deleteObject
public void deleteObject(String containerName, String objectName) throws ContentAddressableStorageException Description copied from interface:WorkspaceContentAddressableStorageDeletes a object representing the data at location containerName/objectName- Specified by:
deleteObjectin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- container where this exists.objectName- fully qualified name relative to the container.- Throws:
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 failure
-
isExistingObject
Description copied from interface:WorkspaceContentAddressableStorageDetermines if an object exists- Specified by:
isExistingObjectin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- container where the object residesobjectName- fully qualified name relative to the container.- Returns:
- boolean type
-
computeObjectDigest
public String computeObjectDigest(String containerName, String objectName, DigestType algo) throws ContentAddressableStorageException Description copied from interface:WorkspaceContentAddressableStoragecompute Object Digest using a defined algorithm- Specified by:
computeObjectDigestin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- container where this exists.objectName- fully qualified name relative to the container.algo- Digest algo- Returns:
- the digest object as String
- Throws:
ContentAddressableStorageNotFoundException- Thrown when the container or the object cannot be locatedContentAddressableStorageServerException- Thrown when internal server error happensContentAddressableStorageException- Thrown when put action failed due some other failure
-
getContainerInformation
public ContainerInformation getContainerInformation(String containerName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException Description copied from interface:WorkspaceContentAddressableStorageGet container information like capacity- Specified by:
getContainerInformationin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- the container name- Returns:
- container information like usableSpace
- Throws:
ContentAddressableStorageNotFoundException- thrown when storage is not available or container does not existContentAddressableStorageServerException
-
getObjectInformation
public com.fasterxml.jackson.databind.JsonNode getObjectInformation(String containerName, String objectName) throws ContentAddressableStorageException Description copied from interface:WorkspaceContentAddressableStorageRetrieves information about an object at location containerName/objectName- Specified by:
getObjectInformationin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName- container where the object is.objectName- fully qualified name relative to the container.- Returns:
- the object informations as a JsonNode object
- Throws:
ContentAddressableStorageNotFoundException- Thrown when the container cannot be located.ContentAddressableStorageException- Thrown when get action failed due some other failure
-
getFilesWithParamsFromFolder
public Map<String,FileParams> getFilesWithParamsFromFolder(String containerName, String folderName) throws ContentAddressableStorageException This method get all files in folder and return a map with the uri as a key and the value is a FileParams that contains whatever it needs. This method can have a huge usage of memory so extract only useful data in callable clients.- Specified by:
getFilesWithParamsFromFolderin interfaceWorkspaceContentAddressableStorage- Parameters:
containerName-folderName-- Returns:
- Throws:
ContentAddressableStorageException
-
compress
public void compress(String containerName, List<String> folderNames, String zipName, String outputContainer) throws IOException, org.apache.commons.compress.archivers.ArchiveException - Parameters:
containerName- name of the containerfolderNames- list of file or directory to archivezipName- name of the archive fileoutputContainer-- Throws:
IOExceptionorg.apache.commons.compress.archivers.ArchiveException
-
getWorkspaceFreeSpace
public int getWorkspaceFreeSpace()
-