Class CloudStorage
- java.lang.Object
-
- edu.wisc.library.ocfl.core.storage.cloud.CloudStorage
-
-
Constructor Summary
Constructors Constructor Description CloudStorage(CloudClient client)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopyDirectoryOutOf(String source, Path outputPath)Recursively copy the source directory from inside this storage system to an external destination.voidcopyFileInternal(String sourceFile, String destinationFile)Copy a file from inside this storage system to another destination inside it.voidcopyFileInto(Path source, String destination, String mediaType)Copy a file from outside this storage system to a destination inside.voidcreateDirectories(String path)Create the specified directory and any missing ancestors.voiddeleteDirectory(String path)Recursively delete the specified directory and all of its children.voiddeleteEmptyDirsDown(String path)Recursively delete all empty directory descendents of the specified directory.voiddeleteEmptyDirsUp(String path)Recursively delete all empty directory ancestors until the first non-empty ancestor is found.voiddeleteFile(String path)Delete the specified filevoiddeleteFiles(Collection<String> paths)Delete the specified filesbooleandirectoryIsEmpty(String directoryPath)Return true if the specified directory contains no childrenbooleanfileExists(String filePath)Indicates if the file existsOcflObjectRootDirIteratoriterateObjects()Return an iterator that iterates over every OCFL object directory in the repository.List<Listing>listDirectory(String directoryPath)Return a list of all files and directories contained in the specified directory.List<Listing>listRecursive(String directoryPath)Return a list of all leaf-node descendents of the specified directory, this includes empty leaf-node directories.voidmoveDirectoryInternal(String source, String destination)Move a directory from inside this storage system to another location inside.voidmoveDirectoryInto(Path source, String destination)Move a directory from outside this storage system to a destination inside.InputStreamread(String filePath)Streams the content of the specified fileOcflFileRetrieverreadLazy(String filePath, DigestAlgorithm algorithm, String digest)Return anOcflFileRetrieverthat can be used to read the specified file at a later time.StringreadToString(String filePath)Read the contents of the specified file to a stringvoidwrite(String filePath, byte[] content, String mediaType)Write the specified content to the specified path.
-
-
-
Constructor Detail
-
CloudStorage
public CloudStorage(CloudClient client)
-
-
Method Detail
-
listDirectory
public List<Listing> listDirectory(String directoryPath)
Return a list of all files and directories contained in the specified directory.- Specified by:
listDirectoryin interfaceStorage- Parameters:
directoryPath- the path to the directory to list- Returns:
- list of children
-
listRecursive
public List<Listing> listRecursive(String directoryPath)
Return a list of all leaf-node descendents of the specified directory, this includes empty leaf-node directories. Intermediary directories are not returned.- Specified by:
listRecursivein interfaceStorage- Parameters:
directoryPath- the path to the directory to list- Returns:
- list of children
-
directoryIsEmpty
public boolean directoryIsEmpty(String directoryPath)
Return true if the specified directory contains no children- Specified by:
directoryIsEmptyin interfaceStorage- Parameters:
directoryPath- the path to the directory- Returns:
- true if empty
-
iterateObjects
public OcflObjectRootDirIterator iterateObjects()
Return an iterator that iterates over every OCFL object directory in the repository.- Specified by:
iterateObjectsin interfaceStorage- Returns:
- object directory iterator
-
fileExists
public boolean fileExists(String filePath)
Indicates if the file exists- Specified by:
fileExistsin interfaceStorage- Parameters:
filePath- path to the file- Returns:
- true if it exists
-
read
public InputStream read(String filePath)
Streams the content of the specified file
-
readToString
public String readToString(String filePath)
Read the contents of the specified file to a string- Specified by:
readToStringin interfaceStorage- Parameters:
filePath- path to the file- Returns:
- file contents string
-
readLazy
public OcflFileRetriever readLazy(String filePath, DigestAlgorithm algorithm, String digest)
Return anOcflFileRetrieverthat can be used to read the specified file at a later time.
-
write
public void write(String filePath, byte[] content, String mediaType)
Write the specified content to the specified path. The file MUST NOT already exist.
-
createDirectories
public void createDirectories(String path)
Create the specified directory and any missing ancestors.- Specified by:
createDirectoriesin interfaceStorage- Parameters:
path- directory to create
-
copyDirectoryOutOf
public void copyDirectoryOutOf(String source, Path outputPath)
Recursively copy the source directory from inside this storage system to an external destination.- Specified by:
copyDirectoryOutOfin interfaceStorage- Parameters:
source- internal source to copyoutputPath- external destination
-
copyFileInto
public void copyFileInto(Path source, String destination, String mediaType)
Copy a file from outside this storage system to a destination inside. If the destination already exists, then it will be overwritten.- Specified by:
copyFileIntoin interfaceStorage- Parameters:
source- file to copydestination- internal destinationmediaType- media type of the file, may be null
-
copyFileInternal
public void copyFileInternal(String sourceFile, String destinationFile)
Copy a file from inside this storage system to another destination inside it. If the destination already exists, then it will be overwritten.- Specified by:
copyFileInternalin interfaceStorage- Parameters:
sourceFile- internal file to copydestinationFile- internal destination
-
moveDirectoryInto
public void moveDirectoryInto(Path source, String destination)
Move a directory from outside this storage system to a destination inside. The destination MUST NOT already exist.- Specified by:
moveDirectoryIntoin interfaceStorage- Parameters:
source- external source directorydestination- internal destination
-
moveDirectoryInternal
public void moveDirectoryInternal(String source, String destination)
Move a directory from inside this storage system to another location inside. The destination MUST NOT already exist.- Specified by:
moveDirectoryInternalin interfaceStorage- Parameters:
source- internal source directorydestination- internal destination
-
deleteDirectory
public void deleteDirectory(String path)
Recursively delete the specified directory and all of its children.- Specified by:
deleteDirectoryin interfaceStorage- Parameters:
path- path to delete
-
deleteFile
public void deleteFile(String path)
Delete the specified file- Specified by:
deleteFilein interfaceStorage- Parameters:
path- file to delete
-
deleteFiles
public void deleteFiles(Collection<String> paths)
Delete the specified files- Specified by:
deleteFilesin interfaceStorage- Parameters:
paths- files to delete
-
deleteEmptyDirsDown
public void deleteEmptyDirsDown(String path)
Recursively delete all empty directory descendents of the specified directory. The starting path is eligible for deletion.- Specified by:
deleteEmptyDirsDownin interfaceStorage- Parameters:
path- starting path
-
deleteEmptyDirsUp
public void deleteEmptyDirsUp(String path)
Recursively delete all empty directory ancestors until the first non-empty ancestor is found. The starting path is eligible for deletion.- Specified by:
deleteEmptyDirsUpin interfaceStorage- Parameters:
path- starting path
-
-