Class MockStorageProvider
- java.lang.Object
-
- org.duracloud.storage.provider.mock.MockStorageProvider
-
- All Implemented Interfaces:
StorageProvider
public class MockStorageProvider extends Object implements StorageProvider
-
-
Field Summary
-
Fields inherited from interface org.duracloud.storage.provider.StorageProvider
DEFAULT_MAX_RESULTS, DEFAULT_MIMETYPE, ISO8601_DATE_FORMAT, PROPERTIES_BUCKET, PROPERTIES_CONTENT_CHECKSUM, PROPERTIES_CONTENT_CREATOR, PROPERTIES_CONTENT_FILE_CREATED, PROPERTIES_CONTENT_FILE_LAST_ACCESSED, PROPERTIES_CONTENT_FILE_MODIFIED, PROPERTIES_CONTENT_FILE_PATH, PROPERTIES_CONTENT_MD5, PROPERTIES_CONTENT_MIMETYPE, PROPERTIES_CONTENT_MODIFIED, PROPERTIES_CONTENT_SIZE, PROPERTIES_COPY_SOURCE, PROPERTIES_COPY_SOURCE_STORE, PROPERTIES_HLS_STREAMING_HOST, PROPERTIES_HLS_STREAMING_TYPE, PROPERTIES_SPACE_ACL, PROPERTIES_SPACE_ACL_GROUP, PROPERTIES_SPACE_ACL_PUBLIC, PROPERTIES_SPACE_COUNT, PROPERTIES_SPACE_CREATED, PROPERTIES_SPACE_SIZE
-
-
Constructor Summary
Constructors Constructor Description MockStorageProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringaddContent(String spaceId, String contentId, String contentMimeType, Map<String,String> userProperties, long contentSize, String contentChecksum, InputStream content)Adds content to a space.StringcopyContent(String sourceSpaceId, String sourceContentId, String destSpaceId, String destContentId)This method copies the content item found in source-space with the id of source-content-id into the dest-space, naming it to dest-content-id.voidcreateSpace(String spaceId)Creates a new space.voiddeleteContent(String spaceId, String contentId)Removes content from a space.voiddeleteSpace(String spaceId)Deletes a space.InputStreamgetContent()RetrievedContentgetContent(String spaceId, String contentId)Gets content from a space.RetrievedContentgetContent(String spaceId, String contentId, String range)Gets a range of bytes from a content item in a space.StringgetContentId()StringgetContentMimeType()Map<String,String>getContentProperties()Map<String,String>getContentProperties(String spaceId, String contentId)Retrieves the properties associated with content.longgetContentSize()Map<String,AclType>getSpaceACLs(String spaceId)Retrieves the ACLs associated with a space.Iterator<String>getSpaceContents(String spaceId, String prefix)Provides access to the content files within a space.List<String>getSpaceContentsChunked(String spaceId, String prefix, long maxResults, String marker)Provides a listing of the content files within a space.StringgetSpaceId()Map<String,String>getSpaceProperties()Map<String,String>getSpaceProperties(String spaceId)Retrieves the properties associated with a space.Iterator<String>getSpaces()Provides a listing of all spaces owned by a customer.org.duracloud.storage.domain.StorageProviderTypegetStorageProviderType()Provides the type of storage provider being used.voidsetContent(InputStream content)voidsetContentId(String contentId)voidsetContentMimeType(String contentMimeType)voidsetContentProperties(String spaceId, String contentId, Map<String,String> contentProperties)Sets the properties associated with content.voidsetContentProperties(Map<String,String> contentProperties)voidsetContentSize(long contentSize)voidsetSpaceACLs(String spaceId, Map<String,AclType> spaceACLs)Sets the ACLs associated with a space.voidsetSpaceId(String spaceId)voidsetSpaces(Iterator<String> spaces)
-
-
-
Method Detail
-
getStorageProviderType
public org.duracloud.storage.domain.StorageProviderType getStorageProviderType()
Description copied from interface:StorageProviderProvides the type of storage provider being used.- Specified by:
getStorageProviderTypein interfaceStorageProvider- Returns:
- StorageProviderType type of provider
-
addContent
public String addContent(String spaceId, String contentId, String contentMimeType, Map<String,String> userProperties, long contentSize, String contentChecksum, InputStream content) throws StorageException
Description copied from interface:StorageProviderAdds content to a space. Computes the checksum of the provided content and checks this against the checksum of the uploaded content to protect against loss or corruption during transfer.- Specified by:
addContentin interfaceStorageProvider- Parameters:
spaceId- - ID of the spacecontentId- - ID of the content in the spacecontentMimeType- - the MIME type of the content being addeduserProperties- - the metadata associated with the contentcontentSize- - the file size (in bytes) of the content being addedcontentChecksum- - the MD5 checksum of the content being added (null if no checksum is known)content- - content to add- Returns:
- The checksum of the provided content
- Throws:
NotFoundException- if space with ID spaceId does not existStorageException- if errors occur
-
copyContent
public String copyContent(String sourceSpaceId, String sourceContentId, String destSpaceId, String destContentId)
Description copied from interface:StorageProviderThis method copies the content item found in source-space with the id of source-content-id into the dest-space, naming it to dest-content-id.- Specified by:
copyContentin interfaceStorageProvider- Parameters:
sourceSpaceId- of content to copysourceContentId- of content to copydestSpaceId- where copied content will end updestContentId- given to copied content- Returns:
- MD5 checksum of destination content item
-
createSpace
public void createSpace(String spaceId) throws StorageException
Description copied from interface:StorageProviderCreates a new space. Depending on the storage implementation, the spaceId may be changed somewhat to comply with the naming rules of the underlying storage provider. The same spaceId value used here can be used in all other methods, as the conversion will be applied internally, however a call to getSpaces() may not include a space with exactly this same name.- Specified by:
createSpacein interfaceStorageProvider- Parameters:
spaceId- - ID of the space- Throws:
StorageException- if space with ID spaceId already exists
-
deleteContent
public void deleteContent(String spaceId, String contentId) throws StorageException
Description copied from interface:StorageProviderRemoves content from a space.- Specified by:
deleteContentin interfaceStorageProvider- Parameters:
spaceId- - ID of the spacecontentId- - ID of the content in the space- Throws:
NotFoundException- if space with ID spaceId does not exist or the content item with ID contentId does not existStorageException- if errors occur
-
deleteSpace
public void deleteSpace(String spaceId) throws StorageException
Description copied from interface:StorageProviderDeletes a space.- Specified by:
deleteSpacein interfaceStorageProvider- Parameters:
spaceId- - ID of the space- Throws:
NotFoundException- if space with ID spaceId does not existStorageException- if errors occur
-
getContent
public RetrievedContent getContent(String spaceId, String contentId) throws StorageException
Description copied from interface:StorageProviderGets content from a space.- Specified by:
getContentin interfaceStorageProvider- Parameters:
spaceId- - ID of the spacecontentId- - ID of the content in the space- Returns:
- object containing metadata and the content stream
- Throws:
NotFoundException- if space with ID spaceId does not exist or the content item with ID contentId does not existStorageException- if errors occur
-
getContent
public RetrievedContent getContent(String spaceId, String contentId, String range) throws StorageException
Description copied from interface:StorageProviderGets a range of bytes from a content item in a space.- Specified by:
getContentin interfaceStorageProvider- Parameters:
spaceId- - ID of the spacecontentId- - ID of the content in the spacerange- - Range of bytes to retrieve, as defined in: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35, only one range is supported per request- Returns:
- object containing metadata and the specified bytes of the content stream
- Throws:
NotFoundException- if space with ID spaceId does not exist or the content item with ID contentId does not existStorageException- if errors occur
-
getContentProperties
public Map<String,String> getContentProperties(String spaceId, String contentId) throws StorageException
Description copied from interface:StorageProviderRetrieves the properties associated with content. This includes both properties generated by the underlying storage system as well as custom properties. Use the PROPERTIES_CONTENT_* constants to retrieve standard properties values.- Specified by:
getContentPropertiesin interfaceStorageProvider- Parameters:
spaceId- - ID of the spacecontentId- - ID of the content in the space- Returns:
- content properties
- Throws:
NotFoundException- if space with ID spaceId does not exist or the content item with ID contentId does not existStorageException- if errors occur
-
getSpaceContents
public Iterator<String> getSpaceContents(String spaceId, String prefix) throws StorageException
Description copied from interface:StorageProviderProvides access to the content files within a space. Chunking of the list is handled internally. Prefix can be set to return only content IDs starting with the prefix value.- Specified by:
getSpaceContentsin interfaceStorageProvider- Parameters:
spaceId- - ID of the spaceprefix- - The prefix of the content id (null for no constraints)- Returns:
- Iterator of contentIds
- Throws:
NotFoundException- if space with ID spaceId does not existStorageException- if errors occur
-
getSpaceContentsChunked
public List<String> getSpaceContentsChunked(String spaceId, String prefix, long maxResults, String marker) throws StorageException
Description copied from interface:StorageProviderProvides a listing of the content files within a space. The number of items returned is limited to maxResults (default is 1000). Retrieve further results by including the last content ID in the previous list as the marker. Set prefix to return only content IDs starting with the prefix value.- Specified by:
getSpaceContentsChunkedin interfaceStorageProvider- Parameters:
spaceId- - ID of the spaceprefix- - Only retrieve content IDs with this prefix (null for all content ids)maxResults- - The maximum number of content IDs to return in the list (0 indicates default (1000))marker- - The content ID marking the last item in the previous set (null indicates the first set of ids)- Returns:
- List of contentIds
- Throws:
NotFoundException- if space with ID spaceId does not existStorageException- if errors occur
-
getSpaceProperties
public Map<String,String> getSpaceProperties(String spaceId) throws StorageException
Description copied from interface:StorageProviderRetrieves the properties associated with a space.- Specified by:
getSpacePropertiesin interfaceStorageProvider- Parameters:
spaceId- - ID of the space- Returns:
- Map of space properties or empty map if no properties exists
- Throws:
NotFoundException- if space with ID spaceId does not existStorageException- if errors occur
-
getSpaces
public Iterator<String> getSpaces() throws StorageException
Description copied from interface:StorageProviderProvides a listing of all spaces owned by a customer.- Specified by:
getSpacesin interfaceStorageProvider- Returns:
- Iterator listing spaceIds
- Throws:
StorageException
-
setContentProperties
public void setContentProperties(String spaceId, String contentId, Map<String,String> contentProperties) throws StorageException
Description copied from interface:StorageProviderSets the properties associated with content. This effectively removes all of the current content properties and adds a new set of properties. Some properties, such as system properties provided by the underlying storage system, cannot be updated or removed. Some of the values which cannot be updated or removed: Content-MD5 ETag Last-Modified Content-Type cannot be removed, but it can be updated- Specified by:
setContentPropertiesin interfaceStorageProvider- Parameters:
spaceId- - ID of the spacecontentId- - ID of the content in the spacecontentProperties- - new content properties- Throws:
NotFoundException- if space with ID spaceId does not exist or the content item with ID contentId does not existStorageException- if errors occur
-
getSpaceACLs
public Map<String,AclType> getSpaceACLs(String spaceId)
Description copied from interface:StorageProviderRetrieves the ACLs associated with a space.- Specified by:
getSpaceACLsin interfaceStorageProvider- Parameters:
spaceId- - ID of the space- Returns:
- Map of space ACLs or empty map if none exists
-
setSpaceACLs
public void setSpaceACLs(String spaceId, Map<String,AclType> spaceACLs)
Description copied from interface:StorageProviderSets the ACLs associated with a space.- Specified by:
setSpaceACLsin interfaceStorageProvider- Parameters:
spaceId- - ID of the spacespaceACLs- - Updated space ACL. Note, null or empty arg spaceACLs will 'clear' the space ACLs.
-
getSpaceId
public String getSpaceId()
-
setSpaceId
public void setSpaceId(String spaceId)
-
getContentId
public String getContentId()
-
setContentId
public void setContentId(String contentId)
-
getContentMimeType
public String getContentMimeType()
-
setContentMimeType
public void setContentMimeType(String contentMimeType)
-
getContentSize
public long getContentSize()
-
setContentSize
public void setContentSize(long contentSize)
-
getContent
public InputStream getContent()
-
setContent
public void setContent(InputStream content)
-
-