org.duracloud.rackspacestorage
Class RackspaceStorageProvider

java.lang.Object
  extended by org.duracloud.storage.provider.StorageProviderBase
      extended by org.duracloud.rackspacestorage.RackspaceStorageProvider
All Implemented Interfaces:
StorageProvider
Direct Known Subclasses:
SDSCStorageProvider

public class RackspaceStorageProvider
extends StorageProviderBase

Provides content storage backed by Rackspace's Cloud Files service.

Author:
Bill Branan

Nested Class Summary
 
Nested classes/interfaces inherited from class org.duracloud.storage.provider.StorageProviderBase
StorageProviderBase.SpaceDeleteWorker
 
Nested classes/interfaces inherited from interface org.duracloud.storage.provider.StorageProvider
StorageProvider.AccessType
 
Field Summary
 
Fields inherited from interface org.duracloud.storage.provider.StorageProvider
DEFAULT_MAX_RESULTS, DEFAULT_MIMETYPE, PROPERTIES_CONTENT_CHECKSUM, PROPERTIES_CONTENT_MD5, PROPERTIES_CONTENT_MIMETYPE, PROPERTIES_CONTENT_MODIFIED, PROPERTIES_CONTENT_SIZE, PROPERTIES_COPY_SOURCE, PROPERTIES_SPACE_ACCESS, PROPERTIES_SPACE_COUNT, PROPERTIES_SPACE_CREATED, PROPERTIES_SPACE_SIZE, RFC822_DATE_FORMAT, SPACE_PROPERTIES_SUFFIX
 
Constructor Summary
RackspaceStorageProvider(com.rackspacecloud.client.cloudfiles.FilesClient filesClient)
           
RackspaceStorageProvider(java.lang.String username, java.lang.String apiAccessKey)
           
RackspaceStorageProvider(java.lang.String username, java.lang.String apiAccessKey, java.lang.String authUrl)
           
 
Method Summary
 java.lang.String addContent(java.lang.String spaceId, java.lang.String contentId, java.lang.String contentMimeType, long contentSize, java.lang.String contentChecksum, java.io.InputStream content)
          Adds content to a space.
 java.lang.String copyContent(java.lang.String sourceSpaceId, java.lang.String sourceContentId, java.lang.String destSpaceId, java.lang.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.
 void createSpace(java.lang.String spaceId)
          Creates a new space.
 void deleteContent(java.lang.String spaceId, java.lang.String contentId)
          Removes content from a space.
protected  java.lang.String getContainerName(java.lang.String spaceId)
          Converts a provided space ID into a valid Rackspace container name.
 java.io.InputStream getContent(java.lang.String spaceId, java.lang.String contentId)
          Gets content from a space.
 java.util.Map<java.lang.String,java.lang.String> getContentProperties(java.lang.String spaceId, java.lang.String contentId)
          Retrieves the properties associated with content.
 java.util.Iterator<java.lang.String> getSpaceContents(java.lang.String spaceId, java.lang.String prefix)
          Provides access to the content files within a space.
 java.util.List<java.lang.String> getSpaceContentsChunked(java.lang.String spaceId, java.lang.String prefix, long maxResults, java.lang.String marker)
          Provides a listing of the content files within a space.
protected  java.lang.String getSpaceFree(java.lang.String name)
          Replaces all spaces with "%20"
 java.util.Map<java.lang.String,java.lang.String> getSpaceProperties(java.lang.String spaceId)
          Retrieves the properties associated with a space.
 java.util.Iterator<java.lang.String> getSpaces()
          Provides a listing of all spaces owned by a customer.
protected  java.lang.String getWithSpace(java.lang.String name)
          Converts "%20" back to spaces
 void removeSpace(java.lang.String spaceId)
          
 void setContentProperties(java.lang.String spaceId, java.lang.String contentId, java.util.Map<java.lang.String,java.lang.String> contentProperties)
          Sets the properties associated with content.
 void setSpaceProperties(java.lang.String spaceId, java.util.Map<java.lang.String,java.lang.String> spaceProperties)
          Sets the properties associated with a space.
protected  void throwIfSpaceNotExist(java.lang.String spaceId)
           
 
Methods inherited from class org.duracloud.storage.provider.StorageProviderBase
deleteSpace, getSpaceAccess, getSpaceDeleteWorker, setSpaceAccess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RackspaceStorageProvider

public RackspaceStorageProvider(java.lang.String username,
                                java.lang.String apiAccessKey,
                                java.lang.String authUrl)

RackspaceStorageProvider

public RackspaceStorageProvider(java.lang.String username,
                                java.lang.String apiAccessKey)

RackspaceStorageProvider

public RackspaceStorageProvider(com.rackspacecloud.client.cloudfiles.FilesClient filesClient)
Method Detail

getSpaces

public java.util.Iterator<java.lang.String> getSpaces()
Provides a listing of all spaces owned by a customer.

Returns:
Iterator listing spaceIds

getSpaceContents

public java.util.Iterator<java.lang.String> getSpaceContents(java.lang.String spaceId,
                                                             java.lang.String prefix)
Provides 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.

Parameters:
spaceId - - ID of the space
prefix - - The prefix of the content id (null for no constraints)
Returns:
Iterator of contentIds

getSpaceContentsChunked

public java.util.List<java.lang.String> getSpaceContentsChunked(java.lang.String spaceId,
                                                                java.lang.String prefix,
                                                                long maxResults,
                                                                java.lang.String marker)
Provides 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.

Parameters:
spaceId - - ID of the space
prefix - - 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

throwIfSpaceNotExist

protected void throwIfSpaceNotExist(java.lang.String spaceId)
Specified by:
throwIfSpaceNotExist in class StorageProviderBase

createSpace

public void createSpace(java.lang.String spaceId)
Creates 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.

Parameters:
spaceId - - ID of the space

removeSpace

public void removeSpace(java.lang.String spaceId)

Specified by:
removeSpace in class StorageProviderBase

getSpaceProperties

public java.util.Map<java.lang.String,java.lang.String> getSpaceProperties(java.lang.String spaceId)
Retrieves the properties associated with a space.

Parameters:
spaceId - - ID of the space
Returns:
Map of space properties or null if no properties exists

setSpaceProperties

public void setSpaceProperties(java.lang.String spaceId,
                               java.util.Map<java.lang.String,java.lang.String> spaceProperties)
Sets the properties associated with a space.

Parameters:
spaceId - - ID of the space
spaceProperties - - Updated space properties

addContent

public java.lang.String addContent(java.lang.String spaceId,
                                   java.lang.String contentId,
                                   java.lang.String contentMimeType,
                                   long contentSize,
                                   java.lang.String contentChecksum,
                                   java.io.InputStream content)
Adds 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.

Parameters:
spaceId - - ID of the space
contentId - - ID of the content in the space
contentMimeType - - the MIME type of the content being added
contentSize - - the file size (in bytes) of the content being added
contentChecksum - - 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

copyContent

public java.lang.String copyContent(java.lang.String sourceSpaceId,
                                    java.lang.String sourceContentId,
                                    java.lang.String destSpaceId,
                                    java.lang.String destContentId)
Description copied from interface: StorageProvider
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.

Parameters:
sourceSpaceId - of content to copy
sourceContentId - of content to copy
destSpaceId - where copied content will end up
destContentId - given to copied content
Returns:
MD5 checksum of destination content item

getContent

public java.io.InputStream getContent(java.lang.String spaceId,
                                      java.lang.String contentId)
Gets content from a space.

Parameters:
spaceId - - ID of the space
contentId - - ID of the content in the space
Returns:
the content stream

deleteContent

public void deleteContent(java.lang.String spaceId,
                          java.lang.String contentId)
Removes content from a space.

Parameters:
spaceId - - ID of the space
contentId - - ID of the content in the space

setContentProperties

public void setContentProperties(java.lang.String spaceId,
                                 java.lang.String contentId,
                                 java.util.Map<java.lang.String,java.lang.String> contentProperties)
Sets 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

Parameters:
spaceId - - ID of the space
contentId - - ID of the content in the space
contentProperties - - new content properties

getContentProperties

public java.util.Map<java.lang.String,java.lang.String> getContentProperties(java.lang.String spaceId,
                                                                             java.lang.String contentId)
Retrieves 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.

Parameters:
spaceId - - ID of the space
contentId - - ID of the content in the space
Returns:
content properties

getContainerName

protected java.lang.String getContainerName(java.lang.String spaceId)
Converts a provided space ID into a valid Rackspace container name. From Cloud Files Docs: The only restrictions on Container names is that they cannot contain a forward slash (/) character or a question mark (?) character and they must be less than 64 characters in length (after URL encoding).

Parameters:
spaceId - user preferred ID of the space
Returns:
spaceId converted to valid Rackspace container name

getSpaceFree

protected java.lang.String getSpaceFree(java.lang.String name)
Replaces all spaces with "%20"

Parameters:
name - string with possible space
Returns:
converted to string without spaces

getWithSpace

protected java.lang.String getWithSpace(java.lang.String name)
Converts "%20" back to spaces

Parameters:
name - string
Returns:
converted to spaces


Copyright © 2009-2011 DuraSpace. All Rights Reserved.