Skip to content

Commit

Permalink
Table Client commit
Browse files Browse the repository at this point in the history
* the table client
* relevant core updates
* table tests
* pom.xml is updated to reference apache commons lang
* Updating useragent to v1.1.2
  • Loading branch information
Joe Giardino authored and loudej committed Feb 28, 2012
1 parent 8d2258b commit 47e16c8
Show file tree
Hide file tree
Showing 46 changed files with 11,104 additions and 24 deletions.
10 changes: 10 additions & 0 deletions microsoft-azure-api/pom.xml
Expand Up @@ -80,6 +80,16 @@
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
</dependencies>

<build>
Expand Down
Expand Up @@ -40,9 +40,8 @@ public static AccessCondition generateEmptyCondition() {
* Returns an access condition such that an operation will be performed only if the resource's ETag value matches
* the specified ETag value.
* <p>
* Setting this access condition modifies the request to include the HTTP <i>If-Match</i> conditional header. If
* this access condition is set, the operation is performed only if the ETag of the resource matches the specified
* ETag.
* Setting this access condition modifies the request to include the HTTP <i>If-Match</i> conditional header. If this
* access condition is set, the operation is performed only if the ETag of the resource matches the specified ETag.
* <p>
* For more information, see <a href= 'http://go.microsoft.com/fwlink/?LinkID=224642&clcid=0x409'>Specifying
* Conditional Headers for Blob Service Operations</a>.
Expand Down Expand Up @@ -84,8 +83,8 @@ public static AccessCondition generateIfModifiedSinceCondition(final Date lastMo
* Returns an access condition such that an operation will be performed only if the resource's ETag value does not
* match the specified ETag value.
* <p>
* Setting this access condition modifies the request to include the HTTP <i>If-None-Match</i> conditional header.
* If this access condition is set, the operation is performed only if the ETag of the resource does not match the
* Setting this access condition modifies the request to include the HTTP <i>If-None-Match</i> conditional header. If
* this access condition is set, the operation is performed only if the ETag of the resource does not match the
* specified ETag.
* <p>
* For more information, see <a href= 'http://go.microsoft.com/fwlink/?LinkID=224642&clcid=0x409'>Specifying
Expand Down
Expand Up @@ -24,6 +24,7 @@
import com.microsoft.windowsazure.services.blob.client.CloudBlobClient;
import com.microsoft.windowsazure.services.core.storage.utils.Utility;
import com.microsoft.windowsazure.services.queue.client.CloudQueueClient;
import com.microsoft.windowsazure.services.table.client.CloudTableClient;

/**
* Represents a Windows Azure storage account.
Expand Down Expand Up @@ -538,6 +539,26 @@ public CloudQueueClient createCloudQueueClient() {
return new CloudQueueClient(this.getQueueEndpoint(), this.getCredentials());
}

/**
* Creates a new table service client.
*
* @return A client object that uses the Table service endpoint.
*/
public CloudTableClient createCloudTableClient() {
if (this.getTableEndpoint() == null) {
throw new IllegalArgumentException("No table endpoint configured.");
}

if (this.credentials == null) {
throw new IllegalArgumentException("No credentials provided.");
}

if (!this.credentials.canCredentialsSignRequest()) {
throw new IllegalArgumentException("CloudTableClient requires a credential that can sign request");
}
return new CloudTableClient(this.getTableEndpoint(), this.getCredentials());
}

/**
* Returns the endpoint for the Blob service, as configured for the storage account. This method is not supported
* when using shared access signature credentials.
Expand Down
Expand Up @@ -287,7 +287,7 @@ public static class HeaderConstants {
/**
* Specifies the value to use for UserAgent header.
*/
public static final String USER_AGENT_VERSION = "Client v0.1.1";
public static final String USER_AGENT_VERSION = "Client v0.1.2";
}

/**
Expand Down
Expand Up @@ -39,9 +39,9 @@ public class ResultSegment<T> {
private final int pageSize;

/**
* Holds the Iterable collection of results.
* Holds the ArrayList of results.
*/
private final Iterable<T> results;
private final ArrayList<T> results;

/**
* Reserved for internal use. Creates an instance of the <code>ResultSegment</code> class.
Expand Down Expand Up @@ -115,11 +115,11 @@ public int getRemainingPageResults() {
}

/**
* Returns an enumerable set of results from the blob service.
* Returns an enumerable set of results from the service.
*
* @return The results retrieved from the blob service.
* @return The results retrieved from the service.
*/
public Iterable<T> getResults() {
public ArrayList<T> getResults() {
return this.results;
}
}
Expand Up @@ -242,13 +242,13 @@ public void setRetryPolicyFactory(final RetryPolicyFactory retryPolicyFactory) {
/**
* Sets the timeout to use when making requests to the storage service.
* <p>
* 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
* 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
* 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#timeoutIntervalInMs} property.
*
* If you are downloading a large blob, you should increase the value of the timeout beyond the default value.
Expand Down
Expand Up @@ -39,8 +39,8 @@ public abstract class StorageCredentials {
* 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.
* {@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.
Expand Down Expand Up @@ -81,8 +81,8 @@ protected static StorageCredentials tryParseCredentials(final HashMap<String, St
* @param connectionString
* A <code>String</code> that contains the key/value pairs that represent the storage credentials.
* <p>
* The format for the connection string is in the pattern "<i>keyname=value</i>". Multiple key/value
* pairs can be separated by a semi-colon, for example, "<i>keyname1=value1;keyname2=value2</i>".
* The format for the connection string is in the pattern "<i>keyname=value</i>". Multiple key/value pairs
* can be separated by a semi-colon, for example, "<i>keyname1=value1;keyname2=value2</i>".
*
* @return A {@link StorageCredentials} object representing the storage credentials determined from the connection
* string.
Expand Down
Expand Up @@ -96,8 +96,8 @@ public String computeHmac256(final String value) {

/**
* Computes a signature for the specified string using the HMAC-SHA256 algorithm with the specified operation
* context. This is not a valid operation for objects of type <code>StorageCredentialsSharedAccessSignature</code>
* so the method merely returns <code>null</code>.
* context. This is not a valid operation for objects of type <code>StorageCredentialsSharedAccessSignature</code> so
* the method merely returns <code>null</code>.
*
* @param value
* The UTF-8-encoded string to sign.
Expand Down Expand Up @@ -130,8 +130,8 @@ public String computeHmac512(final String value) {

/**
* Computes a signature for the specified string using the HMAC-SHA512 algorithm with the specified operation
* context. This is not a valid operation for objects of type <code>StorageCredentialsSharedAccessSignature</code>
* so the method merely returns <code>null</code>.
* context. This is not a valid operation for objects of type <code>StorageCredentialsSharedAccessSignature</code> so
* the method merely returns <code>null</code>.
*
* @param value
* The UTF-8-encoded string to sign.
Expand Down
Expand Up @@ -188,6 +188,11 @@ public final class StorageErrorCodeStrings {
*/
public static final String SERVER_BUSY = "ServerBusy";

/**
* Table Already Exists
*/
public static final String TABLE_ALREADY_EXISTS = "TableAlreadyExists";

/**
* One or more header values are not supported.
*/
Expand Down
Expand Up @@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.microsoft.windowsazure.services.core.storage.utils.implementation;

import java.io.IOException;
Expand All @@ -34,6 +35,7 @@
import com.microsoft.windowsazure.services.core.storage.RetryResult;
import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings;
import com.microsoft.windowsazure.services.core.storage.StorageException;
import com.microsoft.windowsazure.services.table.client.TableServiceException;

/**
* RESERVED FOR INTERNAL USE. A class that handles execution of StorageOperations and enforces retry policies.
Expand Down Expand Up @@ -166,6 +168,17 @@ public static <CLIENT_TYPE, PARENT_TYPE, RESULT_TYPE> RESULT_TYPE executeWithRet
setLastException(opContext, translatedException);
throw translatedException;
}
catch (final TableServiceException e) {
task.getResult().setStatusCode(e.getHttpStatusCode());
task.getResult().setStatusMessage(e.getMessage());
setLastException(opContext, e);
if (!e.isRetryable()) {
throw e;
}
else {
translatedException = e;
}
}
catch (final StorageException e) {
// Non Retryable, just throw
// do not translate StorageException
Expand Down
Expand Up @@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.microsoft.windowsazure.services.core.storage.utils.implementation;

import java.io.InputStream;
Expand Down

0 comments on commit 47e16c8

Please sign in to comment.