From 8617c75b7eda8be92463b902a5572da65b4e6e3e Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Fri, 27 Mar 2015 17:18:26 -0700 Subject: [PATCH] JCLOUDS-867: Use Azure API version 2013-08-15 This changes the format of EnumerationResults. --- providers/azureblob/pom.xml | 2 +- .../azureblob/AzureBlobApiMetadata.java | 2 +- .../AccountNameEnumerationResultsHandler.java | 19 ++++++++--- ...ontainerNameEnumerationResultsHandler.java | 7 ++-- .../azureblob/AzureBlobClientTest.java | 32 +++++++++---------- .../blobstore/AzureBlobRequestSignerTest.java | 12 +++---- .../src/test/resources/test_list_blobs.xml | 6 ++-- .../resources/test_list_blobs_options.xml | 5 +-- .../test/resources/test_list_containers.xml | 8 ++--- .../test_list_containers_options.xml | 8 ++--- 10 files changed, 55 insertions(+), 46 deletions(-) diff --git a/providers/azureblob/pom.xml b/providers/azureblob/pom.xml index fa39b10427..1cc22975ec 100644 --- a/providers/azureblob/pom.xml +++ b/providers/azureblob/pom.xml @@ -33,7 +33,7 @@ https://${jclouds.identity}.blob.core.windows.net - 2012-02-12 + 2013-08-15 ${test.azure.identity} ${test.azure.credential} diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java index ade52bc9e2..c193852c4e 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java @@ -62,7 +62,7 @@ public class AzureBlobApiMetadata extends BaseHttpApiMetadata { .name("Microsoft Azure Blob Service API") .identityName("Account Name") .credentialName("Access Key") - .version("2012-02-12") + .version("2013-08-15") .defaultEndpoint("https://${jclouds.identity}.blob.core.windows.net") .documentation(URI.create("http://msdn.microsoft.com/en-us/library/dd135733.aspx")) .defaultProperties(AzureBlobApiMetadata.defaultProperties()) diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/xml/AccountNameEnumerationResultsHandler.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/xml/AccountNameEnumerationResultsHandler.java index a59ca8b679..544acf6806 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/xml/AccountNameEnumerationResultsHandler.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/xml/AccountNameEnumerationResultsHandler.java @@ -16,7 +16,10 @@ */ package org.jclouds.azureblob.xml; +import static com.google.common.base.Throwables.propagate; + import java.net.URI; +import java.net.URISyntaxException; import java.util.Date; import java.util.Map; import java.util.SortedSet; @@ -50,7 +53,7 @@ public class AccountNameEnumerationResultsHandler extends private String marker; private int maxResults; private String nextMarker; - private URI currentUrl; + private String currentName; private Date currentLastModified; private String currentETag; private boolean inMetadata; @@ -75,7 +78,7 @@ public class AccountNameEnumerationResultsHandler extends } else if (qName.equals("Metadata")) { inMetadata = true; } else if (qName.equals("EnumerationResults")) { - accountUrl = URI.create(attributes.getValue("AccountName").toString().trim()); + accountUrl = URI.create(attributes.getValue("ServiceEndpoint").trim()); } } @@ -101,14 +104,20 @@ public class AccountNameEnumerationResultsHandler extends nextMarker = currentText.toString().trim(); nextMarker = (nextMarker.equals("")) ? null : nextMarker; } else if (qName.equals("Container")) { + URI currentUrl; + try { + currentUrl = new URI(accountUrl.getScheme(), accountUrl.getHost(), "/" + currentName, null); + } catch (URISyntaxException use) { + throw propagate(use); + } containerMetadata.add(new ContainerPropertiesImpl(currentUrl, currentLastModified, currentETag, currentMetadata)); - currentUrl = null; + currentName = null; currentLastModified = null; currentETag = null; currentMetadata = Maps.newHashMap(); - } else if (qName.equals("Url")) { - currentUrl = URI.create(currentText.toString().trim()); + } else if (qName.equals("Name")) { + currentName = currentText.toString().trim(); } else if (qName.equals("Last-Modified")) { currentLastModified = dateParser.rfc822DateParse(currentText.toString().trim()); } else if (qName.equals("Etag")) { diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/xml/ContainerNameEnumerationResultsHandler.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/xml/ContainerNameEnumerationResultsHandler.java index 0973595786..c22d9b82a4 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/xml/ContainerNameEnumerationResultsHandler.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/xml/ContainerNameEnumerationResultsHandler.java @@ -54,7 +54,6 @@ public class ContainerNameEnumerationResultsHandler extends ParseSax.HandlerWith private String marker; private int maxResults; private String nextMarker; - private URI currentUrl; private URI containerUrl; private Date currentLastModified; private String currentETag; @@ -103,7 +102,7 @@ public class ContainerNameEnumerationResultsHandler extends ParseSax.HandlerWith inBlob = true; inMetadata = true; } else if (qName.equals("EnumerationResults")) { - containerUrl = URI.create(attributes.getValue("ContainerName").toString().trim()); + containerUrl = URI.create(attributes.getValue("ServiceEndpoint").trim() + attributes.getValue("ContainerName").trim()); } } @@ -131,6 +130,7 @@ public class ContainerNameEnumerationResultsHandler extends ParseSax.HandlerWith } else if (qName.equals("LeaseStatus")) { currentLeaseStatus = LeaseStatus.fromValue(currentText.toString().trim()); } else if (qName.equals("Blob")) { + URI currentUrl = uriBuilder(containerUrl + "/" + currentName).build(); BlobProperties md = new BlobPropertiesImpl(currentBlobType, currentName, containerUrl.getPath().replace("/", ""), currentUrl, currentLastModified, currentETag, currentSize, currentContentType, currentContentMD5, currentContentEncoding, currentContentLanguage, currentExpires, @@ -138,7 +138,6 @@ public class ContainerNameEnumerationResultsHandler extends ParseSax.HandlerWith blobMetadata.add(md); currentBlobType = null; currentName = null; - currentUrl = null; currentLastModified = null; currentETag = null; currentSize = -1; @@ -149,8 +148,6 @@ public class ContainerNameEnumerationResultsHandler extends ParseSax.HandlerWith currentLeaseStatus = null; currentExpires = null; currentMetadata = Maps.newHashMap(); - } else if (qName.equals("Url")) { - currentUrl = uriBuilder(currentText.toString().trim()).build(); } else if (qName.equals("Last-Modified")) { currentLastModified = dateParser.rfc822DateParse(currentText.toString().trim()); } else if (qName.equals("Etag")) { diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientTest.java index 18a266af82..0c43ce0971 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientTest.java @@ -62,7 +62,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest of("container", "blob")); assertRequestLineEquals(request, "GET https://identity.blob.core.windows.net/container/blob HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "x-ms-version: 2012-02-12\n"); + assertNonPayloadHeadersEqual(request, "x-ms-version: 2013-08-15\n"); assertPayloadEquals(request, null, null, false); assertResponseParserClassEquals(method, request, ParseBlobFromHeadersAndHttpContent.class); @@ -296,7 +296,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest - + 4 @@ -46,4 +48,4 @@ newblob2.txt - \ No newline at end of file + diff --git a/providers/azureblob/src/test/resources/test_list_blobs_options.xml b/providers/azureblob/src/test/resources/test_list_blobs_options.xml index ddc9bc3e46..55a33f41b0 100644 --- a/providers/azureblob/src/test/resources/test_list_blobs_options.xml +++ b/providers/azureblob/src/test/resources/test_list_blobs_options.xml @@ -1,6 +1,7 @@ + ServiceEndpoint="https://jclouds.blob.core.windows.net/" + ContainerName="adriancole-blobstore3"> 1 / @@ -23,4 +24,4 @@ 2!68!MDAwMDA2IWFwcGxlcyEwMDAwMjghOTk5OS0xMi0zMVQyMzo1OTo1OS45OTk5OTk5WiE- - \ No newline at end of file + diff --git a/providers/azureblob/src/test/resources/test_list_containers.xml b/providers/azureblob/src/test/resources/test_list_containers.xml index 6ffb0ed33e..348f266545 100644 --- a/providers/azureblob/src/test/resources/test_list_containers.xml +++ b/providers/azureblob/src/test/resources/test_list_containers.xml @@ -1,19 +1,19 @@ - + 3 - http://myaccount.blob.core.windows.net/audio + audio Wed, 13 Aug 2008 20:39:39 GMT 0x8CACB9BD7C6B1B2 - http://myaccount.blob.core.windows.net/images + images Wed, 14 Aug 2008 20:39:39 GMT 0x8CACB9BD7C1EEEC - http://myaccount.blob.core.windows.net/textfiles + textfiles Wed, 15 Aug 2008 20:39:39 GMT 0x8CACB9BD7BACAC3 diff --git a/providers/azureblob/src/test/resources/test_list_containers_options.xml b/providers/azureblob/src/test/resources/test_list_containers_options.xml index 913e89c108..4a1c45e481 100644 --- a/providers/azureblob/src/test/resources/test_list_containers_options.xml +++ b/providers/azureblob/src/test/resources/test_list_containers_options.xml @@ -1,21 +1,21 @@ - + prefix marker 1 - http://myaccount.blob.core.windows.net/audio + audio Wed, 13 Aug 2008 20:39:39 GMT 0x8CACB9BD7C6B1B2 - http://myaccount.blob.core.windows.net/images + images Wed, 14 Aug 2008 20:39:39 GMT 0x8CACB9BD7C1EEEC - http://myaccount.blob.core.windows.net/textfiles + textfiles Wed, 15 Aug 2008 20:39:39 GMT 0x8CACB9BD7BACAC3