java.net.HttpURLConnection
is supported as a
+ * connection object.
+ *
* @return the connectionObject
*/
public Object getConnectionObject() {
@@ -65,6 +65,9 @@ public Object getConnectionObject() {
}
/**
+ * Gets a context for the current operation. This object is used to track requests to the storage service, and
+ * to provide additional runtime information about the operation.
+ *
* @return the opContext
*/
public OperationContext getOpContext() {
@@ -72,7 +75,9 @@ public OperationContext getOpContext() {
}
/**
- * @return A {@link RequestResult} object that represents the current request result.
+ * Gets a {@link RequestResult} object that represents the current request result.
+ *
+ * @return the {@link RequestResult} object
*/
public RequestResult getRequestResult() {
return this.requestResult;
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/CloudStorageAccount.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/CloudStorageAccount.java
similarity index 87%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/CloudStorageAccount.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/CloudStorageAccount.java
index b5623943b42d3..d79b1a158267a 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/CloudStorageAccount.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/CloudStorageAccount.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
import java.net.URI;
import java.net.URISyntaxException;
@@ -21,14 +21,17 @@
import java.util.HashMap;
import java.util.Map.Entry;
-import com.microsoft.windowsazure.storage.blob.CloudBlobClient;
-import com.microsoft.windowsazure.storage.core.SR;
-import com.microsoft.windowsazure.storage.core.Utility;
-import com.microsoft.windowsazure.storage.queue.CloudQueueClient;
-import com.microsoft.windowsazure.storage.table.CloudTableClient;
+import com.microsoft.azure.storage.blob.CloudBlobClient;
+import com.microsoft.azure.storage.blob.CloudBlobContainer;
+import com.microsoft.azure.storage.core.SR;
+import com.microsoft.azure.storage.core.StorageCredentialsHelper;
+import com.microsoft.azure.storage.core.Utility;
+import com.microsoft.azure.storage.queue.CloudQueueClient;
+import com.microsoft.azure.storage.table.CloudTable;
+import com.microsoft.azure.storage.table.CloudTableClient;
/**
- * Represents a Windows Azure storage account.
+ * Represents a Microsoft Azure storage account.
*/
public final class CloudStorageAccount {
/**
@@ -61,6 +64,17 @@ public final class CloudStorageAccount {
*/
private static final String DEFAULT_ENDPOINTS_PROTOCOL_NAME = "DefaultEndpointsProtocol";
+ /**
+ * The format string for the primary endpoint.
+ */
+ private static final String DEVELOPMENT_STORAGE_PRIMARY_ENDPOINT_FORMAT = "%s://%s:%s/%s";
+
+ /**
+ * The format string for the secondary endpoint
+ */
+ private static final String DEVELOPMENT_STORAGE_SECONDARY_ENDPOINT_FORMAT = DEVELOPMENT_STORAGE_PRIMARY_ENDPOINT_FORMAT
+ + SECONDARY_LOCATION_ACCOUNT_SUFFIX;
+
/**
* The setting name for specifying a development storage proxy Uri.
*/
@@ -86,18 +100,6 @@ public final class CloudStorageAccount {
*/
private static final String SECONDARY_ENDPOINT_FORMAT = "%s://%s%s.%s";
- /**
- * The credentials string used to test for the development storage credentials.
- */
- private static final String DEVSTORE_CREDENTIALS_IN_STRING = CloudStorageAccount.ACCOUNT_NAME_NAME + "="
- + CloudStorageAccount.DEVSTORE_ACCOUNT_NAME + ";" + CloudStorageAccount.ACCOUNT_KEY_NAME + "="
- + CloudStorageAccount.DEVSTORE_ACCOUNT_KEY;
-
- /**
- * A CloudStorageAccount that represents the development storage account.
- */
- private static CloudStorageAccount devStoreAccount;
-
/**
* Represents the root queue DNS name.
*/
@@ -253,28 +255,28 @@ private static StorageUri getDefaultTableStorageUri(final String scheme, final S
}
/**
- * Returns a {@link CloudStorageAccount} object that represents the development storage credentials.
+ * Returns a {@link CloudStorageAccount} object that represents the development storage credentials. Secondary
+ * endpoints are enabled by default.
*
* @return A {@link CloudStorageAccount} object for the development storage credentials.
*/
public static CloudStorageAccount getDevelopmentStorageAccount() {
- if (devStoreAccount == null) {
- try {
- devStoreAccount = getDevelopmentStorageAccount(new URI("http://127.0.0.1"));
- }
- catch (final URISyntaxException e) {
- // this wont happen since we know the uri above.
- }
+ try {
+ return getDevelopmentStorageAccount(null);
+ }
+ catch (final URISyntaxException e) {
+ // this wont happen since we know the standard dev store uri is valid
+ return null;
}
- return devStoreAccount;
}
/**
* Returns a {@link CloudStorageAccount} object that represents the development storage credentials, using the
- * specified proxy URI.
+ * specified proxy URI. Secondary endpoints are enabled by default.
*
* @param proxyUri
- * A java.net.URI
object that represents the proxy endpoint to use.
+ * A java.net.URI
object that represents the proxy endpoint to use. Specifying
+ * null
will use the default http://127.0.0.1
.
*
* @return A {@link CloudStorageAccount} object for the development storage credentials.
*
@@ -282,25 +284,55 @@ public static CloudStorageAccount getDevelopmentStorageAccount() {
* If the resource URI is invalid.
*/
public static CloudStorageAccount getDevelopmentStorageAccount(final URI proxyUri) throws URISyntaxException {
+ String scheme;
+ String host;
if (proxyUri == null) {
- return getDevelopmentStorageAccount();
+ scheme = "http";
+ host = "127.0.0.1";
}
+ else {
+ scheme = proxyUri.getScheme();
+ host = proxyUri.getHost();
+ }
+
+ StorageCredentials credentials = new StorageCredentialsAccountAndKey(DEVSTORE_ACCOUNT_NAME,
+ DEVSTORE_ACCOUNT_KEY);
+
+ URI blobPrimaryEndpoint = new URI(String.format(DEVELOPMENT_STORAGE_PRIMARY_ENDPOINT_FORMAT, scheme, host,
+ "10000", DEVSTORE_ACCOUNT_NAME));
+ URI queuePrimaryEndpoint = new URI(String.format(DEVELOPMENT_STORAGE_PRIMARY_ENDPOINT_FORMAT, scheme, host,
+ "10001", DEVSTORE_ACCOUNT_NAME));
+ URI tablePrimaryEndpoint = new URI(String.format(DEVELOPMENT_STORAGE_PRIMARY_ENDPOINT_FORMAT, scheme, host,
+ "10002", DEVSTORE_ACCOUNT_NAME));
+
+ URI blobSecondaryEndpoint = new URI(String.format(DEVELOPMENT_STORAGE_SECONDARY_ENDPOINT_FORMAT, scheme, host,
+ "10000", DEVSTORE_ACCOUNT_NAME));
+ URI queueSecondaryEndpoint = new URI(String.format(DEVELOPMENT_STORAGE_SECONDARY_ENDPOINT_FORMAT, scheme, host,
+ "10001", DEVSTORE_ACCOUNT_NAME));
+ URI tableSecondaryEndpoint = new URI(String.format(DEVELOPMENT_STORAGE_SECONDARY_ENDPOINT_FORMAT, scheme, host,
+ "10002", DEVSTORE_ACCOUNT_NAME));
+
+ CloudStorageAccount account = new CloudStorageAccount(credentials, new StorageUri(blobPrimaryEndpoint,
+ blobSecondaryEndpoint), new StorageUri(queuePrimaryEndpoint, queueSecondaryEndpoint), new StorageUri(
+ tablePrimaryEndpoint, tableSecondaryEndpoint));
- String prefix = proxyUri.getScheme().concat("://");
- prefix = prefix.concat(proxyUri.getHost());
+ account.isDevStoreAccount = true;
- return new CloudStorageAccount(
- new StorageCredentialsAccountAndKey(DEVSTORE_ACCOUNT_NAME, DEVSTORE_ACCOUNT_KEY), new StorageUri(
- new URI(prefix.concat(":10000/devstoreaccount1"))), new StorageUri(new URI(
- prefix.concat(":10001/devstoreaccount1"))), new StorageUri(new URI(
- prefix.concat(":10002/devstoreaccount1"))));
+ return account;
}
/**
* Parses a connection string and returns a cloud storage account created from the connection string.
* - * Note this method is not supported for shared access signature credentials as they do not contain the required - * endpoint configuration parameters. + * The connection string should be in the Azure + * connection string format. + *
+ * Note that while a connection string may include a SAS token, it is often easier to use the
+ * {@link CloudBlobContainer#CloudBlobContainer(URI)}, {@link CloudBlobContainer#CloudQueue(URI)},
+ * {@link CloudTable#CloudBlobContainer(URI)} constructors directly. To do this, create a
+ * {@link StorageCredentialsSharedAccessSignature#StorageCredentialsSharedAccessSignature(String)} object with your
+ * SAS token, use the {@link StorageCredentialsSharedAccessSignature#transformUri(URI)} method on the container,
+ * queue, or table URI, and then use that URI to construct the object.
*
* @param connectionString
* A
@@ -636,7 +669,7 @@ public CloudBlobClient createCloudBlobClient() {
throw new IllegalArgumentException(SR.MISSING_CREDENTIALS);
}
- if (!this.credentials.canCredentialsSignRequest()) {
+ if (!StorageCredentialsHelper.canCredentialsSignRequest(this.credentials)) {
throw new IllegalArgumentException(SR.CREDENTIALS_CANNOT_SIGN_REQUEST);
}
return new CloudBlobClient(this.getBlobStorageUri(), this.getCredentials());
@@ -656,7 +689,7 @@ public CloudQueueClient createCloudQueueClient() {
throw new IllegalArgumentException(SR.MISSING_CREDENTIALS);
}
- if (!this.credentials.canCredentialsSignRequest()) {
+ if (!StorageCredentialsHelper.canCredentialsSignRequest(this.credentials)) {
throw new IllegalArgumentException(SR.CREDENTIALS_CANNOT_SIGN_REQUEST);
}
return new CloudQueueClient(this.getQueueStorageUri(), this.getCredentials());
@@ -676,7 +709,7 @@ public CloudTableClient createCloudTableClient() {
throw new IllegalArgumentException(SR.MISSING_CREDENTIALS);
}
- if (!this.credentials.canCredentialsSignRequest()) {
+ if (!StorageCredentialsHelper.canCredentialsSignRequest(this.credentials)) {
throw new IllegalArgumentException(SR.CREDENTIALS_CANNOT_SIGN_REQUEST);
}
return new CloudTableClient(this.getTableStorageUri(), this.getCredentials());
@@ -826,20 +859,12 @@ public String toString(final boolean exportSecrets) {
}
final ArrayList
+ * The default RetryPolicyFactory is set in the client and is by default {@link RetryExponentialRetry}. You can
+ * change the RetryPolicyFactory on this request by setting this property. You can also change the value on the
+ * {@link ServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via the service
+ * client will use that RetryPolicyFactory.
*
* @param retryPolicyFactory
* the RetryPolicyFactory object to use when making service requests.
@@ -201,13 +208,11 @@ public final void setRetryPolicyFactory(final RetryPolicyFactory retryPolicyFact
* The server timeout interval begins at the time that the complete request has been received by the service, and
* the server begins processing the response. If the timeout interval elapses before the response is returned to the
* client, the operation times out. The timeout interval resets with each retry, if the request is retried.
- *
- * The default timeout interval for a request is the timeout set in the client (by default 90 seconds). You can
- * change the timeout interval on this request by setting this property. You can also change the value at
- * {@link ServiceClient#setTimeoutInMs(int)} so that all subsequent requests made via the service client will use
- * the new timeout interval.
- *
- * If you are downloading a large blob, you should increase the value of the timeout beyond the default value.
+ *
+ * The default server timeout is set in the client and is by default null, indicating no server timeout. You can
+ * change the server timeout on this request by setting this property. You can also change the value on the
+ * {@link ServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via the service
+ * client will use that server timeout.
*
* @param timeoutInMs
* The timeout, in milliseconds, to use for this request.
@@ -218,6 +223,11 @@ public final void setTimeoutIntervalInMs(final Integer timeoutIntervalInMs) {
/**
* Sets the {@link LocationMode} for this request.
+ *
+ * The default {@link LocationMode} is set in the client and is by default {@link LocationMode#PRIMARY_ONLY}. You
+ * can change the {@link LocationMode} on this request by setting this property. You can also change the value on
+ * the {@link ServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via the service
+ * client will use that {@link LocationMode}.
*
* @param locationMode
* the locationMode to set
@@ -233,10 +243,10 @@ public final void setLocationMode(final LocationMode locationMode) {
* execution time is checked intermittently while uploading data, downloading data, and before executing retries.
* The service will continue to upload, download, and retry until the maximum execution time is reached. At that
* time, any partial uploads or downloads will be cancelled and an exception will be thrown.
- *
+ *
* The default maximum execution is set in the client and is by default null, indicating no maximum time. You can
- * change the maximum execution time on this request by setting this property. You can also change the value at
- * {@link ServiceClient#setMaximumExecutionTimeInMs(Integer)} so that all subsequent requests made via the service
+ * change the maximum execution time on this request by setting this property. You can also change the value on the
+ * {@link ServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via the service
* client will use the maximum execution time.
*
* @param maximumExecutionTimeInMs
@@ -247,6 +257,12 @@ public void setMaximumExecutionTimeInMs(Integer maximumExecutionTimeInMs) {
}
/**
+ * RESERVED FOR INTERNAL USE.
+ *
+ * Returns the time at which this operation expires. This is computed by adding the time the operation begins and
+ * the maximum execution time and will be null if maximum execution time is null. For more information about maximum
+ * execution time, see {@link #setMaximumExecutionTimeInMs(Integer)}.
+ *
* @param operationExpiryTime
* the operationExpiryTime to set
*/
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RequestResult.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/RequestResult.java
similarity index 99%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RequestResult.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/RequestResult.java
index 5b127c19b96a6..0cca268a5cda5 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RequestResult.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/RequestResult.java
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
import java.util.Date;
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ResponseReceivedEvent.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/ResponseReceivedEvent.java
similarity index 54%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ResponseReceivedEvent.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/ResponseReceivedEvent.java
index 695cb49af68f8..ae0d1d8bd7d98 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ResponseReceivedEvent.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/ResponseReceivedEvent.java
@@ -12,15 +12,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
-
-import com.microsoft.windowsazure.storage.core.BaseEvent;
+package com.microsoft.azure.storage;
/**
* Represents an event that is fired when a response is received.
*/
public final class ResponseReceivedEvent extends BaseEvent {
+ /**
+ * Creates an instance of the
- * The server timeout interval begins at the time that the complete request has been received by the service, and
- * the server begins processing the response. If the timeout interval elapses before the response is returned to the
- * client, the operation times out. The timeout interval resets with each retry, if the request is retried.
- *
- * The default timeout interval for a request made via the service client is 90 seconds. You can change this value
- * on the service client by setting this property, so that all subsequent requests made via the service client will
- * use the new timeout interval. You can also change this value for an individual request, by setting the
- * {@link RequestOptions#setTimeoutIntervalInMs(Integer)} property.
- *
- * If you are downloading a large blob, you should increase the value of the timeout beyond the default value.
- *
- * @param timeoutInMs
- * The timeout, in milliseconds, to use when making requests to the storage service.
- */
- public final void setTimeoutInMs(final int timeoutInMs) {
- this.timeoutInMs = timeoutInMs;
- }
-
- /**
- * Sets the maximum execution time to use when making requests to the storage service.
- *
- * The maximum execution time interval begins at the time that the client begins building the request. The maximum
- * execution time is checked intermittently while uploading data, downloading data, and before executing retries.
- * The service will continue to upload, download, and retry until the maximum execution time is reached. At that
- * time, any partial uploads or downloads will be cancelled and an exception will be thrown.
- *
- * The default maximum execution time is null, indicating no maximum time. You can change this value on the service
- * client by setting this property, so that all subsequent requests made via the service client will use the new
- * maximum execution time. You can also change this value for an individual request, by setting the
- * {@link RequestOptions#setMaximumExecutionTimeInMs(Integer)} property.
- *
- * @param maximumExecutionTimeInMs
- * The maximum execution time, in milliseconds, to use when making service requests.
- */
- public void setMaximumExecutionTimeInMs(Integer maximumExecutionTimeInMs) {
- this.maximumExecutionTimeInMs = maximumExecutionTimeInMs;
- }
-
protected StorageRequest
+ * The server timeout interval begins at the time that the complete request has been received by the service, and
+ * the server begins processing the response. If the timeout interval elapses before the response is returned to the
+ * client, the operation times out. The timeout interval resets with each retry, if the request is retried.
+ *
+ * You can change this value on the service client by setting this property, so that all subsequent requests made
+ * via the service client will use the new timeout interval. You can also change this value for an individual
+ * request, by setting the {@link RequestOptions#setTimeoutIntervalInMs(Integer)} property.
+ *
+ * @param timeoutInMs
+ * The timeout, in milliseconds, to use when making requests to the storage service.
+ *
+ * @deprecated use {@link #getDefaultRequestOptions().setTimeoutIntervalInMs()} instead.
+ */
+ @Deprecated
+ public final void setTimeoutInMs(final int timeoutInMs) {
+ this.getDefaultRequestOptions().setTimeoutIntervalInMs(timeoutInMs);
+ }
+
+ /**
+ * Sets the maximum execution time to use when making requests to the storage service.
+ *
+ * The maximum execution time interval begins at the time that the client begins building the request. The maximum
+ * execution time is checked intermittently while uploading data, downloading data, and before executing retries.
+ * The service will continue to upload, download, and retry until the maximum execution time is reached. At that
+ * time, any partial uploads or downloads will be cancelled and an exception will be thrown.
+ *
+ * The default maximum execution time is null, indicating no maximum time. You can change this value on the service
+ * client by setting this property, so that all subsequent requests made via the service client will use the new
+ * maximum execution time. You can also change this value for an individual request, by setting the
+ * {@link RequestOptions#setMaximumExecutionTimeInMs(Integer)} property.
+ *
+ * @param maximumExecutionTimeInMs
+ * The maximum execution time, in milliseconds, to use when making service requests.
+ *
+ * @deprecated use {@link #getDefaultRequestOptions().setMaximumExecutionTimeInMs()} instead.
+ */
+ @Deprecated
+ public void setMaximumExecutionTimeInMs(Integer maximumExecutionTimeInMs) {
+ this.getDefaultRequestOptions().setMaximumExecutionTimeInMs(maximumExecutionTimeInMs);
+ }
+
+ /**
+ * Gets the {@link RequestOptions} that is used for requests associated with this
+ * Either include an account name with an account key (specifying values for
+ * {@link CloudStorageAccount#ACCOUNT_NAME_NAME} and {@link CloudStorageAccount#ACCOUNT_KEY_NAME} ), or a
+ * shared access signature (specifying a value for
+ * {@link CloudStorageAccount#SHARED_ACCESS_SIGNATURE_NAME} ). If you use an account name and account
+ * key, do not include a shared access signature, and vice versa.
+ *
+ * @return A {@link StorageCredentials} object representing the storage credentials determined from the name/value
+ * pairs.
+ *
+ * @throws InvalidKeyException
+ * If the key value specified for {@link CloudStorageAccount#ACCOUNT_KEY_NAME} is not a valid
+ * Base64-encoded string.
+ */
+ protected static StorageCredentials tryParseCredentials(final HashMap
+ * The format for the connection string is in the pattern "keyname=value". Multiple key/value pairs can be
+ * separated by a semi-colon, for example, "keyname1=value1;keyname2=value2". Either include an account name
+ * with an account key or a shared access signature. If you use an account name and account key, do not include a
+ * shared access signature, and vice versa.
+ *
+ * The same connection string can be used as for {@link CloudStorageAccount#parse(String)} but here only the account
+ * name, account key, and sas key/value pairs will be examined.
+ *
+ * @param connectionString
+ * A
* The public access setting indicates whether the container and its blobs can be read via an anonymous request.
*
@@ -50,26 +62,25 @@ public final class BlobContainerPermissions extends Permissions
+ * The public access setting indicates whether the container and its blobs can be read via an anonymous request.
+ *
+ * The {@link BlobContainerPublicAccessType} enumeration provides three levels of anonymous read access:
+ *
- * The ETag value is a unique identifier that is updated when a write operation is performed against the container.
- * It may be used to perform operations conditionally, providing concurrency control and improved efficiency.
- *
- * The {@link AccessCondition#ifMatch} and {@link AccessCondition#ifNoneMatch} methods take an ETag value and return
- * an {@link AccessCondition} object that may be specified on the request.
*/
private String etag;
@@ -58,6 +49,14 @@ public final class BlobContainerProperties {
private LeaseDuration leaseDuration;
/**
+ * Gets the ETag value of the container.
+ *
+ * The ETag value is a unique identifier that is updated when a write operation is performed against the container.
+ * It may be used to perform operations conditionally, providing concurrency control and improved efficiency.
+ *
+ * The {@link AccessCondition#ifMatch} and {@link AccessCondition#ifNoneMatch} methods take an ETag value and return
+ * an {@link AccessCondition} object that may be specified on the request.
+ *
* @return the etag
*/
public String getEtag() {
@@ -65,6 +64,8 @@ public String getEtag() {
}
/**
+ * Gets the last modified time on the container.
+ *
* @return the lastModified
*/
public Date getLastModified() {
@@ -104,7 +105,7 @@ public LeaseDuration getLeaseDuration() {
* @param etag
* The ETag value to set, as a string.
*/
- public void setEtag(final String etag) {
+ protected void setEtag(final String etag) {
this.etag = etag;
}
@@ -114,37 +115,37 @@ public void setEtag(final String etag) {
* @param lastModified
* The last modified time to set, as a
+ * The public access setting indicates whether the container and its blobs can be read via an anonymous request.
+ *
+ * The {@link BlobContainerPublicAccessType} enumeration provides three levels of anonymous read access:
+ *
- * The ETag value is a unique identifier that is updated when a write operation is performed against the container.
- * It may be used to perform operations conditionally, providing concurrency control and improved efficiency.
- *
- * The {@link AccessCondition#ifMatch} and {@link AccessCondition#ifNoneMatch} methods take an ETag value and return
- * an {@link AccessCondition} object that may be specified on the request.
*/
private String etag;
@@ -90,7 +80,7 @@ public final class BlobProperties {
/**
* Represents the blob's lease status.
*/
- private LeaseStatus leaseStatus = com.microsoft.windowsazure.storage.LeaseStatus.UNLOCKED;
+ private LeaseStatus leaseStatus = LeaseStatus.UNLOCKED;
/**
* Represents the blob's lease state.
@@ -146,7 +136,7 @@ public BlobProperties(final BlobType type) {
}
/**
- * Returns the blob type for the blob.
+ * Gets the blob type for the blob.
*
* @return A {@link BlobType} value that represents the blob type.
*/
@@ -155,7 +145,7 @@ public BlobType getBlobType() {
}
/**
- * Returns the cache control value for the blob.
+ * Gets the cache control value for the blob.
*
* @return A string that represents the cache control value for the blob.
*/
@@ -212,7 +202,7 @@ public String getContentType() {
}
/**
- * Returns the blob's copy state.
+ * Gets the blob's copy state.
*
* @return A {@link CopyState} object that represents the copy state of the blob.
*/
@@ -222,6 +212,12 @@ public CopyState getCopyState() {
/**
* Gets the ETag value for the blob.
+ *
+ * The ETag value is a unique identifier that is updated when a write operation is performed against the container.
+ * It may be used to perform operations conditionally, providing concurrency control and improved efficiency.
+ *
+ * The {@link AccessCondition#ifMatch} and {@link AccessCondition#ifNoneMatch} methods take an ETag value and return
+ * an {@link AccessCondition} object that may be specified on the request.
*
* @return A string containing the ETag value.
*/
@@ -239,7 +235,7 @@ public Date getLastModified() {
}
/**
- * Gets the lease status for the blob. Reserved for internal use.
+ * Gets the lease status for the blob.
*
* @return A
- * If a blob size is above the threshold, it will be uploaded as blocks.
+ * inclusive. If a blob size is above the threshold, it will be uploaded as blocks.
*/
public Integer getSingleBlobPutThresholdInBytes() {
return this.singleBlobPutThresholdInBytes;
}
/**
+ * Sets the concurrent number of simultaneous requests per operation.
+ *
+ * The default concurrent request count is set in the client and is by default 1, indicating no concurrency. You can
+ * change the concurrent request count on this request by setting this property. You can also change the value on
+ * the {@link BlobServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via the
+ * service client will use that concurrent request count.
+ *
* @param concurrentRequestCount
* the concurrentRequestCount to set
*/
@@ -198,6 +248,14 @@ public void setConcurrentRequestCount(final Integer concurrentRequestCount) {
}
/**
+ * Sets whether a range PUT or GET operation will use the Content-MD5 header to enforce transactional security.
+ * All partial blob uploads or downloads will be restricted to 4 MB.
+ *
+ * The default useTransactionalContentMD5 value is set in the client and is by default
+ * The default storeBlobContentMD5 value is set in the client and is by default
+ * The default disableContentMD5Validation value is set in the client and is by default
+ * The default threshold size is set in the client and is by default 32MB. You can change the threshold size on this
+ * request by setting this property. You can also change the value on the
+ * {@link BlobServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via the service
+ * client will use that threshold size.
*
* @param singleBlobPutThresholdInBytes
* The maximum size, in bytes, of a blob that may be uploaded as a single blob, ranging from 1 MB to 64
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobResponse.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobResponse.java
similarity index 54%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobResponse.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobResponse.java
index 41ddc0a06114b..a3a20d8626783 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobResponse.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobResponse.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage.blob;
+package com.microsoft.azure.storage.blob;
import java.net.HttpURLConnection;
import java.net.URI;
@@ -21,16 +21,29 @@
import java.util.Calendar;
import java.util.Date;
-import com.microsoft.windowsazure.storage.Constants;
-import com.microsoft.windowsazure.storage.StorageUri;
-import com.microsoft.windowsazure.storage.core.BaseResponse;
-import com.microsoft.windowsazure.storage.core.Utility;
+import com.microsoft.azure.storage.Constants;
+import com.microsoft.azure.storage.StorageException;
+import com.microsoft.azure.storage.StorageUri;
+import com.microsoft.azure.storage.core.BaseResponse;
+import com.microsoft.azure.storage.core.PathUtility;
+import com.microsoft.azure.storage.core.Utility;
/**
- * RESERVED FOR INTERNAL USE. A class for parsing various responses from the blob service
+ * RESERVED FOR INTERNAL USE. A class used to parse the response from blob and container operations.
*/
final class BlobResponse extends BaseResponse {
+ /**
+ * Gets the ACL for the container from the response.
+ *
+ * @param request
+ * the request object for this operation
+ * @return the ACL value indicating the public access level for the container
+ */
+ public static String getAcl(final HttpURLConnection request) {
+ return request.getHeaderField(BlobConstants.BLOB_PUBLIC_ACCESS_HEADER);
+ }
+
/**
* Gets the BlobAttributes from the given request
*
@@ -44,7 +57,7 @@ final class BlobResponse extends BaseResponse {
* @throws ParseException
* @throws URISyntaxException
*/
- public static BlobAttributes getAttributes(final HttpURLConnection request, final StorageUri resourceURI,
+ public static BlobAttributes getBlobAttributes(final HttpURLConnection request, final StorageUri resourceURI,
final String snapshotID) throws URISyntaxException, ParseException {
final String blobType = request.getHeaderField(BlobConstants.BLOB_TYPE_HEADER);
@@ -64,9 +77,9 @@ public static BlobAttributes getAttributes(final HttpURLConnection request, fina
lastModifiedCalendar.setTime(new Date(request.getLastModified()));
properties.setLastModified(lastModifiedCalendar.getTime());
- properties.setLeaseStatus(BaseResponse.getLeaseStatus(request));
- properties.setLeaseState(BaseResponse.getLeaseState(request));
- properties.setLeaseDuration(BaseResponse.getLeaseDuration(request));
+ properties.setLeaseStatus(getLeaseStatus(request));
+ properties.setLeaseState(getLeaseState(request));
+ properties.setLeaseDuration(getLeaseDuration(request));
final String rangeHeader = request.getHeaderField(Constants.HeaderConstants.CONTENT_RANGE);
final String xContentLengthHeader = request.getHeaderField(BlobConstants.CONTENT_LENGTH_HEADER);
@@ -96,6 +109,42 @@ else if (!Utility.isNullOrEmpty(xContentLengthHeader)) {
return attributes;
}
+ /**
+ * Gets the BlobContainerAttributes from the given request.
+ *
+ * @param request
+ * the request to get attributes from.
+ * @param usePathStyleUris
+ * a value indicating if the account is using pathSytleUris.
+ * @return the BlobContainerAttributes from the given request.
+ * @throws StorageException
+ */
+ public static BlobContainerAttributes getBlobContainerAttributes(final HttpURLConnection request,
+ final boolean usePathStyleUris) throws StorageException {
+ final BlobContainerAttributes containerAttributes = new BlobContainerAttributes();
+ URI tempURI;
+ try {
+ tempURI = PathUtility.stripSingleURIQueryAndFragment(request.getURL().toURI());
+ }
+ catch (final URISyntaxException e) {
+ final StorageException wrappedUnexpectedException = Utility.generateNewUnexpectedStorageException(e);
+ throw wrappedUnexpectedException;
+ }
+
+ containerAttributes.setName(PathUtility.getContainerNameFromUri(tempURI, usePathStyleUris));
+
+ final BlobContainerProperties containerProperties = containerAttributes.getProperties();
+ containerProperties.setEtag(BaseResponse.getEtag(request));
+ containerProperties.setLastModified(new Date(request.getLastModified()));
+ containerAttributes.setMetadata(getMetadata(request));
+
+ containerProperties.setLeaseStatus(getLeaseStatus(request));
+ containerProperties.setLeaseState(getLeaseState(request));
+ containerProperties.setLeaseDuration(getLeaseDuration(request));
+
+ return containerAttributes;
+ }
+
/**
* Gets the copyState
*
@@ -138,6 +187,76 @@ public static CopyState getCopyState(final HttpURLConnection request) throws URI
}
}
+ /**
+ * Gets the LeaseDuration
+ *
+ * @param request
+ * The response from server.
+ * @return The LeaseDuration.
+ */
+ public static LeaseDuration getLeaseDuration(final HttpURLConnection request) {
+ final String leaseDuration = request.getHeaderField(Constants.HeaderConstants.LEASE_DURATION);
+ if (!Utility.isNullOrEmpty(leaseDuration)) {
+ return LeaseDuration.parse(leaseDuration);
+ }
+
+ return LeaseDuration.UNSPECIFIED;
+ }
+
+ /**
+ * Gets the lease id from the request header.
+ *
+ * @param request
+ * The response from server.
+ * @return the lease id from the request header.
+ */
+ public static String getLeaseID(final HttpURLConnection request) {
+ return request.getHeaderField(Constants.HeaderConstants.LEASE_ID_HEADER);
+ }
+
+ /**
+ * Gets the LeaseState
+ *
+ * @param request
+ * The response from server.
+ * @return The LeaseState.
+ */
+ public static LeaseState getLeaseState(final HttpURLConnection request) {
+ final String leaseState = request.getHeaderField(Constants.HeaderConstants.LEASE_STATE);
+ if (!Utility.isNullOrEmpty(leaseState)) {
+ return LeaseState.parse(leaseState);
+ }
+
+ return LeaseState.UNSPECIFIED;
+ }
+
+ /**
+ * Gets the LeaseStatus
+ *
+ * @param request
+ * The response from server.
+ * @return The Etag.
+ */
+ public static LeaseStatus getLeaseStatus(final HttpURLConnection request) {
+ final String leaseStatus = request.getHeaderField(Constants.HeaderConstants.LEASE_STATUS);
+ if (!Utility.isNullOrEmpty(leaseStatus)) {
+ return LeaseStatus.parse(leaseStatus);
+ }
+
+ return LeaseStatus.UNSPECIFIED;
+ }
+
+ /**
+ * Gets the lease Time from the request header.
+ *
+ * @param request
+ * The response from server.
+ * @return the lease Time from the request header.
+ */
+ public static String getLeaseTime(final HttpURLConnection request) {
+ return request.getHeaderField(Constants.HeaderConstants.LEASE_TIME_HEADER);
+ }
+
/**
* Gets the snapshot ID from the request header.
*
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobType.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobType.java
similarity index 90%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobType.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobType.java
index 39d64fa08a357..254289efa5ecd 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobType.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobType.java
@@ -12,11 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage.blob;
+package com.microsoft.azure.storage.blob;
import java.util.Locale;
-import com.microsoft.windowsazure.storage.core.Utility;
+import com.microsoft.azure.storage.core.Utility;
/**
* Specifies the type of a blob.
@@ -45,7 +45,7 @@ public enum BlobType {
*
* @return A
- * This method populates the blob's system properties and user-defined metadata. Before reading a blob's properties
- * or metadata, call this method or its overload to retrieve the latest values for the blob's properties and
- * metadata from the Windows Azure storage service.
+ * This method populates the blob's system properties and user-defined metadata. Before reading or modifying a
+ * blob's properties or metadata, call this method or its overload to retrieve the latest values for the blob's
+ * properties and metadata from the Microsoft Azure storage service.
*
* @throws StorageException
* If a storage service error occurred.
@@ -1249,9 +1233,9 @@ public final void downloadAttributes() throws StorageException {
/**
* Populates a blob's properties and metadata using the specified request options and operation context.
*
- * This method populates the blob's system properties and user-defined metadata. Before reading a blob's properties
- * or metadata, call this method or its overload to retrieve the latest values for the blob's properties and
- * metadata from the Windows Azure storage service.
+ * This method populates the blob's system properties and user-defined metadata. Before reading or modifying a
+ * blob's properties or metadata, call this method or its overload to retrieve the latest values for the blob's
+ * properties and metadata from the Microsoft Azure storage service.
*
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
@@ -1281,7 +1265,7 @@ public final void downloadAttributes(final AccessCondition accessCondition, Blob
}
private StorageRequest
+ * Use {@link CloudBlob#downloadAttributes} to retrieve the latest values for the blob's properties and metadata
+ * from the Microsoft Azure storage service.
*
* @throws StorageException
* If a storage service error occurred.
@@ -2862,6 +2835,9 @@ public final void uploadMetadata() throws StorageException {
/**
* Uploads the blob's metadata to the storage service using the specified lease ID, request options, and operation
* context.
+ *
+ * Use {@link CloudBlob#downloadAttributes} to retrieve the latest values for the blob's properties and metadata
+ * from the Microsoft Azure storage service.
*
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
@@ -2894,15 +2870,15 @@ public final void uploadMetadata(final AccessCondition accessCondition, BlobRequ
}
private StorageRequest
+ * Use {@link CloudBlob#downloadAttributes} to retrieve the latest values for the blob's properties and metadata
+ * from the Microsoft Azure storage service.
*
* @throws StorageException
* If a storage service error occurred.
@@ -2945,6 +2924,9 @@ public final void uploadProperties() throws StorageException {
/**
* Updates the blob's properties using the specified lease ID, request options, and operation context.
+ *
+ * Use {@link CloudBlob#downloadAttributes} to retrieve the latest values for the blob's properties and metadata
+ * from the Microsoft Azure storage service.
*
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
@@ -2977,15 +2959,16 @@ public final void uploadProperties(final AccessCondition accessCondition, BlobRe
}
private StorageRequest
* If a blob size is above the threshold, it will be uploaded as blocks.
+ *
+ * @deprecated use {@link #getDefaultRequestOptions().getSingleBlobPutThresholdInBytes()} instead.
*/
+ @Deprecated
public int getSingleBlobPutThresholdInBytes() {
- return this.singleBlobPutThresholdInBytes;
+ return this.getDefaultRequestOptions().getSingleBlobPutThresholdInBytes();
}
/**
@@ -159,10 +181,9 @@ public int getSingleBlobPutThresholdInBytes() {
* @return An enumerable collection of {@link CloudBlobContainer} objects retrieved lazily that represent the
* containers for this
* client.
- * @throws StorageException
*/
@DoesServiceRequest
- public Iterable
* Containers hold directories, which are encapsulated as {@link CloudBlobDirectory} objects, and directories hold block
* blobs and page blobs. Directories can also contain sub-directories.
@@ -127,6 +128,38 @@ private CloudBlobContainer(final CloudBlobClient client) {
this.blobServiceClient = client;
}
+ /**
+ * Creates an instance of the String
that represents the connection string to parse.
@@ -361,19 +393,16 @@ public static CloudStorageAccount parse(final String connectionString) throws UR
private static CloudStorageAccount tryConfigureDevStore(final HashMapCloudStorageAccount
class using the specified account credentials.
* Credentials
class, using the specified storage account name and access
* key; the specified access key is in the form of a byte array.
@@ -65,7 +60,6 @@ public Credentials(final String accountName, final byte[] key) {
this.accountName = accountName;
this.key = new StorageKey(key);
- this.signingAccountName = accountName;
}
/**
@@ -109,14 +103,6 @@ public String getAccountName() {
return this.accountName;
}
- /**
- * Returns the account name whose key is used to sign requests.
- * Internal use only.
- */
- public String getSigningAccountName() {
- return this.signingAccountName;
- }
-
/**
* Returns the name of the access key to be used when signing the request.
* Internal use only.
@@ -144,16 +130,6 @@ protected void setAccountName(final String accountName) {
this.accountName = accountName;
}
- /**
- * Sets the account name whose key is used to sign requests.
- *
- * @param signingAccountName
- * A String
that represents the account name whose key is used to sign requests.
- */
- protected void setSigningAccountName(final String signingAccountName) {
- this.signingAccountName = signingAccountName;
- }
-
/**
* Sets the name of the access key to be used when signing the request.
*
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/DoesServiceRequest.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/DoesServiceRequest.java
similarity index 95%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/DoesServiceRequest.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/DoesServiceRequest.java
index 1dfdfa2ed1edc..776b73534dbca 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/DoesServiceRequest.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/DoesServiceRequest.java
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/GeoReplicationStats.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/GeoReplicationStats.java
new file mode 100644
index 0000000000000..2e5f7a5b18a91
--- /dev/null
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/GeoReplicationStats.java
@@ -0,0 +1,79 @@
+/**
+ * Copyright Microsoft Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.microsoft.azure.storage;
+
+import java.util.Date;
+
+/**
+ * Class representing the geo-replication stats.
+ */
+public class GeoReplicationStats {
+
+ /**
+ * Specifies the geo replication status
+ */
+ private GeoReplicationStatus status;
+
+ /**
+ * Specifies the last sync time
+ */
+ private Date lastSyncTime;
+
+ /**
+ * Default constructor
+ */
+ GeoReplicationStats() {
+ // no op
+ }
+
+ /**
+ * Gets the last sync time. All primary writes preceding this value are guaranteed to be available for read
+ * operations. Primary writes following this point in time may or may not be available for reads.
+ *
+ * @return the lastSyncTime.
+ */
+ public Date getLastSyncTime() {
+ return lastSyncTime;
+ }
+
+ /**
+ * Gets the {@link GeoReplicationStatus} status.
+ *
+ * @return the status
+ */
+ public GeoReplicationStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * Sets the last sync time.
+ *
+ * @param lastSyncTime
+ * the lastSyncTime to set
+ */
+ void setLastSyncTime(Date lastSyncTime) {
+ this.lastSyncTime = lastSyncTime;
+ }
+
+ /**
+ * Sets the geo-replication status.
+ *
+ * @param status
+ * the status to set
+ */
+ void setStatus(GeoReplicationStatus status) {
+ this.status = status;
+ }
+}
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/GeoReplicationStats.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/GeoReplicationStatus.java
similarity index 56%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/GeoReplicationStats.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/GeoReplicationStatus.java
index 1843c6270a923..4639d14db3878 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/GeoReplicationStats.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/GeoReplicationStatus.java
@@ -12,17 +12,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
-import java.util.Date;
-
-import com.microsoft.windowsazure.storage.core.SR;
-import com.microsoft.windowsazure.storage.core.Utility;
+import com.microsoft.azure.storage.core.SR;
+import com.microsoft.azure.storage.core.Utility;
/**
- * Class representing the geo-replication stats.
+ * Enumeration representing the state of geo-replication in a service.
*/
-public class GeoReplicationStats {
+public enum GeoReplicationStatus {
+
+ /**
+ * Status of geo-replication is unavailable.
+ */
+ UNAVAILABLE,
+
+ /**
+ * Geo-replication is live.
+ */
+ LIVE,
+
+ /**
+ * Data is being bootstrapped from primary to secondary.
+ */
+ BOOTSTRAP;
/**
* Gets a {@link GeoReplicationStatus} from a string.
@@ -32,7 +45,7 @@ public class GeoReplicationStats {
* @return
* A {@link GeoReplicationStatus} enumeration.
*/
- public static GeoReplicationStatus getGeoReplicationStatus(String geoReplicationStatus) {
+ protected static GeoReplicationStatus parse(String geoReplicationStatus) {
if (geoReplicationStatus != null) {
if (geoReplicationStatus.equals(Constants.GEO_UNAVAILABLE_VALUE)) {
return GeoReplicationStatus.UNAVAILABLE;
@@ -47,43 +60,4 @@ else if (geoReplicationStatus.equals(Constants.GEO_BOOTSTRAP_VALUE)) {
throw new IllegalArgumentException(String.format(Utility.LOCALE_US, SR.INVALID_GEO_REPLICATION_STATUS,
geoReplicationStatus));
}
-
- private GeoReplicationStatus status;
-
- private Date lastSyncTime;
-
- GeoReplicationStats() {
-
- }
-
- /**
- * @return the lastSyncTime. All primary writes preceding this value are guaranteed to be available for read
- * operations. Primary writes following this point in time may or may not be available for reads.
- */
- public Date getLastSyncTime() {
- return lastSyncTime;
- }
-
- /**
- * @return the status
- */
- public GeoReplicationStatus getStatus() {
- return status;
- }
-
- /**
- * @param lastSyncTime
- * the lastSyncTime to set
- */
- void setLastSyncTime(Date lastSyncTime) {
- this.lastSyncTime = lastSyncTime;
- }
-
- /**
- * @param status
- * the status to set
- */
- void setStatus(GeoReplicationStatus status) {
- this.status = status;
- }
}
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/LocationMode.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/LocationMode.java
similarity index 96%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/LocationMode.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/LocationMode.java
index 9e0539868a74a..2f393d37f2ae1 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/LocationMode.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/LocationMode.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
/**
* Specifies the location mode used to decide which location the request should be sent to.
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/LoggingOperations.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/LoggingOperations.java
similarity index 95%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/LoggingOperations.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/LoggingOperations.java
index e8e09aacce669..bcd1a830b994f 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/LoggingOperations.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/LoggingOperations.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
/**
*
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/LoggingProperties.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/LoggingProperties.java
similarity index 98%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/LoggingProperties.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/LoggingProperties.java
index 00576bbafcb98..75511423a5580 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/LoggingProperties.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/LoggingProperties.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
import java.util.EnumSet;
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/MetricsLevel.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/MetricsLevel.java
similarity index 95%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/MetricsLevel.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/MetricsLevel.java
index 6933b1b1e9ed9..cf1a3b9ad025b 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/MetricsLevel.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/MetricsLevel.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
/**
* Enumeration representing the state of metrics collection in a service.
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/MetricsProperties.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/MetricsProperties.java
similarity index 93%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/MetricsProperties.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/MetricsProperties.java
index 8ca986c55c48d..23872ec49fdda 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/MetricsProperties.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/MetricsProperties.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
/**
* Represents the metrics properties for the analytics service.
@@ -26,7 +26,7 @@ public final class MetricsProperties {
/**
* A {@link MetricsLevel} level used to enable Metric and API logging
*/
- private MetricsLevel metricsLevel = com.microsoft.windowsazure.storage.MetricsLevel.DISABLED;
+ private MetricsLevel metricsLevel = com.microsoft.azure.storage.MetricsLevel.DISABLED;
/**
* The Retention policy for the Metrics data.
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/OperationContext.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/OperationContext.java
similarity index 85%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/OperationContext.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/OperationContext.java
index 3372259b568bd..b0164ed6f0961 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/OperationContext.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/OperationContext.java
@@ -12,9 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
-import java.net.HttpURLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
@@ -146,11 +145,6 @@ public final class OperationContext {
*/
private StorageEventMultiCasterOperationContext
class.
*/
@@ -160,6 +154,8 @@ public OperationContext() {
}
/**
+ * Get the client side trace ID.
+ *
* @return the clientRequestID
*/
public String getClientRequestID() {
@@ -167,23 +163,15 @@ public String getClientRequestID() {
}
/**
+ * Gets the operation latency, in milliseconds, from the client's perspective. This may include any potential
+ * retries.
+ *
* @return the clientTimeInMs
*/
public long getClientTimeInMs() {
return this.clientTimeInMs;
}
- /**
- * Reserved for internal use.
- *
- * @return the currentRequestObject
- * @deprecated Deprecated as of 0.6.0.
- */
- @Deprecated
- public HttpURLConnection getCurrentRequestObject() {
- return this.currentRequestObject;
- }
-
/**
* Returns the last request result encountered for the operation.
*
@@ -213,6 +201,8 @@ public org.slf4j.Logger getLogger() {
}
/**
+ * Gets any additional headers for the request, for example, for proxy or logging information.
+ *
* @return the userHeaders
*/
public HashMapBaseEvent
class that is fired when a request is completed.
+ *
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param connectionObject
+ * Represents a connection object. Currently only java.net.HttpURLConnection
is supported as
+ * a connection object.
+ * @param requestResult
+ * A {@link RequestResult} object that represents the current request result.
+ */
public RequestCompletedEvent(OperationContext opContext, Object connectionObject, RequestResult requestResult) {
super(opContext, connectionObject, requestResult);
}
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RequestOptions.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/RequestOptions.java
similarity index 69%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RequestOptions.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/RequestOptions.java
index 35a832024aab4..67750c0a6ae3e 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RequestOptions.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/RequestOptions.java
@@ -15,11 +15,11 @@
/**
*
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
import java.util.Date;
-import com.microsoft.windowsazure.storage.core.Utility;
+import com.microsoft.azure.storage.core.Utility;
/**
* Represents the options to use while processing a given request.
@@ -80,41 +80,39 @@ public RequestOptions(final RequestOptions other) {
*
* @param options
* The input options to copy from when applying defaults
- * @param client
- * the service client to populate from
*/
- protected static final RequestOptions applyBaseDefaultsInternal(RequestOptions modifiedOptions,
- final ServiceClient client) {
- return applyBaseDefaultsInternal(modifiedOptions, client, true);
+ protected static final RequestOptions applyBaseDefaultsInternal(final RequestOptions modifiedOptions) {
+ Utility.assertNotNull("modifiedOptions", modifiedOptions);
+ if (modifiedOptions.getRetryPolicyFactory() == null) {
+ modifiedOptions.setRetryPolicyFactory(new RetryExponentialRetry());
+ }
+
+ if (modifiedOptions.getLocationMode() == null) {
+ modifiedOptions.setLocationMode(LocationMode.PRIMARY_ONLY);
+ }
+
+ return modifiedOptions;
}
/**
- * Populates the default timeout, retry policy, and location mode from client if they are null.
- *
- * @param options
- * The input options to copy from when applying defaults
- * @param client
- * the service client to populate from
- * @param setStartTime
- * whether to initialize the startTimeInMs field, or not
+ * Populates any null fields in the first requestOptions object with values from the second requestOptions object.
*/
- protected static final RequestOptions applyBaseDefaultsInternal(RequestOptions modifiedOptions,
- final ServiceClient client, final boolean setStartTime) {
- Utility.assertNotNull("modifiedOptions", modifiedOptions);
+ protected static final RequestOptions populateRequestOptions(RequestOptions modifiedOptions,
+ final RequestOptions clientOptions, final boolean setStartTime) {
if (modifiedOptions.getRetryPolicyFactory() == null) {
- modifiedOptions.setRetryPolicyFactory(client.getRetryPolicyFactory());
+ modifiedOptions.setRetryPolicyFactory(clientOptions.getRetryPolicyFactory());
}
- if (modifiedOptions.getTimeoutIntervalInMs() == null) {
- modifiedOptions.setTimeoutIntervalInMs(client.getTimeoutInMs());
+ if (modifiedOptions.getLocationMode() == null) {
+ modifiedOptions.setLocationMode(clientOptions.getLocationMode());
}
- if (modifiedOptions.getLocationMode() == null) {
- modifiedOptions.setLocationMode(client.getLocationMode());
+ if (modifiedOptions.getTimeoutIntervalInMs() == null) {
+ modifiedOptions.setTimeoutIntervalInMs(clientOptions.getTimeoutIntervalInMs());
}
if (modifiedOptions.getMaximumExecutionTimeInMs() == null) {
- modifiedOptions.setMaximumExecutionTimeInMs(client.getMaximumExecutionTimeInMs());
+ modifiedOptions.setMaximumExecutionTimeInMs(clientOptions.getMaximumExecutionTimeInMs());
}
if (modifiedOptions.getMaximumExecutionTimeInMs() != null
@@ -127,7 +125,8 @@ protected static final RequestOptions applyBaseDefaultsInternal(RequestOptions m
}
/**
- * Returns the retry policy to use for this request.
+ * Gets the retry policy to use for this request. For more information about the retry policy defaults, see
+ * {@link #setRetryPolicyFactory(RetryPolicyFactory)}.
*
* @return An {@link RetryPolicyFactory} object that represents the current retry policy.
*
@@ -141,7 +140,7 @@ public final RetryPolicyFactory getRetryPolicyFactory() {
}
/**
- * Returns the timeout value for this request. For more information about the timeout, see
+ * Returns the timeout value for this request. For more information about the timeout defaults, see
* {@link #setTimeoutIntervalInMs(Integer)}.
*
* @return The current timeout value, in milliseconds, for this request.
@@ -151,7 +150,8 @@ public final Integer getTimeoutIntervalInMs() {
}
/**
- * Gets the default location mode for this request.
+ * Gets the default location mode for this request. For more information about location mode, see
+ * {@link #setLocationMode(LocationMode)}.
*
* @return A {@link LocationMode} object that represents the location mode for this request.
*/
@@ -160,7 +160,7 @@ public final LocationMode getLocationMode() {
}
/**
- * Returns the maximum execution time for this request. For more information about maximum execution time, see
+ * Gets the maximum execution time for this request. For more information about maximum execution time defaults, see
* {@link #setMaximumExecutionTimeInMs(Integer)}.
*
* @return The current maximum execution time, in milliseconds, for this request.
@@ -170,6 +170,8 @@ public Integer getMaximumExecutionTimeInMs() {
}
/**
+ * RESERVED FOR INTERNAL USE.
+ *
* Returns the time at which this operation expires. This is computed by adding the time the operation begins and
* the maximum execution time and will be null if maximum execution time is null. For more information about maximum
* execution time, see {@link #setMaximumExecutionTimeInMs(Integer)}.
@@ -182,6 +184,11 @@ public Long getOperationExpiryTimeInMs() {
/**
* Sets the RetryPolicyFactory object to use for this request.
+ * BaseEvent
class that is fired when a response is received.
+ *
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param connectionObject
+ * Represents a connection object. Currently only java.net.HttpURLConnection
is supported as
+ * a connection object.
+ * @param requestResult
+ * A {@link RequestResult} object that represents the current request result.
+ */
public ResponseReceivedEvent(OperationContext opContext, Object connectionObject, RequestResult requestResult) {
super(opContext, connectionObject, requestResult);
}
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ResultContinuation.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/ResultContinuation.java
similarity index 76%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ResultContinuation.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/ResultContinuation.java
index 630e6e3ee60e2..6a38a9d2007a3 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ResultContinuation.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/ResultContinuation.java
@@ -12,9 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
-import com.microsoft.windowsazure.storage.blob.CloudBlobDirectory;
+import com.microsoft.azure.storage.blob.CloudBlobDirectory;
/**
* Represents a continuation token for listing operations. Continuation tokens are used in methods that return a
@@ -27,27 +27,27 @@ public final class ResultContinuation {
private String nextMarker;
/**
- * Gets or sets the NextPartitionKey for TableServiceEntity enumeration operations.
+ * Represents the next partition key for TableServiceEntity enumeration operations.
*/
private String nextPartitionKey;
/**
- * Gets or sets the NextRowKey for TableServiceEntity enumeration operations.
+ * Represents the next row key for TableServiceEntity enumeration operations.
*/
private String nextRowKey;
/**
- * Gets or sets the NextTableName for Table enumeration operations.
+ * Represents the next table name for Table enumeration operations.
*/
private String nextTableName;
/**
- * Gets or sets the type of the continuation token.
+ * Represents the type of the continuation token.
*/
private ResultContinuationType continuationType;
/**
- * Gets the location that the token applies to.
+ * Represents the location that the token applies to.
*/
private StorageLocation targetLocation;
@@ -59,6 +59,8 @@ public ResultContinuation() {
}
/**
+ * Gets the type of the continuation token.
+ *
* @return the continuationType
*/
public ResultContinuationType getContinuationType() {
@@ -66,6 +68,8 @@ public ResultContinuationType getContinuationType() {
}
/**
+ * Gets the next marker for continuing results of listing operations.
+ *
* @return the nextMarker
*/
public String getNextMarker() {
@@ -73,6 +77,8 @@ public String getNextMarker() {
}
/**
+ * Gets the next partition key for TableServiceEntity enumeration operations.
+ *
* @return the nextPartitionKey
*/
public String getNextPartitionKey() {
@@ -80,6 +86,8 @@ public String getNextPartitionKey() {
}
/**
+ * Gets the next row key for TableServiceEntity enumeration operations.
+ *
* @return the nextRowKey
*/
public String getNextRowKey() {
@@ -87,6 +95,8 @@ public String getNextRowKey() {
}
/**
+ * Gets the next table name for Table enumeration operations.
+ *
* @return the nextTableName
*/
public String getNextTableName() {
@@ -94,6 +104,8 @@ public String getNextTableName() {
}
/**
+ * Gets the location that the token applies to.
+ *
* @return the targetLocation
*/
public StorageLocation getTargetLocation() {
@@ -111,6 +123,8 @@ public boolean hasContinuation() {
}
/**
+ * Sets the type of the continuation token.
+ *
* @param continuationType
* the continuationType to set
*/
@@ -119,6 +133,8 @@ public void setContinuationType(final ResultContinuationType continuationType) {
}
/**
+ * Sets the next marker for continuing results of listing operations.
+ *
* @param nextMarker
* the nextMarker to set
*/
@@ -127,6 +143,8 @@ public void setNextMarker(final String nextMarker) {
}
/**
+ * Sets the next partition key for TableServiceEntity enumeration operations.
+ *
* @param nextPartitionKey
* the nextPartitionKey to set
*/
@@ -135,6 +153,8 @@ public void setNextPartitionKey(final String nextPartitionKey) {
}
/**
+ * Sets the next row key for TableServiceEntity enumeration operations.
+ *
* @param nextRowKey
* the nextRowKey to set
*/
@@ -143,6 +163,8 @@ public void setNextRowKey(final String nextRowKey) {
}
/**
+ * Sets the next table name for Table enumeration operations.
+ *
* @param nextTableName
* the nextTableName to set
*/
@@ -151,6 +173,8 @@ public void setNextTableName(final String nextTableName) {
}
/**
+ * Sets the location that the token applies to.
+ *
* @param targetLocation
* the targetLocation to set
*/
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ResultContinuationType.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/ResultContinuationType.java
similarity index 96%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ResultContinuationType.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/ResultContinuationType.java
index 8f51f1bb31f81..0304caa4be9c1 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ResultContinuationType.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/ResultContinuationType.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
/**
* Specifies the type of a continuation token.
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ResultSegment.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/ResultSegment.java
similarity index 98%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ResultSegment.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/ResultSegment.java
index 8cbd59ba7fd81..f652c2adab47b 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ResultSegment.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/ResultSegment.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
import java.util.ArrayList;
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryContext.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryContext.java
similarity index 84%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryContext.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/RetryContext.java
index 9677c9efb572a..9a39951d2c7e6 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryContext.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryContext.java
@@ -12,9 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
-import com.microsoft.windowsazure.storage.core.Utility;
+import com.microsoft.azure.storage.core.Utility;
/**
* Represents the context for a retry of a request made against the storage services.
@@ -31,14 +31,14 @@ public final class RetryContext {
private final LocationMode locationMode;
/**
- * Gets the number of retries for the given operation.
+ * The number of retries for the given operation.
*/
- public final int currentRetryCount;
+ private final int currentRetryCount;
/**
- * Gets the last request's results.
+ * The last request's results.
*/
- public final RequestResult lastRequestResult;
+ private final RequestResult lastRequestResult;
public RetryContext(int currentRetryCount, RequestResult lastRequestResult, StorageLocation nextLocation,
LocationMode locationMode) {
@@ -49,6 +49,8 @@ public RetryContext(int currentRetryCount, RequestResult lastRequestResult, Stor
}
/**
+ * Gets the number of retries for the given operation.
+ *
* @return the currentRetryCount
*/
public int getCurrentRetryCount() {
@@ -56,6 +58,8 @@ public int getCurrentRetryCount() {
}
/**
+ * Gets the last request's results.
+ *
* @return the lastRequestResult
*/
public RequestResult getLastRequestResult() {
@@ -63,6 +67,8 @@ public RequestResult getLastRequestResult() {
}
/**
+ * Gets the location mode for subsequent retries.
+ *
* @return the locationMode
*/
public LocationMode getLocationMode() {
@@ -70,6 +76,8 @@ public LocationMode getLocationMode() {
}
/**
+ * Gets the location that the next retry should target.
+ *
* @return the nextLocation
*/
public StorageLocation getNextLocation() {
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryExponentialRetry.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryExponentialRetry.java
similarity index 96%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryExponentialRetry.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/RetryExponentialRetry.java
index f0949a0501fe5..bc6569f2c1849 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryExponentialRetry.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryExponentialRetry.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
import java.net.HttpURLConnection;
import java.util.Random;
@@ -21,8 +21,8 @@
* Represents a retry policy that performs a specified number of retries, using a randomized exponential backoff scheme
* to determine the interval between retries.
*
- * This class extends the {@link com.microsoft.windowsazure.storage.RetryPolicy} class and implements the
- * {@link com.microsoft.windowsazure.storage.RetryPolicyFactory} interface.
+ * This class extends the {@link com.microsoft.azure.storage.RetryPolicy} class and implements the
+ * {@link com.microsoft.azure.storage.RetryPolicyFactory} interface.
*/
public final class RetryExponentialRetry extends RetryPolicy implements RetryPolicyFactory {
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryInfo.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryInfo.java
similarity index 83%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryInfo.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/RetryInfo.java
index b93473056b5ac..447f44ad226d0 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryInfo.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryInfo.java
@@ -12,9 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
-import com.microsoft.windowsazure.storage.core.Utility;
+import com.microsoft.azure.storage.core.Utility;
/**
* Represents the context for a retry of a request made against the storage services.
@@ -22,17 +22,17 @@
public class RetryInfo {
/**
- * Gets the location that the next retry should target.
+ * The location that the next retry should target.
*/
private StorageLocation targetLocation;
/**
- * Gets or sets the location mode for subsequent retries.
+ * The location mode for subsequent retries.
*/
private LocationMode updatedLocationMode;
/**
- * Gets the interval in ms until the next retry. The minimum back-off interval is 3 seconds.
+ * The interval in ms until the next retry. The minimum back-off interval is 3 seconds.
*/
private int retryInterval = 3000;
@@ -57,6 +57,8 @@ public RetryInfo(RetryContext retryContext) {
}
/**
+ * Gets the interval in ms until the next retry. The minimum back-off interval is 3 seconds.
+ *
* @return the retryInterval
*/
public int getRetryInterval() {
@@ -64,6 +66,8 @@ public int getRetryInterval() {
}
/**
+ * Gets the location that the next retry should target.
+ *
* @return the targetLocation
*/
public final StorageLocation getTargetLocation() {
@@ -71,6 +75,8 @@ public final StorageLocation getTargetLocation() {
}
/**
+ * Gets the location mode for subsequent retries.
+ *
* @return the updatedLocationMode
*/
public LocationMode getUpdatedLocationMode() {
@@ -78,6 +84,8 @@ public LocationMode getUpdatedLocationMode() {
}
/**
+ * Sets the interval in ms until the next retry. The minimum back-off interval is 3 seconds.
+ *
* @param retryInterval
* the retryInterval to set
*/
@@ -86,6 +94,8 @@ public void setRetryInterval(int retryInterval) {
}
/**
+ * Sets the location that the next retry should target.
+ *
* @param targetLocation
* the targetLocation to set
*/
@@ -94,6 +104,8 @@ public void setTargetLocation(StorageLocation targetLocation) {
}
/**
+ * Sets the location mode for subsequent retries.
+ *
* @param updatedLocationMode
* the updatedLocationMode to set
*/
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryLinearRetry.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryLinearRetry.java
similarity index 98%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryLinearRetry.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/RetryLinearRetry.java
index 3830494f2e1ed..3c32552306452 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryLinearRetry.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryLinearRetry.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
import java.net.HttpURLConnection;
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryNoRetry.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryNoRetry.java
similarity index 92%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryNoRetry.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/RetryNoRetry.java
index dbf313f095f41..de66bf8e6902b 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryNoRetry.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryNoRetry.java
@@ -12,13 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
/**
* Represents a retry policy that performs no retries.
*
- * This class extends the {@link com.microsoft.windowsazure.storage.RetryPolicy} class and implements the
- * {@link com.microsoft.windowsazure.storage.RetryPolicyFactory} interface.
+ * This class extends the {@link com.microsoft.azure.storage.RetryPolicy} class and implements the
+ * {@link com.microsoft.azure.storage.RetryPolicyFactory} interface.
*/
public final class RetryNoRetry extends RetryPolicy implements RetryPolicyFactory {
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryPolicy.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryPolicy.java
similarity index 98%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryPolicy.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/RetryPolicy.java
index 48000279bbeb4..80de93f3f101c 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryPolicy.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryPolicy.java
@@ -15,12 +15,12 @@
/**
*
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
import java.net.HttpURLConnection;
import java.util.Date;
-import com.microsoft.windowsazure.storage.core.Utility;
+import com.microsoft.azure.storage.core.Utility;
/**
* Abstract class that represents a retry policy.
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryPolicyFactory.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryPolicyFactory.java
similarity index 96%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryPolicyFactory.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/RetryPolicyFactory.java
index 2e1b1c4ac53af..16c22dce7f3d3 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryPolicyFactory.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryPolicyFactory.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
/**
* Represents a retry policy factory that creates a new {@link RetryPolicy} object per transaction.
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryingEvent.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryingEvent.java
similarity index 87%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryingEvent.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/RetryingEvent.java
index a2df7f7b08745..7c44673cd29b6 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/RetryingEvent.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/RetryingEvent.java
@@ -12,9 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
-
-import com.microsoft.windowsazure.storage.core.BaseEvent;
+package com.microsoft.azure.storage;
/**
* Represents an event that is fired when a request is retried.
@@ -28,7 +26,7 @@ public final class RetryingEvent extends BaseEvent {
private final RetryContext retryContext;
/**
- * Creates an instance of the BaseEvent
class.
+ * Creates an instance of the BaseEvent
class which is fired when a request is retried.
*
* @param opContext
* An {@link OperationContext} object that represents the context for the current operation. This object
@@ -49,6 +47,9 @@ public RetryingEvent(OperationContext opContext, Object connectionObject, Reques
}
/**
+ * Gets the context for a retry of a request made against the storage services. Includes current retry count,
+ * location mode, and next location.
+ *
* @return the retryCount
*/
public RetryContext getRetryContext() {
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/SendingRequestEvent.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/SendingRequestEvent.java
similarity index 52%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/SendingRequestEvent.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/SendingRequestEvent.java
index 5a0486d75b6db..083e26d8611dd 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/SendingRequestEvent.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/SendingRequestEvent.java
@@ -12,15 +12,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
-
-import com.microsoft.windowsazure.storage.core.BaseEvent;
+package com.microsoft.azure.storage;
/**
- * Represents an event that is fired when before sending a request.
+ * Represents an event that is fired when before sending a request. The connection object is not yet live.
*/
public final class SendingRequestEvent extends BaseEvent {
+ /**
+ * Creates an instance of the BaseEvent
class that is fired when before sending a request.
+ *
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param connectionObject
+ * Represents a connection object. Currently only java.net.HttpURLConnection
is supported as
+ * a connection object.
+ * @param requestResult
+ * A {@link RequestResult} object that represents the current request result.
+ */
public SendingRequestEvent(OperationContext opContext, Object connectionObject, RequestResult requestResult) {
super(opContext, connectionObject, requestResult);
}
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ServiceClient.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/ServiceClient.java
similarity index 79%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ServiceClient.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/ServiceClient.java
index a07e3cf3a1854..b36d1dc8f1006 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ServiceClient.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/ServiceClient.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -21,15 +21,15 @@
import javax.xml.stream.XMLStreamException;
-import com.microsoft.windowsazure.storage.core.BaseRequest;
-import com.microsoft.windowsazure.storage.core.RequestLocationMode;
-import com.microsoft.windowsazure.storage.core.SR;
-import com.microsoft.windowsazure.storage.core.StorageRequest;
-import com.microsoft.windowsazure.storage.core.StreamMd5AndLength;
-import com.microsoft.windowsazure.storage.core.Utility;
+import com.microsoft.azure.storage.core.BaseRequest;
+import com.microsoft.azure.storage.core.RequestLocationMode;
+import com.microsoft.azure.storage.core.SR;
+import com.microsoft.azure.storage.core.StorageRequest;
+import com.microsoft.azure.storage.core.StreamMd5AndLength;
+import com.microsoft.azure.storage.core.Utility;
/**
- * Reserved for internal use. Provides a client for accessing the Windows Azure Storage service.
+ * Reserved for internal use. Provides a client for accessing the Microsoft Azure Storage service.
*/
public abstract class ServiceClient {
@@ -38,11 +38,6 @@ public abstract class ServiceClient {
*/
private StorageUri storageUri;
- /**
- * Gets or sets the default location mode for requests made via the service client.
- */
- private LocationMode locationMode;
-
/**
* Holds the StorageCredentials associated with this Service Client.
*/
@@ -53,48 +48,11 @@ public abstract class ServiceClient {
*/
private boolean usePathStyleUris;
- /**
- * Holds the default retry policy for requests made via the service client to set.
- */
- protected RetryPolicyFactory retryPolicyFactory = new RetryExponentialRetry();
-
- /**
- * Holds the default server and client timeout for requests made by the service client.
- */
- protected int timeoutInMs = Constants.DEFAULT_TIMEOUT_IN_MS;
-
- /**
- * The maximum execution time, in milliseconds, across all potential retries.
- */
- private Integer maximumExecutionTimeInMs;
-
/**
* Holds the AuthenticationScheme associated with this Service Client.
*/
protected AuthenticationScheme authenticationScheme = AuthenticationScheme.SHAREDKEYFULL;
- /**
- * Creates an instance of the ServiceClient
class using the specified service endpoint.
- *
- * @param baseUri
- * A java.net.URI
object that represents the service endpoint used to create the client.
- */
- public ServiceClient(final URI baseUri) {
- this(new StorageUri(baseUri), null /* credentials */);
- }
-
- /**
- * Creates an instance of the ServiceClient
class using the specified service endpoint.
- *
- * @param baseUri
- * A java.net.URI
object that represents the service endpoint used to create the client.
- * @param credentials
- * A {@link StorageCredentials} object that represents the account credentials.
- */
- public ServiceClient(final URI baseUri, final StorageCredentials credentials) {
- this(new StorageUri(baseUri), credentials);
- }
-
/**
* Creates an instance of the ServiceClient
class using the specified service endpoint and account
* credentials.
@@ -105,33 +63,26 @@ public ServiceClient(final URI baseUri, final StorageCredentials credentials) {
* @param credentials
* A {@link StorageCredentials} object that represents the account credentials.
*/
- public ServiceClient(final StorageUri storageUri, final StorageCredentials credentials) {
+ protected ServiceClient(final StorageUri storageUri, final StorageCredentials credentials) {
Utility.assertNotNull("baseUri", storageUri);
if (!storageUri.isAbsolute()) {
throw new IllegalArgumentException(String.format(SR.RELATIVE_ADDRESS_NOT_PERMITTED, storageUri));
}
this.credentials = credentials == null ? StorageCredentialsAnonymous.ANONYMOUS : credentials;
-
- this.retryPolicyFactory = new RetryExponentialRetry();
- this.timeoutInMs = Constants.DEFAULT_TIMEOUT_IN_MS;
-
- this.usePathStyleUris = Utility.determinePathStyleFromUri(storageUri.getPrimaryUri(),
- this.credentials.getAccountName());
+ this.usePathStyleUris = Utility.determinePathStyleFromUri(storageUri.getPrimaryUri());
this.storageUri = storageUri;
- this.locationMode = LocationMode.PRIMARY_ONLY;
}
protected StorageRequestStorageUri
object that represents the list of URIs for all locations.
*/
protected final void setStorageUri(final StorageUri storageUri) {
- this.usePathStyleUris = Utility.determinePathStyleFromUri(storageUri.getPrimaryUri(),
- this.credentials.getAccountName());
+ this.usePathStyleUris = Utility.determinePathStyleFromUri(storageUri.getPrimaryUri());
this.storageUri = storageUri;
}
@@ -348,57 +244,6 @@ public final void setAuthenticationScheme(final AuthenticationScheme scheme) {
this.authenticationScheme = scheme;
}
- /**
- * Sets the RetryPolicyFactory object to use when making service requests.
- *
- * @param retryPolicyFactory
- * the RetryPolicyFactory object to use when making service requests.
- */
- public void setRetryPolicyFactory(final RetryPolicyFactory retryPolicyFactory) {
- this.retryPolicyFactory = retryPolicyFactory;
- }
-
- /**
- * Sets the timeout to use when making requests to the storage service.
- * ServiceClient
+ *
+ * @return The {@link RequestOptions} object containing the values used by this ServiceClient
+ */
+ public abstract RequestOptions getDefaultRequestOptions();
}
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ServiceProperties.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/ServiceProperties.java
similarity index 77%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ServiceProperties.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/ServiceProperties.java
index 966a4587d6ba2..e1c22a318d820 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/ServiceProperties.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/ServiceProperties.java
@@ -12,8 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
-
+package com.microsoft.azure.storage;
/**
* Represents the analytics properties for the service.
@@ -57,7 +56,7 @@ public ServiceProperties() {
}
/**
- * Get the logging properties
+ * Gets the logging properties.
*
* @return the logging
*/
@@ -66,7 +65,7 @@ public LoggingProperties getLogging() {
}
/**
- * Set the logging properties
+ * Sets the logging properties.
*
* @param logging
*/
@@ -75,29 +74,7 @@ public void setLogging(final LoggingProperties logging) {
}
/**
- * Get the metrics properties
- *
- * @deprecated use {@link #getHourMetrics()} instead.
- * @return the hour metrics
- */
- @Deprecated
- public MetricsProperties getMetrics() {
- return this.hourMetrics;
- }
-
- /**
- * Set the metrics properties
- *
- * @deprecated use {@link #setHourMetrics()} instead.
- * @param metrics
- */
- @Deprecated
- public void setMetrics(final MetricsProperties metrics) {
- this.hourMetrics = metrics;
- }
-
- /**
- * Get the hour metrics properties
+ * Gets the hour metrics properties.
*
* @return the hour metrics
*/
@@ -106,7 +83,7 @@ public MetricsProperties getHourMetrics() {
}
/**
- * Set the hour metrics properties
+ * Sets the hour metrics properties.
*
* @param metrics
*/
@@ -115,7 +92,7 @@ public void setHourMetrics(final MetricsProperties metrics) {
}
/**
- * Get the minute metrics properties
+ * Gets the minute metrics properties.
*
* @return the minute metrics
*/
@@ -124,7 +101,7 @@ public MetricsProperties getMinuteMetrics() {
}
/**
- * Set the minute metrics properties
+ * Sets the minute metrics properties.
*
* @param metrics
*/
@@ -133,7 +110,7 @@ public void setMinuteMetrics(final MetricsProperties metrics) {
}
/**
- * Get the CORS properties
+ * Gets the Cross Origin Resource Sharing (CORS) properties.
*
* @return the CORS properties
*/
@@ -142,7 +119,7 @@ public CorsProperties getCors() {
}
/**
- * Set the CORS properties
+ * Sets the Cross Origin Resource Sharing (CORS) properties.
*
* @param CORS
*/
@@ -151,7 +128,7 @@ public void setCors(final CorsProperties cors) {
}
/**
- * Get default service version
+ * Gets default service version.
*
* @return the defaultServiceVersion
*/
@@ -160,7 +137,7 @@ public String getDefaultServiceVersion() {
}
/**
- * Set default service version
+ * Sets default service version.
*
* @param defaultServiceVersion
*/
diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/ServicePropertiesHandler.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/ServicePropertiesHandler.java
new file mode 100644
index 0000000000000..ecb9d92cf4e25
--- /dev/null
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/ServicePropertiesHandler.java
@@ -0,0 +1,242 @@
+/**
+ * Copyright Microsoft Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.microsoft.azure.storage;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Stack;
+import java.util.StringTokenizer;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import com.microsoft.azure.storage.core.SR;
+import com.microsoft.azure.storage.core.Utility;
+
+/**
+ * RESERVED FOR INTERNAL USE. A class used to deserialize a service properties.
+ */
+final class ServicePropertiesHandler extends DefaultHandler {
+
+ private final StackSharedAccessPolicy
class type
+ * @return the HashMap of SharedAccessPolicies from the response
+ * @throws SAXException
+ * @throws ParserConfigurationException
+ * @throws ParseException
+ * if a date is incorrectly encoded in the stream
+ * @throws IOException
+ */
+ public static HashMap
object of the name/value pairs that represent the settings to use to configure
+ * the credentials.
+ * String
that contains the key/value pairs that represent the storage credentials.
+ *
+ * @return A {@link StorageCredentials} object representing the storage credentials determined from the connection
+ * string.
+ *
+ * @throws InvalidKeyException
+ * If the account key specified in connectionString
is not valid.
+ */
+ public static StorageCredentials tryParseCredentials(final String connectionString) throws InvalidKeyException {
+ return tryParseCredentials(Utility.parseAccountString(connectionString));
+ }
+
+ /**
+ * Returns the associated account name for the credentials. This is null for anonymous and shared access signature
+ * credentials.
+ *
+ * @return A String
that represents the associated account name for the credentials
+ */
+ public String getAccountName() {
+ return null;
+ }
+
+ /**
+ * Returns a String
that represents this instance.
+ *
+ * @param exportSecrets
+ * true
to include sensitive data in the return string; otherwise, false
.
+ * @return A String
that represents this object, optionally including sensitive data.
+ */
+ public abstract String toString(boolean exportSecrets);
+
+ /**
+ * Transforms a resource URI into a shared access signature URI, by appending a shared access token.
+ *
+ * @param resourceUri
+ * A java.net.URI
object that represents the resource URI to be transformed.
+ *
+ * @return A java.net.URI
object that represents the signature, including the resource URI and the
+ * shared access token.
+ *
+ * @throws StorageException
+ * If a storage service error occurred.
+ * @throws URISyntaxException
+ * If the resource URI is not properly formatted.
+ */
+ public URI transformUri(final URI resourceUri) throws URISyntaxException, StorageException {
+ return this.transformUri(resourceUri, null);
+ }
+
+ /**
+ * Transforms a resource URI into a shared access signature URI, by appending a shared access token.
+ *
+ * @param resourceUri
+ * A StorageUri
object that represents the resource URI to be transformed.
+ *
+ * @return A StorageUri
object that represents the signature, including the resource URI and the
+ * shared access token.
+ *
+ * @throws StorageException
+ * If a storage service error occurred.
+ * @throws URISyntaxException
+ * If the resource URI is not properly formatted.
+ */
+ public StorageUri transformUri(StorageUri resourceUri) throws URISyntaxException, StorageException {
+ return this.transformUri(resourceUri, null /* opContext */);
+ }
+
+ /**
+ * Transforms a resource URI into a shared access signature URI, by appending a shared access token and using the
+ * specified operation context.
+ *
+ * @param resourceUri
+ * A java.net.URI
object that represents the resource URI to be transformed.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ *
+ * @return A java.net.URI
object that represents the signature, including the resource URI and the
+ * shared access token.
+ *
+ * @throws StorageException
+ * If a storage service error occurred.
+ * @throws URISyntaxException
+ * If the resource URI is not properly formatted.
+ */
+ public abstract URI transformUri(URI resourceUri, OperationContext opContext) throws URISyntaxException,
+ StorageException;
+
+ /**
+ * Transforms a resource URI into a shared access signature URI, by appending a shared access token and using the
+ * specified operation context.
+ *
+ * @param resourceUri
+ * A StorageUri
object that represents the resource URI to be transformed.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ *
+ * @return A StorageUri
object that represents the signature, including the resource URI and the
+ * shared access token.
+ *
+ * @throws StorageException
+ * If a storage service error occurred.
+ * @throws URISyntaxException
+ * If the resource URI is not properly formatted.
+ */
+ public abstract StorageUri transformUri(StorageUri resourceUri, OperationContext opContext)
+ throws URISyntaxException, StorageException;
+}
diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageCredentialsAccountAndKey.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageCredentialsAccountAndKey.java
new file mode 100644
index 0000000000000..13a23191d2220
--- /dev/null
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageCredentialsAccountAndKey.java
@@ -0,0 +1,120 @@
+/**
+ * Copyright Microsoft Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.microsoft.azure.storage;
+
+import java.net.URI;
+
+import com.microsoft.azure.storage.core.Base64;
+
+/**
+ * Represents storage account credentials, based on storage account and access key, for accessing the Microsoft Azure
+ * storage services.
+ */
+public final class StorageCredentialsAccountAndKey extends StorageCredentials {
+
+ /**
+ * The internal Credentials associated with the StorageCredentials.
+ */
+ private Credentials credentials;
+
+ /**
+ * Creates an instance of the StorageCredentialsAccountAndKey
class, using the specified storage
+ * account name and access key; the specified access key is in the form of a byte array.
+ *
+ * @param accountName
+ * A String
that represents the name of the storage account.
+ * @param key
+ * An array of bytes that represent the account access key.
+ */
+ public StorageCredentialsAccountAndKey(final String accountName, final byte[] key) {
+ this.credentials = new Credentials(accountName, key);
+ }
+
+ /**
+ * Creates an instance of the StorageCredentialsAccountAndKey
class, using the specified storage
+ * account name and access key; the specified access key is stored as a String
.
+ *
+ * @param accountName
+ * A String
that represents the name of the storage account.
+ * @param key
+ * A String
that represents the Base-64-encoded account access key.
+ */
+ public StorageCredentialsAccountAndKey(final String accountName, final String key) {
+ this(accountName, Base64.decode(key));
+ }
+
+ /**
+ * Returns the associated account name for the credentials.
+ *
+ * @return A String
that contains the account name for the credentials.
+ */
+ @Override
+ public String getAccountName() {
+ return this.credentials.getAccountName();
+ }
+
+ /**
+ * Gets the name of the key used by these credentials.
+ */
+ public String getAccountKeyName() {
+ return this.credentials.getKeyName();
+ }
+
+ /**
+ * Returns the internal credentials associated with the storage credentials.
+ *
+ * @return A Credentials
object that contains the internal credentials associated with this instance of
+ * the StorageCredentialsAccountAndKey
class.
+ */
+ public Credentials getCredentials() {
+ return this.credentials;
+ }
+
+ /**
+ * Sets the credentials.
+ *
+ * @param credentials
+ * A Credentials
object that represents the credentials to set for this instance of the
+ * StorageCredentialsAccountAndKey
class.
+ */
+ public void setCredentials(final Credentials credentials) {
+ this.credentials = credentials;
+ }
+
+ /**
+ * Returns a String
that represents this instance, optionally including sensitive data.
+ *
+ * @param exportSecrets
+ * true
to include sensitive data in the return string; otherwise, false
.
+ *
+ * @return A String
that represents this object, optionally including sensitive data.
+ */
+ @Override
+ public String toString(final boolean exportSecrets) {
+ return String.format("%s=%s;%s=%s", CloudStorageAccount.ACCOUNT_NAME_NAME, this.getAccountName(),
+ CloudStorageAccount.ACCOUNT_KEY_NAME, exportSecrets ? this.credentials.getKey().getBase64EncodedKey()
+ : "[key hidden]");
+ }
+
+ @Override
+ public URI transformUri(URI resourceUri, OperationContext opContext) {
+ return resourceUri;
+ }
+
+ @Override
+ public StorageUri transformUri(StorageUri resourceUri, OperationContext opContext) {
+ return resourceUri;
+ }
+}
diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageCredentialsAnonymous.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageCredentialsAnonymous.java
new file mode 100644
index 0000000000000..b8bf5769b021c
--- /dev/null
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageCredentialsAnonymous.java
@@ -0,0 +1,67 @@
+/**
+ * Copyright Microsoft Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.microsoft.azure.storage;
+
+import java.net.URI;
+
+/**
+ * *RESERVED FOR INTERNAL USE* Represents credentials for anonymous access. This class is used by the internal
+ * implementation (not a public class, so its comments are not built into the Javadoc output).
+ */
+public final class StorageCredentialsAnonymous extends StorageCredentials {
+
+ /**
+ * Stores the singleton instance of this class.
+ */
+ public static final StorageCredentials ANONYMOUS = new StorageCredentialsAnonymous();
+
+ /**
+ * Returns the singleton instance of the StorageCredentials
class.
+ *
+ * @return the singleton instance of this class
+ */
+ protected static StorageCredentials getInstance() {
+ return StorageCredentialsAnonymous.ANONYMOUS;
+ }
+
+ /**
+ * Enforces the singleton pattern via a private constructor.
+ */
+ protected StorageCredentialsAnonymous() {
+ // Empty Default Ctor
+ }
+
+ /**
+ * Returns a String
object that represents this instance.
+ *
+ * @param exportSecrets
+ * true
to include sensitive data in the string; otherwise, false
+ * @return a string representation of the credentials, optionally including sensitive data.
+ */
+ @Override
+ public String toString(final boolean exportSecrets) {
+ return Constants.EMPTY_STRING;
+ }
+
+ @Override
+ public URI transformUri(URI resourceUri, OperationContext opContext) {
+ return resourceUri;
+ }
+
+ @Override
+ public StorageUri transformUri(StorageUri resourceUri, OperationContext opContext) {
+ return resourceUri;
+ }
+}
diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageCredentialsSharedAccessSignature.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageCredentialsSharedAccessSignature.java
new file mode 100644
index 0000000000000..230f9e40dfbe4
--- /dev/null
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageCredentialsSharedAccessSignature.java
@@ -0,0 +1,119 @@
+/**
+ * Copyright Microsoft Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.microsoft.azure.storage;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import com.microsoft.azure.storage.core.PathUtility;
+
+/**
+ * Represents storage credentials for delegated access to Blob service resources via a shared access signature.
+ */
+public final class StorageCredentialsSharedAccessSignature extends StorageCredentials {
+
+ /**
+ * Stores the shared access signature token.
+ */
+ private final String token;
+
+ /**
+ * Creates an instance of the StorageCredentialsSharedAccessSignature
class using the specified shared
+ * access signature token.
+ *
+ * @param token
+ * A String
that represents shared access signature token.
+ */
+ public StorageCredentialsSharedAccessSignature(final String token) {
+ this.token = token;
+ }
+
+ /**
+ * Returns the shared access signature token.
+ *
+ * @return A String
that contains the token.
+ */
+ public String getToken() {
+ return this.token;
+ }
+
+ /**
+ * Returns a String
that represents this instance, optionally including sensitive data.
+ *
+ * @param exportSecrets
+ * true
to include sensitive data in the return string; otherwise, false
.
+ * @return A String
that represents this object, optionally including sensitive data.
+ */
+ @Override
+ public String toString(final boolean exportSecrets) {
+ return String.format("%s=%s", CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME, exportSecrets ? this.token
+ : "[signature hidden]");
+ }
+
+ /**
+ * Transforms a resource URI into a shared access signature URI, by appending a shared access token and using the
+ * specified operation context.
+ *
+ * @param resourceUri
+ * A java.net.URI
object that represents the resource URI to be transformed.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ *
+ * @return A java.net.URI
object that represents the signature, including the resource URI and the
+ * shared access token.
+ *
+ * @throws StorageException
+ * If a storage service error occurred.
+ * @throws URISyntaxException
+ * If the resource URI is not properly formatted.
+ */
+ @Override
+ public URI transformUri(final URI resourceUri, final OperationContext opContext) throws URISyntaxException,
+ StorageException {
+ if (resourceUri == null) {
+ return null;
+ }
+
+ return PathUtility.addToQuery(resourceUri, this.token);
+ }
+
+ /**
+ * Transforms a resource URI into a shared access signature URI, by appending a shared access token and using the
+ * specified operation context.
+ *
+ * @param resourceUri
+ * A StorageUri
object that represents the resource URI to be transformed.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ *
+ * @return A StorageUri
object that represents the signature, including the resource URI and the
+ * shared access token.
+ *
+ * @throws StorageException
+ * If a storage service error occurred.
+ * @throws URISyntaxException
+ * If the resource URI is not properly formatted.
+ */
+ @Override
+ public StorageUri transformUri(StorageUri resourceUri, OperationContext opContext) throws URISyntaxException,
+ StorageException {
+ return new StorageUri(this.transformUri(resourceUri.getPrimaryUri(), opContext), this.transformUri(
+ resourceUri.getSecondaryUri(), opContext));
+ }
+}
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageErrorCode.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageErrorCode.java
similarity index 95%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageErrorCode.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/StorageErrorCode.java
index a5f83c138b299..1f5002419bbc8 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageErrorCode.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageErrorCode.java
@@ -12,11 +12,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
/**
- *
- * Represents error codes that may be returned by the Windows Azure storage services or the storage client library.
+ * Represents error codes that may be returned by the Microsoft Azure storage services or the storage client library.
*/
public enum StorageErrorCode {
/**
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageErrorCodeStrings.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageErrorCodeStrings.java
similarity index 99%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageErrorCodeStrings.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/StorageErrorCodeStrings.java
index 810c65eb5823e..ae26a182b54ee 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageErrorCodeStrings.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageErrorCodeStrings.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
/**
* Represents error code strings that are common to all storage services.
diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageErrorHandler.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageErrorHandler.java
new file mode 100644
index 0000000000000..85a4dcadd6eaf
--- /dev/null
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageErrorHandler.java
@@ -0,0 +1,106 @@
+/**
+ * Copyright Microsoft Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.microsoft.azure.storage;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Stack;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import com.microsoft.azure.storage.core.SR;
+import com.microsoft.azure.storage.core.Utility;
+
+/**
+ * RESERVED FOR INTERNAL USE. A class used to deserialize storage errors.
+ */
+final class StorageErrorHandler extends DefaultHandler {
+
+ private final StackHttpURLConnection
object that represents the request whose exception is being
@@ -107,6 +110,7 @@ protected static StorageExtendedErrorInformation getErrorDetailsFromTableRequest
*
* @return A StorageException
object that represents translated exception.
*/
+ @SuppressWarnings("deprecation")
public static StorageException translateException(final HttpURLConnection request, final Exception cause,
final OperationContext opContext) {
if (request == null) {
@@ -127,7 +131,7 @@ public static StorageException translateException(final HttpURLConnection reques
final String server = request.getHeaderField("Server");
if (server != null && server.startsWith("Windows-Azure-Table")) {
final String type = request.getHeaderField(Constants.HeaderConstants.CONTENT_TYPE);
- if (TableConstants.HeaderConstants.JSON_CONTENT_TYPE.equals(type)) {
+ if (JSON_CONTENT_TYPE.equals(type)) {
extendedError = getErrorDetailsFromTableRequest(request, TablePayloadFormat.Json, opContext);
}
else {
@@ -297,6 +301,8 @@ public StorageException(final String errorCode, final String message, final int
}
/**
+ * Gets the error code returned by the operation.
+ *
* @return the errorCode
*/
public String getErrorCode() {
@@ -304,6 +310,8 @@ public String getErrorCode() {
}
/**
+ * Gets the extended error information returned by the operation.
+ *
* @return the extendedErrorInformation
*/
public StorageExtendedErrorInformation getExtendedErrorInformation() {
@@ -311,6 +319,8 @@ public StorageExtendedErrorInformation getExtendedErrorInformation() {
}
/**
+ * Gets the HTTP status code returned by the operation.
+ *
* @return the httpStatusCode
*/
public int getHttpStatusCode() {
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageExtendedErrorInformation.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageExtendedErrorInformation.java
similarity index 81%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageExtendedErrorInformation.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/StorageExtendedErrorInformation.java
index 17402a44de26d..bb8df5b855be3 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageExtendedErrorInformation.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageExtendedErrorInformation.java
@@ -12,13 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
import java.io.Serializable;
import java.util.HashMap;
/**
- * Represents extended error information returned by the Windows Azure storage service.
+ * Represents extended error information returned by the Microsoft Azure storage service.
*/
public final class StorageExtendedErrorInformation implements Serializable {
/**
@@ -49,6 +49,8 @@ public StorageExtendedErrorInformation() {
}
/**
+ * Gets additional error details, as a java.util.HashMap
object.
+ *
* @return the additionalDetails
*/
public HashMapString
that represents the key being assigned.
- * @throws IOException
- * If the specified key is not a valid Base64-encoded string.
*/
- public void setKey(final String key) throws IOException {
+ public void setKey(final String key) {
this.key = Base64.decode(key);
}
}
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageLocation.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageLocation.java
similarity index 94%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageLocation.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/StorageLocation.java
index 131bcb7e813a6..be2d284868da1 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageLocation.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageLocation.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
/**
* Represents a storage service location.
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageUri.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageUri.java
similarity index 67%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageUri.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/StorageUri.java
index 6e2ab92221b19..17a2fbf426448 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/StorageUri.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/StorageUri.java
@@ -12,12 +12,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage;
+package com.microsoft.azure.storage;
import java.net.URI;
-import com.microsoft.windowsazure.storage.core.SR;
-import com.microsoft.windowsazure.storage.core.Utility;
+import com.microsoft.azure.storage.core.SR;
+import com.microsoft.azure.storage.core.Utility;
/**
* Holds a list of URIs that represents the storage resource.
@@ -50,11 +50,45 @@ public StorageUri(URI primaryUri) {
* Initializes a new instance of the StorageUri
class using the URI specified.
*/
public StorageUri(URI primaryUri, URI secondaryUri) {
- if ((primaryUri != null)
- && (secondaryUri != null)
- && (!(primaryUri.getPath().equals(secondaryUri.getPath())) || (primaryUri.getQuery() != null && !(primaryUri
- .getQuery().equals(secondaryUri.getQuery()))))) {
- throw new IllegalArgumentException(SR.STORAGE_URI_MUST_MATCH);
+ if (primaryUri != null && secondaryUri != null) {
+ // check query component is equivalent
+ if ((primaryUri.getQuery() == null && secondaryUri.getQuery() != null)
+ || (primaryUri.getQuery() != null && !(primaryUri.getQuery().equals(secondaryUri.getQuery())))) {
+ throw new IllegalArgumentException(SR.STORAGE_URI_MUST_MATCH);
+ }
+
+ boolean primaryPathStyle = Utility.determinePathStyleFromUri(primaryUri);
+ boolean secondaryPathStyle = Utility.determinePathStyleFromUri(secondaryUri);
+
+ if (!primaryPathStyle && !secondaryPathStyle) {
+ if ((primaryUri.getPath() == null && secondaryUri.getPath() != null)
+ || (primaryUri.getPath() != null && !(primaryUri.getPath().equals(secondaryUri.getPath())))) {
+ throw new IllegalArgumentException(SR.STORAGE_URI_MUST_MATCH);
+ }
+ }
+ else {
+ final int maxPrimaryPathSegments = primaryPathStyle ? 3 : 2;
+ final int maxSecondaryPathSegments = secondaryPathStyle ? 3 : 2;
+
+ // getPath() on a path-style uri returns /devstore1[/path1/path2], split(3) returns ["","devstore","path1/path2"]
+ // getPath() on a regular uri returns [/path1/path2], split(2) returns ["","path1/path2"]
+ final String[] primaryPathSegments = primaryUri.getPath().split("/", maxPrimaryPathSegments);
+ final String[] secondaryPathSegments = secondaryUri.getPath().split("/", maxSecondaryPathSegments);
+
+ String primaryPath = "";
+ if (primaryPathSegments.length == maxPrimaryPathSegments) {
+ primaryPath = primaryPathSegments[primaryPathSegments.length - 1];
+ }
+
+ String secondaryPath = "";
+ if (secondaryPathSegments.length == maxSecondaryPathSegments) {
+ secondaryPath = secondaryPathSegments[secondaryPathSegments.length - 1];
+ }
+
+ if (!primaryPath.equals(secondaryPath)) {
+ throw new IllegalArgumentException(SR.STORAGE_URI_MUST_MATCH);
+ }
+ }
}
this.setPrimaryUri(primaryUri);
@@ -80,6 +114,8 @@ public boolean equals(StorageUri other) {
}
/**
+ * Gets the endpoint for the primary location for the storage account.
+ *
* @return the primaryUri
*/
public URI getPrimaryUri() {
@@ -87,6 +123,8 @@ public URI getPrimaryUri() {
}
/**
+ * Gets the endpoint for the secondary location for the storage account.
+ *
* @return the secondaryUri
*/
public URI getSecondaryUri() {
@@ -123,6 +161,8 @@ public int hashCode() {
}
/**
+ * Sets the endpoint for the primary location for the storage account.
+ *
* @param primaryUri
* the primaryUri to set
*/
@@ -133,6 +173,8 @@ private void setPrimaryUri(URI primaryUri) {
}
/**
+ * Sets the endpoint for the secondary location for the storage account.
+ *
* @param secondaryUri
* the secondaryUri to set
*/
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobAttributes.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobAttributes.java
similarity index 78%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobAttributes.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobAttributes.java
index eda0deca76a20..567014cefce5a 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobAttributes.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobAttributes.java
@@ -12,16 +12,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage.blob;
+package com.microsoft.azure.storage.blob;
import java.net.URI;
import java.util.HashMap;
-import com.microsoft.windowsazure.storage.StorageUri;
+import com.microsoft.azure.storage.StorageUri;
/**
* RESERVED FOR INTERNAL USE. Represents a blob's attributes.
- *
*/
final class BlobAttributes {
@@ -46,7 +45,7 @@ final class BlobAttributes {
private StorageUri storageUri;
/**
- * Initializes a new instance of the BlobAttributes class. RESERVED FOR INTERNAL USE.
+ * Initializes a new instance of the BlobAttributes class.
*
* @param type
* The type of blob to set.
@@ -57,7 +56,7 @@ public BlobAttributes(final BlobType type) {
}
/**
- * Gets the metadata for the blob. RESERVED FOR INTERNAL USE.
+ * Gets the metadata for the blob.
*
* @return A HashMap
object containing the metadata for the blob.
*/
@@ -66,7 +65,7 @@ public HashMapBlobProperties
object that represents the blob properties.
*/
@@ -75,7 +74,7 @@ public BlobProperties getProperties() {
}
/**
- * Gets the snapshot ID of the blob. RESERVED FOR INTERNAL USE.
+ * Gets the snapshot ID of the blob.
*
* @return A String
that represents snapshot ID of the blob.
*/
@@ -84,7 +83,7 @@ public final String getSnapshotID() {
}
/**
- * Gets the list of URIs for all locations for the blob. RESERVED FOR INTERNAL USE.
+ * Gets the list of URIs for all locations for the blob.
*
* @return A StorageUri
object that represents the list of URIs for all locations for the blob.
*/
@@ -93,7 +92,7 @@ public final StorageUri getStorageUri() {
}
/**
- * Gets the URI of the blob. RESERVED FOR INTERNAL USE.
+ * Gets the URI of the blob.
*
* @return A java.net.URI
object that represents the URI of the blob.
*/
@@ -102,7 +101,7 @@ public final URI getUri() {
}
/**
- * Sets the metadata for a blob. RESERVED FOR INTERNAL USE.
+ * Sets the metadata for a blob.
*
* @param metadata
* The blob meta data to set.
@@ -112,7 +111,7 @@ protected void setMetadata(final HashMapString
that represents snapshot ID of the blob.
*/
- public final void setSnapshotID(String snapshotID) {
+ protected final void setSnapshotID(String snapshotID) {
this.snapshotID = snapshotID;
}
/**
- * Sets the list of URIs for all locations for the blob. RESERVED FOR INTERNAL USE.
+ * Sets the list of URIs for all locations for the blob.
*
* @param storageUri
* The list of URIs for all locations for the blob.
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobConstants.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobConstants.java
similarity index 86%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobConstants.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobConstants.java
index 4670fbe9f0720..17f8a440581e0 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobConstants.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobConstants.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage.blob;
+package com.microsoft.azure.storage.blob;
/**
* Holds the Constants used for the Queue Service.
@@ -26,7 +26,7 @@ final class BlobConstants {
/**
* The header that specifies blob content MD5.
*/
- public static final String BLOB_CONTENT_MD5_HEADER = com.microsoft.windowsazure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ public static final String BLOB_CONTENT_MD5_HEADER = com.microsoft.azure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ "blob-content-md5";
/**
@@ -42,7 +42,7 @@ final class BlobConstants {
/**
* The header that specifies public access to blobs.
*/
- public static final String BLOB_PUBLIC_ACCESS_HEADER = com.microsoft.windowsazure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ public static final String BLOB_PUBLIC_ACCESS_HEADER = com.microsoft.azure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ "blob-public-access";
/**
@@ -52,7 +52,7 @@ final class BlobConstants {
/**
* The header for the blob type.
*/
- public static final String BLOB_TYPE_HEADER = com.microsoft.windowsazure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ public static final String BLOB_TYPE_HEADER = com.microsoft.azure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ "blob-type";
/**
@@ -103,31 +103,31 @@ final class BlobConstants {
/**
* The header that specifies blob content encoding.
*/
- public static final String CONTENT_DISPOSITION_HEADER = com.microsoft.windowsazure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ public static final String CONTENT_DISPOSITION_HEADER = com.microsoft.azure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ "blob-content-disposition";
/**
* The header that specifies blob content encoding.
*/
- public static final String CONTENT_ENCODING_HEADER = com.microsoft.windowsazure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ public static final String CONTENT_ENCODING_HEADER = com.microsoft.azure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ "blob-content-encoding";
/**
* The header that specifies blob content language.
*/
- public static final String CONTENT_LANGUAGE_HEADER = com.microsoft.windowsazure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ public static final String CONTENT_LANGUAGE_HEADER = com.microsoft.azure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ "blob-content-language";
/**
* The header that specifies blob content length.
*/
- public static final String CONTENT_LENGTH_HEADER = com.microsoft.windowsazure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ public static final String CONTENT_LENGTH_HEADER = com.microsoft.azure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ "blob-content-length";
/**
* The header that specifies blob content type.
*/
- public static final String CONTENT_TYPE_HEADER = com.microsoft.windowsazure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ public static final String CONTENT_TYPE_HEADER = com.microsoft.azure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ "blob-content-type";
/**
@@ -163,7 +163,7 @@ final class BlobConstants {
/**
* The default maximum size, in bytes, of a blob before it must be separated into blocks.
*/
- public static final int DEFAULT_SINGLE_BLOB_PUT_THRESHOLD_IN_BYTES = 32 * com.microsoft.windowsazure.storage.Constants.MB;
+ public static final int DEFAULT_SINGLE_BLOB_PUT_THRESHOLD_IN_BYTES = 32 * com.microsoft.azure.storage.Constants.MB;
/**
* Specifies snapshots are to be included.
@@ -178,13 +178,13 @@ final class BlobConstants {
/**
* Maximum commit size
*/
- public static final int MAX_COMMIT_SIZE_4_MB = 4 * com.microsoft.windowsazure.storage.Constants.MB;
+ public static final int MAX_COMMIT_SIZE_4_MB = 4 * com.microsoft.azure.storage.Constants.MB;
/**
* The maximum size, in bytes, of a blob before it must be separated into blocks
*/
// Note if this is updated then Constants.MAX_MARK_LENGTH needs to be as well.
- public static final int MAX_SINGLE_UPLOAD_BLOB_SIZE_IN_BYTES = 64 * com.microsoft.windowsazure.storage.Constants.MB;
+ public static final int MAX_SINGLE_UPLOAD_BLOB_SIZE_IN_BYTES = 64 * com.microsoft.azure.storage.Constants.MB;
/**
* Specifies the page blob type.
@@ -214,7 +214,7 @@ final class BlobConstants {
/**
* The header that specifies page write mode.
*/
- public static final String PAGE_WRITE = com.microsoft.windowsazure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ public static final String PAGE_WRITE = com.microsoft.azure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ "page-write";
/**
@@ -225,13 +225,13 @@ final class BlobConstants {
/**
* The header for specifying the sequence number.
*/
- public static final String SEQUENCE_NUMBER = com.microsoft.windowsazure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ public static final String SEQUENCE_NUMBER = com.microsoft.azure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ "blob-sequence-number";
/**
* The header for the blob content length.
*/
- public static final String SIZE = com.microsoft.windowsazure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ public static final String SIZE = com.microsoft.azure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ "blob-content-length";
/**
@@ -252,7 +252,7 @@ final class BlobConstants {
/**
* The header for snapshots.
*/
- public static final String SNAPSHOT_HEADER = com.microsoft.windowsazure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ public static final String SNAPSHOT_HEADER = com.microsoft.azure.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ "snapshot";
/**
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobContainerAttributes.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobContainerAttributes.java
similarity index 59%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobContainerAttributes.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobContainerAttributes.java
index 1762329a2d8c3..253503b31ad8a 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobContainerAttributes.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobContainerAttributes.java
@@ -12,16 +12,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage.blob;
+package com.microsoft.azure.storage.blob;
import java.net.URI;
import java.util.HashMap;
-import com.microsoft.windowsazure.storage.StorageUri;
+import com.microsoft.azure.storage.StorageUri;
/**
* RESERVED FOR INTERNAL USE. Represents a container's attributes, including its properties and metadata.
- *
*/
final class BlobContainerAttributes {
/**
@@ -52,38 +51,87 @@ public BlobContainerAttributes() {
this.setProperties(new BlobContainerProperties());
}
+ /**
+ * Gets the metadata for the container.
+ *
+ * @return A HashMap
object containing the metadata for the container.
+ */
public HashMapString
that represents name of the container.
+ */
public String getName() {
return this.name;
}
+ /**
+ * Gets the properties for the container.
+ *
+ * @return A BlobContainerProperties
object that represents the container properties.
+ */
public BlobContainerProperties getProperties() {
return this.properties;
}
+ /**
+ * Gets the list of URIs for all locations for the container.
+ *
+ * @return A StorageUri
object that represents the list of URIs for all locations for the container.
+ */
public final StorageUri getStorageUri() {
return this.storageUri;
}
+ /**
+ * Gets the URI of the container.
+ *
+ * @return A java.net.URI
object that represents the URI of the container.
+ */
public URI getUri() {
return this.storageUri.getPrimaryUri();
}
+ /**
+ * Sets the metadata for a container.
+ *
+ * @param metadata
+ * The container metadata to set.
+ */
public void setMetadata(final HashMapString
that represents name of the container.
+ */
public void setName(final String name) {
this.name = name;
}
+ /**
+ * Sets the properties for a container.
+ *
+ * @param properties
+ * The container properties to set.
+ */
public void setProperties(final BlobContainerProperties properties) {
this.properties = properties;
}
+ /**
+ * Sets the list of URIs for all locations for the container.
+ *
+ * @param storageUri
+ * The list of URIs for all locations for the container.
+ */
protected void setStorageUri(final StorageUri storageUri) {
this.storageUri = storageUri;
}
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobContainerPermissions.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobContainerPermissions.java
similarity index 73%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobContainerPermissions.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobContainerPermissions.java
index 248b2fde30a41..f6f1dc18dd808 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobContainerPermissions.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobContainerPermissions.java
@@ -12,9 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage.blob;
+package com.microsoft.azure.storage.blob;
-import com.microsoft.windowsazure.storage.core.Permissions;
+import com.microsoft.azure.storage.Permissions;
/**
* Represents the permissions for a container.
@@ -30,12 +30,24 @@
*
* For more information on managing container permissions, see Managing Access to Containers and Blobs.
- *
*/
public final class BlobContainerPermissions extends PermissionsBlobContainerPermissions
class.
+ */
+ public BlobContainerPermissions() {
+ super();
+ this.setPublicAccess(BlobContainerPublicAccessType.OFF);
+ }
+
+ /**
+ * Gets the public access setting for the container.
* BlobContainerPermissions
class.
- */
- public BlobContainerPermissions() {
- super();
- this.setPublicAccess(BlobContainerPublicAccessType.OFF);
- }
-
- /**
- * @return the publicAccess
- */
public BlobContainerPublicAccessType getPublicAccess() {
return this.publicAccess;
}
/**
- * @param publicAccess
- * the publicAccess to set
+ * Sets the public access setting for the container.
+ *
+ *
+ * For more information on managing anonymous access to Blob service resources, see Setting Access Control for Containers.
*/
public void setPublicAccess(final BlobContainerPublicAccessType publicAccess) {
this.publicAccess = publicAccess;
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobContainerProperties.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobContainerProperties.java
similarity index 81%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobContainerProperties.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobContainerProperties.java
index 53d2e6af6b121..731ab19cd7ca4 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobContainerProperties.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobContainerProperties.java
@@ -12,14 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage.blob;
+package com.microsoft.azure.storage.blob;
import java.util.Date;
-import com.microsoft.windowsazure.storage.AccessCondition;
-import com.microsoft.windowsazure.storage.LeaseDuration;
-import com.microsoft.windowsazure.storage.LeaseState;
-import com.microsoft.windowsazure.storage.LeaseStatus;
+import com.microsoft.azure.storage.AccessCondition;
/**
* Represents the system properties for a container.
@@ -28,12 +25,6 @@ public final class BlobContainerProperties {
/**
* Represents the ETag value for the container.
- * Date
object.
*/
- public void setLastModified(final Date lastModified) {
+ protected void setLastModified(final Date lastModified) {
this.lastModified = lastModified;
}
/**
- * Sets the lease status on the container. Reserved for internal use.
+ * Sets the lease status on the container.
*
* @param leaseStatus
* The lease status to set, as a LeaseStatus
object.
*/
- public void setLeaseStatus(final LeaseStatus leaseStatus) {
+ protected void setLeaseStatus(final LeaseStatus leaseStatus) {
this.leaseStatus = leaseStatus;
}
/**
- * Sets the lease status on the container. Reserved for internal use.
+ * Sets the lease status on the container.
*
* @param leaseState
* The lease state to set, as a LeaseState
object.
*/
- public void setLeaseState(final LeaseState leaseState) {
+ protected void setLeaseState(final LeaseState leaseState) {
this.leaseState = leaseState;
}
/**
- * Sets the lease duration on the container. Reserved for internal use.
+ * Sets the lease duration on the container.
*
* @param leaseDuration
* The lease duration to set, as a LeaseDuration
object.
*/
- public void setLeaseDuration(final LeaseDuration leaseDuration) {
+ protected void setLeaseDuration(final LeaseDuration leaseDuration) {
this.leaseDuration = leaseDuration;
}
}
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobContainerPublicAccessType.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobContainerPublicAccessType.java
similarity index 57%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobContainerPublicAccessType.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobContainerPublicAccessType.java
index 3e846165b94a6..a0f5ef7862a3a 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobContainerPublicAccessType.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobContainerPublicAccessType.java
@@ -12,11 +12,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage.blob;
+package com.microsoft.azure.storage.blob;
/**
* Specifies the level of public access that is allowed on the container.
- *
+ *
+ *
+ * For more information on managing anonymous access to Blob service resources, see Setting Access Control for Containers.
*/
public enum BlobContainerPublicAccessType {
/**
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobInputStream.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobInputStream.java
similarity index 97%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobInputStream.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobInputStream.java
index c03e748dc6b04..c3c50d64bc290 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobInputStream.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobInputStream.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage.blob;
+package com.microsoft.azure.storage.blob;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -21,16 +21,16 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import com.microsoft.windowsazure.storage.AccessCondition;
-import com.microsoft.windowsazure.storage.Constants;
-import com.microsoft.windowsazure.storage.DoesServiceRequest;
-import com.microsoft.windowsazure.storage.OperationContext;
-import com.microsoft.windowsazure.storage.StorageErrorCode;
-import com.microsoft.windowsazure.storage.StorageErrorCodeStrings;
-import com.microsoft.windowsazure.storage.StorageException;
-import com.microsoft.windowsazure.storage.core.Base64;
-import com.microsoft.windowsazure.storage.core.SR;
-import com.microsoft.windowsazure.storage.core.Utility;
+import com.microsoft.azure.storage.AccessCondition;
+import com.microsoft.azure.storage.Constants;
+import com.microsoft.azure.storage.DoesServiceRequest;
+import com.microsoft.azure.storage.OperationContext;
+import com.microsoft.azure.storage.StorageErrorCode;
+import com.microsoft.azure.storage.StorageErrorCodeStrings;
+import com.microsoft.azure.storage.StorageException;
+import com.microsoft.azure.storage.core.Base64;
+import com.microsoft.azure.storage.core.SR;
+import com.microsoft.azure.storage.core.Utility;
/**
* Provides an input stream to read a given blob resource.
diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobListHandler.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobListHandler.java
new file mode 100644
index 0000000000000..ec1e66ec22242
--- /dev/null
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobListHandler.java
@@ -0,0 +1,310 @@
+/**
+ * Copyright Microsoft Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.microsoft.azure.storage.blob;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.ParseException;
+import java.util.HashMap;
+import java.util.Stack;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import com.microsoft.azure.storage.Constants;
+import com.microsoft.azure.storage.StorageException;
+import com.microsoft.azure.storage.core.ListResponse;
+import com.microsoft.azure.storage.core.SR;
+import com.microsoft.azure.storage.core.Utility;
+
+/**
+ * RESERVED FOR INTERNAL USE. A class used to deserialize a list of blobs.
+ */
+final class BlobListHandler extends DefaultHandler {
+
+ private final Stacknull
.
+ * field returns null
.
*/
private String contentDisposition;
@@ -73,12 +69,6 @@ public final class BlobProperties {
/**
* Represents the blob's ETag value.
- * LeaseStatus
object representing the lease status.
*/
@@ -274,16 +270,6 @@ public long getLength() {
return this.length;
}
- /**
- * Sets the blob type. Reserved for internal use.
- *
- * @param blobType
- * The blob type to set, represented by a BlobType
object.
- */
- protected void setBlobType(final BlobType blobType) {
- this.blobType = blobType;
- }
-
/**
* Sets the cache control value for the blob.
*
@@ -345,72 +331,82 @@ public void setContentType(final String contentType) {
}
/**
- * Reserved for internal use.
+ * Sets the blob type.
+ *
+ * @param blobType
+ * The blob type to set, represented by a BlobType
object.
+ */
+ protected void setBlobType(final BlobType blobType) {
+ this.blobType = blobType;
+ }
+
+ /**
+ * Sets the copy state value for the blob
*
* @param copyState
* the copyState to set
*/
- public void setCopyState(final CopyState copyState) {
+ protected void setCopyState(final CopyState copyState) {
this.copyState = copyState;
}
/**
- * Sets the ETag value for the blob. Reserved for internal use.
+ * Sets the ETag value for the blob.
*
* @param etag
* The ETag value to set.
*/
- public void setEtag(final String etag) {
+ protected void setEtag(final String etag) {
this.etag = etag;
}
/**
- * Sets the last modified time for the blob. Reserved for internal use.
+ * Sets the last modified time for the blob.
*
* @param lastModified
* The last modified time to set.
*/
- public void setLastModified(final Date lastModified) {
+ protected void setLastModified(final Date lastModified) {
this.lastModified = lastModified;
}
/**
- * Sets the lease status for the blob. Reserved for internal use.
+ * Sets the lease status for the blob.
*
* @param leaseStatus
* The lease status to set, represented by a LeaseStatus
object.
*/
- public void setLeaseStatus(final LeaseStatus leaseStatus) {
+ protected void setLeaseStatus(final LeaseStatus leaseStatus) {
this.leaseStatus = leaseStatus;
}
/**
- * Sets the lease state for the blob. Reserved for internal use.
+ * Sets the lease state for the blob.
*
* @param leaseState
* The lease state to set, represented by a LeaseState
object.
*/
- public void setLeaseState(final LeaseState leaseState) {
+ protected void setLeaseState(final LeaseState leaseState) {
this.leaseState = leaseState;
}
/**
- * Sets the lease duration for the blob. Reserved for internal use.
+ * Sets the lease duration for the blob.
*
* @param leaseDuration
* The lease duration value to set, represented by a LeaseDuration
object.
*/
- public void setLeaseDuration(final LeaseDuration leaseDuration) {
+ protected void setLeaseDuration(final LeaseDuration leaseDuration) {
this.leaseDuration = leaseDuration;
}
/**
- * Sets the content length, in bytes, for the blob. Reserved for internal use.
+ * Sets the content length, in bytes, for the blob.
*
* @param length
* The length to set.
*/
- public void setLength(final long length) {
+ protected void setLength(final long length) {
this.length = length;
}
diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobRequest.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobRequest.java
new file mode 100644
index 0000000000000..a6cc5e823ba7c
--- /dev/null
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobRequest.java
@@ -0,0 +1,1468 @@
+/**
+ * Copyright Microsoft Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.microsoft.azure.storage.blob;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+
+import com.microsoft.azure.storage.AccessCondition;
+import com.microsoft.azure.storage.Constants;
+import com.microsoft.azure.storage.Constants.HeaderConstants;
+import com.microsoft.azure.storage.OperationContext;
+import com.microsoft.azure.storage.StorageException;
+import com.microsoft.azure.storage.core.BaseRequest;
+import com.microsoft.azure.storage.core.ListingContext;
+import com.microsoft.azure.storage.core.SR;
+import com.microsoft.azure.storage.core.UriQueryBuilder;
+import com.microsoft.azure.storage.core.Utility;
+
+/**
+ * RESERVED FOR INTERNAL USE. Provides a set of methods for constructing requests for blob operations.
+ */
+final class BlobRequest {
+
+ private static final String BLOCK_QUERY_ELEMENT_NAME = "block";
+
+ private static final String BLOCK_ID_QUERY_ELEMENT_NAME = "blockid";
+
+ private static final String BLOCK_LIST_QUERY_ELEMENT_NAME = "blocklist";
+
+ private static final String BLOCK_LIST_TYPE_QUERY_ELEMENT_NAME = "blocklisttype";
+
+ private static final String COPY_QUERY_ELEMENT_NAME = "copy";
+
+ private static final String PAGE_QUERY_ELEMENT_NAME = "page";
+
+ private static final String PAGE_LIST_QUERY_ELEMENT_NAME = "pagelist";
+
+ private static final String SNAPSHOTS_QUERY_ELEMENT_NAME = "snapshots";
+
+ private static final String UNCOMMITTED_BLOBS_QUERY_ELEMENT_NAME = "uncommittedblobs";
+
+ /**
+ * Generates a web request to abort a copy operation.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * The access condition to apply to the request. Only lease conditions are supported for this operation.
+ * @param copyId
+ * A String
object that identifying the copy operation.
+ * @return a HttpURLConnection configured for the operation.
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ * @throws IOException
+ * @throws URISyntaxException
+ */
+ public static HttpURLConnection abortCopy(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final String copyId)
+ throws StorageException, IOException, URISyntaxException {
+
+ final UriQueryBuilder builder = new UriQueryBuilder();
+
+ builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.COPY);
+ builder.add(Constants.QueryConstants.COPY_ID, copyId);
+
+ final HttpURLConnection request = BaseRequest.createURLConnection(uri, blobOptions, builder, opContext);
+
+ request.setFixedLengthStreamingMode(0);
+ request.setDoOutput(true);
+ request.setRequestMethod(Constants.HTTP_PUT);
+
+ request.setRequestProperty(Constants.HeaderConstants.COPY_ACTION_HEADER,
+ Constants.HeaderConstants.COPY_ACTION_ABORT);
+
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request, true);
+ }
+
+ return request;
+ }
+
+ /**
+ * Adds the metadata.
+ *
+ * @param request
+ * The request.
+ * @param metadata
+ * The metadata.
+ */
+ public static void addMetadata(final HttpURLConnection request, final HashMapURI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param source
+ * The canonical path to the source blob, in the form /URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @return a HttpURLConnection configured for the operation.
+ * @throws StorageException
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection createContainer(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext) throws IOException, URISyntaxException, StorageException {
+ final UriQueryBuilder containerBuilder = getContainerUriQueryBuilder();
+ return BaseRequest.create(uri, blobOptions, containerBuilder, opContext);
+ }
+
+ /**
+ * Creates the web request.
+ *
+ * @param uri
+ * The absolute URI to the container.
+ * @param timeout
+ * The server timeout interval.
+ * @param query
+ * The query builder to use.
+ * @param blobOptions
+ * the options to use for the request.
+ * @param opContext
+ * a tracking object for the request
+ * @return a HttpURLConnection configured for the operation.
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ private static HttpURLConnection createURLConnection(final URI uri, final UriQueryBuilder query,
+ final BlobRequestOptions blobOptions, final OperationContext opContext) throws IOException,
+ URISyntaxException, StorageException {
+ return BaseRequest.createURLConnection(uri, blobOptions, query, opContext);
+ }
+
+ /**
+ * Constructs a HttpURLConnection to delete the blob, Sign with no length specified.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @param snapshotVersion
+ * The snapshot version, if the blob is a snapshot.
+ * @param deleteSnapshotsOption
+ * A set of options indicating whether to delete only blobs, only snapshots, or both.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection deleteBlob(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion,
+ final DeleteSnapshotsOption deleteSnapshotsOption) throws IOException, URISyntaxException, StorageException {
+
+ if (snapshotVersion != null && deleteSnapshotsOption != DeleteSnapshotsOption.NONE) {
+ throw new IllegalArgumentException(String.format(SR.DELETE_SNAPSHOT_NOT_VALID_ERROR,
+ "deleteSnapshotsOption", "snapshot"));
+ }
+
+ final UriQueryBuilder builder = new UriQueryBuilder();
+ BlobRequest.addSnapshot(builder, snapshotVersion);
+ final HttpURLConnection request = BaseRequest.delete(uri, blobOptions, builder, opContext);
+
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request);
+ }
+
+ switch (deleteSnapshotsOption) {
+ case NONE:
+ // nop
+ break;
+ case INCLUDE_SNAPSHOTS:
+ request.setRequestProperty(Constants.HeaderConstants.DELETE_SNAPSHOT_HEADER,
+ BlobConstants.INCLUDE_SNAPSHOTS_VALUE);
+ break;
+ case DELETE_SNAPSHOTS_ONLY:
+ request.setRequestProperty(Constants.HeaderConstants.DELETE_SNAPSHOT_HEADER,
+ BlobConstants.SNAPSHOTS_ONLY_VALUE);
+ break;
+ default:
+ break;
+ }
+
+ return request;
+ }
+
+ /**
+ * Constructs a web request to delete the container and all of blobs within it. Sign with no length specified.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the container.
+ * @return a HttpURLConnection configured for the operation.
+ * @throws StorageException
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection deleteContainer(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition) throws IOException,
+ URISyntaxException, StorageException {
+ final UriQueryBuilder containerBuilder = getContainerUriQueryBuilder();
+ HttpURLConnection request = BaseRequest.delete(uri, blobOptions, containerBuilder, opContext);
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request);
+ }
+
+ return request;
+ }
+
+ /**
+ * Constructs a web request to return the ACL for this container. Sign with no length specified.
+ *
+ * @param uri
+ * The absolute URI to the container.
+ * @param timeout
+ * The server timeout interval.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the container.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @return a HttpURLConnection configured for the operation.
+ * @throws StorageException
+ */
+ public static HttpURLConnection getAcl(final URI uri, final BlobRequestOptions blobOptions,
+ final AccessCondition accessCondition, final OperationContext opContext) throws IOException,
+ URISyntaxException, StorageException {
+ final UriQueryBuilder builder = getContainerUriQueryBuilder();
+ builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.ACL);
+
+ final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
+
+ request.setRequestMethod(Constants.HTTP_GET);
+
+ if (accessCondition != null && !Utility.isNullOrEmpty(accessCondition.getLeaseID())) {
+ BaseRequest.addLeaseId(request, accessCondition.getLeaseID());
+ }
+
+ return request;
+ }
+
+ /**
+ * Constructs a HttpURLConnection to download the blob, Sign with no length specified.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @param snapshotVersion
+ * The snapshot version, if the blob is a snapshot.
+ * @param offset
+ * The offset at which to begin returning content.
+ * @param count
+ * The number of bytes to return.
+ * @param requestRangeContentMD5
+ * If set to true, request an MD5 header for the specified range.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection getBlob(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion,
+ final Long offset, final Long count, boolean requestRangeContentMD5) throws IOException,
+ URISyntaxException, StorageException {
+
+ if (offset != null && requestRangeContentMD5) {
+ Utility.assertNotNull("count", count);
+ Utility.assertInBounds("count", count, 1, Constants.MAX_BLOCK_SIZE);
+ }
+
+ final UriQueryBuilder builder = new UriQueryBuilder();
+ BlobRequest.addSnapshot(builder, snapshotVersion);
+ final HttpURLConnection request = BaseRequest.createURLConnection(uri, blobOptions, builder, opContext);
+ request.setRequestMethod(Constants.HTTP_GET);
+
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request);
+ }
+
+ if (offset != null) {
+ long rangeStart = offset;
+ long rangeEnd;
+ if (count != null) {
+ rangeEnd = offset + count - 1;
+ request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, String.format(
+ Utility.LOCALE_US, Constants.HeaderConstants.RANGE_HEADER_FORMAT, rangeStart, rangeEnd));
+ }
+ else {
+ request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, String.format(
+ Utility.LOCALE_US, Constants.HeaderConstants.BEGIN_RANGE_HEADER_FORMAT, rangeStart));
+ }
+ }
+
+ if (offset != null && requestRangeContentMD5) {
+ request.setRequestProperty(Constants.HeaderConstants.RANGE_GET_CONTENT_MD5, Constants.TRUE);
+ }
+
+ return request;
+ }
+
+ /**
+ * Constructs a HttpURLConnection to return the blob's system properties, Sign with no length specified.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @param snapshotVersion
+ * The snapshot version, if the blob is a snapshot.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection getBlobProperties(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion)
+ throws StorageException, IOException, URISyntaxException {
+ final UriQueryBuilder builder = new UriQueryBuilder();
+ BlobRequest.addSnapshot(builder, snapshotVersion);
+ return getProperties(uri, blobOptions, opContext, accessCondition, builder);
+ }
+
+ /**
+ * Constructs a HttpURLConnection to return a list of the block blobs blocks. Sign with no length specified.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @param snapshotVersion
+ * The snapshot version, if the blob is a snapshot.
+ * @param blockFilter
+ * The types of blocks to include in the list: committed, uncommitted, or both.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection getBlockList(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion,
+ final BlockListingFilter blockFilter) throws StorageException, IOException, URISyntaxException {
+
+ final UriQueryBuilder builder = new UriQueryBuilder();
+
+ builder.add(Constants.QueryConstants.COMPONENT, BLOCK_LIST_QUERY_ELEMENT_NAME);
+ builder.add(BLOCK_LIST_TYPE_QUERY_ELEMENT_NAME, blockFilter.toString());
+ BlobRequest.addSnapshot(builder, snapshotVersion);
+
+ final HttpURLConnection request = BaseRequest.createURLConnection(uri, blobOptions, builder, opContext);
+ request.setRequestMethod(Constants.HTTP_GET);
+
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request);
+ }
+
+ return request;
+ }
+
+ /**
+ * Constructs a web request to return the user-defined metadata for this container. Sign with no length specified.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the container.
+ * @return a HttpURLConnection configured for the operation.
+ * @throws StorageException
+ * */
+ public static HttpURLConnection getContainerProperties(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, AccessCondition accessCondition) throws IOException, URISyntaxException,
+ StorageException {
+ final UriQueryBuilder containerBuilder = getContainerUriQueryBuilder();
+ return getProperties(uri, blobOptions, opContext, accessCondition, containerBuilder);
+ }
+
+ /**
+ * Gets the container Uri query builder.
+ *
+ * A UriQueryBuilder
for the container.
+ *
+ * @throws StorageException
+ */
+ private static UriQueryBuilder getContainerUriQueryBuilder() throws StorageException {
+ final UriQueryBuilder uriBuilder = new UriQueryBuilder();
+ try {
+ uriBuilder.add(Constants.QueryConstants.RESOURCETYPE, "container");
+ }
+ catch (final IllegalArgumentException e) {
+ throw Utility.generateNewUnexpectedStorageException(e);
+ }
+ return uriBuilder;
+ }
+
+ /**
+ * Constructs a HttpURLConnection to return a list of the PageBlob's page ranges. Sign with no length specified.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @param snapshotVersion
+ * The snapshot version, if the blob is a snapshot.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection getPageRanges(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion)
+ throws StorageException, IOException, URISyntaxException {
+
+ final UriQueryBuilder builder = new UriQueryBuilder();
+ builder.add(Constants.QueryConstants.COMPONENT, PAGE_LIST_QUERY_ELEMENT_NAME);
+ BlobRequest.addSnapshot(builder, snapshotVersion);
+
+ final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
+ request.setRequestMethod(Constants.HTTP_GET);
+
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request);
+ }
+
+ BaseRequest.addOptionalHeader(request, BlobConstants.SNAPSHOT, snapshotVersion);
+ return request;
+ }
+
+ /**
+ * Constructs a web request to return the user-defined metadata for this container. Sign with no length specified.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the container.
+ * @return a HttpURLConnection configured for the operation.
+ * @throws StorageException
+ * */
+ private static HttpURLConnection getProperties(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, AccessCondition accessCondition, final UriQueryBuilder builder)
+ throws IOException, URISyntaxException, StorageException {
+ HttpURLConnection request = BaseRequest.getProperties(uri, blobOptions, builder, opContext);
+
+ if (accessCondition != null && !Utility.isNullOrEmpty(accessCondition.getLeaseID())) {
+ BaseRequest.addLeaseId(request, accessCondition.getLeaseID());
+ }
+
+ return request;
+ }
+
+ /**
+ * Constructs a HttpURLConnection to Acquire,Release,Break, or Renew a blob/container lease. Sign with 0 length.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @param action
+ * the LeaseAction to perform
+ * @param proposedLeaseId
+ * A String
that represents the proposed lease ID for the new lease,
+ * or null if no lease ID is proposed.
+ * @param breakPeriodInSeconds
+ * Specifies the amount of time to allow the lease to remain, in seconds.
+ * If null, the break period is the remainder of the current lease, or zero for infinite leases.
+ * @param visibilityTimeoutInSeconds
+ * Specifies the the span of time for which to acquire the lease, in seconds.
+ * If null, an infinite lease will be acquired. If not null, this must be greater than zero.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ private static HttpURLConnection lease(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final LeaseAction action,
+ final Integer leaseTimeInSeconds, final String proposedLeaseId, final Integer breakPeriodInSeconds,
+ final UriQueryBuilder builder) throws IOException, URISyntaxException, StorageException {
+ final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
+
+ request.setDoOutput(true);
+ request.setRequestMethod(Constants.HTTP_PUT);
+ request.setFixedLengthStreamingMode(0);
+ request.setRequestProperty(HeaderConstants.LEASE_ACTION_HEADER, action.toString());
+
+ request.setRequestProperty(HeaderConstants.LEASE_DURATION, leaseTimeInSeconds == null ? "-1"
+ : leaseTimeInSeconds.toString());
+
+ if (proposedLeaseId != null) {
+ request.setRequestProperty(HeaderConstants.PROPOSED_LEASE_ID_HEADER, proposedLeaseId);
+ }
+
+ if (breakPeriodInSeconds != null) {
+ request.setRequestProperty(HeaderConstants.LEASE_BREAK_PERIOD_HEADER, breakPeriodInSeconds.toString());
+ }
+
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request);
+ }
+ return request;
+ }
+
+ /**
+ * Constructs a HttpURLConnection to Acquire,Release,Break, or Renew a blob lease. Sign with 0 length.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @param action
+ * the LeaseAction to perform
+ * @param proposedLeaseId
+ * A String
that represents the proposed lease ID for the new lease,
+ * or null if no lease ID is proposed.
+ * @param breakPeriodInSeconds
+ * Specifies the amount of time to allow the lease to remain, in seconds.
+ * If null, the break period is the remainder of the current lease, or zero for infinite leases.
+ * @param visibilityTimeoutInSeconds
+ * Specifies the the span of time for which to acquire the lease, in seconds.
+ * If null, an infinite lease will be acquired. If not null, this must be greater than zero.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection leaseBlob(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final LeaseAction action,
+ final Integer leaseTimeInSeconds, final String proposedLeaseId, final Integer breakPeriodInSeconds)
+ throws IOException, URISyntaxException, StorageException {
+ UriQueryBuilder builder = new UriQueryBuilder();
+ builder.add(Constants.QueryConstants.COMPONENT, BlobConstants.LEASE);
+
+ return lease(uri, blobOptions, opContext, accessCondition, action, leaseTimeInSeconds, proposedLeaseId,
+ breakPeriodInSeconds, builder);
+ }
+
+ /**
+ * Constructs a HttpURLConnection to Acquire,Release,Break, or Renew a container lease. Sign with 0 length.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the container.
+ * @param action
+ * the LeaseAction to perform
+ * @param proposedLeaseId
+ * A String
that represents the proposed lease ID for the new lease,
+ * or null if no lease ID is proposed.
+ * @param breakPeriodInSeconds
+ * Specifies the amount of time to allow the lease to remain, in seconds.
+ * If null, the break period is the remainder of the current lease, or zero for infinite leases.
+ * @param visibilityTimeoutInSeconds
+ * Specifies the the span of time for which to acquire the lease, in seconds.
+ * If null, an infinite lease will be acquired. If not null, this must be greater than zero.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection leaseContainer(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final LeaseAction action,
+ final Integer leaseTimeInSeconds, final String proposedLeaseId, final Integer breakPeriodInSeconds)
+ throws IOException, URISyntaxException, StorageException {
+
+ final UriQueryBuilder builder = getContainerUriQueryBuilder();
+ builder.add(Constants.QueryConstants.COMPONENT, BlobConstants.LEASE);
+
+ return lease(uri, blobOptions, opContext, accessCondition, action, leaseTimeInSeconds, proposedLeaseId,
+ breakPeriodInSeconds, builder);
+ }
+
+ /**
+ * Constructs a HttpURLConnection to list blobs. Sign with no length specified.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param listingContext
+ * A set of parameters for the listing operation.
+ * @return a HttpURLConnection configured for the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ * */
+ public static HttpURLConnection listBlobs(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final BlobListingContext listingContext) throws URISyntaxException,
+ IOException, StorageException {
+
+ final UriQueryBuilder builder = getContainerUriQueryBuilder();
+ builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.LIST);
+
+ if (listingContext != null) {
+ if (!Utility.isNullOrEmpty(listingContext.getPrefix())) {
+ builder.add(Constants.QueryConstants.PREFIX, listingContext.getPrefix());
+ }
+
+ if (!Utility.isNullOrEmpty(listingContext.getDelimiter())) {
+ builder.add(Constants.QueryConstants.DELIMITER, listingContext.getDelimiter());
+ }
+
+ if (!Utility.isNullOrEmpty(listingContext.getMarker())) {
+ builder.add(Constants.QueryConstants.MARKER, listingContext.getMarker());
+ }
+
+ if (listingContext.getMaxResults() != null && listingContext.getMaxResults() > 0) {
+ builder.add(Constants.QueryConstants.MAX_RESULTS, listingContext.getMaxResults().toString());
+ }
+
+ if (listingContext.getListingDetails().size() > 0) {
+ final StringBuilder sb = new StringBuilder();
+
+ boolean started = false;
+
+ if (listingContext.getListingDetails().contains(BlobListingDetails.SNAPSHOTS)) {
+ if (!started) {
+ started = true;
+ }
+ else {
+ sb.append(",");
+ }
+
+ sb.append(SNAPSHOTS_QUERY_ELEMENT_NAME);
+ }
+
+ if (listingContext.getListingDetails().contains(BlobListingDetails.UNCOMMITTED_BLOBS)) {
+ if (!started) {
+ started = true;
+ }
+ else {
+ sb.append(",");
+ }
+
+ sb.append(UNCOMMITTED_BLOBS_QUERY_ELEMENT_NAME);
+ }
+
+ if (listingContext.getListingDetails().contains(BlobListingDetails.COPY)) {
+ if (!started) {
+ started = true;
+ }
+ else {
+ sb.append(",");
+ }
+
+ sb.append(COPY_QUERY_ELEMENT_NAME);
+ }
+
+ if (listingContext.getListingDetails().contains(BlobListingDetails.METADATA)) {
+ if (!started) {
+ started = true;
+ }
+ else {
+ sb.append(",");
+ }
+
+ sb.append(Constants.QueryConstants.METADATA);
+ }
+
+ builder.add(Constants.QueryConstants.INCLUDE, sb.toString());
+ }
+ }
+
+ final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
+
+ request.setRequestMethod(Constants.HTTP_GET);
+
+ return request;
+ }
+
+ /**
+ * Constructs a request to return a listing of all containers in this storage account. Sign with no length
+ * specified.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param listingContext
+ * A set of parameters for the listing operation.
+ * @param detailsIncluded
+ * Additional details to return with the listing.
+ * @return a HttpURLConnection configured for the operation.
+ * @throws IOException
+ * @throws URISyntaxException
+ * @throws StorageException
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection listContainers(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final ListingContext listingContext,
+ final ContainerListingDetails detailsIncluded) throws URISyntaxException, IOException, StorageException {
+
+ final UriQueryBuilder builder = getContainerUriQueryBuilder();
+ builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.LIST);
+
+ if (listingContext != null) {
+ if (!Utility.isNullOrEmpty(listingContext.getPrefix())) {
+ builder.add(Constants.QueryConstants.PREFIX, listingContext.getPrefix());
+ }
+
+ if (!Utility.isNullOrEmpty(listingContext.getMarker())) {
+ builder.add(Constants.QueryConstants.MARKER, listingContext.getMarker());
+ }
+
+ if (listingContext.getMaxResults() != null && listingContext.getMaxResults() > 0) {
+ builder.add(Constants.QueryConstants.MAX_RESULTS, listingContext.getMaxResults().toString());
+ }
+ }
+
+ if (detailsIncluded == ContainerListingDetails.ALL || detailsIncluded == ContainerListingDetails.METADATA) {
+ builder.add(Constants.QueryConstants.INCLUDE, Constants.QueryConstants.METADATA);
+ }
+
+ final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
+
+ request.setRequestMethod(Constants.HTTP_GET);
+
+ return request;
+ }
+
+ /**
+ * Constructs a HttpURLConnection to upload a blob. Sign with blob length, or -1 for pageblob create.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @param properties
+ * The properties to set for the blob.
+ * @param blobType
+ * The type of the blob.
+ * @param pageBlobSize
+ * For a page blob, the size of the blob. This parameter is ignored for block blobs.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection putBlob(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final BlobProperties properties,
+ final BlobType blobType, final long pageBlobSize) throws IOException, URISyntaxException, StorageException {
+ if (blobType == BlobType.UNSPECIFIED) {
+ throw new IllegalArgumentException(SR.BLOB_TYPE_NOT_DEFINED);
+ }
+
+ final HttpURLConnection request = createURLConnection(uri, null, blobOptions, opContext);
+
+ request.setDoOutput(true);
+
+ request.setRequestMethod(Constants.HTTP_PUT);
+
+ addProperties(request, properties);
+
+ if (blobType == BlobType.PAGE_BLOB) {
+ request.setFixedLengthStreamingMode(0);
+ request.setRequestProperty(Constants.HeaderConstants.CONTENT_LENGTH, "0");
+
+ request.setRequestProperty(BlobConstants.BLOB_TYPE_HEADER, BlobConstants.PAGE_BLOB);
+ request.setRequestProperty(BlobConstants.SIZE, String.valueOf(pageBlobSize));
+
+ properties.setLength(pageBlobSize);
+ }
+ else {
+ request.setRequestProperty(BlobConstants.BLOB_TYPE_HEADER, BlobConstants.BLOCK_BLOB);
+ }
+
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request);
+ }
+
+ return request;
+ }
+
+ /**
+ * Constructs a HttpURLConnection to upload a block. Sign with length of block data.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @param blockId
+ * the Base64 ID for the block
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection putBlock(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final String blockId)
+ throws IOException, URISyntaxException, StorageException {
+ final UriQueryBuilder builder = new UriQueryBuilder();
+ builder.add(Constants.QueryConstants.COMPONENT, BLOCK_QUERY_ELEMENT_NAME);
+ builder.add(BLOCK_ID_QUERY_ELEMENT_NAME, blockId);
+
+ final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
+
+ request.setDoOutput(true);
+ request.setRequestMethod(Constants.HTTP_PUT);
+
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request);
+ }
+
+ return request;
+ }
+
+ /**
+ * Constructs a HttpURLConnection to write a blob by specifying the list of block IDs that make up the blob. Sign
+ * with length of block list data.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection putBlockList(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final BlobProperties properties)
+ throws IOException, URISyntaxException, StorageException {
+
+ final UriQueryBuilder builder = new UriQueryBuilder();
+ builder.add(Constants.QueryConstants.COMPONENT, BLOCK_LIST_QUERY_ELEMENT_NAME);
+
+ final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
+
+ request.setDoOutput(true);
+ request.setRequestMethod(Constants.HTTP_PUT);
+
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request);
+ }
+
+ addProperties(request, properties);
+
+ return request;
+ }
+
+ /**
+ * Constructs a HttpURLConnection to upload a page. Sign with page length for update, or 0 for clear.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @param properties
+ * the page properties
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection putPage(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final PageProperties properties)
+ throws IOException, URISyntaxException, StorageException {
+ final UriQueryBuilder builder = new UriQueryBuilder();
+ builder.add(Constants.QueryConstants.COMPONENT, PAGE_QUERY_ELEMENT_NAME);
+
+ final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
+
+ request.setDoOutput(true);
+ request.setRequestMethod(Constants.HTTP_PUT);
+
+ if (properties.getPageOperation() == PageOperationType.CLEAR) {
+ request.setFixedLengthStreamingMode(0);
+ }
+
+ // Page write is either update or clean; required
+ request.setRequestProperty(BlobConstants.PAGE_WRITE, properties.getPageOperation().toString());
+ request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, properties.getRange().toString());
+
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request);
+ }
+
+ return request;
+ }
+
+ /**
+ * Constructs a HttpURLConnection to set the page blob's size, Sign with zero length specified.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @param newBlobSize
+ * The new blob size, if the blob is a page blob. Set this parameter to null to keep the existing blob
+ * size.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection resize(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final Long newBlobSize)
+ throws IOException, URISyntaxException, StorageException {
+ final UriQueryBuilder builder = new UriQueryBuilder();
+ builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.PROPERTIES);
+
+ final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
+
+ request.setFixedLengthStreamingMode(0);
+ request.setDoOutput(true);
+ request.setRequestMethod(Constants.HTTP_PUT);
+
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request);
+ }
+
+ if (newBlobSize != null) {
+ request.setRequestProperty(BlobConstants.SIZE, newBlobSize.toString());
+ }
+
+ return request;
+ }
+
+ /**
+ * Sets the ACL for the container. Sign with length of aclBytes.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the container.
+ * @param publicAccess
+ * The type of public access to allow for the container.
+ * @return a HttpURLConnection configured for the operation.
+ * @throws StorageException
+ * */
+ public static HttpURLConnection setAcl(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition,
+ final BlobContainerPublicAccessType publicAccess) throws IOException, URISyntaxException, StorageException {
+ final UriQueryBuilder builder = getContainerUriQueryBuilder();
+ builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.ACL);
+
+ final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
+
+ request.setRequestMethod(Constants.HTTP_PUT);
+ request.setDoOutput(true);
+
+ if (publicAccess != BlobContainerPublicAccessType.OFF) {
+ request.setRequestProperty(BlobConstants.BLOB_PUBLIC_ACCESS_HEADER, publicAccess.toString().toLowerCase());
+ }
+
+ if (accessCondition != null && !Utility.isNullOrEmpty(accessCondition.getLeaseID())) {
+ BaseRequest.addLeaseId(request, accessCondition.getLeaseID());
+ }
+
+ return request;
+ }
+
+ /**
+ * Constructs a HttpURLConnection to set the blob's metadata, Sign with 0 length.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection setBlobMetadata(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition) throws IOException,
+ URISyntaxException, StorageException {
+ return setMetadata(uri, blobOptions, opContext, accessCondition, null);
+ }
+
+ /**
+ * Constructs a HttpURLConnection to set the blob's properties, Sign with zero length specified.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @param properties
+ * The properties to upload.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection setBlobProperties(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final BlobProperties properties)
+ throws IOException, URISyntaxException, StorageException {
+ final UriQueryBuilder builder = new UriQueryBuilder();
+ builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.PROPERTIES);
+
+ final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
+
+ request.setFixedLengthStreamingMode(0);
+ request.setDoOutput(true);
+ request.setRequestMethod(Constants.HTTP_PUT);
+
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request);
+ }
+
+ if (properties != null) {
+ addProperties(request, properties);
+ }
+
+ return request;
+ }
+
+ /**
+ * Constructs a web request to set user-defined metadata for the container, Sign with 0 Length.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the container.
+ * @return a HttpURLConnection configured for the operation.
+ * @throws StorageException
+ * */
+ public static HttpURLConnection setContainerMetadata(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition) throws IOException,
+ URISyntaxException, StorageException {
+ final UriQueryBuilder containerBuilder = getContainerUriQueryBuilder();
+ return setMetadata(uri, blobOptions, opContext, accessCondition, containerBuilder);
+ }
+
+ /**
+ * Constructs a HttpURLConnection to set the blob's metadata, Sign with 0 length.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ private static HttpURLConnection setMetadata(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition, final UriQueryBuilder builder)
+ throws IOException, URISyntaxException, StorageException {
+ final HttpURLConnection request = BaseRequest.setMetadata(uri, blobOptions, builder, opContext);
+
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request);
+ }
+
+ return request;
+ }
+
+ /**
+ * Constructs a HttpURLConnection to create a snapshot of the blob. Sign with 0 length.
+ *
+ * @param uri
+ * A URI
object that specifies the absolute URI.
+ * @param blobOptions
+ * A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
+ * settings for the operation. Specify null
to use the request options specified on the
+ * {@link CloudBlobClient}.
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the blob.
+ * @return a HttpURLConnection to use to perform the operation.
+ * @throws IOException
+ * if there is an error opening the connection
+ * @throws URISyntaxException
+ * if the resource URI is invalid
+ * @throws StorageException
+ * an exception representing any error which occurred during the operation.
+ * @throws IllegalArgumentException
+ */
+ public static HttpURLConnection snapshot(final URI uri, final BlobRequestOptions blobOptions,
+ final OperationContext opContext, final AccessCondition accessCondition) throws IOException,
+ URISyntaxException, StorageException {
+ final UriQueryBuilder builder = new UriQueryBuilder();
+ builder.add(Constants.QueryConstants.COMPONENT, BlobConstants.SNAPSHOT);
+ final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
+
+ request.setFixedLengthStreamingMode(0);
+ request.setDoOutput(true);
+ request.setRequestMethod(Constants.HTTP_PUT);
+
+ if (accessCondition != null) {
+ accessCondition.applyConditionToRequest(request);
+ }
+
+ return request;
+ }
+
+ /**
+ * Private Default Ctor
+ */
+ private BlobRequest() {
+ // No op
+ }
+}
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobRequestOptions.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobRequestOptions.java
similarity index 61%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobRequestOptions.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobRequestOptions.java
index b5c1898ff44f9..b62dc04a54626 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlobRequestOptions.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobRequestOptions.java
@@ -13,12 +13,12 @@
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage.blob;
+package com.microsoft.azure.storage.blob;
-import com.microsoft.windowsazure.storage.Constants;
-import com.microsoft.windowsazure.storage.RequestOptions;
-import com.microsoft.windowsazure.storage.core.SR;
-import com.microsoft.windowsazure.storage.core.Utility;
+import com.microsoft.azure.storage.Constants;
+import com.microsoft.azure.storage.RequestOptions;
+import com.microsoft.azure.storage.core.SR;
+import com.microsoft.azure.storage.core.Utility;
/**
* Represents a set of options that may be specified on a request.
@@ -118,16 +118,20 @@ protected static final BlobRequestOptions applyDefaults(final BlobRequestOptions
protected static final BlobRequestOptions applyDefaults(final BlobRequestOptions options, final BlobType blobType,
final CloudBlobClient client, final boolean setStartTime) {
BlobRequestOptions modifiedOptions = new BlobRequestOptions(options);
+ BlobRequestOptions.populateRequestOptions(modifiedOptions, client.getDefaultRequestOptions(), setStartTime);
return BlobRequestOptions.applyDefaultsInternal(modifiedOptions, blobType, client, setStartTime);
}
private static final BlobRequestOptions applyDefaultsInternal(final BlobRequestOptions modifiedOptions,
final BlobType blobtype, final CloudBlobClient client, final boolean setStartTime) {
Utility.assertNotNull("modifiedOptions", modifiedOptions);
- RequestOptions.applyBaseDefaultsInternal(modifiedOptions, client, setStartTime);
-
+ RequestOptions.applyBaseDefaultsInternal(modifiedOptions);
if (modifiedOptions.getConcurrentRequestCount() == null) {
- modifiedOptions.setConcurrentRequestCount(client.getConcurrentRequestCount());
+ modifiedOptions.setConcurrentRequestCount(BlobConstants.DEFAULT_CONCURRENT_REQUEST_COUNT);
+ }
+
+ if (modifiedOptions.getSingleBlobPutThresholdInBytes() == null) {
+ modifiedOptions.setSingleBlobPutThresholdInBytes(BlobConstants.DEFAULT_SINGLE_BLOB_PUT_THRESHOLD_IN_BYTES);
}
if (modifiedOptions.getUseTransactionalContentMD5() == null) {
@@ -142,14 +146,42 @@ private static final BlobRequestOptions applyDefaultsInternal(final BlobRequestO
modifiedOptions.setDisableContentMD5Validation(false);
}
+ return modifiedOptions;
+ }
+
+ /**
+ * Populates any null fields in the first requestOptions object with values from the second requestOptions object.
+ */
+ private static final BlobRequestOptions populateRequestOptions(BlobRequestOptions modifiedOptions,
+ final BlobRequestOptions clientOptions, final boolean setStartTime) {
+ RequestOptions.populateRequestOptions(modifiedOptions, clientOptions, setStartTime);
+ if (modifiedOptions.getConcurrentRequestCount() == null) {
+ modifiedOptions.setConcurrentRequestCount(clientOptions.getConcurrentRequestCount());
+ }
+
if (modifiedOptions.getSingleBlobPutThresholdInBytes() == null) {
- modifiedOptions.setSingleBlobPutThresholdInBytes(client.getSingleBlobPutThresholdInBytes());
+ modifiedOptions.setSingleBlobPutThresholdInBytes(clientOptions.getSingleBlobPutThresholdInBytes());
+ }
+
+ if (modifiedOptions.getUseTransactionalContentMD5() == null) {
+ modifiedOptions.setUseTransactionalContentMD5(clientOptions.getUseTransactionalContentMD5());
+ }
+
+ if (modifiedOptions.getStoreBlobContentMD5() == null) {
+ modifiedOptions.setStoreBlobContentMD5(clientOptions.getStoreBlobContentMD5());
+ }
+
+ if (modifiedOptions.getDisableContentMD5Validation() == null) {
+ modifiedOptions.setDisableContentMD5Validation(clientOptions.getDisableContentMD5Validation());
}
return modifiedOptions;
}
/**
+ * Gets the concurrent number of simultaneous requests per operation. For more information about concurrent request
+ * count defaults, see {@link #setConcurrentRequestCount(Integer)}.
+ *
* @return the concurrentRequestCount
*/
public Integer getConcurrentRequestCount() {
@@ -157,6 +189,10 @@ public Integer getConcurrentRequestCount() {
}
/**
+ * Gets whether a range PUT or GET operation will use the Content-MD5 header to enforce transactional security.
+ * All partial blob uploads or downloads will be restricted to 4 MB. For more information about transactional
+ * content MD5 defaults, see {@link #setUseTransactionalContentMD5(Boolean)}.
+ *
* @return the useTransactionalContentMD5
*/
public Boolean getUseTransactionalContentMD5() {
@@ -164,6 +200,10 @@ public Boolean getUseTransactionalContentMD5() {
}
/**
+ * Gets whether the blob's ContentMD5 header should be set on uploads. This field is not supported for page
+ * blobs. For more information about storing blob content MD5 defaults, see {@link #setStoreBlobContentMD5(Boolean)}
+ * .
+ *
* @return the storeBlobContentMD5
*/
public Boolean getStoreBlobContentMD5() {
@@ -171,25 +211,35 @@ public Boolean getStoreBlobContentMD5() {
}
/**
+ * Gets whether download and {@link BlobInputStream} methods should ignore the blob's ContentMD5 header. For more
+ * information about disabling content MD5 validation defaults, see {@link #setDisableContentMD5Validation(Boolean)}
+ * .
+ *
* @return the disableContentMD5Validation
*/
- protected Boolean getDisableContentMD5Validation() {
+ public Boolean getDisableContentMD5Validation() {
return this.disableContentMD5Validation;
}
/**
- * Returns the threshold size used for writing a single blob.
+ * Gets the threshold size used for writing a single blob. For more information about the threshold size defaults,
+ * see {@link #setSingleBlobPutThresholdInBytes(Integer)}.
*
* @return The maximum size, in bytes, of a blob that may be uploaded as a single blob, ranging from 1 to 64 MB
- * inclusive. The default value is 32 MBs.
- * false
. You can
+ * change the useTransactionalContentMD5 value on this request by setting this property. You can also change the
+ * value on the {@link BlobServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via
+ * the service client will use that useTransactionalContentMD5 value.
+ *
* @param useTransactionalContentMD5
* the useTransactionalContentMD5 to set
*/
@@ -206,6 +264,14 @@ public void setUseTransactionalContentMD5(final Boolean useTransactionalContentM
}
/**
+ * Sets whether the blob's ContentMD5 header should be set on uploads. This field is not supported for page
+ * blobs.
+ * true
for block blobs.
+ * You can change the storeBlobContentMD5 value on this request by setting this property. You can also change the
+ * value on the {@link BlobServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via
+ * the service client will use that storeBlobContentMD5 value.
+ *
* @param storeBlobContentMD5
* the storeBlobContentMD5 to set
*/
@@ -214,6 +280,13 @@ public void setStoreBlobContentMD5(final Boolean storeBlobContentMD5) {
}
/**
+ * Sets whether download and {@link BlobInputStream} methods should ignore the blob's ContentMD5 header.
+ * false
. You can
+ * change the disableContentMD5Validation value on this request by setting this property. You can also change the
+ * value on the {@link BlobServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via
+ * the service client will use that disableContentMD5Validation value.
+ *
* @param disableContentMD5Validation
* the disableContentMD5Validation to set
*/
@@ -223,6 +296,11 @@ public void setDisableContentMD5Validation(final Boolean disableContentMD5Valida
/**
* Sets the threshold size used for writing a single blob to use.
+ * BlobType
value corresponding to the string specified by typeString
.
*/
- public static BlobType parse(final String typeString) {
+ protected static BlobType parse(final String typeString) {
if (Utility.isNullOrEmpty(typeString)) {
return UNSPECIFIED;
}
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlockEntry.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlockEntry.java
similarity index 52%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlockEntry.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlockEntry.java
index 4988e946206b8..001899dbe3b48 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlockEntry.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlockEntry.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage.blob;
+package com.microsoft.azure.storage.blob;
/**
* A class which is used to list and commit blocks of a {@link CloudBlockBlob}.
@@ -31,10 +31,22 @@ public final class BlockEntry {
/**
* Represents the block search mode. The default value is {@link BlockSearchMode#LATEST}.
*/
- public BlockSearchMode searchMode = BlockSearchMode.LATEST;
+ private BlockSearchMode searchMode;
/**
- * Creates an instance of the BlockEntry
class.
+ * Creates an instance of the BlockEntry
class with the specified id and default search mode
+ * {@link BlockSearchMode#LATEST}.
+ *
+ * @param id
+ * A String
that represents the name of the block.
+ */
+ public BlockEntry(final String id) {
+ this.setId(id);
+ this.searchMode = BlockSearchMode.LATEST;
+ }
+
+ /**
+ * Creates an instance of the BlockEntry
class with the specified id and search mode.
*
* @param id
* A String
that represents the name of the block.
@@ -47,6 +59,10 @@ public BlockEntry(final String id, final BlockSearchMode searchMode) {
}
/**
+ * Gets the id of the block. The block id is a valid Base64 string value that identifies the block. Prior to
+ * encoding, the string must be less than or equal to 64 bytes in size. For a given blob, the length of the block id
+ * must be the same size for each block.
+ *
* @return the id
*/
public String getId() {
@@ -54,6 +70,8 @@ public String getId() {
}
/**
+ * Gets the size, in bytes, of the block.
+ *
* @return the size
*/
public long getSize() {
@@ -61,6 +79,19 @@ public long getSize() {
}
/**
+ * Gets the {@link BlockSearchMode}.
+ *
+ * @return the block search mode
+ */
+ public BlockSearchMode getSearchMode() {
+ return searchMode;
+ }
+
+ /**
+ * Sets the id of the block. The block id is a valid Base64 string value that identifies the block. Prior to
+ * encoding, the string must be less than or equal to 64 bytes in size. For a given blob, the length of the block id
+ * must be the same size for each block.
+ *
* @param id
* the id to set
*/
@@ -69,10 +100,22 @@ public void setId(final String id) {
}
/**
+ * Sets the size, in bytes, of the block.
+ *
* @param size
* the size to set
*/
public void setSize(final long size) {
this.size = size;
}
+
+ /**
+ * Sets the {@link BlockSearchMode}.
+ *
+ * @param searchMode
+ * the block search mode to set
+ */
+ public void setSearchMode(BlockSearchMode searchMode) {
+ this.searchMode = searchMode;
+ }
}
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlockEntryListSerializer.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlockEntryListSerializer.java
similarity index 86%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlockEntryListSerializer.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlockEntryListSerializer.java
index eb2398c27b346..7f00ef0d8a65a 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/BlockEntryListSerializer.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlockEntryListSerializer.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage.blob;
+package com.microsoft.azure.storage.blob;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
@@ -21,9 +21,9 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
-import com.microsoft.windowsazure.storage.OperationContext;
-import com.microsoft.windowsazure.storage.StorageException;
-import com.microsoft.windowsazure.storage.core.Utility;
+import com.microsoft.azure.storage.OperationContext;
+import com.microsoft.azure.storage.StorageException;
+import com.microsoft.azure.storage.core.Utility;
/**
* RESERVED FOR INTERNAL USE. A class used to serialize a block list to a byte array.
@@ -54,13 +54,13 @@ public static byte[] writeBlockListToStream(final IterableOutputStream
object that represents the target stream.
- *
- * @throws IOException
- * If an I/O exception occurred.
* @throws StorageException
* If a storage service error occurred.
*/
@DoesServiceRequest
- public final void download(final OutputStream outStream) throws StorageException, IOException {
+ public final void download(final OutputStream outStream) throws StorageException {
this.download(outStream, null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -1140,15 +1133,12 @@ public final void download(final OutputStream outStream) throws StorageException
* An {@link OperationContext} object that represents the context for the current operation. This object
* is used to track requests to the storage service, and to provide additional runtime information about
* the operation.
- *
- * @throws IOException
- * If an I/O exception occurred.
* @throws StorageException
* If a storage service error occurred.
*/
@DoesServiceRequest
public final void download(final OutputStream outStream, final AccessCondition accessCondition,
- BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException {
+ BlobRequestOptions options, OperationContext opContext) throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
}
@@ -1170,15 +1160,12 @@ public final void download(final OutputStream outStream, final AccessCondition a
* The number of bytes to read or null
.
* @param outStream
* An OutputStream
object that represents the target stream.
- *
- * @throws IOException
- * If an I/O exception occurred.
* @throws StorageException
* If a storage service error occurred.
*/
@DoesServiceRequest
public final void downloadRange(final long offset, final Long length, final OutputStream outStream)
- throws StorageException, IOException {
+ throws StorageException {
this.downloadRange(offset, length, outStream, null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -1201,16 +1188,13 @@ public final void downloadRange(final long offset, final Long length, final Outp
* An {@link OperationContext} object that represents the context for the current operation. This object
* is used to track requests to the storage service, and to provide additional runtime information about
* the operation.
- *
- * @throws IOException
- * If an I/O exception occurred.
* @throws StorageException
* If a storage service error occurred.
*/
@DoesServiceRequest
public final void downloadRange(final long offset, final Long length, final OutputStream outStream,
final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
- throws StorageException, IOException {
+ throws StorageException {
if (offset < 0 || (length != null && length <= 0)) {
throw new IndexOutOfBoundsException();
}
@@ -1234,9 +1218,9 @@ public final void downloadRange(final long offset, final Long length, final Outp
/**
* Populates a blob's properties and metadata.
* CloudBlobClient
class using the specified Blob service endpoint.
+ * Creates an instance of the CloudBlobClient
class using the specified Blob service endpoint and
+ * anonymous credentials.
*
* @param baseUri
* A java.net.URI
object that represents the Blob service endpoint used to create the
* client.
*/
public CloudBlobClient(final URI baseUri) {
- this(new StorageUri(baseUri), StorageCredentialsAnonymous.ANONYMOUS);
+ this(new StorageUri(baseUri), null /* credentials */);
+ }
+
+ /**
+ * Creates an instance of the CloudBlobClient
class using the specified Blob service endpoint and
+ * anonymous credentials.
+ *
+ * @param baseUri
+ * A {@link StorageUri} object that represents the Blob service endpoint used to create the
+ * client.
+ */
+ public CloudBlobClient(final StorageUri baseUri) {
+ this(baseUri, null /* credentials */);
}
/**
@@ -99,16 +108,26 @@ public CloudBlobClient(final URI baseUri, StorageCredentials credentials) {
*/
public CloudBlobClient(final StorageUri storageUri, StorageCredentials credentials) {
super(storageUri, credentials);
- this.directoryDelimiter = BlobConstants.DEFAULT_DELIMITER;
+ this.defaultRequestOptions = new BlobRequestOptions();
+ this.defaultRequestOptions.setLocationMode(LocationMode.PRIMARY_ONLY);
+ this.defaultRequestOptions.setRetryPolicyFactory(new RetryExponentialRetry());
+ this.defaultRequestOptions.setConcurrentRequestCount(BlobConstants.DEFAULT_CONCURRENT_REQUEST_COUNT);
+ this.defaultRequestOptions.setDisableContentMD5Validation(false);
+ this.defaultRequestOptions
+ .setSingleBlobPutThresholdInBytes(BlobConstants.DEFAULT_SINGLE_BLOB_PUT_THRESHOLD_IN_BYTES);
+ this.defaultRequestOptions.setUseTransactionalContentMD5(false);
}
/**
* Returns the number of maximum concurrent requests allowed.
*
* @return The number of maximum concurrent requests allowed.
+ *
+ * @deprecated use {@link #getDefaultRequestOptions().getConcurrentRequestCount()} instead.
*/
+ @Deprecated
public int getConcurrentRequestCount() {
- return this.concurrentRequestCount;
+ return this.defaultRequestOptions.getConcurrentRequestCount();
}
/**
@@ -124,8 +143,8 @@ public int getConcurrentRequestCount() {
* If the resource URI constructed based on the containerName is invalid.
* @throws StorageException
* If a storage service error occurred.
- * @see Naming and Referencing
- * Containers, Blobs, and Metadata
+ * @see Naming and Referencing Containers,
+ * Blobs, and Metadata
*/
public CloudBlobContainer getContainerReference(final String containerName) throws URISyntaxException,
StorageException {
@@ -148,9 +167,12 @@ public String getDirectoryDelimiter() {
* inclusive. The default value is 32 MBs.
* null
will use the default request options from the associated service client (
@@ -573,9 +596,12 @@ public void uploadServiceProperties(final ServiceProperties properties, BlobRequ
* @param concurrentRequestCount
* The value being assigned as the maximum number of concurrent requests allowed for the Blob service
* client.
+ *
+ * @deprecated use {@link #getDefaultRequestOptions().setConcurrentRequestCount()} instead.
*/
+ @Deprecated
public void setConcurrentRequestCount(final int concurrentRequestCount) {
- this.concurrentRequestCount = concurrentRequestCount;
+ this.defaultRequestOptions.setConcurrentRequestCount(concurrentRequestCount);
}
/**
@@ -598,13 +624,42 @@ public void setDirectoryDelimiter(final String directoryDelimiter) {
*
* @throws IllegalArgumentException
* If minimumReadSize
is less than 1 MB or greater than 64 MB.
+ *
+ * @deprecated use {@link #getDefaultRequestOptions().setSingleBlobPutThresholdInBytes()} instead.
*/
+ @Deprecated
public void setSingleBlobPutThresholdInBytes(final int singleBlobPutThresholdInBytes) {
- if (singleBlobPutThresholdInBytes > BlobConstants.MAX_SINGLE_UPLOAD_BLOB_SIZE_IN_BYTES
- || singleBlobPutThresholdInBytes < 1 * Constants.MB) {
- throw new IllegalArgumentException("SingleBlobUploadThresholdInBytes");
- }
+ this.defaultRequestOptions.setSingleBlobPutThresholdInBytes(singleBlobPutThresholdInBytes);
+ }
+
+ /**
+ * Gets the {@link BlobRequestOptions} that is used for requests associated with this CloudBlobClient
+ *
+ * @return
+ * The {@link BlobRequestOptions} object containing the values used by this CloudBlobClient
+ */
+ @Override
+ public BlobRequestOptions getDefaultRequestOptions() {
+ return this.defaultRequestOptions;
+ }
- this.singleBlobPutThresholdInBytes = singleBlobPutThresholdInBytes;
+ /**
+ * Sets the {@link BlobRequestOptions} that is used for any requests associated with this
+ * CloudBlobClient
object.
+ *
+ * @param defaultRequestOptions
+ * The BlobRequestOptions to use.
+ */
+ public void setDefaultRequestOptions(BlobRequestOptions defaultRequestOptions) {
+ Utility.assertNotNull("defaultRequestOptions", defaultRequestOptions);
+ this.defaultRequestOptions = defaultRequestOptions;
+ }
+
+ /**
+ * @return the usePathStyleUris
+ */
+ @Override
+ protected boolean isUsePathStyleUris() {
+ return super.isUsePathStyleUris();
}
}
diff --git a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/CloudBlobContainer.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/CloudBlobContainer.java
similarity index 91%
rename from microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/CloudBlobContainer.java
rename to microsoft-azure-storage/src/com/microsoft/azure/storage/blob/CloudBlobContainer.java
index 1e77f562a6a18..0b8d38438af16 100644
--- a/microsoft-azure-storage/src/main/java/com/microsoft/windowsazure/storage/blob/CloudBlobContainer.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/CloudBlobContainer.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.microsoft.windowsazure.storage.blob;
+package com.microsoft.azure.storage.blob;
import java.io.ByteArrayInputStream;
import java.io.StringWriter;
@@ -28,33 +28,34 @@
import javax.xml.stream.XMLStreamException;
-import com.microsoft.windowsazure.storage.AccessCondition;
-import com.microsoft.windowsazure.storage.Constants;
-import com.microsoft.windowsazure.storage.DoesServiceRequest;
-import com.microsoft.windowsazure.storage.OperationContext;
-import com.microsoft.windowsazure.storage.ResultContinuation;
-import com.microsoft.windowsazure.storage.ResultContinuationType;
-import com.microsoft.windowsazure.storage.ResultSegment;
-import com.microsoft.windowsazure.storage.StorageCredentialsSharedAccessSignature;
-import com.microsoft.windowsazure.storage.StorageErrorCode;
-import com.microsoft.windowsazure.storage.StorageErrorCodeStrings;
-import com.microsoft.windowsazure.storage.StorageException;
-import com.microsoft.windowsazure.storage.StorageUri;
-import com.microsoft.windowsazure.storage.core.ExecutionEngine;
-import com.microsoft.windowsazure.storage.core.LazySegmentedIterable;
-import com.microsoft.windowsazure.storage.core.PathUtility;
-import com.microsoft.windowsazure.storage.core.RequestLocationMode;
-import com.microsoft.windowsazure.storage.core.SR;
-import com.microsoft.windowsazure.storage.core.SegmentedStorageRequest;
-import com.microsoft.windowsazure.storage.core.SharedAccessPolicyDeserializer;
-import com.microsoft.windowsazure.storage.core.SharedAccessPolicySerializer;
-import com.microsoft.windowsazure.storage.core.SharedAccessSignatureHelper;
-import com.microsoft.windowsazure.storage.core.StorageRequest;
-import com.microsoft.windowsazure.storage.core.UriQueryBuilder;
-import com.microsoft.windowsazure.storage.core.Utility;
+import com.microsoft.azure.storage.AccessCondition;
+import com.microsoft.azure.storage.Constants;
+import com.microsoft.azure.storage.DoesServiceRequest;
+import com.microsoft.azure.storage.OperationContext;
+import com.microsoft.azure.storage.ResultContinuation;
+import com.microsoft.azure.storage.ResultContinuationType;
+import com.microsoft.azure.storage.ResultSegment;
+import com.microsoft.azure.storage.SharedAccessPolicyHandler;
+import com.microsoft.azure.storage.SharedAccessPolicySerializer;
+import com.microsoft.azure.storage.StorageCredentialsSharedAccessSignature;
+import com.microsoft.azure.storage.StorageErrorCode;
+import com.microsoft.azure.storage.StorageErrorCodeStrings;
+import com.microsoft.azure.storage.StorageException;
+import com.microsoft.azure.storage.StorageUri;
+import com.microsoft.azure.storage.core.ExecutionEngine;
+import com.microsoft.azure.storage.core.LazySegmentedIterable;
+import com.microsoft.azure.storage.core.PathUtility;
+import com.microsoft.azure.storage.core.RequestLocationMode;
+import com.microsoft.azure.storage.core.SR;
+import com.microsoft.azure.storage.core.SegmentedStorageRequest;
+import com.microsoft.azure.storage.core.SharedAccessSignatureHelper;
+import com.microsoft.azure.storage.core.StorageCredentialsHelper;
+import com.microsoft.azure.storage.core.StorageRequest;
+import com.microsoft.azure.storage.core.UriQueryBuilder;
+import com.microsoft.azure.storage.core.Utility;
/**
- * Represents a container in the Windows Azure Blob service.
+ * Represents a container in the Microsoft Azure Blob service.
* CloudBlobContainer
class using the specified URI. The blob URI should
+ * include a SAS token unless anonymous access is to be used.
+ *
+ * @param uri
+ * A java.net.URI
object that represents the URI of the container.
+ *
+ * @throws StorageException
+ * If a storage service error occurred.
+ * @throws URISyntaxException
+ * If the resource URI is invalid.
+ */
+ public CloudBlobContainer(final URI uri) throws URISyntaxException, StorageException {
+ this(new StorageUri(uri));
+ }
+
+ /**
+ * Creates an instance of the CloudBlobContainer
class using the specified URI. The blob URI should
+ * include a SAS token unless anonymous access is to be used.
+ *
+ * @param storageUri
+ * A StorageUri
object that represents the URI of the container.
+ *
+ * @throws StorageException
+ * If a storage service error occurred.
+ * @throws URISyntaxException
+ * If the resource URI is invalid.
+ */
+ public CloudBlobContainer(final StorageUri storageUri) throws URISyntaxException, StorageException {
+ this(storageUri, (CloudBlobClient) null /* client */);
+ }
+
/**
* Creates an instance of the CloudBlobContainer
class using the specified name and client.
*
@@ -142,8 +175,8 @@ private CloudBlobContainer(final CloudBlobClient client) {
* If a storage service error occurred.
* @throws URISyntaxException
* If the resource URI constructed based on the containerName is invalid.
- * @see Naming and Referencing
- * Containers, Blobs, and Metadata
+ * @see Naming and Referencing Containers,
+ * Blobs, and Metadata
*/
public CloudBlobContainer(final String containerName, final CloudBlobClient client) throws URISyntaxException,
StorageException {
@@ -161,7 +194,7 @@ public CloudBlobContainer(final String containerName, final CloudBlobClient clie
* Creates an instance of the CloudBlobContainer
class using the specified URI and client.
*
* @param uri
- * A java.net.URI
object that represents the URI of the container.
+ * A java.net.URI
object that represents the absolute URI of the container.
* @param client
* A {@link CloudBlobClient} object that represents the associated service client, and that specifies the
* endpoint for the Blob service.
@@ -179,7 +212,7 @@ public CloudBlobContainer(final URI uri, final CloudBlobClient client) throws UR
* Creates an instance of the CloudBlobContainer
class using the specified URI and client.
*
* @param storageUri
- * A StorageUri
object that represents the URI of the container.
+ * A StorageUri
object that represents the absolute URI of the container.
* @param client
* A {@link CloudBlobClient} object that represents the associated service client, and that specifies the
* endpoint for the Blob service.
@@ -197,8 +230,7 @@ public CloudBlobContainer(final StorageUri storageUri, final CloudBlobClient cli
this.storageUri = storageUri;
- boolean usePathStyleUris = client == null ? Utility.determinePathStyleFromUri(this.storageUri.getPrimaryUri(),
- null) : client.isUsePathStyleUris();
+ boolean usePathStyleUris = client == null ? Utility.determinePathStyleFromUri(this.storageUri.getPrimaryUri()) : client.isUsePathStyleUris();
this.name = PathUtility.getContainerNameFromUri(storageUri.getPrimaryUri(), usePathStyleUris);
@@ -251,15 +283,14 @@ private StorageRequestString
that represents the name of the virtual blob directory. If the root directory
* (the directory representing the container itself) is desired, use an empty string.
* @return A {@link CloudBlobDirectory} that represents a virtual blob directory within this container.
- *
- * @throws StorageException
- * If a storage service error occurred.
* @throws URISyntaxException
* If the resource URI is invalid.
*/
- public CloudBlobDirectory getDirectoryReference(String directoryName) throws URISyntaxException, StorageException {
+ public CloudBlobDirectory getDirectoryReference(String directoryName) throws URISyntaxException {
Utility.assertNotNull("directoryName", directoryName);
// if the directory name does not end in the delimiter, add the delimiter
@@ -866,7 +895,8 @@ public CloudBlobDirectory getDirectoryReference(String directoryName) throws URI
}
/**
- * Returns the metadata for the container.
+ * Returns the metadata for the container. This value is initialized with the metadata from the queue by a call to
+ * {@link #downloadAttributes}, and is set on the queue with a call to {@link #uploadMetadata}.
*
* @return A java.util.HashMap
object that represents the metadata for the container.
*/
@@ -888,7 +918,7 @@ public String getName() {
*
* @return A StorageUri
that represents the list of URIs for all locations..
*/
- public final StorageUri getStorageUri() {
+ public StorageUri getStorageUri() {
return this.storageUri;
}
@@ -983,19 +1013,7 @@ private String getSharedAccessCanonicalName() {
* If the resource URI is invalid.
*/
private StorageUri getTransformedAddress() throws URISyntaxException, StorageException {
- if (this.blobServiceClient.getCredentials().doCredentialsNeedTransformUri()) {
- if (this.getStorageUri().isAbsolute()) {
- return this.blobServiceClient.getCredentials().transformUri(this.storageUri);
- }
- else {
- final StorageException ex = Utility.generateNewUnexpectedStorageException(null);
- ex.getExtendedErrorInformation().setErrorMessage("Blob Object relative URIs not supported.");
- throw ex;
- }
- }
- else {
- return this.storageUri;
- }
+ return this.blobServiceClient.getCredentials().transformUri(this.storageUri);
}
/**
@@ -1012,11 +1030,9 @@ public URI getUri() {
*
* @return An enumerable collection of {@link ListBlobItem} objects retrieved lazily that represents the items in
* this container.
- * @throws StorageException
- * If a storage service error occurred.
*/
@DoesServiceRequest
- public Iterable