Package org.duracloud.storage.util
Class StorageProviderUtil
- java.lang.Object
-
- org.duracloud.storage.util.StorageProviderUtil
-
public class StorageProviderUtil extends Object
Provides utility methods for Storage Providers- Author:
- Bill Branan
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringcompareChecksum(String providerChecksum, String spaceId, String contentId, String checksum)Determines if two checksum values are equalstatic StringcompareChecksum(StorageProvider provider, String spaceId, String contentId, String checksum)Determines if the checksum for a particular piece of content stored in a StorageProvider matches the expected checksum value.static booleancontains(Iterator<String> iterator, String value)Determines if a String value is included in a Iterated list.static longcount(Iterator<String> iterator)Determines the number of elements in an iteration.static Map<String,String>createContentProperties(String absolutePath, String creator)Generates a map of all client-side default content properties to be added with new content.static List<String>getList(Iterator<String> iterator)Creates a list of all of the items in an iteration.static Map<String,String>loadProperties(InputStream is)Loads a stream containing properties and populates a map with the properties name/value pairs.static Map<String,String>removeCalculatedProperties(Map<String,String> contentProperties)Returns a new map with the calculated properties removed.static ByteArrayInputStreamstoreProperties(Map<String,String> propertiesMap)Converts properties stored in a Map into a stream for storage purposes.
-
-
-
Method Detail
-
loadProperties
public static Map<String,String> loadProperties(InputStream is) throws StorageException
Loads a stream containing properties and populates a map with the properties name/value pairs.- Parameters:
is-- Returns:
- Throws:
StorageException
-
storeProperties
public static ByteArrayInputStream storeProperties(Map<String,String> propertiesMap) throws StorageException
Converts properties stored in a Map into a stream for storage purposes.- Parameters:
propertiesMap-- Returns:
- Throws:
StorageException
-
compareChecksum
public static String compareChecksum(StorageProvider provider, String spaceId, String contentId, String checksum) throws StorageException
Determines if the checksum for a particular piece of content stored in a StorageProvider matches the expected checksum value.- Parameters:
provider- The StorageProvider where the content was storedspaceId- The Space in which the content was storedcontentId- The Id of the contentchecksum- The content checksum, either provided or computed- Throws:
StorageException- if the included checksum does not match the storage provider generated checksum
-
compareChecksum
public static String compareChecksum(String providerChecksum, String spaceId, String contentId, String checksum) throws ChecksumMismatchException
Determines if two checksum values are equal- Parameters:
providerChecksum- The checksum provided by the StorageProviderspaceId- The Space in which the content was storedcontentId- The Id of the contentchecksum- The content checksum, either provided or computed- Throws:
ChecksumMismatchException- if the included checksum does not match the storage provider generated checksum
-
contains
public static boolean contains(Iterator<String> iterator, String value)
Determines if a String value is included in a Iterated list. The iteration is only run as far as necessary to determine if the value is included in the underlying list.- Parameters:
iterator-value-- Returns:
-
count
public static long count(Iterator<String> iterator)
Determines the number of elements in an iteration.- Parameters:
iterator-- Returns:
-
getList
public static List<String> getList(Iterator<String> iterator)
Creates a list of all of the items in an iteration. Be wary of using this for Iterations of very long lists.- Parameters:
iterator-- Returns:
-
createContentProperties
public static Map<String,String> createContentProperties(String absolutePath, String creator)
Generates a map of all client-side default content properties to be added with new content.- Parameters:
absolutePath-creator-- Returns:
-
-