From 671e917d4b8917d0b4ae6fa49da95812e3654f37 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 8 May 2013 15:33:27 -0700 Subject: [PATCH 01/48] message count details. --- .../implementation/ServiceBusRestProxy.java | 2 +- .../services/serviceBus/models/QueueInfo.java | 5 +++ .../serviceBus/models/SubscriptionInfo.java | 5 +++ .../services/serviceBus/models/TopicInfo.java | 5 +++ ...netservices.2010.10.servicebus.connect.xsd | 31 ++++++++++++++++ .../serviceBus/ServiceBusIntegrationTest.java | 35 +++++++++++++++++++ 6 files changed, 82 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 05e12f33bfac6..482d26a741990 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -110,7 +110,7 @@ public void setChannel(Client channel) { } private WebResource getResource() { - WebResource resource = getChannel().resource(uri); + WebResource resource = getChannel().resource(uri).queryParam("api-version", "2012-08"); for (ServiceFilter filter : filters) { resource.addFilter(new ClientFilterAdapter(filter)); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index 8cc7a1efde54b..732536aa7373a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -24,6 +24,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.EntityStatus; import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; +import com.microsoft.windowsazure.services.serviceBus.implementation.MessageCountDetails; import com.microsoft.windowsazure.services.serviceBus.implementation.PartitioningPolicy; import com.microsoft.windowsazure.services.serviceBus.implementation.QueueDescription; @@ -538,4 +539,8 @@ public QueueInfo setUserMetadata(String userMetadata) { getModel().setUserMetadata(userMetadata); return this; } + + public MessageCountDetails getCountDetails() { + return getModel().getCountDetails(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java index 04263c1115036..7bd3637e47d3b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java @@ -24,6 +24,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.EntityStatus; import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; +import com.microsoft.windowsazure.services.serviceBus.implementation.MessageCountDetails; import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; import com.microsoft.windowsazure.services.serviceBus.implementation.SubscriptionDescription; @@ -430,4 +431,8 @@ public EntityAvailabilityStatus getEntityAvailabilityStatus() { return getModel().getEntityAvailabilityStatus(); } + public MessageCountDetails getCountDetails() { + return getModel().getCountDetails(); + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java index 41be6a80acd38..60701a7c57ff6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java @@ -24,6 +24,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.EntityStatus; import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; +import com.microsoft.windowsazure.services.serviceBus.implementation.MessageCountDetails; import com.microsoft.windowsazure.services.serviceBus.implementation.PartitioningPolicy; import com.microsoft.windowsazure.services.serviceBus.implementation.TopicDescription; @@ -405,6 +406,10 @@ public Integer getSubscriptionCount() { return getModel().getSubscriptionCount(); } + public MessageCountDetails getCountDetails() { + return getModel().getCountDetails(); + } + /** * Sets the auto delete on idle. * diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index ff5f9bb9359a8..a9a1de46cfdc2 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -150,6 +150,13 @@ + + + + + + + @@ -274,6 +281,13 @@ + + + + + + + @@ -362,6 +376,16 @@ + + + + + + + + + + @@ -532,6 +556,13 @@ + + + + + + + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index a8c20cce470f2..b00abc8a5ac34 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -36,6 +36,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.CorrelationFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.EmptyRuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.FalseFilter; +import com.microsoft.windowsazure.services.serviceBus.implementation.MessageCountDetails; import com.microsoft.windowsazure.services.serviceBus.implementation.SqlFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.SqlRuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.TrueFilter; @@ -170,6 +171,40 @@ public void sendMessageWorks() throws Exception { // Assert } + @Test + public void getQueueMessageCountDetails() throws Exception { + // Arrange + String queueName = "testGetQueueMessageCountDetails"; + service.createQueue(new QueueInfo(queueName)); + service.sendQueueMessage(queueName, new BrokeredMessage("Hello World")); + Long expectedActiveMessageCount = 1L; + + // Act + QueueInfo queueInfo = service.getQueue(queueName).getValue(); + MessageCountDetails countDetails = queueInfo.getCountDetails(); + + // Assert + assertEquals(true, queueInfo.isSupportOrdering()); + assertNotNull(countDetails); + assertEquals(expectedActiveMessageCount, countDetails.getActiveMessageCount()); + + } + + @Test + public void getTopicMessageCountDetails() throws Exception { + // Arrange + + // Act + + // Assert + + } + + @Test + public void getSubscriptionMessageCountDetails() throws Exception { + + } + @Test public void receiveMessageWorks() throws Exception { // Arrange From 5a65fb23df43d94795696b44860bdec17533cdcc Mon Sep 17 00:00:00 2001 From: veudayab Date: Thu, 9 May 2013 13:19:42 -0700 Subject: [PATCH 02/48] Test commit --- .../windowsazure/services/blob/client/BlobTestBase.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java index cba0245c4270c..a2cc575d3a7b0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java @@ -30,7 +30,7 @@ */ public class BlobTestBase { public static boolean USE_DEV_FABRIC = false; - public static final String CLOUD_ACCOUNT_HTTP = "DefaultEndpointsProtocol=https;AccountName=[ACCOUNT NAME];AccountKey=[ACCOUNT KEY]"; + public static final String CLOUD_ACCOUNT_HTTP = "DefaultEndpointsProtocol=http;AccountName=[ACCOUNT NAME];AccountKey=[ACCOUNT KEY]"; public static final String CLOUD_ACCOUNT_HTTPS = "DefaultEndpointsProtocol=https;AccountName=[ACCOUNT NAME];AccountKey=[ACCOUNT KEY]"; protected static CloudStorageAccount httpAcc; @@ -45,8 +45,9 @@ public static void setup() throws URISyntaxException, StorageException, InvalidK } else { String cloudAccount = CLOUD_ACCOUNT_HTTP; - cloudAccount = cloudAccount.replace("[ACCOUNT NAME]", System.getenv("blob.accountName")); - cloudAccount = cloudAccount.replace("[ACCOUNT KEY]", System.getenv("blob.accountKey")); + cloudAccount = cloudAccount.replace("[ACCOUNT NAME]", "jaidb3"); + cloudAccount = cloudAccount.replace("[ACCOUNT KEY]", + "+qjm/8MjakncuZwpjNfYtaKDHrJH3zkQAKDywuTNh9hdb3ETcQ4wweVdX3nzFsXsWkI5la8EZg04PIbPkWrWBQ=="); httpAcc = CloudStorageAccount.parse(cloudAccount); } From e4d4e21b47ed19b306a2c5573afb9c1d3f393583 Mon Sep 17 00:00:00 2001 From: veudayab Date: Thu, 9 May 2013 13:24:04 -0700 Subject: [PATCH 03/48] Include HttpURLConnection in the executor task to drain the response after every request --- .../services/blob/client/CloudBlob.java | 19 ++++++++++++++- .../services/blob/client/CloudBlobClient.java | 1 + .../blob/client/CloudBlobContainer.java | 15 ++++++++++++ .../services/blob/client/CloudBlockBlob.java | 4 ++++ .../services/blob/client/CloudPageBlob.java | 3 +++ .../storage/AccessPolicyResponseBase.java | 6 ----- .../services/core/storage/utils/Utility.java | 9 +++++-- .../utils/implementation/ExecutionEngine.java | 21 +++++++++++++++- .../implementation/StorageOperation.java | 24 +++++++++++++++++-- .../services/queue/client/CloudQueue.java | 15 ++++++++++++ .../queue/client/CloudQueueClient.java | 1 + .../services/table/client/CloudTable.java | 2 ++ .../table/client/CloudTableClient.java | 19 ++++++--------- .../table/client/QueryTableOperation.java | 10 +++----- .../table/client/TableBatchOperation.java | 23 ++++++++---------- .../services/table/client/TableOperation.java | 13 +++++----- 16 files changed, 134 insertions(+), 51 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index 84e345591cc55..10193bc590c65 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -295,7 +295,7 @@ public String execute(final CloudBlobClient client, final CloudBlob blob, final final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.ACQUIRE, leaseTimeInSeconds, proposedLeaseId, null, accessCondition, blobOptions, opContext); - + this.setConnection(request); client.getCredentials().signRequest(request, 0L); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -407,6 +407,7 @@ public Long execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.BREAK, null, null, breakPeriodInSeconds, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, 0L); @@ -540,6 +541,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.copyFrom(blob.getTransformedAddress(opContext), blobOptions.getTimeoutIntervalInMs(), source.toString(), blob.snapshotID, sourceAccessCondition, destinationAccessCondition, blobOptions, opContext); + this.setConnection(request); BlobRequest.addMetadata(request, blob.metadata, opContext); client.getCredentials().signRequest(request, 0); @@ -620,6 +622,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.abortCopy(blob.getTransformedAddress(opContext), blobOptions.getTimeoutIntervalInMs(), copyId, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, 0); @@ -695,6 +698,7 @@ public CloudBlob execute(final CloudBlobClient client, final CloudBlob blob, final HttpURLConnection request = BlobRequest.snapshot(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, 0L); @@ -784,6 +788,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.delete(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), blob.snapshotID, deleteSnapshotsOption, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -875,6 +880,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlob blob, final final HttpURLConnection request = BlobRequest.delete(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), blob.snapshotID, deleteSnapshotsOption, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -959,6 +965,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.get(blob.getTransformedAddress(opContext), blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext, this.getResult()); @@ -1137,6 +1144,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.getProperties(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -1290,6 +1298,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.get(blob.getTransformedAddress(opContext), blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, blobOffset, length, accessCondition, blobOptions, opContext); + this.setConnection(request); if (blobOptions.getUseTransactionalContentMD5()) { request.setRequestProperty(Constants.HeaderConstants.RANGE_GET_CONTENT_MD5, "true"); @@ -1430,6 +1439,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlob blob, final final HttpURLConnection request = BlobRequest.getProperties(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -1917,6 +1927,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.RELEASE, null, null, null, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, 0L); @@ -1997,6 +2008,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.RENEW, null, null, null, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, 0L); @@ -2086,6 +2098,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.CHANGE, null, proposedLeaseId, null, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, 0L); @@ -2213,6 +2226,7 @@ public Long execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.BREAK, null, null, null, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, 0L); @@ -2351,6 +2365,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.put(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), blob.properties, blob.properties.getBlobType(), 0, accessCondition, blobOptions, opContext); + this.setConnection(request); BlobRequest.addMetadata(request, blob.metadata, opContext); @@ -2436,6 +2451,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.setMetadata(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), accessCondition, blobOptions, opContext); + this.setConnection(request); BlobRequest.addMetadata(request, blob.metadata, opContext); client.getCredentials().signRequest(request, 0L); @@ -2510,6 +2526,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.setProperties(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), blob.properties, null, accessCondition, blobOptions, opContext); + this.setConnection(request); BlobRequest.addMetadata(request, blob.metadata, opContext); client.getCredentials().signRequest(request, 0L); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java index c000b97c98edc..4a85876d6c987 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java @@ -385,6 +385,7 @@ ResultSegment listContainersCore(final String prefix, final HttpURLConnection listContainerRequest = ContainerRequest.list(this.getEndpoint(), options.getTimeoutIntervalInMs(), listingContext, detailsIncluded, opContext); + taskReference.setConnection(listContainerRequest); this.getCredentials().signRequest(listContainerRequest, -1L); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java index b1d1a7a6c8db1..0465a0e5d0345 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java @@ -220,6 +220,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta final OperationContext opContext) throws Exception { final HttpURLConnection request = ContainerRequest.create(container.uri, this.getRequestOptions() .getTimeoutIntervalInMs(), opContext); + this.setConnection(request); ContainerRequest.addMetadata(request, container.metadata, opContext); client.getCredentials().signRequest(request, 0L); @@ -294,6 +295,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlobContainer co final OperationContext opContext) throws Exception { final HttpURLConnection request = ContainerRequest.create(container.uri, this.getRequestOptions() .getTimeoutIntervalInMs(), opContext); + this.setConnection(request); ContainerRequest.addMetadata(request, container.metadata, opContext); client.getCredentials().signRequest(request, 0L); @@ -387,6 +389,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta final HttpURLConnection request = ContainerRequest.delete(container.uri, this.getRequestOptions() .getTimeoutIntervalInMs(), opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -457,6 +460,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlobContainer co final HttpURLConnection request = ContainerRequest.delete(container.uri, this.getRequestOptions() .getTimeoutIntervalInMs(), opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -530,6 +534,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta final OperationContext opContext) throws Exception { final HttpURLConnection request = ContainerRequest.getProperties(container.uri, this .getRequestOptions().getTimeoutIntervalInMs(), opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -607,6 +612,7 @@ public BlobContainerPermissions execute(final CloudBlobClient client, final Clou final HttpURLConnection request = ContainerRequest.getAcl(container.uri, this.getRequestOptions() .getTimeoutIntervalInMs(), opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -686,6 +692,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlobContainer co final OperationContext opContext) throws Exception { final HttpURLConnection request = ContainerRequest.getProperties(container.uri, this .getRequestOptions().getTimeoutIntervalInMs(), opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -1105,6 +1112,7 @@ ResultSegment listBlobsCore(final String prefix, final boolean use final HttpURLConnection listBlobsRequest = BlobRequest.list(this.getTransformedAddress(), options.getTimeoutIntervalInMs(), listingContext, options, opContext); + taskReference.setConnection(listBlobsRequest); this.blobServiceClient.getCredentials().signRequest(listBlobsRequest, -1L); @@ -1529,6 +1537,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta final HttpURLConnection request = ContainerRequest.setMetadata(container.uri, this.getRequestOptions() .getTimeoutIntervalInMs(), opContext); + this.setConnection(request); ContainerRequest.addMetadata(request, container.metadata, opContext); client.getCredentials().signRequest(request, 0L); @@ -1603,6 +1612,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta final HttpURLConnection request = ContainerRequest.setAcl(container.uri, this.getRequestOptions() .getTimeoutIntervalInMs(), permissions.getPublicAccess(), opContext); + this.setConnection(request); final StringWriter outBuffer = new StringWriter(); @@ -1707,6 +1717,7 @@ public String execute(final CloudBlobClient client, final CloudBlobContainer con final HttpURLConnection request = ContainerRequest.lease(container.uri, this.getRequestOptions() .getTimeoutIntervalInMs(), LeaseAction.ACQUIRE, leaseTimeInSeconds, proposedLeaseId, null, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, 0L); @@ -1789,6 +1800,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta final HttpURLConnection request = ContainerRequest.lease(container.uri, this.getRequestOptions() .getTimeoutIntervalInMs(), LeaseAction.RENEW, null, null, null, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, 0L); @@ -1871,6 +1883,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta final HttpURLConnection request = ContainerRequest.lease(container.uri, this.getRequestOptions() .getTimeoutIntervalInMs(), LeaseAction.RELEASE, null, null, null, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, 0L); @@ -1956,6 +1969,7 @@ public Long execute(final CloudBlobClient client, final CloudBlobContainer conta final HttpURLConnection request = ContainerRequest.lease(container.uri, this.getRequestOptions() .getTimeoutIntervalInMs(), LeaseAction.BREAK, null, null, breakPeriodInSeconds, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, 0L); @@ -2048,6 +2062,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta final HttpURLConnection request = ContainerRequest.lease(container.uri, this.getRequestOptions() .getTimeoutIntervalInMs(), LeaseAction.CHANGE, null, proposedLeaseId, null, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, 0L); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java index 9ee73d83c1d15..91ad867eac9b8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java @@ -184,6 +184,8 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.putBlockList(blob.getTransformedAddress(opContext), blobOptions.getTimeoutIntervalInMs(), blob.properties, accessCondition, blobOptions, opContext); + this.setConnection(request); + BlobRequest.addMetadata(request, blob.metadata, opContext); // Potential optimization, we can write this stream outside of @@ -290,6 +292,7 @@ public ArrayList execute(final CloudBlobClient client, final CloudBl final HttpURLConnection request = BlobRequest.getBlockList(blob.getTransformedAddress(opContext), blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, blockListingFilter, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -615,6 +618,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.putBlock(blob.getTransformedAddress(opContext), blobOptions.getTimeoutIntervalInMs(), blockId, accessCondition, blobOptions, opContext); + this.setConnection(request); if (blobOptions.getUseTransactionalContentMD5()) { request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, md5); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java index d81af25c62672..90ef8038334a9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java @@ -267,6 +267,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.put(blob.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), blob.properties, BlobType.PAGE_BLOB, length, accessCondition, blobOptions, opContext); + this.setConnection(request); BlobRequest.addMetadata(request, blob.metadata, opContext); @@ -349,6 +350,7 @@ public ArrayList execute(final CloudBlobClient client, final CloudBlo final HttpURLConnection request = BlobRequest.getPageRanges(blob.getTransformedAddress(opContext), blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -471,6 +473,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final HttpURLConnection request = BlobRequest.putPage(blob.getTransformedAddress(opContext), blobOptions.getTimeoutIntervalInMs(), pageProperties, accessCondition, blobOptions, opContext); + this.setConnection(request); if (pageProperties.getPageOperation() == PageOperationType.UPDATE) { if (blobOptions.getUseTransactionalContentMD5()) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessPolicyResponseBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessPolicyResponseBase.java index 7d03cb86b6776..a1c748afcad10 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessPolicyResponseBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessPolicyResponseBase.java @@ -94,15 +94,9 @@ public void parseResponse() throws XMLStreamException, ParseException { if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.SIGNED_IDENTIFIERS_ELEMENT)) { this.readPolicies(xmlr); - } - else if (eventType == XMLStreamConstants.END_ELEMENT - && name.equals(Constants.SIGNED_IDENTIFIERS_ELEMENT)) { break; } } - else if (eventType == XMLStreamConstants.END_DOCUMENT) { - break; - } } this.isParsed = true; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java index 37c099517e7d9..54e66cd05b83c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java @@ -1015,7 +1015,10 @@ public static StreamMd5AndLength writeToOutputStream(final InputStream sourceStr count = sourceStream.read(retrievedBuff, 0, nextCopy); while (nextCopy > 0 && count != -1) { - outStream.write(retrievedBuff, 0, count); + if (outStream != null) { + outStream.write(retrievedBuff, 0, count); + } + if (calculateMD5) { opContext.getIntermediateMD5().update(retrievedBuff, 0, count); } @@ -1029,7 +1032,9 @@ public static StreamMd5AndLength writeToOutputStream(final InputStream sourceStr count = sourceStream.read(retrievedBuff, 0, nextCopy); } - outStream.flush(); + if (outStream != null) { + outStream.flush(); + } if (calculateMD5) { retVal.setDigest(opContext.getIntermediateMD5()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java index 9d3ad41e569ab..9e60f511677bd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java @@ -36,6 +36,7 @@ import com.microsoft.windowsazure.services.core.storage.SendingRequestEvent; import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; import com.microsoft.windowsazure.services.table.client.TableServiceException; /** @@ -113,7 +114,25 @@ public static RESULT_TYPE executeWithRet opContext.setClientTimeInMs(new Date().getTime() - startTime); if (!task.isNonExceptionedRetryableFailure()) { - // Success return result, the rest of the return paths throw. + // Success return result and drain the input stream. + HttpURLConnection request = task.getConnection(); + if ((task.getResult().getStatusCode() >= 200) && (task.getResult().getStatusCode() < 300)) { + if (request != null) { + InputStream inStream = request.getInputStream(); + try { + Utility.writeToOutputStream(inStream, null, -1, false, false, task.getResult(), null); + } + // At this point, we already have a result / exception to return to the user. + // This is just an optimization to improve socket reuse. + catch (final IOException ex) { + } + catch (StorageException e) { + } + finally { + inStream.close(); + } + } + } return result; } else { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java index 803bbdfa5481c..a18d41dc19dd7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java @@ -39,7 +39,7 @@ public abstract class StorageOperation { private StorageException exceptionReference; /** - * A flag to indicate a failure which did not result in an exceptin, i.e a 400 class status code. + * A flag to indicate a failure which did not result in an exception, i.e a 400 class status code. */ private boolean nonExceptionedRetryableFailure; @@ -53,6 +53,11 @@ public abstract class StorageOperation { */ private RequestResult result; + /** + * Holds the url connection for the operation. + */ + private HttpURLConnection connection; + /** * Default Ctor. */ @@ -106,6 +111,13 @@ public final RequestResult getResult() { return this.result; } + /** + * @return the URL connection + */ + public final HttpURLConnection getConnection() { + return this.connection; + } + /** * Resets the operation status flags between operations. */ @@ -126,7 +138,7 @@ public final boolean isNonExceptionedRetryableFailure() { } /** - * Returns either the held exception from the operation if it is set, othwerwise the translated exception. + * Returns either the held exception from the operation if it is set, otherwise the translated exception. * * @param request * the reference to the HttpURLConnection for the operation. @@ -174,4 +186,12 @@ protected final void setRequestOptions(final RequestOptions requestOptions) { public final void setResult(final RequestResult result) { this.result = result; } + + /** + * @param connection + * the connection to set + */ + public final void setConnection(final HttpURLConnection connection) { + this.connection = connection; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java index c29f1067844c6..15b646e336519 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -213,6 +213,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final final HttpURLConnection request = QueueRequest.putMessage(queue.getMessageRequestAddress(opContext), this.getRequestOptions().getTimeoutIntervalInMs(), initialVisibilityDelayInSeconds, timeToLiveInSeconds, opContext); + this.setConnection(request); final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); @@ -283,6 +284,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final final HttpURLConnection request = QueueRequest.clearMessages(queue.getMessageRequestAddress(opContext), this.getRequestOptions().getTimeoutIntervalInMs(), opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -347,6 +349,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final throws Exception { final HttpURLConnection request = QueueRequest.create(queue.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), opContext); + this.setConnection(request); QueueRequest.addMetadata(request, queue.metadata, opContext); client.getCredentials().signRequest(request, 0L); @@ -420,6 +423,7 @@ public Boolean execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) throws Exception { final HttpURLConnection request = QueueRequest.create(queue.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), opContext); + this.setConnection(request); QueueRequest.addMetadata(request, queue.metadata, opContext); client.getCredentials().signRequest(request, 0L); @@ -506,6 +510,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final throws Exception { final HttpURLConnection request = QueueRequest.delete(queue.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -577,6 +582,7 @@ public Boolean execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) throws Exception { final HttpURLConnection request = QueueRequest.delete(queue.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -664,6 +670,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final final HttpURLConnection request = QueueRequest.deleteMessage(queue.getIndividualMessageAddress( messageId, opContext), this.getRequestOptions().getTimeoutIntervalInMs(), messagePopReceipt, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -730,6 +737,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final final HttpURLConnection request = QueueRequest.downloadAttributes( queue.getTransformedAddress(opContext), this.getRequestOptions().getTimeoutIntervalInMs(), opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -803,6 +811,7 @@ public Boolean execute(final CloudQueueClient client, final CloudQueue queue, final HttpURLConnection request = QueueRequest.downloadAttributes( queue.getTransformedAddress(opContext), this.getRequestOptions().getTimeoutIntervalInMs(), opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -1018,6 +1027,7 @@ public ArrayList execute(final CloudQueueClient client, final final HttpURLConnection request = QueueRequest.peekMessages(queue.getMessageRequestAddress(opContext), this.getRequestOptions().getTimeoutIntervalInMs(), numberOfMessages, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -1152,6 +1162,7 @@ public ArrayList execute(final CloudQueueClient client, final final HttpURLConnection request = QueueRequest.retrieveMessages( queue.getMessageRequestAddress(opContext), this.getRequestOptions().getTimeoutIntervalInMs(), numberOfMessages, visibilityTimeoutInSeconds, opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); @@ -1280,6 +1291,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final final HttpURLConnection request = QueueRequest.updateMessage(queue.getIndividualMessageAddress( message.getId(), opContext), this.getRequestOptions().getTimeoutIntervalInMs(), message .getPopReceipt(), visibilityTimeoutInSeconds, opContext); + this.setConnection(request); if (messageUpdateFields.contains(MessageUpdateFields.CONTENT)) { final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); @@ -1362,6 +1374,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final final HttpURLConnection request = QueueRequest.setMetadata(queue.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), opContext); + this.setConnection(request); QueueRequest.addMetadata(request, queue.metadata, opContext); client.getCredentials().signRequest(request, 0L); @@ -1435,6 +1448,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final final HttpURLConnection request = QueueRequest.setAcl(queue.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), opContext); + this.setConnection(request); final StringWriter outBuffer = new StringWriter(); @@ -1512,6 +1526,7 @@ public QueuePermissions execute(final CloudQueueClient client, final CloudQueue final HttpURLConnection request = QueueRequest.getAcl(queue.getTransformedAddress(opContext), this .getRequestOptions().getTimeoutIntervalInMs(), opContext); + this.setConnection(request); client.getCredentials().signRequest(request, -1L); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java index addec40b3b9cd..7f1f12938aa09 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java @@ -224,6 +224,7 @@ ResultSegment listQueuesCore(final String prefix, final QueueListing final HttpURLConnection listQueueRequest = QueueRequest.list(this.getEndpoint(), options.getTimeoutIntervalInMs(), listingContext, detailsIncluded, opContext); + taskReference.setConnection(listQueueRequest); this.getCredentials().signRequest(listQueueRequest, -1L); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java index f13eac657acfc..47dc6bce8f9c0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java @@ -483,6 +483,7 @@ public Void execute(final CloudTableClient client, final CloudTable table, final final HttpURLConnection request = TableRequest.setAcl(table.uri, this.getRequestOptions() .getTimeoutIntervalInMs(), opContext); + this.setConnection(request); final StringWriter outBuffer = new StringWriter(); @@ -561,6 +562,7 @@ public TablePermissions execute(final CloudTableClient client, final CloudTable final HttpURLConnection request = TableRequest.getAcl(table.uri, tableName, this.getRequestOptions() .getTimeoutIntervalInMs(), opContext); + this.setConnection(request); client.getCredentials().signRequestLite(request, -1L, opContext); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java index 26a506cc39a65..8a240fe9bb9d9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java @@ -797,9 +797,9 @@ protected ResultSegment executeQuerySegmentedCore( final HttpURLConnection queryRequest = TableRequest.query(this.getTransformedEndPoint(opContext), queryToExecute.getSourceTableName(), null/* identity */, options.getTimeoutIntervalInMs(), queryToExecute.generateQueryBuilder(), continuationToken, options, opContext); + taskReference.setConnection(queryRequest); this.getCredentials().signRequestLite(queryRequest, -1L, opContext); - ExecutionEngine.processRequest(queryRequest, opContext, taskReference.getResult()); if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { @@ -812,18 +812,13 @@ protected ResultSegment executeQuerySegmentedCore( InputStream inStream = queryRequest.getInputStream(); - try { - if (resolver == null) { - clazzResponse = (ODataPayload) AtomPubParser.parseResponse(inStream, queryToExecute.getClazzType(), - null, opContext); - } - else { - resolvedResponse = (ODataPayload) AtomPubParser.parseResponse(inStream, - queryToExecute.getClazzType(), resolver, opContext); - } + if (resolver == null) { + clazzResponse = (ODataPayload) AtomPubParser.parseResponse(inStream, queryToExecute.getClazzType(), + null, opContext); } - finally { - inStream.close(); + else { + resolvedResponse = (ODataPayload) AtomPubParser.parseResponse(inStream, queryToExecute.getClazzType(), + resolver, opContext); } final ResultContinuation nextToken = TableResponse.getTableContinuationFromResponse(queryRequest); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java index 14c130540b18c..e92207cd4ae40 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java @@ -186,6 +186,7 @@ public TableResult execute(final CloudTableClient client, final QueryTableOperat tableName, generateRequestIdentity(isTableEntry, operation.getPartitionKey(), false), options.getTimeoutIntervalInMs(), null/* Query Builder */, null/* Continuation Token */, options, opContext); + this.setConnection(request); client.getCredentials().signRequestLite(request, -1L, opContext); @@ -197,13 +198,8 @@ tableName, generateRequestIdentity(isTableEntry, operation.getPartitionKey(), fa final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(inStream); TableResult res = null; - try { - res = AtomPubParser.parseSingleOpResponse(xmlr, this.getResult().getStatusCode(), - operation.getClazzType(), operation.getResolver(), opContext); - } - finally { - inStream.close(); - } + res = AtomPubParser.parseSingleOpResponse(xmlr, this.getResult().getStatusCode(), + operation.getClazzType(), operation.getResolver(), opContext); return res; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java index a2e814a92e00a..90b773477e552 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java @@ -393,6 +393,7 @@ public ArrayList execute(final CloudTableClient client, final Table final HttpURLConnection request = TableRequest.batch(client.getTransformedEndPoint(opContext), options.getTimeoutIntervalInMs(), batchID, null, options, opContext); + this.setConnection(request); client.getCredentials().signRequestLite(request, -1L, opContext); @@ -401,22 +402,18 @@ public ArrayList execute(final CloudTableClient client, final Table final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext, this.getResult()); ArrayList responseParts = null; - try { - final String contentType = request.getHeaderField(Constants.HeaderConstants.CONTENT_TYPE); - - final String[] headerVals = contentType.split("multipart/mixed; boundary="); - if (headerVals == null || headerVals.length != 2) { - throw new StorageException(StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, - "An incorrect Content-type was returned from the server.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - responseParts = MimeHelper.readBatchResponseStream(streamRef, headerVals[1], opContext); - } - finally { - streamRef.close(); + final String contentType = request.getHeaderField(Constants.HeaderConstants.CONTENT_TYPE); + + final String[] headerVals = contentType.split("multipart/mixed; boundary="); + if (headerVals == null || headerVals.length != 2) { + throw new StorageException(StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, + "An incorrect Content-type was returned from the server.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } + responseParts = MimeHelper.readBatchResponseStream(streamRef, headerVals[1], opContext); + ExecutionEngine.getResponseCode(this.getResult(), request, opContext); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java index 65987567691ce..72d385e1996a8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java @@ -259,6 +259,7 @@ public TableResult execute(final CloudTableClient client, final TableOperation o final HttpURLConnection request = TableRequest.delete(client.getTransformedEndPoint(opContext), tableName, generateRequestIdentity(isTableEntry, tableIdentity, false), operation.getEntity() .getEtag(), options.getTimeoutIntervalInMs(), null, options, opContext); + this.setConnection(request); client.getCredentials().signRequestLite(request, -1L, opContext); @@ -327,6 +328,7 @@ public TableResult execute(final CloudTableClient client, final TableOperation o tableName, generateRequestIdentity(isTableEntry, tableIdentity, false), operation.opType != TableOperationType.INSERT ? operation.getEntity().getEtag() : null, operation.opType.getUpdateType(), options.getTimeoutIntervalInMs(), null, options, opContext); + this.setConnection(request); client.getCredentials().signRequestLite(request, -1L, opContext); @@ -348,13 +350,8 @@ tableName, generateRequestIdentity(isTableEntry, tableIdentity, false), InputStream inStream = request.getInputStream(); TableResult res = null; - try { - final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(inStream); - res = operation.parseResponse(xmlr, this.getResult().getStatusCode(), null, opContext); - } - finally { - inStream.close(); - } + final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(inStream); + res = operation.parseResponse(xmlr, this.getResult().getStatusCode(), null, opContext); return res; } @@ -413,6 +410,7 @@ public TableResult execute(final CloudTableClient client, final TableOperation o final HttpURLConnection request = TableRequest.merge(client.getTransformedEndPoint(opContext), tableName, generateRequestIdentity(false, null, false), operation.getEntity().getEtag(), options.getTimeoutIntervalInMs(), null, options, opContext); + this.setConnection(request); client.getCredentials().signRequestLite(request, -1L, opContext); @@ -479,6 +477,7 @@ public TableResult execute(final CloudTableClient client, final TableOperation o final HttpURLConnection request = TableRequest.update(client.getTransformedEndPoint(opContext), tableName, generateRequestIdentity(false, null, false), operation.getEntity().getEtag(), options.getTimeoutIntervalInMs(), null, options, opContext); + this.setConnection(request); client.getCredentials().signRequestLite(request, -1L, opContext); From 305003149d27b582633288ee6bddfc282e779478 Mon Sep 17 00:00:00 2001 From: veudayab Date: Thu, 9 May 2013 13:28:04 -0700 Subject: [PATCH 04/48] Unit test fixes --- .../windowsazure/services/blob/client/BlobTestBase.java | 5 ++--- .../windowsazure/services/queue/client/QueueTestBase.java | 2 +- .../windowsazure/services/table/client/TableTestBase.java | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java index a2cc575d3a7b0..3da51d425a0e2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java @@ -45,9 +45,8 @@ public static void setup() throws URISyntaxException, StorageException, InvalidK } else { String cloudAccount = CLOUD_ACCOUNT_HTTP; - cloudAccount = cloudAccount.replace("[ACCOUNT NAME]", "jaidb3"); - cloudAccount = cloudAccount.replace("[ACCOUNT KEY]", - "+qjm/8MjakncuZwpjNfYtaKDHrJH3zkQAKDywuTNh9hdb3ETcQ4wweVdX3nzFsXsWkI5la8EZg04PIbPkWrWBQ=="); + cloudAccount = cloudAccount.replace("[ACCOUNT NAME]", System.getenv("blob.accountName")); + cloudAccount = cloudAccount.replace("[ACCOUNT KEY]", System.getenv("blob.accountKey")); httpAcc = CloudStorageAccount.parse(cloudAccount); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java index e44acb2a21000..831bbf6ca30dc 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java @@ -31,7 +31,7 @@ */ public class QueueTestBase { public static boolean USE_DEV_FABRIC = false; - public static final String CLOUD_ACCOUNT_HTTP = "DefaultEndpointsProtocol=https;AccountName=[ACCOUNT NAME];AccountKey=[ACCOUNT KEY]"; + public static final String CLOUD_ACCOUNT_HTTP = "DefaultEndpointsProtocol=http;AccountName=[ACCOUNT NAME];AccountKey=[ACCOUNT KEY]"; public static final String CLOUD_ACCOUNT_HTTPS = "DefaultEndpointsProtocol=https;AccountName=[ACCOUNT NAME];AccountKey=[ACCOUNT KEY]"; protected static CloudStorageAccount httpAcc; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java index 80c7ce30738af..bb4d9d1a156d3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java @@ -35,7 +35,7 @@ */ public class TableTestBase { public static boolean USE_DEV_FABRIC = false; - public static final String CLOUD_ACCOUNT_HTTP = "DefaultEndpointsProtocol=https;AccountName=[ACCOUNT NAME];AccountKey=[ACCOUNT KEY]"; + public static final String CLOUD_ACCOUNT_HTTP = "DefaultEndpointsProtocol=http;AccountName=[ACCOUNT NAME];AccountKey=[ACCOUNT KEY]"; public static final String CLOUD_ACCOUNT_HTTPS = "DefaultEndpointsProtocol=https;AccountName=[ACCOUNT NAME];AccountKey=[ACCOUNT KEY]"; public static class class1 extends TableServiceEntity { From 69b37ab70be5c1848421e0a756bfd80273814232 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 15 May 2013 18:05:29 -0700 Subject: [PATCH 05/48] initial check in for forward to feature. --- .../implementation/ServiceBusRestProxy.java | 7 ++- .../services/serviceBus/models/QueueInfo.java | 21 +++++++ ...netservices.2010.10.servicebus.connect.xsd | 7 +++ .../serviceBus/ServiceBusIntegrationTest.java | 56 +++++++++++++++++++ 4 files changed, 89 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 482d26a741990..6d76eb402d846 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -268,8 +268,11 @@ public void deleteMessage(BrokeredMessage message) throws ServiceException { @Override public CreateQueueResult createQueue(QueueInfo entry) throws ServiceException { - return new CreateQueueResult(getResource().path(entry.getPath()) - .type("application/atom+xml;type=entry;charset=utf-8").put(QueueInfo.class, entry)); + ClientResponse clientResponse = getResource().path(entry.getPath()) + .type("application/atom+xml;type=entry;charset=utf-8").put(ClientResponse.class, entry); + QueueInfo queueInfo = new QueueInfo(); + CreateQueueResult createQueueResult = new CreateQueueResult(queueInfo); + return createQueueResult; } @Override diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index 8cc7a1efde54b..b4bb5197a8ec9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -14,6 +14,7 @@ */ package com.microsoft.windowsazure.services.serviceBus.models; +import java.net.URI; import java.util.Calendar; import javax.ws.rs.core.MediaType; @@ -32,6 +33,8 @@ */ public class QueueInfo extends EntryModel { + private URI uri; + /** * Creates an instance of the QueueInfo class. */ @@ -538,4 +541,22 @@ public QueueInfo setUserMetadata(String userMetadata) { getModel().setUserMetadata(userMetadata); return this; } + + public QueueInfo setUri(URI uri) { + this.uri = uri; + return this; + } + + public URI getUri() { + return uri; + } + + public QueueInfo setForwardTo(String forwardTo) { + getModel().setForwardTo(forwardTo); + return this; + } + + public String getForwardTo() { + return getModel().getForwardTo(); + } } diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index 2c8d69df7be6a..490d5b9397da0 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -115,6 +115,13 @@ + + + + + + + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 221a358acedc3..7a104e2a7a494 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -240,6 +240,62 @@ public void receiveMessageEmptyQueueWorks() throws Exception { assertNull(receiveQueueMessageResult.getValue()); } + @Test + public void receiveQueueForwardToQueueMessageSuccess() throws Exception { + // Arrange + String sourceQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; + String destinationQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(sourceQueueName)).getValue(); + service.createQueue(new QueueInfo(sourceQueueName).setForwardTo(destinationQueueInfo.getUri().toString())); + + // Act + service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); + ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, + RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveQueueMessageResult); + assertNull(receiveQueueMessageResult.getValue()); + } + + @Test + public void receiveSubscriptionForwardToQueueMessageSuccess() throws Exception { + // Arrange + String sourceQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; + String destinationQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(sourceQueueName)).getValue(); + service.createQueue(new QueueInfo(sourceQueueName).setForwardTo(destinationQueueInfo.getUri().toString())); + + // Act + service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); + ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, + RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveQueueMessageResult); + assertNull(receiveQueueMessageResult.getValue()); + } + + @Test + public void receiveSubscriptionForwardToTopicMessageSuccess() throws Exception { + + } + + @Test + public void receiveQueueForwardToTopicMessageWorks() throws Exception { + + } + + @Test + public void receiveForwardedTopicMessageFails() throws Exception { + + } + + @Test + public void receiveForwardedSubscriptionMessageFails() throws Exception { + + } + @Test public void peekLockMessageWorks() throws Exception { // Arrange From 5481757c183948ff6a1849150b932acce2dc23c6 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 16 May 2013 14:56:33 -0700 Subject: [PATCH 06/48] additional implementation of forward to feature. --- .../implementation/ServiceBusRestProxy.java | 11 +++--- .../serviceBus/implementation/WrapFilter.java | 36 ++++++++++++++----- .../services/serviceBus/models/QueueInfo.java | 9 +++-- ...netservices.2010.10.servicebus.connect.xsd | 2 +- .../src/main/resources/servicebus-atom.xsd | 4 +-- .../serviceBus/ServiceBusIntegrationTest.java | 9 ++--- 6 files changed, 49 insertions(+), 22 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 6d76eb402d846..f1096e4d279ff 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -268,11 +268,12 @@ public void deleteMessage(BrokeredMessage message) throws ServiceException { @Override public CreateQueueResult createQueue(QueueInfo entry) throws ServiceException { - ClientResponse clientResponse = getResource().path(entry.getPath()) - .type("application/atom+xml;type=entry;charset=utf-8").put(ClientResponse.class, entry); - QueueInfo queueInfo = new QueueInfo(); - CreateQueueResult createQueueResult = new CreateQueueResult(queueInfo); - return createQueueResult; + Builder webResourceBuilder = getResource().path(entry.getPath()).type( + "application/atom+xml;type=entry;charset=utf-8"); + if ((entry.getForwardTo() != null) && !entry.getForwardTo().isEmpty()) { + webResourceBuilder.header("ServiceBusSupplementaryAuthorization", entry.getForwardTo()); + } + return new CreateQueueResult(webResourceBuilder.put(QueueInfo.class, entry)); } @Override diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java index ac3c15b3a7d08..198783afb60bb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java @@ -2,18 +2,19 @@ * 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 + * 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. + * 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.windowsazure.services.serviceBus.implementation; +import java.net.URI; import java.net.URISyntaxException; import com.microsoft.windowsazure.services.core.ServiceException; @@ -47,6 +48,25 @@ public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { cr.getHeaders().add("Authorization", "WRAP access_token=\"" + accessToken + "\""); + String secondaryAuthorizationUri = (String) cr.getHeaders().getFirst("ServiceBusSupplementaryAuthorization"); + if ((secondaryAuthorizationUri != null) && (!secondaryAuthorizationUri.isEmpty())) { + String secondaryAccessToken; + try { + secondaryAccessToken = tokenManager.getAccessToken(URI.create(secondaryAuthorizationUri)); + } + catch (ServiceException e) { + // must wrap exception because of base class signature + throw new ClientHandlerException(e); + } + catch (URISyntaxException e) { + // must wrap exception because of base class signature + throw new ClientHandlerException(e); + } + cr.getHeaders().remove("ServiceBusSupplementaryAuthorization"); + cr.getHeaders().add("ServiceBusSupplementaryAuthorization", + "WRAP access_token=\"" + secondaryAccessToken + "\""); + } + return this.getNext().handle(cr); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index b4bb5197a8ec9..0d44c8288e9a4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -543,12 +543,17 @@ public QueueInfo setUserMetadata(String userMetadata) { } public QueueInfo setUri(URI uri) { - this.uri = uri; + getEntry().setId(uri.toString()); return this; } public URI getUri() { - return uri; + return URI.create(removeQueryString(getEntry().getId())); + } + + private String removeQueryString(String uri) { + String[] result = uri.split("\\?"); + return result[0]; } public QueueInfo setForwardTo(String forwardTo) { diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index 490d5b9397da0..74142943124b2 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -337,7 +337,7 @@ - + diff --git a/microsoft-azure-api/src/main/resources/servicebus-atom.xsd b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd index b8387023a54be..415ccefeaae5a 100644 --- a/microsoft-azure-api/src/main/resources/servicebus-atom.xsd +++ b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd @@ -12,7 +12,6 @@ - @@ -20,7 +19,8 @@ - + + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 7a104e2a7a494..8cc96ae3696c7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -244,9 +244,10 @@ public void receiveMessageEmptyQueueWorks() throws Exception { public void receiveQueueForwardToQueueMessageSuccess() throws Exception { // Arrange String sourceQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; - String destinationQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; - QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(sourceQueueName)).getValue(); - service.createQueue(new QueueInfo(sourceQueueName).setForwardTo(destinationQueueInfo.getUri().toString())); + String destinationQueueName = "TestReceiveQueueForwardToQueueMessageSuccessDestination"; + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + QueueInfo sourceQueueInfo = service.createQueue( + new QueueInfo(sourceQueueName).setForwardTo(destinationQueueInfo.getUri().toString())).getValue(); // Act service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); @@ -255,7 +256,7 @@ public void receiveQueueForwardToQueueMessageSuccess() throws Exception { // Assert assertNotNull(receiveQueueMessageResult); - assertNull(receiveQueueMessageResult.getValue()); + assertNotNull(receiveQueueMessageResult.getValue()); } @Test From a6a749f9cf6e8ff5cddb49e29e016cc2440ae6e4 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 16 May 2013 15:37:12 -0700 Subject: [PATCH 07/48] implement subscription forward to feature. --- .../implementation/ServiceBusRestProxy.java | 10 +++++++--- .../serviceBus/models/SubscriptionInfo.java | 9 +++++++++ ...com.netservices.2010.10.servicebus.connect.xsd | 7 +++++++ .../serviceBus/ServiceBusIntegrationTest.java | 15 +++++++++------ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index f1096e4d279ff..5508c2b4fe9cc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -350,9 +350,13 @@ public TopicInfo updateTopic(TopicInfo topicInfo) throws ServiceException { @Override public CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) { - return new CreateSubscriptionResult(getResource().path(topicPath).path("subscriptions") - .path(subscription.getName()).type("application/atom+xml;type=entry;charset=utf-8") - .put(SubscriptionInfo.class, subscription)); + Builder webResourceBuilder = getResource().path(topicPath).path("subscriptions").path(subscription.getName()) + .type("application/atom+xml;type=entry;charset=utf-8"); + if ((subscription.getForwardTo() != null) && (!subscription.getForwardTo().isEmpty())) { + webResourceBuilder.header("ServiceBusSupplementaryAuthorization", subscription.getForwardTo()); + + } + return new CreateSubscriptionResult(webResourceBuilder.put(SubscriptionInfo.class, subscription)); } @Override diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java index 04263c1115036..7bb06502885fe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java @@ -430,4 +430,13 @@ public EntityAvailabilityStatus getEntityAvailabilityStatus() { return getModel().getEntityAvailabilityStatus(); } + public SubscriptionInfo setForwardTo(String forwardTo) { + getModel().setForwardTo(forwardTo); + return this; + } + + public String getForwardTo() { + return getModel().getForwardTo(); + } + } diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index 74142943124b2..8eb6931a6ee51 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -253,6 +253,13 @@ + + + + + + + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 8cc96ae3696c7..21530a17665d1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -262,19 +262,22 @@ public void receiveQueueForwardToQueueMessageSuccess() throws Exception { @Test public void receiveSubscriptionForwardToQueueMessageSuccess() throws Exception { // Arrange - String sourceQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; - String destinationQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; - QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(sourceQueueName)).getValue(); - service.createQueue(new QueueInfo(sourceQueueName).setForwardTo(destinationQueueInfo.getUri().toString())); + String sourceTopicName = "TestReceiveSubForwardToQueueMessageSuccessSource"; + String sourceSubscriptionName = "TestReceiveSubForwardToQueueMessageSuccessSource"; + String destinationQueueName = "TestReceiveSubForwardToQueueMessageSuccessDestination"; + TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + service.createSubscription(sourceTopicName, + new SubscriptionInfo(sourceSubscriptionName).setForwardTo(destinationQueueInfo.getUri().toString())); // Act - service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); + service.sendTopicMessage(sourceTopicName, new BrokeredMessage("Hello source queue!")); ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, RECEIVE_AND_DELETE_5_SECONDS); // Assert assertNotNull(receiveQueueMessageResult); - assertNull(receiveQueueMessageResult.getValue()); + assertNotNull(receiveQueueMessageResult.getValue()); } @Test From ff2faf48bc14b983cbfe639aae8e4a116aed3d5c Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 16 May 2013 16:07:55 -0700 Subject: [PATCH 08/48] implementing update for forward to feature. --- .../implementation/ServiceBusRestProxy.java | 18 +++++--- .../serviceBus/ServiceBusIntegrationTest.java | 42 +++++++++++++++++++ 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 5508c2b4fe9cc..a894df4619166 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -300,8 +300,12 @@ public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceExce @Override public QueueInfo updateQueue(QueueInfo queueInfo) throws ServiceException { - return getResource().path(queueInfo.getPath()).type("application/atom+xml;type=entry;charset=utf-8") - .header("If-Match", "*").put(QueueInfo.class, queueInfo); + Builder webResourceBuilder = getResource().path(queueInfo.getPath()) + .type("application/atom+xml;type=entry;charset=utf-8").header("If-Match", "*"); + if ((queueInfo.getForwardTo() != null) && !queueInfo.getForwardTo().isEmpty()) { + webResourceBuilder.header("ServiceBusSupplementaryAuthorization", queueInfo.getForwardTo()); + } + return webResourceBuilder.put(QueueInfo.class, queueInfo); } private WebResource listOptions(AbstractListOptions options, WebResource path) { @@ -385,9 +389,13 @@ public ListSubscriptionsResult listSubscriptions(String topicPath, ListSubscript @Override public SubscriptionInfo updateSubscription(String topicName, SubscriptionInfo subscriptionInfo) throws ServiceException { - return getResource().path(topicName).path("subscriptions").path(subscriptionInfo.getName()) - .type("application/atom+xml;type=entry;charset=utf-8").header("If-Match", "*") - .put(SubscriptionInfo.class, subscriptionInfo); + Builder webResourceBuilder = getResource().path(topicName).path("subscriptions") + .path(subscriptionInfo.getName()).type("application/atom+xml;type=entry;charset=utf-8") + .header("If-Match", "*"); + if ((subscriptionInfo.getForwardTo() != null) && !subscriptionInfo.getForwardTo().isEmpty()) { + webResourceBuilder.header("ServiceBusSupplementaryAuthorization", subscriptionInfo.getForwardTo()); + } + return webResourceBuilder.put(SubscriptionInfo.class, subscriptionInfo); } @Override diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 21530a17665d1..e9058e355d9e1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -259,6 +259,26 @@ public void receiveQueueForwardToQueueMessageSuccess() throws Exception { assertNotNull(receiveQueueMessageResult.getValue()); } + @Test + public void receiveUpdatedQueueForwardToQueueMessageSuccess() throws Exception { + // Arrange + String sourceQueueName = "TestReceiveUpdatedQueueForwardToQueueMessageSuccessSource"; + String destinationQueueName = "TestReceiveUpdatedQueueForwardToQueueMessageSuccessDestination"; + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + QueueInfo sourceQueueInfo = new QueueInfo(sourceQueueName); + service.createQueue(sourceQueueInfo).getValue(); + service.updateQueue(sourceQueueInfo.setForwardTo(destinationQueueInfo.getUri().toString())); + + // Act + service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); + ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, + RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveQueueMessageResult); + assertNotNull(receiveQueueMessageResult.getValue()); + } + @Test public void receiveSubscriptionForwardToQueueMessageSuccess() throws Exception { // Arrange @@ -280,6 +300,28 @@ public void receiveSubscriptionForwardToQueueMessageSuccess() throws Exception { assertNotNull(receiveQueueMessageResult.getValue()); } + @Test + public void receiveUpdatedSubscriptionForwardToQueueMessageSuccess() throws Exception { + // Arrange + String sourceTopicName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; + String sourceSubscriptionName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; + String destinationQueueName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessDestination"; + TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + SubscriptionInfo sourceSubscriptionInfo = service.createSubscription(sourceTopicName, + new SubscriptionInfo(sourceSubscriptionName)).getValue(); + service.updateSubscription(sourceTopicName, + sourceSubscriptionInfo.setForwardTo(destinationQueueInfo.getUri().toString())); + // Act + service.sendTopicMessage(sourceTopicName, new BrokeredMessage("Hello source queue!")); + ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, + RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveQueueMessageResult); + assertNotNull(receiveQueueMessageResult.getValue()); + } + @Test public void receiveSubscriptionForwardToTopicMessageSuccess() throws Exception { From a1a095a88bee0acd3c7dd80286c969c6aae4a89d Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 16 May 2013 16:54:52 -0700 Subject: [PATCH 09/48] update forward to integration test. --- .../services/serviceBus/models/TopicInfo.java | 5 ++ .../serviceBus/ServiceBusIntegrationTest.java | 74 ++++++++++++++++++- 2 files changed, 75 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java index 627af7f6d05ea..af1f75e97955e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java @@ -14,6 +14,7 @@ */ package com.microsoft.windowsazure.services.serviceBus.models; +import java.net.URI; import java.util.Calendar; import javax.ws.rs.core.MediaType; @@ -467,4 +468,8 @@ public TopicInfo setEntityAvailabilityStatus(EntityAvailabilityStatus entityAvai public EntityAvailabilityStatus getEntityAvailabilityStatus() { return getModel().getEntityAvailabilityStatus(); } + + public URI getUri() { + return URI.create(getEntry().getId()); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index e9058e355d9e1..44d9e61396cef 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -49,6 +49,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; @@ -323,23 +324,88 @@ public void receiveUpdatedSubscriptionForwardToQueueMessageSuccess() throws Exce } @Test - public void receiveSubscriptionForwardToTopicMessageSuccess() throws Exception { + public void receiveQueueForwardToTopicMessageSuccess() throws Exception { + // Arrange + String sourceQueueName = "TestReceiveQueueForwardToTopicMessageSuccessSource"; + String destinationTopicName = "TestReceiveQueueForwardToTopicMessageSuccessDestination"; + String destinationSubscriptionName = "TestReceiveQueueForwardToTopicMessageSuccessDestination"; + TopicInfo destinationTopicInfo = service.createTopic(new TopicInfo(destinationTopicName)).getValue(); + QueueInfo sourceQueueInfo = service.createQueue( + new QueueInfo(sourceQueueName).setForwardTo(destinationTopicInfo.getUri().toString())).getValue(); + // Act + service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); + ReceiveSubscriptionMessageResult receiveSubscriptionMessageResult = service.receiveSubscriptionMessage( + destinationTopicName, destinationSubscriptionName, RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveSubscriptionMessageResult); + assertNotNull(receiveSubscriptionMessageResult.getValue()); } @Test - public void receiveQueueForwardToTopicMessageWorks() throws Exception { + public void receiveUpdatedQueueForwardToTopicMessageSuccess() throws Exception { + // Arrange + String sourceQueueName = "TestReceiveUpdatedQueueForwardToTopicMessageSuccessSource"; + String destinationTopicName = "TestReceiveUpdatedQueueForwardToTopicMessageSuccessDestination"; + String destinationSubscriptionName = "TestReceiveUpdatedQueueForwardToTopicMessageSuccessDestination"; + TopicInfo destinationTopicInfo = service.createTopic(new TopicInfo(destinationTopicName)).getValue(); + QueueInfo sourceQueueInfo = new QueueInfo(sourceQueueName); + service.createQueue(sourceQueueInfo).getValue(); + service.updateQueue(sourceQueueInfo.setForwardTo(destinationTopicInfo.getUri().toString())); + // Act + service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); + ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, + RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveQueueMessageResult); + assertNotNull(receiveQueueMessageResult.getValue()); } @Test - public void receiveForwardedTopicMessageFails() throws Exception { + public void receiveSubscriptionForwardToTopicMessageSuccess() throws Exception { + // Arrange + String sourceTopicName = "TestReceiveSubForwardToQueueMessageSuccessSource"; + String sourceSubscriptionName = "TestReceiveSubForwardToQueueMessageSuccessSource"; + String destinationQueueName = "TestReceiveSubForwardToQueueMessageSuccessDestination"; + TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + service.createSubscription(sourceTopicName, + new SubscriptionInfo(sourceSubscriptionName).setForwardTo(destinationQueueInfo.getUri().toString())); + // Act + service.sendTopicMessage(sourceTopicName, new BrokeredMessage("Hello source queue!")); + ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, + RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveQueueMessageResult); + assertNotNull(receiveQueueMessageResult.getValue()); } @Test - public void receiveForwardedSubscriptionMessageFails() throws Exception { + public void receiveUpdatedSubscriptionForwardToTopicMessageSuccess() throws Exception { + // Arrange + String sourceTopicName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; + String sourceSubscriptionName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; + String destinationQueueName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessDestination"; + TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + SubscriptionInfo sourceSubscriptionInfo = service.createSubscription(sourceTopicName, + new SubscriptionInfo(sourceSubscriptionName)).getValue(); + service.updateSubscription(sourceTopicName, + sourceSubscriptionInfo.setForwardTo(destinationQueueInfo.getUri().toString())); + // Act + service.sendTopicMessage(sourceTopicName, new BrokeredMessage("Hello source queue!")); + ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, + RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveQueueMessageResult); + assertNotNull(receiveQueueMessageResult.getValue()); } @Test From f0609a82463e4e3f5a79067de2ca8aab6038b34b Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Fri, 17 May 2013 16:43:42 -0700 Subject: [PATCH 10/48] add more integration tests for forward to feature. --- .../serviceBus/ServiceBusIntegrationTest.java | 56 ++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 44d9e61396cef..435707051391f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -304,9 +304,9 @@ public void receiveSubscriptionForwardToQueueMessageSuccess() throws Exception { @Test public void receiveUpdatedSubscriptionForwardToQueueMessageSuccess() throws Exception { // Arrange - String sourceTopicName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; - String sourceSubscriptionName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; - String destinationQueueName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessDestination"; + String sourceTopicName = "TestUpdatedReceiveSubForwardToQMessageSuccessSrc"; + String sourceSubscriptionName = "TestUpdatedReceiveSubForwardToQMessageSuccessSrc"; + String destinationQueueName = "TestUpdatedReceiveSubForwardToQMessageSuccessDest"; TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); SubscriptionInfo sourceSubscriptionInfo = service.createSubscription(sourceTopicName, @@ -356,56 +356,62 @@ public void receiveUpdatedQueueForwardToTopicMessageSuccess() throws Exception { // Act service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); - ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, - RECEIVE_AND_DELETE_5_SECONDS); + ReceiveSubscriptionMessageResult receiveSubscriptionMessageResult = service.receiveSubscriptionMessage( + destinationTopicName, destinationSubscriptionName, RECEIVE_AND_DELETE_5_SECONDS); // Assert - assertNotNull(receiveQueueMessageResult); - assertNotNull(receiveQueueMessageResult.getValue()); + assertNotNull(receiveSubscriptionMessageResult); + assertNotNull(receiveSubscriptionMessageResult.getValue()); } @Test public void receiveSubscriptionForwardToTopicMessageSuccess() throws Exception { // Arrange - String sourceTopicName = "TestReceiveSubForwardToQueueMessageSuccessSource"; - String sourceSubscriptionName = "TestReceiveSubForwardToQueueMessageSuccessSource"; - String destinationQueueName = "TestReceiveSubForwardToQueueMessageSuccessDestination"; + String sourceTopicName = "TestReceiveSubForwardToTopMessageSuccessSrc"; + String sourceSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessSrc"; + String destinationTopicName = "TestReceiveSubForwardToTopMessageSuccessDest"; + String destinationSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessDest"; TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); - QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + TopicInfo destinationTopicInfo = service.createTopic(new TopicInfo(destinationTopicName)).getValue(); + SubscriptionInfo destinationSubscriptionInfo = service.createSubscription(destinationTopicName, + new SubscriptionInfo(destinationSubscriptionName)).getValue(); service.createSubscription(sourceTopicName, - new SubscriptionInfo(sourceSubscriptionName).setForwardTo(destinationQueueInfo.getUri().toString())); + new SubscriptionInfo(sourceSubscriptionName).setForwardTo(destinationTopicInfo.getUri().toString())); // Act service.sendTopicMessage(sourceTopicName, new BrokeredMessage("Hello source queue!")); - ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, - RECEIVE_AND_DELETE_5_SECONDS); + ReceiveSubscriptionMessageResult receiveSubscriptionMessageResult = service.receiveSubscriptionMessage( + destinationTopicName, destinationSubscriptionName, RECEIVE_AND_DELETE_5_SECONDS); // Assert - assertNotNull(receiveQueueMessageResult); - assertNotNull(receiveQueueMessageResult.getValue()); + assertNotNull(receiveSubscriptionMessageResult); + assertNotNull(receiveSubscriptionMessageResult.getValue()); } @Test public void receiveUpdatedSubscriptionForwardToTopicMessageSuccess() throws Exception { // Arrange - String sourceTopicName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; - String sourceSubscriptionName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; - String destinationQueueName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessDestination"; + String sourceTopicName = "TestReceiveSubForwardToTopMessageSuccessSrc"; + String sourceSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessSrc"; + String destinationTopicName = "TestReceiveSubForwardToTopMessageSuccessDest"; + String destinationSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessDest"; TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); - QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + TopicInfo destinationTopicInfo = service.createTopic(new TopicInfo(destinationTopicName)).getValue(); + SubscriptionInfo destinationSubscriptionInfo = service.createSubscription(destinationTopicName, + new SubscriptionInfo(destinationSubscriptionName)).getValue(); SubscriptionInfo sourceSubscriptionInfo = service.createSubscription(sourceTopicName, new SubscriptionInfo(sourceSubscriptionName)).getValue(); service.updateSubscription(sourceTopicName, - sourceSubscriptionInfo.setForwardTo(destinationQueueInfo.getUri().toString())); + sourceSubscriptionInfo.setForwardTo(destinationTopicInfo.getUri().toString())); // Act service.sendTopicMessage(sourceTopicName, new BrokeredMessage("Hello source queue!")); - ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, - RECEIVE_AND_DELETE_5_SECONDS); + ReceiveSubscriptionMessageResult receiveSubscriptionMessageResult = service.receiveSubscriptionMessage( + destinationTopicName, destinationSubscriptionName, RECEIVE_AND_DELETE_5_SECONDS); // Assert - assertNotNull(receiveQueueMessageResult); - assertNotNull(receiveQueueMessageResult.getValue()); + assertNotNull(receiveSubscriptionMessageResult); + assertNotNull(receiveSubscriptionMessageResult.getValue()); } @Test From eb11213cf3ea07ac980d9a9050fab4699b57aeca Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Fri, 17 May 2013 17:55:57 -0700 Subject: [PATCH 11/48] refactoring and documentation work. --- .../serviceBus/ServiceBusContract.java | 6 +-- .../implementation/ServiceBusRestProxy.java | 22 +++++----- .../serviceBus/implementation/WrapFilter.java | 40 ++++++++----------- .../services/serviceBus/models/QueueInfo.java | 34 +++++++++++++++- .../serviceBus/models/SubscriptionInfo.java | 12 ++++++ .../serviceBus/ServiceBusIntegrationTest.java | 22 +++++----- 6 files changed, 84 insertions(+), 52 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 075f3c7484335..537d22623dd0a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -195,13 +195,13 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicPath, St /** * Creates a queue. * - * @param queue - * A Queue object that represents the queue to create. + * @param queueInfo + * A QueueInfo object that represents the queue to create. * @return A CreateQueueResult object that represents the result. * @throws ServiceException * If a service exception is encountered. */ - CreateQueueResult createQueue(QueueInfo queue) throws ServiceException; + CreateQueueResult createQueue(QueueInfo queueInfo) throws ServiceException; /** * Deletes a queue. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index a894df4619166..472bf9e510563 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -267,13 +267,13 @@ public void deleteMessage(BrokeredMessage message) throws ServiceException { } @Override - public CreateQueueResult createQueue(QueueInfo entry) throws ServiceException { - Builder webResourceBuilder = getResource().path(entry.getPath()).type( + public CreateQueueResult createQueue(QueueInfo queueInfo) throws ServiceException { + Builder webResourceBuilder = getResource().path(queueInfo.getPath()).type( "application/atom+xml;type=entry;charset=utf-8"); - if ((entry.getForwardTo() != null) && !entry.getForwardTo().isEmpty()) { - webResourceBuilder.header("ServiceBusSupplementaryAuthorization", entry.getForwardTo()); + if ((queueInfo.getForwardTo() != null) && !queueInfo.getForwardTo().isEmpty()) { + webResourceBuilder.header("ServiceBusSupplementaryAuthorization", queueInfo.getForwardTo()); } - return new CreateQueueResult(webResourceBuilder.put(QueueInfo.class, entry)); + return new CreateQueueResult(webResourceBuilder.put(QueueInfo.class, queueInfo)); } @Override @@ -353,14 +353,14 @@ public TopicInfo updateTopic(TopicInfo topicInfo) throws ServiceException { } @Override - public CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) { - Builder webResourceBuilder = getResource().path(topicPath).path("subscriptions").path(subscription.getName()) - .type("application/atom+xml;type=entry;charset=utf-8"); - if ((subscription.getForwardTo() != null) && (!subscription.getForwardTo().isEmpty())) { - webResourceBuilder.header("ServiceBusSupplementaryAuthorization", subscription.getForwardTo()); + public CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscriptionInfo) { + Builder webResourceBuilder = getResource().path(topicPath).path("subscriptions") + .path(subscriptionInfo.getName()).type("application/atom+xml;type=entry;charset=utf-8"); + if ((subscriptionInfo.getForwardTo() != null) && (!subscriptionInfo.getForwardTo().isEmpty())) { + webResourceBuilder.header("ServiceBusSupplementaryAuthorization", subscriptionInfo.getForwardTo()); } - return new CreateSubscriptionResult(webResourceBuilder.put(SubscriptionInfo.class, subscription)); + return new CreateSubscriptionResult(webResourceBuilder.put(SubscriptionInfo.class, subscriptionInfo)); } @Override diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java index 198783afb60bb..f1d0187a6b21c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java @@ -32,10 +32,23 @@ public WrapFilter(WrapTokenManager tokenManager) { @Override public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { + String accessToken = getWrapToken(cr.getURI()); + cr.getHeaders().add("Authorization", accessToken); - String accessToken; + String secondaryAuthorizationUri = (String) cr.getHeaders().getFirst("ServiceBusSupplementaryAuthorization"); + if ((secondaryAuthorizationUri != null) && (!secondaryAuthorizationUri.isEmpty())) { + String secondaryAccessToken = getWrapToken(URI.create(secondaryAuthorizationUri)); + cr.getHeaders().remove("ServiceBusSupplementaryAuthorization"); + cr.getHeaders().add("ServiceBusSupplementaryAuthorization", secondaryAccessToken); + } + + return this.getNext().handle(cr); + } + + private String getWrapToken(URI uri) { + String result; try { - accessToken = tokenManager.getAccessToken(cr.getURI()); + result = tokenManager.getAccessToken(uri); } catch (ServiceException e) { // must wrap exception because of base class signature @@ -46,27 +59,6 @@ public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { throw new ClientHandlerException(e); } - cr.getHeaders().add("Authorization", "WRAP access_token=\"" + accessToken + "\""); - - String secondaryAuthorizationUri = (String) cr.getHeaders().getFirst("ServiceBusSupplementaryAuthorization"); - if ((secondaryAuthorizationUri != null) && (!secondaryAuthorizationUri.isEmpty())) { - String secondaryAccessToken; - try { - secondaryAccessToken = tokenManager.getAccessToken(URI.create(secondaryAuthorizationUri)); - } - catch (ServiceException e) { - // must wrap exception because of base class signature - throw new ClientHandlerException(e); - } - catch (URISyntaxException e) { - // must wrap exception because of base class signature - throw new ClientHandlerException(e); - } - cr.getHeaders().remove("ServiceBusSupplementaryAuthorization"); - cr.getHeaders().add("ServiceBusSupplementaryAuthorization", - "WRAP access_token=\"" + secondaryAccessToken + "\""); - } - - return this.getNext().handle(cr); + return "WRAP access_token=\"" + result + "\""; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index 0d44c8288e9a4..b8eb8be76a64c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -33,8 +33,6 @@ */ public class QueueInfo extends EntryModel { - private URI uri; - /** * Creates an instance of the QueueInfo class. */ @@ -542,25 +540,57 @@ public QueueInfo setUserMetadata(String userMetadata) { return this; } + /** + * Sets the URI of the QueueInfo instance. + * + * @param uri + * the URI of the QueueInfo + * + * @return A QueueInfo object that represents the updated queue. + */ public QueueInfo setUri(URI uri) { getEntry().setId(uri.toString()); return this; } + /** + * Gets the URI of the QueueInfo instance. + * + * @return A URI representing the QueueInfo. + */ public URI getUri() { return URI.create(removeQueryString(getEntry().getId())); } + /** + * Removes the query string of the URI. + * + * @param uri + * A raw string representing the URI of queue. + * @return the string + */ private String removeQueryString(String uri) { String[] result = uri.split("\\?"); return result[0]; } + /** + * Sets the URI of the entity to forward to. + * + * @param forwardTo + * A String instance representing the URI of the entity to forward message to. + * @return A QueueInfo instance representing the updated queue information. + */ public QueueInfo setForwardTo(String forwardTo) { getModel().setForwardTo(forwardTo); return this; } + /** + * Gets a String instance representing entity to forward to. + * + * @return A String instance representing the URI of the instance to forward to. + */ public String getForwardTo() { return getModel().getForwardTo(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java index 7bb06502885fe..d6d8f5d432461 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java @@ -430,11 +430,23 @@ public EntityAvailabilityStatus getEntityAvailabilityStatus() { return getModel().getEntityAvailabilityStatus(); } + /** + * Sets the forward to. + * + * @param forwardTo + * A String representing the string to forward to. + * @return the subscription info + */ public SubscriptionInfo setForwardTo(String forwardTo) { getModel().setForwardTo(forwardTo); return this; } + /** + * Gets a String representing the URI of the entity to forward to. + * + * @return A String representing the URI of the entity to forward to. + */ public String getForwardTo() { return getModel().getForwardTo(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 435707051391f..ed67cb2528177 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -247,8 +247,8 @@ public void receiveQueueForwardToQueueMessageSuccess() throws Exception { String sourceQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; String destinationQueueName = "TestReceiveQueueForwardToQueueMessageSuccessDestination"; QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); - QueueInfo sourceQueueInfo = service.createQueue( - new QueueInfo(sourceQueueName).setForwardTo(destinationQueueInfo.getUri().toString())).getValue(); + service.createQueue(new QueueInfo(sourceQueueName).setForwardTo(destinationQueueInfo.getUri().toString())) + .getValue(); // Act service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); @@ -286,7 +286,7 @@ public void receiveSubscriptionForwardToQueueMessageSuccess() throws Exception { String sourceTopicName = "TestReceiveSubForwardToQueueMessageSuccessSource"; String sourceSubscriptionName = "TestReceiveSubForwardToQueueMessageSuccessSource"; String destinationQueueName = "TestReceiveSubForwardToQueueMessageSuccessDestination"; - TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + service.createTopic(new TopicInfo(sourceTopicName)).getValue(); QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); service.createSubscription(sourceTopicName, new SubscriptionInfo(sourceSubscriptionName).setForwardTo(destinationQueueInfo.getUri().toString())); @@ -307,7 +307,7 @@ public void receiveUpdatedSubscriptionForwardToQueueMessageSuccess() throws Exce String sourceTopicName = "TestUpdatedReceiveSubForwardToQMessageSuccessSrc"; String sourceSubscriptionName = "TestUpdatedReceiveSubForwardToQMessageSuccessSrc"; String destinationQueueName = "TestUpdatedReceiveSubForwardToQMessageSuccessDest"; - TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + service.createTopic(new TopicInfo(sourceTopicName)).getValue(); QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); SubscriptionInfo sourceSubscriptionInfo = service.createSubscription(sourceTopicName, new SubscriptionInfo(sourceSubscriptionName)).getValue(); @@ -330,8 +330,8 @@ public void receiveQueueForwardToTopicMessageSuccess() throws Exception { String destinationTopicName = "TestReceiveQueueForwardToTopicMessageSuccessDestination"; String destinationSubscriptionName = "TestReceiveQueueForwardToTopicMessageSuccessDestination"; TopicInfo destinationTopicInfo = service.createTopic(new TopicInfo(destinationTopicName)).getValue(); - QueueInfo sourceQueueInfo = service.createQueue( - new QueueInfo(sourceQueueName).setForwardTo(destinationTopicInfo.getUri().toString())).getValue(); + service.createQueue(new QueueInfo(sourceQueueName).setForwardTo(destinationTopicInfo.getUri().toString())) + .getValue(); // Act service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); @@ -371,10 +371,9 @@ public void receiveSubscriptionForwardToTopicMessageSuccess() throws Exception { String sourceSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessSrc"; String destinationTopicName = "TestReceiveSubForwardToTopMessageSuccessDest"; String destinationSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessDest"; - TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + service.createTopic(new TopicInfo(sourceTopicName)).getValue(); TopicInfo destinationTopicInfo = service.createTopic(new TopicInfo(destinationTopicName)).getValue(); - SubscriptionInfo destinationSubscriptionInfo = service.createSubscription(destinationTopicName, - new SubscriptionInfo(destinationSubscriptionName)).getValue(); + service.createSubscription(destinationTopicName, new SubscriptionInfo(destinationSubscriptionName)).getValue(); service.createSubscription(sourceTopicName, new SubscriptionInfo(sourceSubscriptionName).setForwardTo(destinationTopicInfo.getUri().toString())); @@ -395,10 +394,9 @@ public void receiveUpdatedSubscriptionForwardToTopicMessageSuccess() throws Exce String sourceSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessSrc"; String destinationTopicName = "TestReceiveSubForwardToTopMessageSuccessDest"; String destinationSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessDest"; - TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + service.createTopic(new TopicInfo(sourceTopicName)).getValue(); TopicInfo destinationTopicInfo = service.createTopic(new TopicInfo(destinationTopicName)).getValue(); - SubscriptionInfo destinationSubscriptionInfo = service.createSubscription(destinationTopicName, - new SubscriptionInfo(destinationSubscriptionName)).getValue(); + service.createSubscription(destinationTopicName, new SubscriptionInfo(destinationSubscriptionName)).getValue(); SubscriptionInfo sourceSubscriptionInfo = service.createSubscription(sourceTopicName, new SubscriptionInfo(sourceSubscriptionName)).getValue(); service.updateSubscription(sourceTopicName, From 928fafefdaec8190447fb771c23e2e2034626430 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 20 May 2013 16:52:41 -0700 Subject: [PATCH 12/48] initial check in for multiple property filter --- ...t.com.netservices.2010.10.servicebus.connect.xsd | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index 8eb6931a6ee51..5a5d0adf905e5 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -406,11 +406,24 @@ + + + + + + + + + + + + + From d6abcae89fa07b768e7cd691780efa757de445cb Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 22 May 2013 16:42:13 -0700 Subject: [PATCH 13/48] complete the schema change for correlation filter. --- ...crosoft.com.netservices.2010.10.servicebus.connect.xsd | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index 5a5d0adf905e5..4bdf4c154a337 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -406,9 +406,15 @@ + + + + + + - + From 931004ceac9a82437e8586257494c1d9f0b39a9d Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 22 May 2013 18:18:33 -0700 Subject: [PATCH 14/48] integration test for multiple properties filter. --- ...netservices.2010.10.servicebus.connect.xsd | 2 +- .../serviceBus/ServiceBusIntegrationTest.java | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index 4bdf4c154a337..f39e6c7b02f43 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -414,7 +414,7 @@ - + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index ed67cb2528177..ef1ffded6b895 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -37,6 +37,9 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.EmptyRuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.EntityStatus; import com.microsoft.windowsazure.services.serviceBus.implementation.FalseFilter; +import com.microsoft.windowsazure.services.serviceBus.implementation.FilterProperties; +import com.microsoft.windowsazure.services.serviceBus.implementation.KeyValueOfStringAnyType; +import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; import com.microsoft.windowsazure.services.serviceBus.implementation.SqlFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.SqlRuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.TrueFilter; @@ -641,6 +644,36 @@ public void subscriptionsCanBeCreatedOnTopics() throws Exception { assertNotNull(created.getAutoDeleteOnIdle()); } + @Test + public void createSubscriptionWithCorrelationFilter() throws Exception { + // Arrange + String topicName = "createSubscriptionWithCorrelationFilter"; + service.createTopic(new TopicInfo(topicName)); + CorrelationFilter correlationFilter = new CorrelationFilter(); + FilterProperties filterProperties = new FilterProperties(); + KeyValueOfStringAnyType keyValueOfStringAnyType = new KeyValueOfStringAnyType(); + keyValueOfStringAnyType.setKey("AKey"); + keyValueOfStringAnyType.setValue(new String("A Value")); + filterProperties.getKeyValueOfstringanyTypes().add(keyValueOfStringAnyType); + correlationFilter.setProperties(filterProperties); + RuleDescription ruleDescription = new RuleDescription(); + ruleDescription.setFilter(correlationFilter); + + // Act + SubscriptionInfo created = service.createSubscription(topicName, + new SubscriptionInfo("MySubscription").setDefaultRuleDescription(ruleDescription)).getValue(); + + // Assert + assertNotNull(created); + assertEquals("MySubscription", created.getName()); + assertEquals(false, created.isRequiresSession()); + assertEquals(true, created.isDeadLetteringOnFilterEvaluationExceptions()); + assertNotNull(created.getCreatedAt()); + assertNotNull(created.getUpdatedAt()); + assertNotNull(created.getAccessedAt()); + assertNotNull(created.getAutoDeleteOnIdle()); + } + @Test public void subscriptionsCanBeListed() throws Exception { // Arrange From 92c356e98a2e4fdaa50acbb3fdc97379bc2f29ae Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 22 May 2013 18:23:41 -0700 Subject: [PATCH 15/48] initial check in for OData support. --- .../models/AbstractListOptions.java | 26 ++++--- .../serviceBus/ServiceBusIntegrationTest.java | 72 +++++++++++++++++++ 2 files changed, 90 insertions(+), 8 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java index 5970d10fc96f7..d18d87edf874d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java @@ -2,21 +2,22 @@ * 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 + * 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. + * 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.windowsazure.services.serviceBus.models; public abstract class AbstractListOptions { Integer skip; Integer top; + String filter; public Integer getSkip() { return skip; @@ -37,4 +38,13 @@ public T setTop(Integer top) { this.top = top; return (T) this; } + + public String getFilter() { + return filter; + } + + public T setFilter(String filter) { + this.filter = filter; + return (T) this; + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index a8c20cce470f2..5520d372f5da4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -44,6 +44,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; @@ -382,6 +383,77 @@ public void topicCanBeCreatedListedFetchedAndDeleted() throws ServiceException { assertEquals(listed.getItems().size() - 1, listed2.getItems().size()); } + @Test + public void listTopicsUnderASpecificPath() throws ServiceException { + // Arrange + String topicName = "testPathA/testPathB/listTopicUnderASpecificPath"; + + // Act + TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); + ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() + .setFilter("startswith(path, \"testPathA\\/testPathB\") eq true")); + + // Assert + assertNotNull(topicInfo); + assertEquals(1, listTopicResult.getItems().size()); + } + + @Test + public void listTopicsUpdatedInLastFiveMinutes() throws ServiceException { + String topicName = "testListTopicUpdatedInLastFiveMinutes"; + + // Act + TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); + ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() + .setFilter("ModifiedAt gt '1/25/2012 3:41:41 PM'")); + + // Assert + assertNotNull(topicInfo); + assertEquals(1, listTopicResult.getItems().size()); + } + + @Test + public void listTopicsAccessedInLastFiveMinutes() throws ServiceException { + String topicName = "testListTopicAccessedInLastFiveMinutes"; + + // Act + TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); + ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() + .setFilter("AccessedAt gt '1/25/2012 3:41:41 PM'")); + + // Assert + assertNotNull(topicInfo); + assertEquals(1, listTopicResult.getItems().size()); + } + + @Test + public void listTopicsCreatedInLastFiveMinutes() throws ServiceException { + String topicName = "testListTopicCreatedInLastFiveMinutes"; + + // Act + TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); + ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() + .setFilter("CreatedAt gt '1/25/2012 3:41:41 PM'")); + + // Assert + assertNotNull(topicInfo); + assertEquals(1, listTopicResult.getItems().size()); + } + + @Test + public void listTopicsUnderSpecificPathWithAtLeastOneMessage() throws ServiceException { + String topicName = "testListTopicsUnderSpecificPathWithAtLeastOneMessage"; + + // Act + TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); + ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() + .setFilter("startwith(path, 'foo/bar') eq true and messageCount Gt 0")); + + // Assert + assertNotNull(topicInfo); + assertEquals(1, listTopicResult.getItems().size()); + } + @Test public void topicCanBeUpdated() throws ServiceException { // Arrange From fc61698a28d5937da6270ec78c6bfd4b9a733eea Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 23 May 2013 16:35:23 -0700 Subject: [PATCH 16/48] implement the integration tests for odata query. --- .../implementation/ServiceBusRestProxy.java | 3 ++ .../serviceBus/IntegrationTestBase.java | 34 ++++++++++++------- .../serviceBus/ServiceBusIntegrationTest.java | 15 +++++--- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 05e12f33bfac6..c65567db64dd7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -307,6 +307,9 @@ private WebResource listOptions(AbstractListOptions options, WebResource path if (options.getSkip() != null) { path = path.queryParam("$skip", options.getSkip().toString()); } + if (options.getFilter() != null) { + path = path.queryParam("$filter", options.getFilter()); + } return path; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index aa8c21ec5cbbc..02e0cbee1984b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -2,15 +2,15 @@ * 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 + * 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. + * 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.windowsazure.services.serviceBus; @@ -21,11 +21,15 @@ import org.junit.BeforeClass; import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; public abstract class IntegrationTestBase { + + private ServiceBusContract service; + @BeforeClass public static void initializeSystem() { System.setProperty("http.keepAlive", "false"); @@ -36,7 +40,7 @@ public void initialize() throws Exception { boolean testAlphaExists = false; Configuration config = createConfiguration(); - ServiceBusContract service = ServiceBusService.create(config); + service = ServiceBusService.create(config); for (QueueInfo queue : iterateQueues(service)) { String queueName = queue.getPath(); if (queueName.startsWith("Test") || queueName.startsWith("test")) { @@ -52,15 +56,21 @@ public void initialize() throws Exception { } } } + + removeTopics(); + + if (!testAlphaExists) { + service.createQueue(new QueueInfo("TestAlpha")); + } + } + + protected void removeTopics() throws ServiceException { for (TopicInfo topic : iterateTopics(service)) { String topicName = topic.getPath(); if (topicName.startsWith("Test") || topicName.startsWith("test")) { service.deleteTopic(topicName); } } - if (!testAlphaExists) { - service.createQueue(new QueueInfo("TestAlpha")); - } } @AfterClass diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 5520d372f5da4..c50b7a0307fc6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -413,7 +413,8 @@ public void listTopicsUpdatedInLastFiveMinutes() throws ServiceException { } @Test - public void listTopicsAccessedInLastFiveMinutes() throws ServiceException { + public void listTopicsAccessedSinceASpecificTime() throws ServiceException { + removeTopics(); String topicName = "testListTopicAccessedInLastFiveMinutes"; // Act @@ -427,7 +428,8 @@ public void listTopicsAccessedInLastFiveMinutes() throws ServiceException { } @Test - public void listTopicsCreatedInLastFiveMinutes() throws ServiceException { + public void listTopicsCreatedSinceASpecificTime() throws ServiceException { + removeTopics(); String topicName = "testListTopicCreatedInLastFiveMinutes"; // Act @@ -442,15 +444,20 @@ public void listTopicsCreatedInLastFiveMinutes() throws ServiceException { @Test public void listTopicsUnderSpecificPathWithAtLeastOneMessage() throws ServiceException { - String topicName = "testListTopicsUnderSpecificPathWithAtLeastOneMessage"; + removeTopics(); + String topicName = "testListTopics/UnderSpecificPathWithAtLeastOneMessage"; + String secondTopicName = "testListTopics/UnderNoMessage"; // Act TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); + TopicInfo secondTopicInfo = service.createTopic(new TopicInfo().setPath(secondTopicName)).getValue(); + service.sendTopicMessage(topicName, new BrokeredMessage("Hello!")); ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() - .setFilter("startwith(path, 'foo/bar') eq true and messageCount Gt 0")); + .setFilter("startwith(path, 'testListTopics/Under') eq true and messageCount Gt 0")); // Assert assertNotNull(topicInfo); + assertNotNull(secondTopicInfo); assertEquals(1, listTopicResult.getItems().size()); } From cdecace8524f26004d34ea5fe319c5b46f1b8866 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 23 May 2013 16:54:33 -0700 Subject: [PATCH 17/48] modification of service bus integration test. --- .../services/serviceBus/ServiceBusIntegrationTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 1600b71d6cb99..8020a4d3799d1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -568,7 +568,7 @@ public void listTopicsUnderASpecificPath() throws ServiceException { // Act TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() - .setFilter("startswith(path, \"testPathA\\/testPathB\") eq true")); + .setFilter("startswith(path, 'testPathA/testPathB') eq true")); // Assert assertNotNull(topicInfo); @@ -629,8 +629,7 @@ public void listTopicsUnderSpecificPathWithAtLeastOneMessage() throws ServiceExc TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); TopicInfo secondTopicInfo = service.createTopic(new TopicInfo().setPath(secondTopicName)).getValue(); service.sendTopicMessage(topicName, new BrokeredMessage("Hello!")); - ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() - .setFilter("startwith(path, 'testListTopics/Under') eq true and messageCount Gt 0")); + ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions().setFilter("MessageCount gt 0")); // Assert assertNotNull(topicInfo); From dc4e7d2ad555ccc94e7d32a2de30637732d5bb00 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 23 May 2013 17:10:43 -0700 Subject: [PATCH 18/48] remove invalid scenarios. --- .../serviceBus/ServiceBusIntegrationTest.java | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 8020a4d3799d1..121ec2ffd8c23 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -619,24 +619,6 @@ public void listTopicsCreatedSinceASpecificTime() throws ServiceException { assertEquals(1, listTopicResult.getItems().size()); } - @Test - public void listTopicsUnderSpecificPathWithAtLeastOneMessage() throws ServiceException { - removeTopics(); - String topicName = "testListTopics/UnderSpecificPathWithAtLeastOneMessage"; - String secondTopicName = "testListTopics/UnderNoMessage"; - - // Act - TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); - TopicInfo secondTopicInfo = service.createTopic(new TopicInfo().setPath(secondTopicName)).getValue(); - service.sendTopicMessage(topicName, new BrokeredMessage("Hello!")); - ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions().setFilter("MessageCount gt 0")); - - // Assert - assertNotNull(topicInfo); - assertNotNull(secondTopicInfo); - assertEquals(1, listTopicResult.getItems().size()); - } - @Test public void topicCreatedContainsMetadata() throws ServiceException { // Arrange From 8d1b7718c709dc849caedc53dc1a89daa811364f Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 23 May 2013 17:29:42 -0700 Subject: [PATCH 19/48] fix a broken unit test for odata query. --- .../services/serviceBus/ServiceBusIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 121ec2ffd8c23..7724d8d2fcbfc 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -601,7 +601,7 @@ public void listTopicsAccessedSinceASpecificTime() throws ServiceException { // Assert assertNotNull(topicInfo); - assertEquals(1, listTopicResult.getItems().size()); + assertEquals(0, listTopicResult.getItems().size()); } @Test From 2c564fcd1b8870da7d1b40dfcccbd9667d8385e6 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Fri, 24 May 2013 17:17:26 -0700 Subject: [PATCH 20/48] separate message count details into a separated namespace. --- .../serviceBus/implementation/EntryModel.java | 19 +++++++------ .../src/main/resources/package-names.xjb | 5 ++++ ...netservices.2010.10.servicebus.connect.xsd | 18 ++++-------- ...oft.com.netservices.2011.06.servicebus.xsd | 28 +++++++++++++++++++ .../serviceBus/ServiceBusIntegrationTest.java | 24 ++++++++++++++++ 5 files changed, 73 insertions(+), 21 deletions(-) create mode 100644 microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java index 71f11d9e6e463..248b2afcf145e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java @@ -2,15 +2,15 @@ * 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 + * 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. + * 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.windowsazure.services.serviceBus.implementation; @@ -18,6 +18,9 @@ public class EntryModel { Entry entry; T model; + public EntryModel() { + } + public EntryModel(Entry entry, T model) { this.entry = entry; this.model = model; diff --git a/microsoft-azure-api/src/main/resources/package-names.xjb b/microsoft-azure-api/src/main/resources/package-names.xjb index 70e0e3714dd7b..3befcf2e0bb08 100644 --- a/microsoft-azure-api/src/main/resources/package-names.xjb +++ b/microsoft-azure-api/src/main/resources/package-names.xjb @@ -4,6 +4,11 @@ xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:version="2.0" jaxb:extensionBindingPrefixes="xjc"> + + + + + diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index eeb464a32d625..c79fba2d99c66 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -2,6 +2,7 @@ + @@ -150,7 +152,7 @@ - + @@ -281,7 +283,7 @@ - + @@ -376,16 +378,6 @@ - - - - - - - - - - @@ -556,7 +548,7 @@ - + diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd new file mode 100644 index 0000000000000..406ce46ddd86b --- /dev/null +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index e0991c81b2f4f..50dc4dfb89c5c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -16,12 +16,16 @@ import static org.junit.Assert.*; +import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Unmarshaller; + import org.junit.Before; import org.junit.Test; @@ -205,6 +209,26 @@ public void getTopicMessageCountDetails() throws Exception { } + @Test + public void deSerializeMessageCountDetails() throws Exception { + // Arrange + // String queueInfoString = "https://gongchen1.servicebus.windows.net/testGetQueueMessageCountDetails?api-version=2012-08testGetQueueMessageCountDetails2013-05-24T18:15:47Z2013-05-24T18:15:47Zgongchen1PT1M1024falsefalseP10675199DT2H48M5.4775807SfalsePT10M10true1551falseActive2013-05-24T18:15:52.2785247Z2013-05-24T18:15:52.2785247Z2013-05-24T18:15:52.8919861Ztrue10000P10675199DT2H48M5.4775807S"; + + File queueInfoFile = new File("d:\\src\\jaxb\\queueinfo.xml"); + + JAXBContext jaxbContext = JAXBContext.newInstance(String.class); + + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); + + String result = (String) jaxbUnmarshaller.unmarshal(queueInfoFile); + + // QueueInfo queueInfo = (QueueInfo) jaxbUnmarshaller.unmarshal(queueInfoFile); + + // Act + assertNotNull(result); + // Assert + } + @Test public void getSubscriptionMessageCountDetails() throws Exception { From d41dfe049b83fbea3c6361a2744ea62fc7a83bdf Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Fri, 24 May 2013 17:26:33 -0700 Subject: [PATCH 21/48] fix a typo for the schema. --- .../schemas.microsoft.com.netservices.2011.06.servicebus.xsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd index 406ce46ddd86b..b82e6e6388d90 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd @@ -5,7 +5,7 @@ xmlns:tnsn="http://schemas.microsoft.com/netservices/2011/06/servicebus" elementFormDefault="qualified" attributeFormDefault="qualified" - targetNamespace="http://schemas.microsoft.com/netservices/2011/06/servicebus/connect" + targetNamespace="http://schemas.microsoft.com/netservices/2011/06/servicebus" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" version="0.2" From f88ea6c024cd8d544803ec562dd4bf12d1db2666 Mon Sep 17 00:00:00 2001 From: veudayab Date: Tue, 28 May 2013 11:22:01 -0700 Subject: [PATCH 22/48] Support all flavors of sharedkeysigning in java --- .../services/blob/client/CloudBlob.java | 41 ++-- .../services/blob/client/CloudBlobClient.java | 2 +- .../blob/client/CloudBlobContainer.java | 35 ++-- .../services/blob/client/CloudBlockBlob.java | 8 +- .../services/blob/client/CloudPageBlob.java | 9 +- .../core/storage/AuthenticationScheme.java | 30 +++ .../services/core/storage/ServiceClient.java | 35 +++- .../core/storage/StorageCredentials.java | 175 ++++++++++++++++- .../StorageCredentialsAccountAndKey.java | 176 +++++++++++++++++- .../storage/StorageCredentialsAnonymous.java | 70 ++++++- ...orageCredentialsSharedAccessSignature.java | 84 ++++++++- .../utils/implementation/BaseRequest.java | 35 +++- .../utils/implementation/Canonicalizer.java | 78 +++++++- .../implementation/CanonicalizerFactory.java | 20 +- .../implementation/StorageOperation.java | 23 +++ .../TableFullCanonicalizer.java | 57 ++++++ .../TableLiteCanonicalizer.java | 10 +- .../services/queue/client/CloudQueue.java | 39 ++-- .../queue/client/CloudQueueClient.java | 2 +- .../services/table/client/CloudTable.java | 6 +- .../table/client/CloudTableClient.java | 3 +- .../table/client/QueryTableOperation.java | 2 +- .../table/client/TableBatchOperation.java | 2 +- .../services/table/client/TableOperation.java | 8 +- .../services/blob/client/BlobTestBase.java | 2 + .../blob/client/CloudBlobContainerTests.java | 43 +++++ .../queue/client/CloudQueueTests.java | 32 ++++ .../services/queue/client/QueueTestBase.java | 2 + .../table/client/TableClientTests.java | 25 +++ .../services/table/client/TableTestBase.java | 2 + 30 files changed, 958 insertions(+), 98 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AuthenticationScheme.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableFullCanonicalizer.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index 10193bc590c65..578019fa34c03 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -296,7 +296,8 @@ public String execute(final CloudBlobClient client, final CloudBlob blob, final .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.ACQUIRE, leaseTimeInSeconds, proposedLeaseId, null, accessCondition, blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, 0L); + + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -409,7 +410,7 @@ public Long execute(final CloudBlobClient client, final CloudBlob blob, final Op breakPeriodInSeconds, accessCondition, blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, 0L); + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -544,7 +545,8 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op this.setConnection(request); BlobRequest.addMetadata(request, blob.metadata, opContext); - client.getCredentials().signRequest(request, 0); + + this.signRequest(client, request, 0, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -624,7 +626,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op blobOptions.getTimeoutIntervalInMs(), copyId, accessCondition, blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, 0); + this.signRequest(client, request, 0, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -700,7 +702,7 @@ public CloudBlob execute(final CloudBlobClient client, final CloudBlob blob, .getRequestOptions().getTimeoutIntervalInMs(), accessCondition, blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, 0L); + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -790,7 +792,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op accessCondition, blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -882,7 +884,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlob blob, final accessCondition, blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -967,7 +969,8 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); + final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext, this.getResult()); final String contentMD5 = request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); @@ -1146,7 +1149,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -1304,7 +1307,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op request.setRequestProperty(Constants.HeaderConstants.RANGE_GET_CONTENT_MD5, "true"); } - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); final InputStream sourceStream = ExecutionEngine.getInputStream(request, opContext, this.getResult()); @@ -1441,7 +1444,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlob blob, final opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -1929,7 +1932,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op accessCondition, blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, 0L); + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -2010,7 +2013,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op accessCondition, blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, 0L); + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -2100,7 +2103,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op accessCondition, blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, 0L); + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -2228,7 +2231,7 @@ public Long execute(final CloudBlobClient client, final CloudBlob blob, final Op accessCondition, blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, 0L); + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -2369,7 +2372,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op BlobRequest.addMetadata(request, blob.metadata, opContext); - client.getCredentials().signRequest(request, length); + this.signRequest(client, request, length, null); final StreamMd5AndLength descriptor = Utility.writeToOutputStream(sourceStream, request.getOutputStream(), length, true, false, null, opContext); @@ -2454,7 +2457,8 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op this.setConnection(request); BlobRequest.addMetadata(request, blob.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -2529,7 +2533,8 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op this.setConnection(request); BlobRequest.addMetadata(request, blob.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java index 4a85876d6c987..5113afab641d5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java @@ -387,7 +387,7 @@ ResultSegment listContainersCore(final String prefix, options.getTimeoutIntervalInMs(), listingContext, detailsIncluded, opContext); taskReference.setConnection(listContainerRequest); - this.getCredentials().signRequest(listContainerRequest, -1L); + taskReference.signRequest(this, listContainerRequest, -1L, null); ExecutionEngine.processRequest(listContainerRequest, opContext, taskReference.getResult()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java index 0465a0e5d0345..10e2a450a514e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java @@ -223,7 +223,8 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta this.setConnection(request); ContainerRequest.addMetadata(request, container.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -298,7 +299,8 @@ public Boolean execute(final CloudBlobClient client, final CloudBlobContainer co this.setConnection(request); ContainerRequest.addMetadata(request, container.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -391,7 +393,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta .getTimeoutIntervalInMs(), opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -462,7 +464,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlobContainer co .getTimeoutIntervalInMs(), opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -536,7 +538,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta .getRequestOptions().getTimeoutIntervalInMs(), opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -614,7 +616,7 @@ public BlobContainerPermissions execute(final CloudBlobClient client, final Clou .getTimeoutIntervalInMs(), opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -694,7 +696,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlobContainer co .getRequestOptions().getTimeoutIntervalInMs(), opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -1114,7 +1116,7 @@ ResultSegment listBlobsCore(final String prefix, final boolean use options.getTimeoutIntervalInMs(), listingContext, options, opContext); taskReference.setConnection(listBlobsRequest); - this.blobServiceClient.getCredentials().signRequest(listBlobsRequest, -1L); + taskReference.signRequest(this.blobServiceClient, listBlobsRequest, -1L, null); ExecutionEngine.processRequest(listBlobsRequest, opContext, taskReference.getResult()); @@ -1540,7 +1542,8 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta this.setConnection(request); ContainerRequest.addMetadata(request, container.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -1619,7 +1622,9 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta ContainerRequest.writeSharedAccessIdentifiersToStream(permissions.getSharedAccessPolicies(), outBuffer); final byte[] aclBytes = outBuffer.toString().getBytes("UTF8"); - client.getCredentials().signRequest(request, aclBytes.length); + + this.signRequest(client, request, aclBytes.length, null); + final OutputStream outStreamRef = request.getOutputStream(); outStreamRef.write(aclBytes); @@ -1719,7 +1724,7 @@ public String execute(final CloudBlobClient client, final CloudBlobContainer con accessCondition, blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, 0L); + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -1802,7 +1807,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta opContext); this.setConnection(request); - client.getCredentials().signRequest(request, 0L); + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -1885,7 +1890,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta opContext); this.setConnection(request); - client.getCredentials().signRequest(request, 0L); + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -1971,7 +1976,7 @@ public Long execute(final CloudBlobClient client, final CloudBlobContainer conta accessCondition, blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, 0L); + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -2064,7 +2069,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, 0L); + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java index 91ad867eac9b8..d6724ed776ae1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java @@ -202,7 +202,8 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); - client.getCredentials().signRequest(request, descriptor.getLength()); + this.signRequest(client, request, descriptor.getLength(), null); + Utility.writeToOutputStream(blockListInputStream, request.getOutputStream(), descriptor.getLength(), false, false, null, opContext); @@ -294,7 +295,7 @@ public ArrayList execute(final CloudBlobClient client, final CloudBl blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -624,7 +625,8 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, md5); } - client.getCredentials().signRequest(request, length); + this.signRequest(client, request, length, null); + Utility.writeToOutputStream(sourceStream, request.getOutputStream(), length, true /* rewindSourceStream */, false /* calculateMD5 */, null, opContext); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java index 90ef8038334a9..38611d54063ee 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java @@ -271,7 +271,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op BlobRequest.addMetadata(request, blob.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -352,7 +352,7 @@ public ArrayList execute(final CloudBlobClient client, final CloudBlo blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -480,11 +480,12 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, md5); } - client.getCredentials().signRequest(request, length); + this.signRequest(client, request, length, null); + request.getOutputStream().write(data); } else { - client.getCredentials().signRequest(request, 0L); + this.signRequest(client, request, 0L, null); } ExecutionEngine.processRequest(request, opContext, this.getResult()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AuthenticationScheme.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AuthenticationScheme.java new file mode 100644 index 0000000000000..b2b8980550469 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AuthenticationScheme.java @@ -0,0 +1,30 @@ +/** + * 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.windowsazure.services.core.storage; + +/** + * Specifies the authentication scheme used to sign HTTP requests. + */ +public enum AuthenticationScheme { + /** + * Signs HTTP requests using the Shared Key Lite authentication scheme. + */ + SHAREDKEYLITE, + + /** + * Signs HTTP requests using the Shared Key authentication scheme. + */ + SHAREDKEYFULL; +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java index 8a6df9f916f3e..1360b9cedfb46 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java @@ -57,6 +57,11 @@ public abstract class ServiceClient { */ protected int timeoutInMs = Constants.DEFAULT_TIMEOUT_IN_MS; + /** + * 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. * @@ -142,8 +147,10 @@ public ServiceProperties execute(final ServiceClient client, final Void v, final final HttpURLConnection request = BaseRequest.getServiceProperties(client.getEndpoint(), this .getRequestOptions().getTimeoutIntervalInMs(), null, opContext); + this.setConnection(request); + + this.signRequest(client, request, -1, null); - client.getCredentials().signRequest(request, -1); ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { @@ -167,6 +174,16 @@ public final StorageCredentials getCredentials() { return this.credentials; } + /** + * Returns the AuthenticationScheme associated with this service client. + * + * @return An {@link AuthenticationScheme} object that represents the authentication scheme associated with this + * client. + */ + public final AuthenticationScheme getAuthenticationScheme() { + return this.authenticationScheme; + } + /** * Returns the base URI for this service client. * @@ -229,6 +246,18 @@ protected final void setCredentials(final StorageCredentials credentials) { this.credentials = credentials; } + /** + * Sets the Authentication Scheme to use with this service client. + * + * @param scheme + * An AuthenticationScheme object that represents the authentication scheme being assigned + * for the service + * client. + */ + public final void setAuthenticationScheme(final AuthenticationScheme scheme) { + this.authenticationScheme = scheme; + } + /** * Sets the RetryPolicyFactory object to use when making service requests. * @@ -317,6 +346,7 @@ public Void execute(final ServiceClient client, final Void v, final OperationCon final HttpURLConnection request = BaseRequest.setServiceProperties(client.getEndpoint(), this .getRequestOptions().getTimeoutIntervalInMs(), null, opContext); + this.setConnection(request); final byte[] propertiesBytes = BaseRequest.serializeServicePropertiesToByteArray(properties, opContext); @@ -326,7 +356,8 @@ public Void execute(final ServiceClient client, final Void v, final OperationCon true /* rewindSourceStream */, true /* calculateMD5 */); request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); - client.getCredentials().signRequest(request, descriptor.getLength()); + this.signRequest(client, request, descriptor.getLength(), null); + Utility.writeToOutputStream(dataInputStream, request.getOutputStream(), descriptor.getLength(), false /* rewindSourceStream */, false /* calculateMD5 */, null, opContext); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java index 009a716557465..245ff1dd91425 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java @@ -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. @@ -81,8 +81,8 @@ protected static StorageCredentials tryParseCredentials(final HashMapString that contains the key/value pairs that represent the storage credentials. *

- * 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". + * 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". * * @return A {@link StorageCredentials} object representing the storage credentials determined from the connection * string. @@ -214,6 +214,9 @@ public static StorageCredentials tryParseCredentials(final String connectionStri /** * Signs a request under the Shared Key authentication scheme. * + * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and + * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. + * * @param request * An HttpURLConnection object that represents the request to sign. * @param contentLength @@ -225,12 +228,16 @@ public static StorageCredentials tryParseCredentials(final String connectionStri * @throws StorageException * If a storage service error occurred. */ + @Deprecated public abstract void signRequest(HttpURLConnection request, long contentLength) throws InvalidKeyException, StorageException; /** * Signs a request using the specified operation context under the Shared Key authentication scheme. * + * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and + * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. + * * @param request * An HttpURLConnection object that represents the request to sign. * @param contentLength @@ -245,11 +252,15 @@ public abstract void signRequest(HttpURLConnection request, long contentLength) * @throws StorageException * If a storage service error occurred. */ + @Deprecated public abstract void signRequest(HttpURLConnection request, long contentLength, OperationContext opContext) throws InvalidKeyException, StorageException; /** - * Signs a request under the Shared Key Lite authentication scheme. + * Signs a table request under the Shared Key Lite authentication scheme. + * + * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} + * depending on the desired shared key authentication scheme. * * @param request * An HttpURLConnection object that represents the request to sign. @@ -261,12 +272,15 @@ public abstract void signRequest(HttpURLConnection request, long contentLength, * @throws StorageException * If an unspecified storage exception occurs. */ + @Deprecated public abstract void signRequestLite(HttpURLConnection request, long contentLength) throws StorageException, InvalidKeyException; /** - * Signs a request using the specified operation context under the Shared Key Lite authentication scheme. + * Signs a table request using the specified operation context under the Shared Key Lite authentication scheme. * + * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} + * depending on the desired shared key authentication scheme. * @param request * An HttpURLConnection object that represents the request to sign. * @param contentLength @@ -281,9 +295,157 @@ public abstract void signRequestLite(HttpURLConnection request, long contentLeng * @throws StorageException * If a storage service error occurred. */ + @Deprecated public abstract void signRequestLite(HttpURLConnection request, long contentLength, OperationContext opContext) throws StorageException, InvalidKeyException; + /** + * Signs a request under the Shared Key authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * + * @throws InvalidKeyException + * If the given key is invalid. + * + * @throws StorageException + * If a storage service error occurred. + */ + public abstract void signBlobAndQueueRequest(HttpURLConnection request, long contentLength) + throws InvalidKeyException, StorageException; + + /** + * Signs a request using the specified operation context under the Shared Key authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @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. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public abstract void signBlobAndQueueRequest(HttpURLConnection request, long contentLength, + OperationContext opContext) throws InvalidKeyException, StorageException; + + /** + * Signs a request under the Shared Key Lite authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If an unspecified storage exception occurs. + */ + public abstract void signBlobAndQueueRequestLite(HttpURLConnection request, long contentLength) + throws StorageException, InvalidKeyException; + + /** + * Signs a request using the specified operation context under the Shared Key Lite authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @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. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public abstract void signBlobAndQueueRequestLite(HttpURLConnection request, long contentLength, + OperationContext opContext) throws StorageException, InvalidKeyException; + + /** + * Signs a table request under the Shared Key authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * + * @throws InvalidKeyException + * If the given key is invalid. + * + * @throws StorageException + * If a storage service error occurred. + */ + public abstract void signTableRequest(HttpURLConnection request, long contentLength) throws InvalidKeyException, + StorageException; + + /** + * Signs a table request using the specified operation context under the Shared Key authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @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. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public abstract void signTableRequest(HttpURLConnection request, long contentLength, OperationContext opContext) + throws InvalidKeyException, StorageException; + + /** + * Signs a table request under the Shared Key Lite authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If an unspecified storage exception occurs. + */ + public abstract void signTableRequestLite(HttpURLConnection request, long contentLength) throws StorageException, + InvalidKeyException; + + /** + * Signs a table request using the specified operation context under the Shared Key Lite authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @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. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + + public abstract void signTableRequestLite(HttpURLConnection request, long contentLength, OperationContext opContext) + throws StorageException, InvalidKeyException; + /** * Returns a String that represents this instance. * @@ -330,4 +492,5 @@ public abstract void signRequestLite(HttpURLConnection request, long contentLeng */ public abstract URI transformUri(URI resourceUri, OperationContext opContext) throws URISyntaxException, StorageException; + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java index 2881295c1f26a..b0b27ab63d98e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java @@ -257,7 +257,7 @@ public void setCredentials(final Credentials credentials) { @Override public void signRequest(final java.net.HttpURLConnection request, final long contentLength) throws InvalidKeyException, StorageException { - this.signRequest(request, contentLength, null); + this.signBlobAndQueueRequest(request, contentLength, null); } /** @@ -300,7 +300,7 @@ public void signRequest(final java.net.HttpURLConnection request, final long con @Override public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength) throws InvalidKeyException, StorageException { - this.signRequestLite(request, contentLength, null); + this.signTableRequestLite(request, contentLength, null); } /** @@ -327,6 +327,178 @@ public void signRequestLite(final java.net.HttpURLConnection request, final long BaseRequest.signRequestForTableSharedKeyLite(request, this.credentials, contentLength, opContext); } + /** + * Signs a request under the Shared Key authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + @Override + public void signBlobAndQueueRequest(final java.net.HttpURLConnection request, final long contentLength) + throws InvalidKeyException, StorageException { + this.signBlobAndQueueRequest(request, contentLength, null); + } + + /** + * Signs a request using the specified operation context under the Shared Key authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @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. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + @Override + public void signBlobAndQueueRequest(final java.net.HttpURLConnection request, final long contentLength, + OperationContext opContext) throws InvalidKeyException, StorageException { + opContext = opContext == null ? new OperationContext() : opContext; + BaseRequest.signRequestForBlobAndQueue(request, this.credentials, contentLength, opContext); + } + + /** + * Signs a request using the Shared Key Lite authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If an unspecified storage exception occurs. + */ + @Override + public void signBlobAndQueueRequestLite(final java.net.HttpURLConnection request, final long contentLength) + throws InvalidKeyException, StorageException { + this.signBlobAndQueueRequestLite(request, contentLength, null); + } + + /** + * Signs a request using the specified operation context under the Shared Key Lite authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @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. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + @Override + public void signBlobAndQueueRequestLite(final java.net.HttpURLConnection request, final long contentLength, + OperationContext opContext) throws StorageException, InvalidKeyException { + opContext = opContext == null ? new OperationContext() : opContext; + BaseRequest.signRequestForBlobAndQueueSharedKeyLite(request, this.credentials, contentLength, opContext); + } + + /** + * Signs a request under the Shared Key authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + @Override + public void signTableRequest(final java.net.HttpURLConnection request, final long contentLength) + throws InvalidKeyException, StorageException { + this.signTableRequest(request, contentLength, null); + } + + /** + * Signs a request using the specified operation context under the Shared Key authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @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. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + @Override + public void signTableRequest(final java.net.HttpURLConnection request, final long contentLength, + OperationContext opContext) throws InvalidKeyException, StorageException { + opContext = opContext == null ? new OperationContext() : opContext; + BaseRequest.signRequestForTableSharedKey(request, this.credentials, contentLength, opContext); + } + + /** + * Signs a request using the Shared Key Lite authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If an unspecified storage exception occurs. + */ + @Override + public void signTableRequestLite(final java.net.HttpURLConnection request, final long contentLength) + throws InvalidKeyException, StorageException { + this.signTableRequestLite(request, contentLength, null); + } + + /** + * Signs a request using the specified operation context under the Shared Key Lite authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @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. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + @Override + public void signTableRequestLite(final java.net.HttpURLConnection request, final long contentLength, + OperationContext opContext) throws StorageException, InvalidKeyException { + opContext = opContext == null ? new OperationContext() : opContext; + BaseRequest.signRequestForTableSharedKeyLite(request, this.credentials, contentLength, opContext); + } + /** * Returns a String that represents this instance, optionally including sensitive data. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java index baf4e16dd16d6..f7890b6234f95 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java @@ -178,7 +178,7 @@ public String getAccountName() { * the length of the content written to the output stream. If unknown, specify -1. */ @Override - public void signRequest(final java.net.HttpURLConnection connection, final long contentLength) { + public void signBlobAndQueueRequest(final java.net.HttpURLConnection connection, final long contentLength) { // No op } @@ -196,7 +196,7 @@ public void signRequest(final java.net.HttpURLConnection connection, final long * object, that represents the current operation */ @Override - public void signRequest(final java.net.HttpURLConnection request, final long contentLength, + public void signBlobAndQueueRequest(final java.net.HttpURLConnection request, final long contentLength, final OperationContext opContext) { // No op } @@ -209,7 +209,7 @@ public void signRequest(final java.net.HttpURLConnection request, final long con * the request, as an HttpURLConnection object, to sign */ @Override - public void signRequestLite(final java.net.HttpURLConnection connection, final long contentLength) { + public void signBlobAndQueueRequestLite(final java.net.HttpURLConnection connection, final long contentLength) { // No op } @@ -225,7 +225,69 @@ public void signRequestLite(final java.net.HttpURLConnection connection, final l * object, that represents the current operation */ @Override - public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength, + public void signBlobAndQueueRequestLite(final java.net.HttpURLConnection request, final long contentLength, + final OperationContext opContext) { + // No op + } + + /** + * Signs a request using the specified credentials under the Shared Key authentication scheme. This is not a valid + * operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. + * + * @param connection + * the request, as an HttpURLConnection object, to sign + * @param contentLength + * the length of the content written to the output stream. If unknown, specify -1. + */ + @Override + public void signTableRequest(final java.net.HttpURLConnection connection, final long contentLength) { + // No op + } + + /** + * Signs a request using the specified credentials and operation context under the Shared Key authentication scheme. + * This is not a valid operation for objects of type StorageCredentialsAnonymous so the method performs + * a no-op. + * + * @param request + * the request, as an HttpURLConnection object, to sign + * @param contentLength + * the length of the content written to the output stream. If unknown, specify -1. + * @param opContext + * an operation context, as a {@link com.microsoft.windowsazure.services.core.storage.OperationContext} + * object, that represents the current operation + */ + @Override + public void signTableRequest(final java.net.HttpURLConnection request, final long contentLength, + final OperationContext opContext) { + // No op + } + + /** + * Signs a request using the specified credentials under the Shared Key Lite authentication scheme. This is not a + * valid operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. + * + * @param connection + * the request, as an HttpURLConnection object, to sign + */ + @Override + public void signTableRequestLite(final java.net.HttpURLConnection connection, final long contentLength) { + // No op + } + + /** + * Signs a request using the specified credentials under the Shared Key Lite authentication scheme. This is not a + * valid operation for objects of type StorageCredentialsSharedAccessSignature so the method performs a + * no-op. + * + * @param request + * the request, as an HttpURLConnection object, to sign + * @param opContext + * an operation context, as a {@link com.microsoft.windowsazure.services.core.storage.OperationContext} + * object, that represents the current operation + */ + @Override + public void signTableRequestLite(final java.net.HttpURLConnection request, final long contentLength, final OperationContext opContext) { // No op } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java index 4702824027ff7..1bee911c69cbc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java @@ -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 StorageCredentialsSharedAccessSignature so - * the method merely returns null. + * context. This is not a valid operation for objects of type StorageCredentialsSharedAccessSignature + * so the method merely returns null. * * @param value * The UTF-8-encoded string to sign. @@ -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 StorageCredentialsSharedAccessSignature so - * the method merely returns null. + * context. This is not a valid operation for objects of type StorageCredentialsSharedAccessSignature + * so the method merely returns null. * * @param value * The UTF-8-encoded string to sign. @@ -191,7 +191,7 @@ public String getToken() { * The length of the content written to the output stream. If unknown, specify -1. */ @Override - public void signRequest(final java.net.HttpURLConnection request, final long contentLength) { + public void signBlobAndQueueRequest(final java.net.HttpURLConnection request, final long contentLength) { // No op } @@ -210,7 +210,7 @@ public void signRequest(final java.net.HttpURLConnection request, final long con * the operation. */ @Override - public void signRequest(final java.net.HttpURLConnection request, final long contentLength, + public void signBlobAndQueueRequest(final java.net.HttpURLConnection request, final long contentLength, final OperationContext opContext) { // No op } @@ -225,7 +225,7 @@ public void signRequest(final java.net.HttpURLConnection request, final long con * The length of the content written to the output stream. If unknown, specify -1. */ @Override - public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength) { + public void signBlobAndQueueRequestLite(final java.net.HttpURLConnection request, final long contentLength) { // No op } @@ -244,7 +244,75 @@ public void signRequestLite(final java.net.HttpURLConnection request, final long * the operation. */ @Override - public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength, + public void signBlobAndQueueRequestLite(final java.net.HttpURLConnection request, final long contentLength, + final OperationContext opContext) { + // No op + } + + /** + * Signs a request under the Shared Key authentication scheme. This is not a valid operation for objects of type + * StorageCredentialsSharedAccessSignature so the method performs a no-op. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + */ + @Override + public void signTableRequest(final java.net.HttpURLConnection request, final long contentLength) { + // No op + } + + /** + * Signs a request using the specified operation context under the Shared Key authentication scheme. This is not a + * valid operation for objects of type StorageCredentialsSharedAccessSignature so the method performs a + * no-op. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @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. + */ + @Override + public void signTableRequest(final java.net.HttpURLConnection request, final long contentLength, + final OperationContext opContext) { + // No op + } + + /** + * Signs a request under the Shared Key Lite authentication scheme. This is not a valid operation for objects of + * type StorageCredentialsSharedAccessSignature so the method performs a no-op. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + */ + @Override + public void signTableRequestLite(final java.net.HttpURLConnection request, final long contentLength) { + // No op + } + + /** + * Signs a request using the specified operation context under the Shared Key Lite authentication scheme. This is + * not a valid operation for objects of type StorageCredentialsSharedAccessSignature so the method + * performs a no-op. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @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. + */ + @Override + public void signTableRequestLite(final java.net.HttpURLConnection request, final long contentLength, final OperationContext opContext) { // No op } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java index e5273db93f60b..19538da0c9854 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java @@ -498,7 +498,40 @@ public static void signRequestForBlobAndQueueSharedKeyLite(final HttpURLConnecti /** * - * Signs the request appropriately to make it an authenticated request for Blob and Queue. + * Signs the request appropriately to make it an authenticated request for Table. + * + * @param request + * a HttpURLConnection for the operation. + * @param credentials + * the credentials to use for signing. + * @param contentLength + * the length of the content written to the output stream, -1 if unknown. + * @param opContext + * an object used to track the execution of the operation + * @throws InvalidKeyException + * if the credentials key is invalid. + * @throws StorageException + */ + public static void signRequestForTableSharedKey(final HttpURLConnection request, final Credentials credentials, + final Long contentLength, final OperationContext opContext) throws InvalidKeyException, StorageException { + request.setRequestProperty(Constants.HeaderConstants.DATE, Utility.getGMTTime()); + + final Canonicalizer canonicalizer = CanonicalizerFactory.getTableFullCanonicalizer(request); + + final String stringToSign = canonicalizer.canonicalize(request, credentials.getAccountName(), contentLength, + opContext); + + final String computedBase64Signature = StorageKey.computeMacSha256(credentials.getKey(), stringToSign); + + // TODO Vnext add logging + // System.out.println(String.format("Signing %s\r\n%s\r\n", stringToSign, computedBase64Signature)); + request.setRequestProperty(Constants.HeaderConstants.AUTHORIZATION, + String.format("%s %s:%s", "SharedKey", credentials.getAccountName(), computedBase64Signature)); + } + + /** + * + * Signs the request appropriately to make it an authenticated request for Table. * * @param request * a HttpURLConnection for the operation. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java index b78e9c258cd3a..77c5f71d266d7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java @@ -34,11 +34,26 @@ import com.microsoft.windowsazure.services.core.storage.utils.Utility; /** - * RESERVED FOR INTERNAL USE. This is a Version 2 Canoncicalization strategy conforming to the PDC 2009-09-19 + * RESERVED FOR INTERNAL USE. This is a Version 2 Canonicalization strategy conforming to the PDC 2009-09-19 * specification */ abstract class Canonicalizer { + /** + * The expected length for the canonicalized string when SharedKeyFull is used to sign requests. + */ + private static final int ExpectedBlobQueueCanonicalizedStringLength = 300; + + /** + * The expected length for the canonicalized string when SharedKeyLite is used to sign requests. + */ + private static final int ExpectedBlobQueueLiteCanonicalizedStringLength = 250; + + /** + * The expected length for the canonicalized string when SharedKeyFull is used to sign table requests. + */ + private static final int ExpectedTableCanonicalizedStringLength = 200; + /** * Add x-ms- prefixed headers in a fixed order. * @@ -130,7 +145,8 @@ protected static String canonicalizeHttpRequest(final java.net.URL address, fina // The first element should be the Method of the request. // I.e. GET, POST, PUT, or HEAD. - final StringBuilder canonicalizedString = new StringBuilder(conn.getRequestMethod()); + final StringBuilder canonicalizedString = new StringBuilder(ExpectedBlobQueueCanonicalizedStringLength); + canonicalizedString.append(conn.getRequestMethod()); // The next elements are // If any element is missing it may be empty. @@ -199,7 +215,9 @@ protected static String canonicalizeHttpRequestLite(final java.net.URL address, final HttpURLConnection conn, final OperationContext opContext) throws StorageException { // The first element should be the Method of the request. // I.e. GET, POST, PUT, or HEAD. - final StringBuilder canonicalizedString = new StringBuilder(conn.getRequestMethod()); + // + final StringBuilder canonicalizedString = new StringBuilder(ExpectedBlobQueueLiteCanonicalizedStringLength); + canonicalizedString.append(conn.getRequestMethod()); // The second element should be the MD5 value. // This is optional and may be empty. @@ -220,7 +238,59 @@ protected static String canonicalizeHttpRequestLite(final java.net.URL address, addCanonicalizedHeaders(conn, canonicalizedString); - appendCanonicalizedElement(canonicalizedString, getCanonicalizedResource(address, accountName)); + appendCanonicalizedElement(canonicalizedString, getCanonicalizedResourceLite(address, accountName)); + + return canonicalizedString.toString(); + } + + /** + * Constructs a canonicalized string that will be used to construct the signature string + * for signing a Table service request under the Shared Key authentication scheme. + * + * @param address + * the request URI + * @param accountName + * the account name associated with the request + * @param method + * the verb to be used for the HTTP request. + * @param contentType + * the content type of the HTTP request. + * @param contentLength + * the length of the content written to the outputstream in bytes, -1 if unknown + * @param date + * the date/time specification for the HTTP request + * @param conn + * the HttpURLConnection for the operation. + * @param opContext + * the OperationContext for the request. + * @return A canonicalized string. + * @throws StorageException + */ + protected static String canonicalizeTableHttpRequest(final java.net.URL address, final String accountName, + final String method, final String contentType, final long contentLength, final String date, + final HttpURLConnection conn, final OperationContext opContext) throws StorageException { + // The first element should be the Method of the request. + // I.e. GET, POST, PUT, or HEAD. + final StringBuilder canonicalizedString = new StringBuilder(ExpectedTableCanonicalizedStringLength); + canonicalizedString.append(conn.getRequestMethod()); + + // The second element should be the MD5 value. + // This is optional and may be empty. + final String httpContentMD5Value = Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_MD5); + appendCanonicalizedElement(canonicalizedString, httpContentMD5Value); + + // The third element should be the content type. + appendCanonicalizedElement(canonicalizedString, contentType); + + // The fourth element should be the request date. + // See if there's an storage date header. + // If there's one, then don't use the date header. + + final String dateString = Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.DATE); + // If x-ms-date header exists, Date should be that value. + appendCanonicalizedElement(canonicalizedString, dateString.equals(Constants.EMPTY_STRING) ? date : dateString); + + appendCanonicalizedElement(canonicalizedString, getCanonicalizedResourceLite(address, accountName)); return canonicalizedString.toString(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java index 54ae1d41fe3ec..1ba789f44c40b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java @@ -45,6 +45,11 @@ final class CanonicalizerFactory { /** * The Canonicalizer instance for Table */ + private static final TableFullCanonicalizer TABLE_FULL_INSTANCE = new TableFullCanonicalizer(); + + /** + * The Canonicalizer instance for Table Lite + */ private static final TableLiteCanonicalizer TABLE_LITE_INSTANCE = new TableLiteCanonicalizer(); /** @@ -81,7 +86,18 @@ protected static Canonicalizer getBlobQueueLiteCanonicalizer(final HttpURLConnec } /** - * Gets the Blob queue lite Canonicalizer + * Gets the table full Canonicalizer. + * + * @param conn + * the HttpURLConnection for the current operation + * @return the appropriate Canonicalizer for the operation. + */ + protected static Canonicalizer getTableFullCanonicalizer(final HttpURLConnection conn) { + return TABLE_FULL_INSTANCE; + } + + /** + * Gets the table lite Canonicalizer * * @param conn * the HttpURLConnection for the current operation @@ -93,7 +109,7 @@ protected static Canonicalizer getTableLiteCanonicalizer(final HttpURLConnection } else { throw new UnsupportedOperationException( - "Versions before 2009-09-19 do not support Shared Key Lite for Blob And Queue."); + "Versions before 2009-09-19 do not support Shared Key Lite for Table."); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java index a18d41dc19dd7..47ae9204e384c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java @@ -15,10 +15,13 @@ package com.microsoft.windowsazure.services.core.storage.utils.implementation; import java.net.HttpURLConnection; +import java.security.InvalidKeyException; +import com.microsoft.windowsazure.services.core.storage.AuthenticationScheme; import com.microsoft.windowsazure.services.core.storage.OperationContext; import com.microsoft.windowsazure.services.core.storage.RequestOptions; import com.microsoft.windowsazure.services.core.storage.RequestResult; +import com.microsoft.windowsazure.services.core.storage.ServiceClient; import com.microsoft.windowsazure.services.core.storage.StorageException; /** @@ -155,6 +158,26 @@ protected final StorageException materializeException(final HttpURLConnection re return StorageException.translateException(request, null, opContext); } + public final void signRequest(ServiceClient client, HttpURLConnection request, long contentLength, + OperationContext context) throws InvalidKeyException, StorageException { + if (client.getAuthenticationScheme() == AuthenticationScheme.SHAREDKEYFULL) { + client.getCredentials().signBlobAndQueueRequest(request, contentLength, context); + } + else { + client.getCredentials().signBlobAndQueueRequestLite(request, contentLength, context); + } + } + + public final void signTableRequest(ServiceClient client, HttpURLConnection request, long contentLength, + OperationContext context) throws InvalidKeyException, StorageException { + if (client.getAuthenticationScheme() == AuthenticationScheme.SHAREDKEYFULL) { + client.getCredentials().signTableRequest(request, contentLength, context); + } + else { + client.getCredentials().signTableRequestLite(request, contentLength, context); + } + } + /** * @param exceptionReference * the exception to set diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableFullCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableFullCanonicalizer.java new file mode 100644 index 0000000000000..c3088315fb731 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableFullCanonicalizer.java @@ -0,0 +1,57 @@ +/** + * 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.windowsazure.services.core.storage.utils.implementation; + +import java.net.HttpURLConnection; +import java.security.InvalidParameterException; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. Provides an implementation of the Canonicalizer class for requests against Table + * Service under the Shared Key authentication scheme. + */ +final class TableFullCanonicalizer extends Canonicalizer { + + /** + * Constructs a canonicalized string for signing a request. + * + * @param conn + * the HttpURLConnection to canonicalize + * @param accountName + * the account name associated with the request + * @param contentLength + * the length of the content written to the outputstream in bytes, -1 if unknown + * @param opContext + * the OperationContext for the given request + * @return a canonicalized string. + * @throws StorageException + */ + @Override + protected String canonicalize(final HttpURLConnection conn, final String accountName, final Long contentLength, + final OperationContext opContext) throws StorageException { + + if (contentLength < -1) { + throw new InvalidParameterException("ContentLength must be set to -1 or non-negative Long value"); + } + + return canonicalizeTableHttpRequest(conn.getURL(), accountName, conn.getRequestMethod(), + Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_TYPE), contentLength, null, + conn, opContext); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java index 913ed76d908af..44211bf769467 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java @@ -30,6 +30,12 @@ * under the Shared Key Lite authentication scheme. */ class TableLiteCanonicalizer extends Canonicalizer { + + /** + * The expected length for the canonicalized string when SharedKeyLite is used to sign table requests. + */ + private static final int ExpectedTableLiteCanonicalizedStringLength = 150; + /** * Constructs a canonicalized string for signing a request. * @@ -56,8 +62,8 @@ protected String canonicalize(final HttpURLConnection conn, final String account throw new IllegalArgumentException( "Canonicalization did not find a non empty x-ms-date header in the request. Please use a request with a valid x-ms-date header in RFC 123 format."); } - - final StringBuilder canonicalizedString = new StringBuilder(dateString); + final StringBuilder canonicalizedString = new StringBuilder(ExpectedTableLiteCanonicalizedStringLength); + canonicalizedString.append(dateString); appendCanonicalizedElement(canonicalizedString, getCanonicalizedResourceLite(conn.getURL(), accountName)); return canonicalizedString.toString(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java index 15b646e336519..4190dd58ac73f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -217,7 +217,8 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); - client.getCredentials().signRequest(request, messageBytes.length); + this.signRequest(client, request, messageBytes.length, null); + final OutputStream outStreamRef = request.getOutputStream(); outStreamRef.write(messageBytes); @@ -286,7 +287,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final this.getRequestOptions().getTimeoutIntervalInMs(), opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -352,7 +353,8 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final this.setConnection(request); QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -426,7 +428,8 @@ public Boolean execute(final CloudQueueClient client, final CloudQueue queue, this.setConnection(request); QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -512,7 +515,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final .getRequestOptions().getTimeoutIntervalInMs(), opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -584,7 +587,7 @@ public Boolean execute(final CloudQueueClient client, final CloudQueue queue, .getRequestOptions().getTimeoutIntervalInMs(), opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -672,7 +675,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -739,7 +742,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -813,7 +816,7 @@ public Boolean execute(final CloudQueueClient client, final CloudQueue queue, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -1029,7 +1032,7 @@ public ArrayList execute(final CloudQueueClient client, final this.getRequestOptions().getTimeoutIntervalInMs(), numberOfMessages, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -1164,7 +1167,7 @@ public ArrayList execute(final CloudQueueClient client, final numberOfMessages, visibilityTimeoutInSeconds, opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -1296,13 +1299,15 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final if (messageUpdateFields.contains(MessageUpdateFields.CONTENT)) { final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); - client.getCredentials().signRequest(request, messageBytes.length); + this.signRequest(client, request, messageBytes.length, null); + final OutputStream outStreamRef = request.getOutputStream(); outStreamRef.write(messageBytes); } else { request.setFixedLengthStreamingMode(0); - client.getCredentials().signRequest(request, 0L); + + this.signRequest(client, request, 0L, null); } ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -1377,7 +1382,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final this.setConnection(request); QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + this.signRequest(client, request, 0L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -1455,7 +1460,9 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final QueueRequest.writeSharedAccessIdentifiersToStream(permissions.getSharedAccessPolicies(), outBuffer); final byte[] aclBytes = outBuffer.toString().getBytes("UTF8"); - client.getCredentials().signRequest(request, aclBytes.length); + + this.signRequest(client, request, aclBytes.length, null); + final OutputStream outStreamRef = request.getOutputStream(); outStreamRef.write(aclBytes); @@ -1528,7 +1535,7 @@ public QueuePermissions execute(final CloudQueueClient client, final CloudQueue .getRequestOptions().getTimeoutIntervalInMs(), opContext); this.setConnection(request); - client.getCredentials().signRequest(request, -1L); + this.signRequest(client, request, -1L, null); ExecutionEngine.processRequest(request, opContext, this.getResult()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java index 7f1f12938aa09..b4b1f97c2bed2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java @@ -226,7 +226,7 @@ ResultSegment listQueuesCore(final String prefix, final QueueListing options.getTimeoutIntervalInMs(), listingContext, detailsIncluded, opContext); taskReference.setConnection(listQueueRequest); - this.getCredentials().signRequest(listQueueRequest, -1L); + taskReference.signRequest(this, listQueueRequest, -1L, null); ExecutionEngine.processRequest(listQueueRequest, opContext, taskReference.getResult()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java index 47dc6bce8f9c0..298f2a8f6064a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java @@ -490,7 +490,9 @@ public Void execute(final CloudTableClient client, final CloudTable table, final TableRequest.writeSharedAccessIdentifiersToStream(permissions.getSharedAccessPolicies(), outBuffer); final byte[] aclBytes = outBuffer.toString().getBytes("UTF8"); - client.getCredentials().signRequestLite(request, aclBytes.length, opContext); + + this.signTableRequest(client, request, aclBytes.length, opContext); + final OutputStream outStreamRef = request.getOutputStream(); outStreamRef.write(aclBytes); @@ -564,7 +566,7 @@ public TablePermissions execute(final CloudTableClient client, final CloudTable .getTimeoutIntervalInMs(), opContext); this.setConnection(request); - client.getCredentials().signRequestLite(request, -1L, opContext); + this.signTableRequest(client, request, -1L, opContext); ExecutionEngine.processRequest(request, opContext, this.getResult()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java index 8a240fe9bb9d9..ca181e471aa67 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java @@ -799,7 +799,8 @@ protected ResultSegment executeQuerySegmentedCore( queryToExecute.generateQueryBuilder(), continuationToken, options, opContext); taskReference.setConnection(queryRequest); - this.getCredentials().signRequestLite(queryRequest, -1L, opContext); + taskReference.signTableRequest(this, queryRequest, -1L, opContext); + ExecutionEngine.processRequest(queryRequest, opContext, taskReference.getResult()); if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java index e92207cd4ae40..48a01577e8084 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java @@ -188,7 +188,7 @@ tableName, generateRequestIdentity(isTableEntry, operation.getPartitionKey(), fa options, opContext); this.setConnection(request); - client.getCredentials().signRequestLite(request, -1L, opContext); + this.signTableRequest(client, request, -1L, opContext); ExecutionEngine.processRequest(request, opContext, this.getResult()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java index 90b773477e552..cef17a1c030b7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java @@ -395,7 +395,7 @@ public ArrayList execute(final CloudTableClient client, final Table options.getTimeoutIntervalInMs(), batchID, null, options, opContext); this.setConnection(request); - client.getCredentials().signRequestLite(request, -1L, opContext); + this.signTableRequest(client, request, -1L, opContext); MimeHelper.writeBatchToStream(request.getOutputStream(), tableName, batch, batchID, changeSet, opContext); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java index 72d385e1996a8..81b030426817f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java @@ -261,7 +261,7 @@ tableName, generateRequestIdentity(isTableEntry, tableIdentity, false), operatio .getEtag(), options.getTimeoutIntervalInMs(), null, options, opContext); this.setConnection(request); - client.getCredentials().signRequestLite(request, -1L, opContext); + this.signTableRequest(client, request, -1L, opContext); ExecutionEngine.processRequest(request, opContext, this.getResult()); @@ -330,7 +330,7 @@ tableName, generateRequestIdentity(isTableEntry, tableIdentity, false), operation.opType.getUpdateType(), options.getTimeoutIntervalInMs(), null, options, opContext); this.setConnection(request); - client.getCredentials().signRequestLite(request, -1L, opContext); + this.signTableRequest(client, request, -1L, opContext); AtomPubParser.writeSingleEntityToStream(operation.getEntity(), isTableEntry, request.getOutputStream(), opContext); @@ -412,7 +412,7 @@ tableName, generateRequestIdentity(false, null, false), operation.getEntity().ge options.getTimeoutIntervalInMs(), null, options, opContext); this.setConnection(request); - client.getCredentials().signRequestLite(request, -1L, opContext); + this.signTableRequest(client, request, -1L, opContext); AtomPubParser.writeSingleEntityToStream(operation.getEntity(), false, request.getOutputStream(), opContext); @@ -479,7 +479,7 @@ tableName, generateRequestIdentity(false, null, false), operation.getEntity().ge options.getTimeoutIntervalInMs(), null, options, opContext); this.setConnection(request); - client.getCredentials().signRequestLite(request, -1L, opContext); + this.signTableRequest(client, request, -1L, opContext); AtomPubParser.writeSingleEntityToStream(operation.getEntity(), false, request.getOutputStream(), opContext); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java index 3da51d425a0e2..1b69119c1e48b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java @@ -21,6 +21,7 @@ import org.junit.AfterClass; import org.junit.BeforeClass; +import com.microsoft.windowsazure.services.core.storage.AuthenticationScheme; import com.microsoft.windowsazure.services.core.storage.CloudStorageAccount; import com.microsoft.windowsazure.services.core.storage.StorageException; @@ -52,6 +53,7 @@ public static void setup() throws URISyntaxException, StorageException, InvalidK } bClient = httpAcc.createCloudBlobClient(); + bClient.setAuthenticationScheme(AuthenticationScheme.SHAREDKEYFULL); testSuiteContainerName = generateRandomContainerName(); CloudBlobContainer container = bClient.getContainerReference(testSuiteContainerName); container.create(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java index e007c41511408..36a73da82be8e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java @@ -36,6 +36,7 @@ import org.junit.Test; import com.microsoft.windowsazure.services.core.storage.AccessCondition; +import com.microsoft.windowsazure.services.core.storage.AuthenticationScheme; import com.microsoft.windowsazure.services.core.storage.OperationContext; import com.microsoft.windowsazure.services.core.storage.ResultSegment; import com.microsoft.windowsazure.services.core.storage.RetryNoRetry; @@ -808,4 +809,46 @@ public void testCurrentOperationByteCount() throws URISyntaxException, StorageEx blobRef.delete(); } + + @Test + public void testContainerSharedKeyLite() throws StorageException, URISyntaxException { + bClient.setAuthenticationScheme(AuthenticationScheme.SHAREDKEYLITE); + String name = generateRandomContainerName(); + CloudBlobContainer newContainer = bClient.getContainerReference(name); + newContainer.create(); + + BlobContainerPermissions expectedPermissions; + BlobContainerPermissions testPermissions; + + try { + // Test new permissions. + expectedPermissions = new BlobContainerPermissions(); + testPermissions = newContainer.downloadPermissions(); + assertTablePermissionsEqual(expectedPermissions, testPermissions); + + // Test setting empty permissions. + newContainer.uploadPermissions(expectedPermissions); + testPermissions = newContainer.downloadPermissions(); + assertTablePermissionsEqual(expectedPermissions, testPermissions); + + // Add a policy, check setting and getting. + SharedAccessBlobPolicy policy1 = new SharedAccessBlobPolicy(); + Calendar now = GregorianCalendar.getInstance(); + policy1.setSharedAccessStartTime(now.getTime()); + now.add(Calendar.MINUTE, 10); + policy1.setSharedAccessExpiryTime(now.getTime()); + + policy1.setPermissions(EnumSet.of(SharedAccessBlobPermissions.READ, SharedAccessBlobPermissions.DELETE, + SharedAccessBlobPermissions.LIST, SharedAccessBlobPermissions.DELETE)); + expectedPermissions.getSharedAccessPolicies().put(UUID.randomUUID().toString(), policy1); + + newContainer.uploadPermissions(expectedPermissions); + testPermissions = newContainer.downloadPermissions(); + assertTablePermissionsEqual(expectedPermissions, testPermissions); + } + finally { + // cleanup + newContainer.deleteIfExists(); + } + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java index 53c95807d4650..2f91a392326cd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java @@ -34,6 +34,7 @@ import org.junit.Test; +import com.microsoft.windowsazure.services.core.storage.AuthenticationScheme; import com.microsoft.windowsazure.services.core.storage.OperationContext; import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature; import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; @@ -1359,4 +1360,35 @@ public void testSASClientParse() throws StorageException, URISyntaxException, In CloudQueue queue2 = new CloudQueue(queueUri, queueClient2); queue2.getName(); } + + @Test + public void testQueueSharedKeyLite() throws URISyntaxException, StorageException { + qClient.setAuthenticationScheme(AuthenticationScheme.SHAREDKEYLITE); + String queueName = UUID.randomUUID().toString().toLowerCase(); + CloudQueue queue = qClient.getQueueReference(queueName); + Assert.assertEquals(queueName, queue.getName()); + + OperationContext createQueueContext = new OperationContext(); + queue.create(null, createQueueContext); + Assert.assertEquals(createQueueContext.getLastResult().getStatusCode(), HttpURLConnection.HTTP_CREATED); + + try { + HashMap metadata1 = new HashMap(); + metadata1.put("ExistingMetadata1", "ExistingMetadataValue1"); + queue.setMetadata(metadata1); + queue.create(); + Assert.fail(); + } + catch (StorageException e) { + Assert.assertTrue(e.getHttpStatusCode() == HttpURLConnection.HTTP_CONFLICT); + + } + + queue.downloadAttributes(); + OperationContext createQueueContext2 = new OperationContext(); + queue.create(null, createQueueContext2); + Assert.assertEquals(createQueueContext2.getLastResult().getStatusCode(), HttpURLConnection.HTTP_NO_CONTENT); + + queue.delete(); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java index 831bbf6ca30dc..4ccfa9f781365 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java @@ -22,6 +22,7 @@ import org.junit.AfterClass; import org.junit.BeforeClass; +import com.microsoft.windowsazure.services.core.storage.AuthenticationScheme; import com.microsoft.windowsazure.services.core.storage.CloudStorageAccount; import com.microsoft.windowsazure.services.core.storage.StorageException; @@ -53,6 +54,7 @@ public static void setup() throws URISyntaxException, StorageException, InvalidK } qClient = httpAcc.createCloudQueueClient(); + qClient.setAuthenticationScheme(AuthenticationScheme.SHAREDKEYFULL); testSuiteQueueName = generateRandomQueueName(); queue = qClient.getQueueReference(testSuiteQueueName); queue.create(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableClientTests.java index 3f9bf6fa9a757..dda98602e798f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableClientTests.java @@ -33,6 +33,7 @@ import org.junit.Test; +import com.microsoft.windowsazure.services.core.storage.AuthenticationScheme; import com.microsoft.windowsazure.services.core.storage.ResultSegment; import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature; import com.microsoft.windowsazure.services.core.storage.StorageException; @@ -641,6 +642,30 @@ public void testTableSASFromPermission() throws StorageException, URISyntaxExcep } } + @Test + public void tableCreateAndAttemptCreateOnceExistsSharedKeyLite() throws StorageException, URISyntaxException { + tClient.setAuthenticationScheme(AuthenticationScheme.SHAREDKEYLITE); + String tableName = generateRandomTableName(); + CloudTable table = tClient.getTableReference(tableName); + try { + table.create(); + Assert.assertTrue(table.exists()); + + // Should fail as it already exists + try { + table.create(); + fail(); + } + catch (StorageException ex) { + Assert.assertEquals(ex.getErrorCode(), "TableAlreadyExists"); + } + } + finally { + // cleanup + table.deleteIfExists(); + } + } + private CloudTableClient getTableForSas(CloudTable table, SharedAccessTablePolicy policy, String accessIdentifier, String startPk, String startRk, String endPk, String endRk) throws InvalidKeyException, StorageException { String sasString = table diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java index bb4d9d1a156d3..4d50f8dce7030 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java @@ -26,6 +26,7 @@ import org.junit.BeforeClass; import com.microsoft.windowsazure.services.blob.client.CloudBlobClient; +import com.microsoft.windowsazure.services.core.storage.AuthenticationScheme; import com.microsoft.windowsazure.services.core.storage.CloudStorageAccount; import com.microsoft.windowsazure.services.core.storage.StorageException; import com.microsoft.windowsazure.services.queue.client.CloudQueueClient; @@ -595,6 +596,7 @@ public static void setup() throws URISyntaxException, StorageException, InvalidK tClient = httpAcc.createCloudTableClient(); qClient = httpAcc.createCloudQueueClient(); testSuiteTableName = generateRandomTableName(); + tClient.setAuthenticationScheme(AuthenticationScheme.SHAREDKEYFULL); CloudTable table = tClient.getTableReference(testSuiteTableName); table.create(); } From 409a11267bf79accbb9ef2bfc19b9dbea7e45ab1 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 28 May 2013 16:13:57 -0700 Subject: [PATCH 23/48] a fix for servicebus schema. --- microsoft-azure-api/src/main/resources/servicebus-atom.xsd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/microsoft-azure-api/src/main/resources/servicebus-atom.xsd b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd index b8387023a54be..af199118fb4cc 100644 --- a/microsoft-azure-api/src/main/resources/servicebus-atom.xsd +++ b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd @@ -3,6 +3,9 @@ attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.w3.org/2005/Atom" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ser="http://schemas.microsoft.com/2003/10/Serialization/"> + From 704be53cbdde3b580a7ad921cc47e2999d007709 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 3 Jun 2013 16:57:36 -0700 Subject: [PATCH 24/48] remove bad service bus design. --- ...t.com.netservices.2010.10.servicebus.connect.xsd | 13 ------------- .../serviceBus/ServiceBusIntegrationTest.java | 11 ++--------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index f39e6c7b02f43..dde511d1558c8 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -406,17 +406,6 @@ - - - - - - - - - - - @@ -429,12 +418,10 @@ - - diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 36a3ef04cce5b..39958694b2589 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -37,8 +37,6 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.EmptyRuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.EntityStatus; import com.microsoft.windowsazure.services.serviceBus.implementation.FalseFilter; -import com.microsoft.windowsazure.services.serviceBus.implementation.FilterProperties; -import com.microsoft.windowsazure.services.serviceBus.implementation.KeyValueOfStringAnyType; import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; import com.microsoft.windowsazure.services.serviceBus.implementation.SqlFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.SqlRuleAction; @@ -707,15 +705,10 @@ public void subscriptionsCanBeCreatedOnTopics() throws Exception { @Test public void createSubscriptionWithCorrelationFilter() throws Exception { // Arrange - String topicName = "createSubscriptionWithCorrelationFilter"; + String topicName = "testCreateSubscriptionWithCorrelationFilter"; service.createTopic(new TopicInfo(topicName)); CorrelationFilter correlationFilter = new CorrelationFilter(); - FilterProperties filterProperties = new FilterProperties(); - KeyValueOfStringAnyType keyValueOfStringAnyType = new KeyValueOfStringAnyType(); - keyValueOfStringAnyType.setKey("AKey"); - keyValueOfStringAnyType.setValue(new String("A Value")); - filterProperties.getKeyValueOfstringanyTypes().add(keyValueOfStringAnyType); - correlationFilter.setProperties(filterProperties); + correlationFilter.setContentType("sampleCorrelationId"); RuleDescription ruleDescription = new RuleDescription(); ruleDescription.setFilter(correlationFilter); From e63622eb4ee52ba9b678644f3d2a09ff7e5d1789 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 4 Jun 2013 10:55:12 -0700 Subject: [PATCH 25/48] fix the schema for message count details. --- microsoft-azure-api/pom.xml | 8 +++++--- ....com.netservices.2010.10.servicebus.connect.xsd | 4 ++-- ...icrosoft.com.netservices.2011.06.servicebus.xsd | 14 +++++--------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 9c0bb981d0a7e..f1c0aca272d33 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -143,7 +143,7 @@ org.jvnet.jaxb2.maven2 maven-jaxb2-plugin - 0.8.0 + 0.8.3 generate-sources @@ -154,16 +154,18 @@ true + true + true org.jvnet.jaxb2_commons jaxb2-basics - 0.6.0 + 0.6.4 org.jvnet.jaxb2_commons jaxb2-basics-annotate - 0.6.0 + 0.6.4 diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index c79fba2d99c66..ed557fbea1df5 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -22,8 +22,8 @@ - - + + diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd index b82e6e6388d90..8c184128c6426 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd @@ -1,17 +1,14 @@ + version="0.2" + jaxb:version="2.0" + xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" + jaxb:extensionBindingPrefixes="xjc"> @@ -24,5 +21,4 @@ - From 74def0cb45be88523f1acaa075893c4b8845cdfa Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 4 Jun 2013 18:01:44 -0700 Subject: [PATCH 26/48] improving unit test for message count details. --- .../serviceBus/ServiceBusIntegrationTest.java | 75 ++++++++++++------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 7024d4d1fc154..f0d61225c162a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -16,16 +16,12 @@ import static org.junit.Assert.*; -import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Unmarshaller; - import org.junit.Before; import org.junit.Test; @@ -190,6 +186,10 @@ public void getQueueMessageCountDetails() throws Exception { service.createQueue(new QueueInfo(queueName)); service.sendQueueMessage(queueName, new BrokeredMessage("Hello World")); Long expectedActiveMessageCount = 1L; + Long expectedDeadLetterMessageCount = 0L; + Long expectedScheduledMessageCount = 0L; + Long expectedTransferMessageCount = 0L; + Long expectedTransferDeadLetterMessageCount = 0L; // Act QueueInfo queueInfo = service.getQueue(queueName).getValue(); @@ -199,41 +199,66 @@ public void getQueueMessageCountDetails() throws Exception { assertEquals(true, queueInfo.isSupportOrdering()); assertNotNull(countDetails); assertEquals(expectedActiveMessageCount, countDetails.getActiveMessageCount()); + assertEquals(expectedDeadLetterMessageCount, countDetails.getDeadLetterMessageCount()); + assertEquals(expectedScheduledMessageCount, countDetails.getScheduledMessageCount()); + assertEquals(expectedTransferMessageCount, countDetails.getTransferMessageCount()); + assertEquals(expectedTransferDeadLetterMessageCount, countDetails.getTransferDeadLetterMessageCount()); } @Test public void getTopicMessageCountDetails() throws Exception { - // Arrange + // Arrange + String topicName = "TestGetTopicMessageCountDetails"; + service.createTopic(new TopicInfo(topicName)).getValue(); + service.sendTopicMessage(topicName, new BrokeredMessage("Hello World!")); + Long expectedActiveMessageCount = 1L; + Long expectedDeadLetterMessageCount = 0L; + Long expectedScheduledMessageCount = 0L; + Long expectedTransferMessageCount = 0L; + Long expectedTransferDeadLetterMessageCount = 0L; - // Act + // Act + TopicInfo topicInfo = service.getTopic(topicName).getValue(); + MessageCountDetails countDetails = topicInfo.getCountDetails(); - // Assert + // Assert + assertNotNull(topicInfo); + assertNotNull(countDetails); + assertEquals(expectedActiveMessageCount, countDetails.getActiveMessageCount()); + assertEquals(expectedDeadLetterMessageCount, countDetails.getDeadLetterMessageCount()); + assertEquals(expectedScheduledMessageCount, countDetails.getScheduledMessageCount()); + assertEquals(expectedTransferMessageCount, countDetails.getTransferMessageCount()); + assertEquals(expectedTransferDeadLetterMessageCount, countDetails.getTransferDeadLetterMessageCount()); } @Test - public void deSerializeMessageCountDetails() throws Exception { - // Arrange - // String queueInfoString = "https://gongchen1.servicebus.windows.net/testGetQueueMessageCountDetails?api-version=2012-08testGetQueueMessageCountDetails2013-05-24T18:15:47Z2013-05-24T18:15:47Zgongchen1PT1M1024falsefalseP10675199DT2H48M5.4775807SfalsePT10M10true1551falseActive2013-05-24T18:15:52.2785247Z2013-05-24T18:15:52.2785247Z2013-05-24T18:15:52.8919861Ztrue10000P10675199DT2H48M5.4775807S"; - - File queueInfoFile = new File("d:\\src\\jaxb\\queueinfo.xml"); - - JAXBContext jaxbContext = JAXBContext.newInstance(String.class); - - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); - - String result = (String) jaxbUnmarshaller.unmarshal(queueInfoFile); + public void getSubscriptionMessageCountDetails() throws Exception { + // Arrange + String topicName = "TestGetSubscriptionMessageCountDetails"; + String subscriptionName = "TestGetSubscriptionMessageCountDetails"; + service.createTopic(new TopicInfo(topicName)).getValue(); + service.createSubscription(topicName, new SubscriptionInfo(subscriptionName)); + Long expectedActiveMessageCount = 1L; + Long expectedDeadLetterMessageCount = 0L; + Long expectedScheduledMessageCount = 0L; + Long expectedTransferMessageCount = 0L; + Long expectedTransferDeadLetterMessageCount = 0L; - // QueueInfo queueInfo = (QueueInfo) jaxbUnmarshaller.unmarshal(queueInfoFile); + // Act + service.sendTopicMessage(topicName, new BrokeredMessage("Hello world!")); + SubscriptionInfo subscriptionInfo = service.getSubscription(topicName, subscriptionName).getValue(); + MessageCountDetails countDetails = subscriptionInfo.getCountDetails(); - // Act - assertNotNull(result); // Assert - } - - @Test - public void getSubscriptionMessageCountDetails() throws Exception { + assertNotNull(subscriptionInfo); + assertNotNull(countDetails); + assertEquals(expectedActiveMessageCount, countDetails.getActiveMessageCount()); + assertEquals(expectedDeadLetterMessageCount, countDetails.getDeadLetterMessageCount()); + assertEquals(expectedScheduledMessageCount, countDetails.getScheduledMessageCount()); + assertEquals(expectedTransferMessageCount, countDetails.getTransferMessageCount()); + assertEquals(expectedTransferDeadLetterMessageCount, countDetails.getTransferDeadLetterMessageCount()); } From 5576deae8bafea3c9c9157fe6c744eee8abad54a Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 5 Jun 2013 10:37:40 -0700 Subject: [PATCH 27/48] add javadoc for message count details. --- .../services/serviceBus/models/QueueInfo.java | 6 ++++++ .../services/serviceBus/models/SubscriptionInfo.java | 6 ++++++ .../services/serviceBus/models/TopicInfo.java | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index 9f3642b0428b2..2ebe5ed5a5945 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -29,6 +29,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.PartitioningPolicy; import com.microsoft.windowsazure.services.serviceBus.implementation.QueueDescription; +// TODO: Auto-generated Javadoc /** * Represents a queue. */ @@ -541,6 +542,11 @@ public QueueInfo setUserMetadata(String userMetadata) { return this; } + /** + * Gets the message count details. + * + * @return A MessageCountDetails instance that represents the details of the message count. + */ public MessageCountDetails getCountDetails() { return getModel().getCountDetails(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java index 10864cd736c62..675302f172688 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java @@ -28,6 +28,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; import com.microsoft.windowsazure.services.serviceBus.implementation.SubscriptionDescription; +// TODO: Auto-generated Javadoc /** * Represents a subscription. */ @@ -431,6 +432,11 @@ public EntityAvailabilityStatus getEntityAvailabilityStatus() { return getModel().getEntityAvailabilityStatus(); } + /** + * Gets the message count details. + * + * @return A MessageCountDetails instance representing the details of the message count. + */ public MessageCountDetails getCountDetails() { return getModel().getCountDetails(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java index d722ecc218887..44ca571e983e6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java @@ -29,6 +29,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.PartitioningPolicy; import com.microsoft.windowsazure.services.serviceBus.implementation.TopicDescription; +// TODO: Auto-generated Javadoc /** * Represents a topic. */ @@ -407,6 +408,11 @@ public Integer getSubscriptionCount() { return getModel().getSubscriptionCount(); } + /** + * Gets the message count details. + * + * @return A MessageCountDetails instance representing the details of the message count. + */ public MessageCountDetails getCountDetails() { return getModel().getCountDetails(); } @@ -474,6 +480,11 @@ public EntityAvailabilityStatus getEntityAvailabilityStatus() { return getModel().getEntityAvailabilityStatus(); } + /** + * Gets the uri. + * + * @return the uri + */ public URI getUri() { return URI.create(getEntry().getId()); } From 1a61a24b1ca40e5f4385e07b8a9b7de7b9fcd7c1 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 5 Jun 2013 10:43:38 -0700 Subject: [PATCH 28/48] remove newly introduced TODOs --- .../windowsazure/services/serviceBus/models/QueueInfo.java | 1 - .../services/serviceBus/models/SubscriptionInfo.java | 1 - .../windowsazure/services/serviceBus/models/TopicInfo.java | 1 - 3 files changed, 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index 2ebe5ed5a5945..d0600c19ec43f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -29,7 +29,6 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.PartitioningPolicy; import com.microsoft.windowsazure.services.serviceBus.implementation.QueueDescription; -// TODO: Auto-generated Javadoc /** * Represents a queue. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java index 675302f172688..0df71b38b78f5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java @@ -28,7 +28,6 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; import com.microsoft.windowsazure.services.serviceBus.implementation.SubscriptionDescription; -// TODO: Auto-generated Javadoc /** * Represents a subscription. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java index 44ca571e983e6..d3233b1a81745 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java @@ -29,7 +29,6 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.PartitioningPolicy; import com.microsoft.windowsazure.services.serviceBus.implementation.TopicDescription; -// TODO: Auto-generated Javadoc /** * Represents a topic. */ From 2bfbfcae9418cf0c8f188c86d1928c70a6566fa9 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 5 Jun 2013 13:09:45 -0700 Subject: [PATCH 29/48] code review feedback --- .../schemas.microsoft.com.netservices.2011.06.servicebus.xsd | 2 +- .../services/serviceBus/ServiceBusIntegrationTest.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd index 8c184128c6426..b3bf4be77e9fd 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd @@ -16,7 +16,7 @@ - + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index f0d61225c162a..d2f97235afb67 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -211,8 +211,7 @@ public void getTopicMessageCountDetails() throws Exception { // Arrange String topicName = "TestGetTopicMessageCountDetails"; service.createTopic(new TopicInfo(topicName)).getValue(); - service.sendTopicMessage(topicName, new BrokeredMessage("Hello World!")); - Long expectedActiveMessageCount = 1L; + Long expectedActiveMessageCount = 0L; Long expectedDeadLetterMessageCount = 0L; Long expectedScheduledMessageCount = 0L; Long expectedTransferMessageCount = 0L; From b2eccda962b309e9919448a2d1b557eee06a2a9c Mon Sep 17 00:00:00 2001 From: veudayab Date: Wed, 5 Jun 2013 15:19:42 -0700 Subject: [PATCH 30/48] Support all flavors of sharedkeysigning in Java --- .../storage/StorageCredentialsAnonymous.java | 78 +++++++++++++++++++ ...orageCredentialsSharedAccessSignature.java | 78 +++++++++++++++++++ 2 files changed, 156 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java index f7890b6234f95..e676a277b068e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java @@ -168,6 +168,84 @@ public String getAccountName() { return null; } + /** + * Signs a request using the specified credentials under the Shared Key authentication scheme. This is not a valid + * operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. + * + * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and + * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. + * + * @param connection + * the request, as an HttpURLConnection object, to sign + * @param contentLength + * the length of the content written to the output stream. If unknown, specify -1. + */ + @Override + @Deprecated + public void signRequest(final java.net.HttpURLConnection connection, final long contentLength) { + // No op + } + + /** + * Signs a request using the specified credentials and operation context under the Shared Key authentication scheme. + * This is not a valid operation for objects of type StorageCredentialsAnonymous so the method performs + * a no-op. + * + * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and + * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. + * + * @param request + * the request, as an HttpURLConnection object, to sign + * @param contentLength + * the length of the content written to the output stream. If unknown, specify -1. + * @param opContext + * an operation context, as a {@link com.microsoft.windowsazure.services.core.storage.OperationContext} + * object, that represents the current operation + */ + @Override + @Deprecated + public void signRequest(final java.net.HttpURLConnection request, final long contentLength, + final OperationContext opContext) { + // No op + } + + /** + * Signs a request using the specified credentials under the Shared Key Lite authentication scheme. This is not a + * valid operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. + * + * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} + * depending on the desired shared key authentication scheme. + * + * @param connection + * the request, as an HttpURLConnection object, to sign + */ + @Override + @Deprecated + public void signRequestLite(final java.net.HttpURLConnection connection, final long contentLength) { + // No op + } + + /** + * Signs a request using the specified credentials under the Shared Key Lite authentication scheme. This is not a + * valid operation for objects of type StorageCredentialsSharedAccessSignature so the method performs a + * no-op. + * + * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} + * depending on the desired shared key authentication scheme. + * + * @param request + * the request, as an HttpURLConnection object, to sign + * @param opContext + * an operation context, as a {@link com.microsoft.windowsazure.services.core.storage.OperationContext} + * object, that represents the current operation + */ + @Override + @Deprecated + public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength, + final OperationContext opContext) { + // No op + } + /** * Signs a request using the specified credentials under the Shared Key authentication scheme. This is not a valid * operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java index 1bee911c69cbc..189fb00f95127 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java @@ -181,6 +181,84 @@ public String getToken() { return this.token; } + /** + * Signs a request using the specified credentials under the Shared Key authentication scheme. This is not a valid + * operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. + * + * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and + * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. + * + * @param connection + * the request, as an HttpURLConnection object, to sign + * @param contentLength + * the length of the content written to the output stream. If unknown, specify -1. + */ + @Override + @Deprecated + public void signRequest(final java.net.HttpURLConnection connection, final long contentLength) { + // No op + } + + /** + * Signs a request using the specified credentials and operation context under the Shared Key authentication scheme. + * This is not a valid operation for objects of type StorageCredentialsAnonymous so the method performs + * a no-op. + * + * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and + * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. + * + * @param request + * the request, as an HttpURLConnection object, to sign + * @param contentLength + * the length of the content written to the output stream. If unknown, specify -1. + * @param opContext + * an operation context, as a {@link com.microsoft.windowsazure.services.core.storage.OperationContext} + * object, that represents the current operation + */ + @Override + @Deprecated + public void signRequest(final java.net.HttpURLConnection request, final long contentLength, + final OperationContext opContext) { + // No op + } + + /** + * Signs a request using the specified credentials under the Shared Key Lite authentication scheme. This is not a + * valid operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. + * + * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} + * depending on the desired shared key authentication scheme. + * + * @param connection + * the request, as an HttpURLConnection object, to sign + */ + @Override + @Deprecated + public void signRequestLite(final java.net.HttpURLConnection connection, final long contentLength) { + // No op + } + + /** + * Signs a request using the specified credentials under the Shared Key Lite authentication scheme. This is not a + * valid operation for objects of type StorageCredentialsSharedAccessSignature so the method performs a + * no-op. + * + * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} + * depending on the desired shared key authentication scheme. + * + * @param request + * the request, as an HttpURLConnection object, to sign + * @param opContext + * an operation context, as a {@link com.microsoft.windowsazure.services.core.storage.OperationContext} + * object, that represents the current operation + */ + @Override + @Deprecated + public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength, + final OperationContext opContext) { + // No op + } + /** * Signs a request under the Shared Key authentication scheme. This is not a valid operation for objects of type * StorageCredentialsSharedAccessSignature so the method performs a no-op. From 8ee99c91fd4304d284dcdc60ce2338db13b6e3e6 Mon Sep 17 00:00:00 2001 From: Anu Bandi Date: Mon, 10 Jun 2013 15:14:38 -0700 Subject: [PATCH 31/48] fixed README.md fixes #360 - code sample now uses containerPermissions variable - added java and xml tags for syntax highlighting --- README.md | 117 ++++++++++++++++++++++++++---------------------------- 1 file changed, 57 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index a8805eb2e3262..97d57a4855d2d 100644 --- a/README.md +++ b/README.md @@ -42,11 +42,13 @@ To get the source code of the SDK via git just type: To get the binaries of this library as distributed by Microsoft, ready for use within your project you can also have them installed by the Java package manager Maven. - - com.microsoft.windowsazure - microsoft-windowsazure-api - 0.4.2 - +```xml + + com.microsoft.windowsazure + microsoft-windowsazure-api + 0.4.2 + +``` ##Minimum Requirements @@ -61,67 +63,62 @@ account. To host your Java code in Windows Azure, you additionally need to down the full Windows Azure SDK for Java - which includes packaging, emulation, and deployment tools. -##Code Samples +##Code Sample The following is a quick example on how to set up a Azure blob using the API and uploading a file to it. For additional information on using the client libraries to access Azure services see the How To guides listed [here](http://www.windowsazure.com/en-us/develop/java/). +```java +import java.io.*; + +import com.microsoft.windowsazure.services.core.storage.*; +import com.microsoft.windowsazure.services.blob.client.*; + +public class BlobSample { + public static final String storageConnectionString = + "DefaultEndpointsProtocol=http;" + + "AccountName=your_account_name;" + + "AccountKey= your_account_name"; + + public static void main(String[] args) { + try { + CloudStorageAccount account; + CloudBlobClient serviceClient; + CloudBlobContainer container; + CloudBlockBlob blob; + + account = CloudStorageAccount.parse(storageConnectionString); + serviceClient = account.createCloudBlobClient(); + // Container name must be lower case. + container = serviceClient.getContainerReference("blobsample"); + container.createIfNotExist(); + + // Set anonymous access on the container. + BlobContainerPermissions containerPermissions; + containerPermissions = new BlobContainerPermissions(); + container.uploadPermissions(containerPermissions); + + // Upload an image file. + blob = container.getBlockBlobReference("image1.jpg"); + File fileReference = new File("c:\\myimages\\image1.jpg"); + blob.upload(new FileInputStream(fileReference), fileReference.length()); + } catch (FileNotFoundException fileNotFoundException) { + System.out.print("FileNotFoundException encountered: "); + System.out.println(fileNotFoundException.getMessage()); + System.exit(-1); + } catch (StorageException storageException) { + System.out.print("StorageException encountered: "); + System.out.println(storageException.getMessage()); + System.exit(-1); + } catch (Exception e) { + System.out.print("Exception encountered: "); + System.out.println(e.getMessage()); + System.exit(-1); + } - import com.microsoft.windowsazure.services.core.storage.*; - import com.microsoft.windowsazure.services.blob.client.*; - - public class BlobSample { - public static final String storageConnectionString = - "DefaultEndpointsProtocol=http;" + - "AccountName=your_account_name;" + - "AccountKey= your_account_name"; - - public static void main(String[] args) - { - try - { - CloudStorageAccount account; - CloudBlobClient serviceClient; - CloudBlobContainer container; - CloudBlockBlob blob; - - account = CloudStorageAccount.parse(storageConnectionString); - serviceClient = account.createCloudBlobClient(); - // Container name must be lower case. - container = serviceClient.getContainerReference("blobsample"); - container.createIfNotExist(); - - // Set anonymous access on the container. - BlobContainerPermissions containerPermissions; - containerPermissions = new BlobContainerPermissions(); - - // Upload an image file. - blob = container.getBlockBlobReference("image1.jpg"); - File fileReference = new File ("c:\\myimages\\image1.jpg"); - blob.upload(new FileInputStream(fileReference), fileReference.length()); - } - catch (FileNotFoundException fileNotFoundException) - { - System.out.print("FileNotFoundException encountered: "); - System.out.println(fileNotFoundException.getMessage()); - System.exit(-1); - } - catch (StorageException storageException) - { - System.out.print("StorageException encountered: "); - System.out.println(storageException.getMessage()); - System.exit(-1); - } - catch (Exception e) - { - System.out.print("Exception encountered: "); - System.out.println(e.getMessage()); - System.exit(-1); - } - - } } - +} +``` #Need Help? From 07297a3616b6cf11742d7f4da475f1d654a087e0 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 10 Jun 2013 16:20:04 -0700 Subject: [PATCH 32/48] harmonize the design with mooncake requirement. --- .../ServiceBusConnectionSettings.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java index dc0d3da353c8c..00405bc666c93 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java @@ -1,11 +1,11 @@ /** * 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. @@ -15,18 +15,17 @@ package com.microsoft.windowsazure.services.serviceBus.implementation; -import com.microsoft.windowsazure.services.core.utils.ConnectionStringSyntaxException; - import java.net.URI; import java.net.URISyntaxException; +import com.microsoft.windowsazure.services.core.utils.ConnectionStringSyntaxException; + /** * Class that encapsulates all the various settings needed * to connect to Service Bus, provided via either a * connection string or via separate configuration variables. *

- * The connection string is looked for first, falling back - * to separate config values if not found. + * The connection string is looked for first, falling back to separate config values if not found. */ class ServiceBusConnectionSettings { private String uri; @@ -34,10 +33,12 @@ class ServiceBusConnectionSettings { private String wrapName; private String wrapPassword; - public ServiceBusConnectionSettings(String connectionString, String uri, String wrapUri, String wrapName, String wrapPassword) throws ConnectionStringSyntaxException, URISyntaxException { + public ServiceBusConnectionSettings(String connectionString, String uri, String wrapUri, String wrapName, + String wrapPassword) throws ConnectionStringSyntaxException, URISyntaxException { if (connectionString != null) { parseConnectionString(connectionString); - } else { + } + else { this.uri = uri; this.wrapUri = wrapUri; this.wrapName = wrapName; @@ -61,7 +62,8 @@ public String getWrapPassword() { return wrapPassword; } - private boolean parseConnectionString(String connectionString) throws URISyntaxException, ConnectionStringSyntaxException { + private boolean parseConnectionString(String connectionString) throws URISyntaxException, + ConnectionStringSyntaxException { ServiceBusConnectionString cs = new ServiceBusConnectionString(connectionString); setUri(cs); setWrapUri(cs); @@ -79,8 +81,9 @@ private void setWrapUri(ServiceBusConnectionString connectionString) throws URIS URI hostUri = new URI(uri); String namespace = hostUri.getHost().split("\\.")[0]; wrapUri = "https://" + namespace + "-sb.accesscontrol.windows.net/WRAPv0.9"; - } else { - wrapUri = connectionString.getStsEndpoint(); + } + else { + wrapUri = connectionString.getStsEndpoint() + "/WRAPv0.9"; } } } From 3ebd298828ce11222b58263d8908528da8d6dd8a Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 11 Jun 2013 10:42:55 -0700 Subject: [PATCH 33/48] improve the unit test to ensure that the created correlation filter does exist. --- .../services/serviceBus/ServiceBusIntegrationTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 39958694b2589..a8daefc71df74 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -706,9 +706,10 @@ public void subscriptionsCanBeCreatedOnTopics() throws Exception { public void createSubscriptionWithCorrelationFilter() throws Exception { // Arrange String topicName = "testCreateSubscriptionWithCorrelationFilter"; + String expectedCorrelationId = "sampleCorrelationId"; service.createTopic(new TopicInfo(topicName)); CorrelationFilter correlationFilter = new CorrelationFilter(); - correlationFilter.setContentType("sampleCorrelationId"); + correlationFilter.setCorrelationId(expectedCorrelationId); RuleDescription ruleDescription = new RuleDescription(); ruleDescription.setFilter(correlationFilter); @@ -716,6 +717,9 @@ public void createSubscriptionWithCorrelationFilter() throws Exception { SubscriptionInfo created = service.createSubscription(topicName, new SubscriptionInfo("MySubscription").setDefaultRuleDescription(ruleDescription)).getValue(); + RuleInfo ruleInfo = service.getRule(topicName, "MySubscription", "$Default").getValue(); + CorrelationFilter correlationFilterResult = (CorrelationFilter) ruleInfo.getFilter(); + // Assert assertNotNull(created); assertEquals("MySubscription", created.getName()); @@ -725,6 +729,8 @@ public void createSubscriptionWithCorrelationFilter() throws Exception { assertNotNull(created.getUpdatedAt()); assertNotNull(created.getAccessedAt()); assertNotNull(created.getAutoDeleteOnIdle()); + assertNotNull(correlationFilterResult); + assertEquals(expectedCorrelationId, correlationFilterResult.getCorrelationId()); } @Test From 63e3fc94412a401d8fc01d1d6af1ab86b7a767c0 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 11 Jun 2013 11:28:00 -0700 Subject: [PATCH 34/48] address code review fedback by trimming the / at the end of the sts end point. --- .../serviceBus/implementation/ServiceBusConnectionSettings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java index 00405bc666c93..20bd238789b9e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java @@ -83,7 +83,7 @@ private void setWrapUri(ServiceBusConnectionString connectionString) throws URIS wrapUri = "https://" + namespace + "-sb.accesscontrol.windows.net/WRAPv0.9"; } else { - wrapUri = connectionString.getStsEndpoint() + "/WRAPv0.9"; + wrapUri = connectionString.getStsEndpoint().replaceAll("\\/$", "") + "/WRAPv0.9"; } } } From a4586585ed2ba7885f1e24848beacc5ad5afa069 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 11 Jun 2013 13:33:04 -0700 Subject: [PATCH 35/48] more test improvements to validate the properties on correlation filter. --- .../serviceBus/ServiceBusIntegrationTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index a8daefc71df74..75e648b6b449d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -707,9 +707,21 @@ public void createSubscriptionWithCorrelationFilter() throws Exception { // Arrange String topicName = "testCreateSubscriptionWithCorrelationFilter"; String expectedCorrelationId = "sampleCorrelationId"; + String expectedContentType = "sampleContentType"; + String expectedLabel = "sampleLabel"; + String expectedMessageId = "sampleMessageId"; + String expectedSessionId = "sampleSessionId"; + String expectedReplyTo = "sampleReplyTo"; + String expectedTo = "sampleTo"; service.createTopic(new TopicInfo(topicName)); CorrelationFilter correlationFilter = new CorrelationFilter(); correlationFilter.setCorrelationId(expectedCorrelationId); + correlationFilter.setContentType(expectedContentType); + correlationFilter.setLabel(expectedLabel); + correlationFilter.setMessageId(expectedMessageId); + correlationFilter.setReplyTo(expectedReplyTo); + correlationFilter.setSessionId(expectedSessionId); + correlationFilter.setTo(expectedTo); RuleDescription ruleDescription = new RuleDescription(); ruleDescription.setFilter(correlationFilter); @@ -731,6 +743,12 @@ public void createSubscriptionWithCorrelationFilter() throws Exception { assertNotNull(created.getAutoDeleteOnIdle()); assertNotNull(correlationFilterResult); assertEquals(expectedCorrelationId, correlationFilterResult.getCorrelationId()); + assertEquals(expectedContentType, correlationFilterResult.getContentType()); + assertEquals(expectedLabel, correlationFilterResult.getLabel()); + assertEquals(expectedMessageId, correlationFilterResult.getMessageId()); + assertEquals(expectedSessionId, correlationFilterResult.getSessionId()); + assertEquals(expectedReplyTo, correlationFilterResult.getReplyTo()); + assertEquals(expectedTo, correlationFilterResult.getTo()); } @Test From e1440fa6a33609ac4f1cbe91fd59f7f79568e2fe Mon Sep 17 00:00:00 2001 From: veudayab Date: Wed, 12 Jun 2013 14:42:48 -0700 Subject: [PATCH 36/48] Mark signRequest* methods as deprecated in StorageCredentialsAccountAndKey.java --- .../storage/StorageCredentialsAccountAndKey.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java index b0b27ab63d98e..791497a68fe38 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java @@ -244,6 +244,8 @@ public void setCredentials(final Credentials credentials) { /** * Signs a request under the Shared Key authentication scheme. * + * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and + * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. * @param request * An HttpURLConnection object that represents the request to sign. * @param contentLength @@ -255,6 +257,7 @@ public void setCredentials(final Credentials credentials) { * If a storage service error occurred. */ @Override + @Deprecated public void signRequest(final java.net.HttpURLConnection request, final long contentLength) throws InvalidKeyException, StorageException { this.signBlobAndQueueRequest(request, contentLength, null); @@ -263,6 +266,8 @@ public void signRequest(final java.net.HttpURLConnection request, final long con /** * Signs a request using the specified operation context under the Shared Key authentication scheme. * + * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and + * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. * @param request * An HttpURLConnection object that represents the request to sign. * @param contentLength @@ -278,6 +283,7 @@ public void signRequest(final java.net.HttpURLConnection request, final long con * If a storage service error occurred. */ @Override + @Deprecated public void signRequest(final java.net.HttpURLConnection request, final long contentLength, OperationContext opContext) throws InvalidKeyException, StorageException { opContext = opContext == null ? new OperationContext() : opContext; @@ -287,6 +293,8 @@ public void signRequest(final java.net.HttpURLConnection request, final long con /** * Signs a request using the Shared Key Lite authentication scheme. * + * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} + * depending on the desired shared key authentication scheme. * @param request * An HttpURLConnection object that represents the request to sign. * @param contentLength @@ -298,6 +306,7 @@ public void signRequest(final java.net.HttpURLConnection request, final long con * If an unspecified storage exception occurs. */ @Override + @Deprecated public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength) throws InvalidKeyException, StorageException { this.signTableRequestLite(request, contentLength, null); @@ -306,6 +315,8 @@ public void signRequestLite(final java.net.HttpURLConnection request, final long /** * Signs a request using the specified operation context under the Shared Key Lite authentication scheme. * + * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} + * depending on the desired shared key authentication scheme. * @param request * An HttpURLConnection object that represents the request to sign. * @param contentLength @@ -321,6 +332,7 @@ public void signRequestLite(final java.net.HttpURLConnection request, final long * If a storage service error occurred. */ @Override + @Deprecated public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength, OperationContext opContext) throws StorageException, InvalidKeyException { opContext = opContext == null ? new OperationContext() : opContext; From f9fb1ff38deb267b8caa20adf8640f26fdb438b8 Mon Sep 17 00:00:00 2001 From: Anu Bandi Date: Thu, 13 Jun 2013 11:48:20 -0700 Subject: [PATCH 37/48] fixed mislabeled string --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc83347a4da73..f12d7aa79956f 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ public class BlobSample { public static final String storageConnectionString = "DefaultEndpointsProtocol=http;" + "AccountName=your_account_name;" - + "AccountKey= your_account_name"; + + "AccountKey= your_account_key"; public static void main(String[] args) { try { From 552f5f66d71afb556bc77e311495cccdf9b7a633 Mon Sep 17 00:00:00 2001 From: veudayab Date: Thu, 20 Jun 2013 15:08:12 -0700 Subject: [PATCH 38/48] Documentation changes to deprecated methods --- .../core/storage/StorageCredentials.java | 17 +++++++++-------- .../StorageCredentialsAccountAndKey.java | 18 ++++++++++-------- .../storage/StorageCredentialsAnonymous.java | 16 ++++++++-------- ...torageCredentialsSharedAccessSignature.java | 16 ++++++++-------- 4 files changed, 35 insertions(+), 32 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java index 245ff1dd91425..a766631e84b50 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java @@ -214,8 +214,8 @@ public static StorageCredentials tryParseCredentials(final String connectionStri /** * Signs a request under the Shared Key authentication scheme. * - * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and - * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signBlobAndQueueRequest} or + * {@link signBlobAndQueueRequestLite}, depending on your desired shared key authentication scheme. * * @param request * An HttpURLConnection object that represents the request to sign. @@ -235,8 +235,8 @@ public abstract void signRequest(HttpURLConnection request, long contentLength) /** * Signs a request using the specified operation context under the Shared Key authentication scheme. * - * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and - * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signBlobAndQueueRequest} or + * {@link signBlobAndQueueRequestLite}, depending on your desired shared key authentication scheme. * * @param request * An HttpURLConnection object that represents the request to sign. @@ -259,8 +259,8 @@ public abstract void signRequest(HttpURLConnection request, long contentLength, /** * Signs a table request under the Shared Key Lite authentication scheme. * - * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} - * depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signTableRequest} or + * {@link signTableRequestLite}, depending on your desired shared key authentication scheme. * * @param request * An HttpURLConnection object that represents the request to sign. @@ -279,8 +279,9 @@ public abstract void signRequestLite(HttpURLConnection request, long contentLeng /** * Signs a table request using the specified operation context under the Shared Key Lite authentication scheme. * - * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} - * depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signTableRequest} or + * {@link signTableRequestLite}, depending on your desired shared key authentication scheme. + * * @param request * An HttpURLConnection object that represents the request to sign. * @param contentLength diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java index 791497a68fe38..27fd4f9cac3f1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java @@ -244,8 +244,8 @@ public void setCredentials(final Credentials credentials) { /** * Signs a request under the Shared Key authentication scheme. * - * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and - * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signBlobAndQueueRequest} or + * {@link signBlobAndQueueRequestLite}, depending on your desired shared key authentication scheme. * @param request * An HttpURLConnection object that represents the request to sign. * @param contentLength @@ -266,8 +266,8 @@ public void signRequest(final java.net.HttpURLConnection request, final long con /** * Signs a request using the specified operation context under the Shared Key authentication scheme. * - * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and - * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signBlobAndQueueRequest} or + * {@link signBlobAndQueueRequestLite}, depending on your desired shared key authentication scheme. * @param request * An HttpURLConnection object that represents the request to sign. * @param contentLength @@ -293,8 +293,9 @@ public void signRequest(final java.net.HttpURLConnection request, final long con /** * Signs a request using the Shared Key Lite authentication scheme. * - * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} - * depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signTableRequest} or + * {@link signTableRequestLite}, depending on your desired shared key authentication scheme. + * * @param request * An HttpURLConnection object that represents the request to sign. * @param contentLength @@ -315,8 +316,9 @@ public void signRequestLite(final java.net.HttpURLConnection request, final long /** * Signs a request using the specified operation context under the Shared Key Lite authentication scheme. * - * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} - * depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signTableRequest} or + * {@link signTableRequestLite}, depending on your desired shared key authentication scheme. + * * @param request * An HttpURLConnection object that represents the request to sign. * @param contentLength diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java index e676a277b068e..7ceb94a78675f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java @@ -172,8 +172,8 @@ public String getAccountName() { * Signs a request using the specified credentials under the Shared Key authentication scheme. This is not a valid * operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. * - * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and - * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signBlobAndQueueRequest} or + * {@link signBlobAndQueueRequestLite}, depending on your desired shared key authentication scheme. * * @param connection * the request, as an HttpURLConnection object, to sign @@ -191,8 +191,8 @@ public void signRequest(final java.net.HttpURLConnection connection, final long * This is not a valid operation for objects of type StorageCredentialsAnonymous so the method performs * a no-op. * - * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and - * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signBlobAndQueueRequest} or + * {@link signBlobAndQueueRequestLite}, depending on your desired shared key authentication scheme. * * @param request * the request, as an HttpURLConnection object, to sign @@ -213,8 +213,8 @@ public void signRequest(final java.net.HttpURLConnection request, final long con * Signs a request using the specified credentials under the Shared Key Lite authentication scheme. This is not a * valid operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. * - * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} - * depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signTableRequest} or + * {@link signTableRequestLite}, depending on your desired shared key authentication scheme. * * @param connection * the request, as an HttpURLConnection object, to sign @@ -230,8 +230,8 @@ public void signRequestLite(final java.net.HttpURLConnection connection, final l * valid operation for objects of type StorageCredentialsSharedAccessSignature so the method performs a * no-op. * - * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} - * depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signTableRequest} or + * {@link signTableRequestLite}, depending on your desired shared key authentication scheme. * * @param request * the request, as an HttpURLConnection object, to sign diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java index 189fb00f95127..8e0d609f5fe60 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java @@ -185,8 +185,8 @@ public String getToken() { * Signs a request using the specified credentials under the Shared Key authentication scheme. This is not a valid * operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. * - * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and - * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signBlobAndQueueRequest} or + * {@link signBlobAndQueueRequestLite}, depending on your desired shared key authentication scheme. * * @param connection * the request, as an HttpURLConnection object, to sign @@ -204,8 +204,8 @@ public void signRequest(final java.net.HttpURLConnection connection, final long * This is not a valid operation for objects of type StorageCredentialsAnonymous so the method performs * a no-op. * - * @deprecated This method has been deprecated. Please use {@link signBlobAndQueueRequest} and - * {@link signBlobAndQueueRequestLite} depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signBlobAndQueueRequest} or + * {@link signBlobAndQueueRequestLite}, depending on your desired shared key authentication scheme. * * @param request * the request, as an HttpURLConnection object, to sign @@ -226,8 +226,8 @@ public void signRequest(final java.net.HttpURLConnection request, final long con * Signs a request using the specified credentials under the Shared Key Lite authentication scheme. This is not a * valid operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. * - * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} - * depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signTableRequest} or + * {@link signTableRequestLite}, depending on your desired shared key authentication scheme. * * @param connection * the request, as an HttpURLConnection object, to sign @@ -243,8 +243,8 @@ public void signRequestLite(final java.net.HttpURLConnection connection, final l * valid operation for objects of type StorageCredentialsSharedAccessSignature so the method performs a * no-op. * - * @deprecated This method has been deprecated. Please use {@link signTableRequest} and {@link signTableRequestLite} - * depending on the desired shared key authentication scheme. + * @deprecated This method has been deprecated. Please use either {@link signTableRequest} or + * {@link signTableRequestLite}, depending on your desired shared key authentication scheme. * * @param request * the request, as an HttpURLConnection object, to sign From 7478ff924f2befe12da9dbb7a5784e17e173d603 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 26 Jun 2013 15:31:25 -0700 Subject: [PATCH 39/48] update unit tests to fix failures on CI machines. --- .../services/media/MediaProcessorIntegrationTest.java | 5 ++--- .../services/scenarios/MediaServiceWrapper.java | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java index 824c34d2dc935..26f11507aedf5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java @@ -38,13 +38,12 @@ private void verifyMediaProcessorInfo(String message, MediaProcessorInfo mediaPr } private void verifyMediaProcessorInfo(String message, String id, String name, String description, String sku, - String vendor, String version, MediaProcessorInfo mediaProcessorInfo) { + String vendor, MediaProcessorInfo mediaProcessorInfo) { assertEquals(message + " id", id, mediaProcessorInfo.getId()); assertEquals(message + " name", name, mediaProcessorInfo.getName()); assertEquals(message + " description", description, mediaProcessorInfo.getDescription()); assertEquals(message + " sku", sku, mediaProcessorInfo.getSku()); assertEquals(message + " vendor", vendor, mediaProcessorInfo.getVendor()); - assertEquals(message + " version", version, mediaProcessorInfo.getVersion()); } @Test @@ -73,6 +72,6 @@ public void listMediaProcessorWithOptionSuccess() throws ServiceException { assertEquals("listMediaProcessors size", 1, listMediaProcessorsResult.size()); MediaProcessorInfo mediaProcessorInfo = listMediaProcessorsResult.get(0); verifyMediaProcessorInfo("mediaProcessorInfo", "nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10", - "Storage Decryption", "Storage Decryption", "", "Microsoft", "1.6", mediaProcessorInfo); + "Storage Decryption", "Storage Decryption", "", "Microsoft", mediaProcessorInfo); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index c71781c96fe61..bc92439348ea8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -272,13 +272,13 @@ public Task.CreateBatchOperation createTaskOptions(String taskName, int inputAss String configuration = null; switch (encoderType) { case WindowsAzureMediaEncoder: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER, "2.2.0.0"); + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER); // Full list of configurations strings for version 2.1 is at: // http://msdn.microsoft.com/en-us/library/jj129582.aspx configuration = "VC1 Broadband SD 4x3"; break; case StorageDecryption: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION, "1.6"); + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION); configuration = null; break; default: @@ -296,10 +296,9 @@ private String getTaskBody(int inputAssetId, int outputAssetId) { + "JobOutputAsset(" + outputAssetId + ")"; } - private String getMediaProcessorIdByName(String processorName, String version) throws ServiceException { + private String getMediaProcessorIdByName(String processorName) throws ServiceException { EntityListOperation operation = MediaProcessor.list(); - operation.getQueryParameters().putSingle("$filter", - "(Name eq '" + processorName + "') and (Version eq '" + version + "')"); + operation.getQueryParameters().putSingle("$filter", "(Name eq '" + processorName + "')"); MediaProcessorInfo processor = service.list(operation).get(0); return processor.getId(); } From 200217c9ebf2d376863a618dd10af19bc5951d67 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 26 Jun 2013 15:56:15 -0700 Subject: [PATCH 40/48] fix a broken unit test on CI machine. --- .../ServiceBusConnectionSettingsTest.java | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettingsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettingsTest.java index ec64e7d76effb..263213071b87b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettingsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettingsTest.java @@ -1,25 +1,26 @@ /** * 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. + * 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.windowsazure.services.serviceBus.implementation; -import com.microsoft.windowsazure.services.core.Configuration; -import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; +import static junit.framework.Assert.*; + import org.junit.Test; -import static junit.framework.Assert.*; +import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; public class ServiceBusConnectionSettingsTest { @@ -31,7 +32,8 @@ public void settingsAreParsedFromConnectionString() throws Exception { String connectionString = getConnectionString(ns, issuer, secret); - ServiceBusConnectionSettings settings = new ServiceBusConnectionSettings(connectionString, null, null, null, null); + ServiceBusConnectionSettings settings = new ServiceBusConnectionSettings(connectionString, null, null, null, + null); assertEquals(String.format("https://%1$s.servicebus.windows.net/", ns), settings.getUri()); assertEquals(String.format("https://%1$s-sb.accesscontrol.windows.net/WRAPv0.9", ns), settings.getWrapUri()); @@ -41,15 +43,16 @@ public void settingsAreParsedFromConnectionString() throws Exception { private String getConnectionString(String ns, String issuer, String secret) { return String.format( - "Endpoint=sb://%1$s.servicebus.windows.net/;SharedSecretIssuer=%2$s;SharedSecretValue=%3$s", - ns, issuer, secret); + "Endpoint=sb://%1$s.servicebus.windows.net/;SharedSecretIssuer=%2$s;SharedSecretValue=%3$s", ns, + issuer, secret); } private String getConnectionString(String ns, String stsEndpoint, String issuer, String secret) { - return String.format( - "Endpoint=sb://%1$s.servicebus.windows.net/;StsEndpoint=https://%1$s%4$s;SharedSecretIssuer=%2$s;SharedSecretValue=%3$s", - ns, issuer, secret, stsEndpoint); + return String + .format("Endpoint=sb://%1$s.servicebus.windows.net/;StsEndpoint=https://%1$s%4$s;SharedSecretIssuer=%2$s;SharedSecretValue=%3$s", + ns, issuer, secret, stsEndpoint); } + @Test public void settingsAreUsedFromConnectionStringInConfig() throws Exception { Configuration config = Configuration.load(); @@ -68,8 +71,8 @@ public void settingsAreUsedFromConnectionStringInConfig() throws Exception { public void settingsAreUsedFromIndividualSettingsInConfiguration() throws Exception { Configuration config = Configuration.load(); - ServiceBusConfiguration.configureWithWrapAuthentication(config, - "myNamespace", "owner", "secret", ".servicebus.windows.net/", "-sb.accesscontrol.windows.net/WRAPv0.9"); + ServiceBusConfiguration.configureWithWrapAuthentication(config, "myNamespace", "owner", "secret", + ".servicebus.windows.net/", "-sb.accesscontrol.windows.net/WRAPv0.9"); ServiceBusConnectionSettings settings = config.create(ServiceBusConnectionSettings.class); @@ -83,9 +86,8 @@ public void settingsAreUsedFromIndividualSettingsInConfiguration() throws Except public void settingsPreferConnectionStringIfBothPresentInConfiguration() throws Exception { Configuration config = Configuration.load(); - ServiceBusConfiguration.configureWithWrapAuthentication(config, - "myIndividualNamespace", "individualowner", "individualsecret", - ".servicebus.windows.net/", "-sb.accesscontrol.windows.net/WRAPv0.9"); + ServiceBusConfiguration.configureWithWrapAuthentication(config, "myIndividualNamespace", "individualowner", + "individualsecret", ".servicebus.windows.net/", "-sb.accesscontrol.windows.net/WRAPv0.9"); ServiceBusConfiguration.configureWithConnectionString(null, config, getConnectionString("myNamespaceCS", "ownerCS", "secretCS")); @@ -100,12 +102,11 @@ public void settingsPreferConnectionStringIfBothPresentInConfiguration() throws @Test public void canSetStSEndPointInConnectionString() throws Exception { - ServiceBusConnectionSettings settings = new ServiceBusConnectionSettings( - getConnectionString("myNs", "-some.accesscontrol.net", "owner", "secret"), - null, null, null, null); + ServiceBusConnectionSettings settings = new ServiceBusConnectionSettings(getConnectionString("myNs", + "-some.accesscontrol.net", "owner", "secret"), null, null, null, null); assertEquals("https://myNs.servicebus.windows.net/", settings.getUri()); - assertEquals("https://myNs-some.accesscontrol.net", settings.getWrapUri()); + assertEquals("https://myNs-some.accesscontrol.net/WRAPv0.9", settings.getWrapUri()); assertEquals("owner", settings.getWrapName()); assertEquals("secret", settings.getWrapPassword()); } From 2b5c3f6aff54b1b56c8c7313520ef0207892f059 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 27 Jun 2013 10:45:18 -0700 Subject: [PATCH 41/48] code review feedback regarding media processor integrration test. --- .../services/media/MediaProcessorIntegrationTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java index 26f11507aedf5..8132e3d52e67f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java @@ -44,6 +44,7 @@ private void verifyMediaProcessorInfo(String message, String id, String name, St assertEquals(message + " description", description, mediaProcessorInfo.getDescription()); assertEquals(message + " sku", sku, mediaProcessorInfo.getSku()); assertEquals(message + " vendor", vendor, mediaProcessorInfo.getVendor()); + assertTrue(message + "version length > 0", mediaProcessorInfo.getVersion().length() > 0); } @Test From 23aa9f41295202b58dc5a82ab331ab59224ca3f6 Mon Sep 17 00:00:00 2001 From: veudayab Date: Thu, 27 Jun 2013 19:01:03 -0700 Subject: [PATCH 42/48] Updated changelog --- ChangeLog.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 2c15b781280a6..dbdbdf8e95824 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +2013.06.27 Version 0.4.4 + * Make sure the response stream is drained to prevent socket exhaustion. + * Support for all flavors of SharedKey and SharedKeyLite message signing through AuthenticationScheme property on client classes. + 2013.03.12 Version 0.4.1 * Added "Azure-SDK-For-Java/" To User-Agent HTTP header * Added connection string support for Service Bus From c0c8d9719919c044f70e333f7bf5335a0e23120f Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Fri, 28 Jun 2013 13:48:39 -0700 Subject: [PATCH 43/48] reduce the chance of a sporadic failure. --- .../services/serviceBus/ServiceBusIntegrationTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 971df258c02cb..391a080279aee 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -486,6 +486,7 @@ public void receiveUpdatedSubscriptionForwardToTopicMessageSuccess() throws Exce new SubscriptionInfo(sourceSubscriptionName)).getValue(); service.updateSubscription(sourceTopicName, sourceSubscriptionInfo.setForwardTo(destinationTopicInfo.getUri().toString())); + Thread.sleep(1000); // Act service.sendTopicMessage(sourceTopicName, new BrokeredMessage("Hello source queue!")); From 79ce3c3842228d70dfb42a94bd115b5ee0dbf812 Mon Sep 17 00:00:00 2001 From: Guang Yang Date: Fri, 28 Jun 2013 16:39:52 -0700 Subject: [PATCH 44/48] update to 0.4.4 --- microsoft-azure-api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 5fc0ac2584377..f3199d17474f3 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -17,7 +17,7 @@ 4.0.0 com.microsoft.windowsazure microsoft-windowsazure-api - 0.4.3 + 0.4.4 jar Microsoft Windows Azure Client API From cff277550969d106b62abb43119bf3bf8cabced6 Mon Sep 17 00:00:00 2001 From: Guang Yang Date: Fri, 28 Jun 2013 17:30:41 -0700 Subject: [PATCH 45/48] update changelog and readme for 0.4.4 --- ChangeLog.txt | 7 ++++++- README.md | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index e4643aa46091c..02e6a9807803d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,9 @@ -2013.06.27 Version 0.4.4 +2013.07.03 Version 0.4.4 + * Windows Azure China environemnt support + * Service Bus metadata support updated to latest version + * Rich Odata entity query support for Service Bus Queue/Topic/Subscription + * Added support for Service Bus message forwarding + * Added support for Service Bus message count details * Make sure the response stream is drained to prevent socket exhaustion. * Support for all flavors of SharedKey and SharedKeyLite message signing through AuthenticationScheme property on client classes. diff --git a/README.md b/README.md index f12d7aa79956f..86248e1374fb0 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,14 @@ This project provides a client library in Java that makes it easy to consume Win * Create/Read/Update/Delete queues * Send/Receive/Unlock/Delete messages * Renew message lock + * Message forwarding * Topics * Create/Read/Update/Delete topics * Create/Read/Update/Delete subscriptions * Create/Read/Update/Delete rules * Send/Receive/Unlock/Delete messages * Renew message lock + * Message forwarding * Media Services * Create/Read/Update/Delete access policies * Create/Read/Update/Delete asset files @@ -57,7 +59,7 @@ within your project you can also have them installed by the Java package manager com.microsoft.windowsazure microsoft-windowsazure-api - 0.4.2 + 0.4.4 ``` From 32af1c840d881905248874ff8f4fefd1c647b032 Mon Sep 17 00:00:00 2001 From: Guang Yang Date: Fri, 28 Jun 2013 17:34:52 -0700 Subject: [PATCH 46/48] some minor fix --- ChangeLog.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 02e6a9807803d..92c8e627002d0 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -4,8 +4,8 @@ * Rich Odata entity query support for Service Bus Queue/Topic/Subscription * Added support for Service Bus message forwarding * Added support for Service Bus message count details - * Make sure the response stream is drained to prevent socket exhaustion. - * Support for all flavors of SharedKey and SharedKeyLite message signing through AuthenticationScheme property on client classes. + * Make sure the response stream is drained to prevent socket exhaustion in Storage + * Support for all flavors of SharedKey and SharedKeyLite message signing through AuthenticationScheme property on client classes in Storage 2013.05.27 Version 0.4.3 * Added support for updating existing Queue/Topic/Subscription for Service Bus From 423f2700a8fbb930f25de94521e904100a99fde4 Mon Sep 17 00:00:00 2001 From: Guang Yang Date: Mon, 1 Jul 2013 09:15:23 -0700 Subject: [PATCH 47/48] incorporate feedback --- ChangeLog.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 92c8e627002d0..18378c9cde813 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,11 +1,11 @@ 2013.07.03 Version 0.4.4 * Windows Azure China environemnt support - * Service Bus metadata support updated to latest version + * Service Bus metadata support updated to the latest version * Rich Odata entity query support for Service Bus Queue/Topic/Subscription * Added support for Service Bus message forwarding * Added support for Service Bus message count details - * Make sure the response stream is drained to prevent socket exhaustion in Storage - * Support for all flavors of SharedKey and SharedKeyLite message signing through AuthenticationScheme property on client classes in Storage + * Made sure the response stream is drained to prevent socket exhaustion in Storage + * Added support for all flavors of SharedKey and SharedKeyLite message signing through AuthenticationScheme property on client classes in Storage 2013.05.27 Version 0.4.3 * Added support for updating existing Queue/Topic/Subscription for Service Bus From 160210409e247b592d0df13785a27140f5e6dbc8 Mon Sep 17 00:00:00 2001 From: veudayab Date: Mon, 1 Jul 2013 10:24:50 -0700 Subject: [PATCH 48/48] Fix test issue for DateTime comparison --- .../windowsazure/services/table/client/TableTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java index 4d50f8dce7030..32f9a19837e64 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java @@ -177,7 +177,7 @@ public void assertEquality(ComplexEntity other) { Assert.assertEquals(this.getPartitionKey(), other.getPartitionKey()); Assert.assertEquals(this.getRowKey(), other.getRowKey()); - assertDateApproxEquals(this.getDateTime(), other.getDateTime(), 100); + Assert.assertEquals(this.getDateTime().toString(), other.getDateTime().toString()); Assert.assertEquals(this.getGuid(), other.getGuid()); Assert.assertEquals(this.getString(), other.getString());