org.soyatec.windowsazure.blob
Class BlobStorageClient

java.lang.Object
  extended by org.soyatec.windowsazure.proxy.AbstractProxyDelegate
      extended by org.soyatec.windowsazure.blob.BlobStorageClient

public abstract class BlobStorageClient
extends AbstractProxyDelegate

The entry point of the blob storage API


Field Summary
static IRetryPolicy DefaultRetryPolicy
          The default retry policy
static org.soyatec.windowsazure.internal.util.TimeSpan DefaultTimeout
          The default timeout
 
Method Summary
static BlobStorageClient create(boolean usePathStyleUris, java.lang.String accountName, java.lang.String base64key)
          Convenient way to create a new BlobStorageClient.
static BlobStorageClient create(StorageAccountInfo accountInfo)
          Factory method for BlobStorageClient
static BlobStorageClient create(java.net.URI baseUri, boolean usePathStyleUris, java.lang.String accountName, java.lang.String base64Key)
          Factory method for BlobStorageClient
static IBlobContents createBlobContents(BlobStream stream)
          Create a IBlobContents from BlobStream
static IBlobContents createBlobContents(byte[] value)
          Create a IBlobContents from direct values
static IBlobContents createBlobContents(java.io.File file)
          Create a IBlobContents from File
static IBlobContents createBlobContents(java.io.InputStream stream)
          Create a IBlobContents from InputStream
static IBlobProperties createBlobProperties(java.lang.String blobName)
          Create a IBlobProperties for given Blob name
abstract  IBlobContainer createContainer(java.lang.String containerName)
          Create the container if it does not exist.
abstract  IBlobContainer createContainer(java.lang.String containerName, org.soyatec.windowsazure.internal.util.NameValueCollection metadata, IContainerAccessControl accessControl)
          Create the container with the specified metadata and access control if it does not exist.
abstract  ISharedAccessUrl createSharedAccessUrl(java.lang.String containerName, java.lang.String blobName, ResourceType resource, int permissions, DateTime start, DateTime expiry, java.lang.String identifier)
          Create a SharedAccessUrl
abstract  boolean deleteContainer(java.lang.String name)
          Deletes the container.
 java.lang.String getAccountName()
           
 java.lang.String getBase64Key()
           
 java.net.URI getBaseUri()
           
abstract  IBlobContainer getBlobContainer(java.lang.String containerName)
          Get a reference to a newly created BlobContainer object.
abstract  java.lang.String getLastStatus()
           
 IRetryPolicy getRetryPolicy()
           
 org.soyatec.windowsazure.internal.util.TimeSpan getTimeout()
           
abstract  boolean isContainerExist(java.lang.String containerName)
          Check if the blob container exists
 boolean isUsePathStyleUris()
          Indicates whether to use/generate path-style or host-style URIs.
abstract  java.util.List<IBlobContainer> listBlobContainers()
          Lists the containers within the account.
 void setBase64Key(java.lang.String base64Key)
           
 void setRetryPolicy(IRetryPolicy retryPolicy)
           
 void setTimeout(org.soyatec.windowsazure.internal.util.TimeSpan timeout)
           
 
Methods inherited from class org.soyatec.windowsazure.proxy.AbstractProxyDelegate
disableProxy, isProxyEnabled, setProxyConfiguration
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DefaultTimeout

public static final org.soyatec.windowsazure.internal.util.TimeSpan DefaultTimeout
The default timeout


DefaultRetryPolicy

public static final IRetryPolicy DefaultRetryPolicy
The default retry policy

Method Detail

create

public static BlobStorageClient create(java.net.URI baseUri,
                                       boolean usePathStyleUris,
                                       java.lang.String accountName,
                                       java.lang.String base64Key)
Factory method for BlobStorageClient

Parameters:
baseUri - The base URI of the blob storage service
usePathStyleUris - If true, path-style URIs (http://baseuri/accountname/containername/objectname) are used. If false host-style URIs (http://accountname.baseuri/containername/objectname) are used, where baseuri is the URI of the service. If null, the choice is made automatically: path-style URIs if host name part of base URI is an IP addres, host-style otherwise.
accountName - The name of the storage account
base64Key - Authentication key used for signing requests
Returns:
A newly created BlobStorage instance

create

public static BlobStorageClient create(boolean usePathStyleUris,
                                       java.lang.String accountName,
                                       java.lang.String base64key)
Convenient way to create a new BlobStorageClient.

Parameters:
usePathStyleUris - If true, path-style URIs (http://baseuri/accountname/containername/objectname) are used. If false host-style URIs (http://accountname.baseuri/containername/objectname) are used, where baseuri is the URI of the service. If null, the choice is made automatically: path-style URIs if host name part of base URI is an IP addres, host-style otherwise.
accountName - The name of the storage account
base64key - Authentication key used for signing requests
Returns:
A newly created BlobStorageClient instance

create

public static BlobStorageClient create(StorageAccountInfo accountInfo)
Factory method for BlobStorageClient

Parameters:
accountInfo - Account information
Returns:
A newly created BlobStorageClient instance

createBlobProperties

public static IBlobProperties createBlobProperties(java.lang.String blobName)
Create a IBlobProperties for given Blob name

Parameters:
blobName - The name of the BLOB.
Returns:
A newly created BlobProperties instance

createBlobContents

public static IBlobContents createBlobContents(java.io.File file)
                                        throws java.io.IOException
Create a IBlobContents from File

Parameters:
file -
Returns:
A newly created BlobContents instance
Throws:
java.io.IOException

createBlobContents

public static IBlobContents createBlobContents(byte[] value)
Create a IBlobContents from direct values

Parameters:
value - A byte array.
Returns:
A newly created BlobContents instance
Throws:
java.io.IOException

createBlobContents

public static IBlobContents createBlobContents(java.io.InputStream stream)
                                        throws java.io.IOException
Create a IBlobContents from InputStream

Parameters:
stream - inputStream.
Returns:
A newly created BlobContents instance
Throws:
java.io.IOException

createBlobContents

public static IBlobContents createBlobContents(BlobStream stream)
Create a IBlobContents from BlobStream

Parameters:
stream - blobStream
Returns:
A newly created BlobContents instance
Throws:
java.io.IOException

isContainerExist

public abstract boolean isContainerExist(java.lang.String containerName)
                                  throws StorageException
Check if the blob container exists

Parameters:
containerName - of the BLOB.
Returns:
true if the blob exists, false otherwise.
Throws:
StorageException

createContainer

public abstract IBlobContainer createContainer(java.lang.String containerName,
                                               org.soyatec.windowsazure.internal.util.NameValueCollection metadata,
                                               IContainerAccessControl accessControl)
                                        throws StorageException
Create the container with the specified metadata and access control if it does not exist. Metadata Names are case-insensitive. If two or more headers with the same name are submitted for a resource, the headers will be combined into a single header with a comma delimiting each value.The total size of the metadata, including both the name and value together, may not exceed 8 KB in size.

Parameters:
containerName - The name of the container
metadata - The metadata for the container. Can be null to indicate no metadata
accessControl - The access control (public or private) with which to create the container
Returns:
the container that is created
Throws:
StorageException - If container already exists, it will raise exception.

createContainer

public abstract IBlobContainer createContainer(java.lang.String containerName)
                                        throws StorageException
Create the container if it does not exist. The container is created with private access control and no metadata.

Returns:
the container that is created
Throws:
StorageException - If container already exists, it will raise exception.

getBlobContainer

public abstract IBlobContainer getBlobContainer(java.lang.String containerName)
Get a reference to a newly created BlobContainer object. This method does not make any calls to the storage service.

Parameters:
containerName - The name of the container
Returns:
A reference to a newly created BlobContainer object

listBlobContainers

public abstract java.util.List<IBlobContainer> listBlobContainers()
                                                           throws StorageServerException
Lists the containers within the account.

Returns:
A list of containers
Throws:
java.lang.Exception
StorageServerException

createSharedAccessUrl

public abstract ISharedAccessUrl createSharedAccessUrl(java.lang.String containerName,
                                                       java.lang.String blobName,
                                                       ResourceType resource,
                                                       int permissions,
                                                       DateTime start,
                                                       DateTime expiry,
                                                       java.lang.String identifier)
                                                throws StorageServerException
Create a SharedAccessUrl

Parameters:
containerName - The name of container.
blobName - The name of Bolb.
resource - The resource type.
permissions - ONE = 0;READ = 1;WRITE = 2;DELETE = 4;LIST = 8
start - The start time.
expiry - The expiry time.
identifier - The identifier of SharedAccessUrl.
Returns:
Throws:
StorageServerException

deleteContainer

public abstract boolean deleteContainer(java.lang.String name)
                                 throws StorageException
Deletes the container.

Returns:
true:delete success/ false:delete failed
Throws:
StorageException

isUsePathStyleUris

public boolean isUsePathStyleUris()
Indicates whether to use/generate path-style or host-style URIs.

Returns:
true/false

getBaseUri

public java.net.URI getBaseUri()
Returns:
The base URI of the blob storate service.

getAccountName

public java.lang.String getAccountName()
Returns:
The name of the storage account.

getBase64Key

public java.lang.String getBase64Key()
Returns:
Authentication key used for signing requests

getTimeout

public org.soyatec.windowsazure.internal.util.TimeSpan getTimeout()
Returns:
The time out for each request to the storage service.

getRetryPolicy

public IRetryPolicy getRetryPolicy()
Returns:
The retry policy used for retrying requests.

setBase64Key

public void setBase64Key(java.lang.String base64Key)
Parameters:
base64Key - Authentication key used for signing requests

setTimeout

public void setTimeout(org.soyatec.windowsazure.internal.util.TimeSpan timeout)
Parameters:
timeout - The time out for each request to the storage service.

setRetryPolicy

public void setRetryPolicy(IRetryPolicy retryPolicy)
Parameters:
retryPolicy - The retry policy used for retrying requests.

getLastStatus

public abstract java.lang.String getLastStatus()