JCLOUDS-867: Use Azure API version 2013-08-15

This changes the format of EnumerationResults.
This commit is contained in:
Andrew Gaul 2015-03-27 17:18:26 -07:00
parent 77d846c5ff
commit 8617c75b7e
10 changed files with 55 additions and 46 deletions

View File

@ -33,7 +33,7 @@
<properties>
<test.azureblob.endpoint>https://${jclouds.identity}.blob.core.windows.net</test.azureblob.endpoint>
<test.azureblob.api-version>2012-02-12</test.azureblob.api-version>
<test.azureblob.api-version>2013-08-15</test.azureblob.api-version>
<test.azureblob.build-version />
<test.azureblob.identity>${test.azure.identity}</test.azureblob.identity>
<test.azureblob.credential>${test.azure.credential}</test.azureblob.credential>

View File

@ -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())

View File

@ -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")) {

View File

@ -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")) {

View File

@ -62,7 +62,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(request, "GET https://identity.blob.core.windows.net/?comp=list 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, ParseSax.class);
@ -77,7 +77,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
assertRequestLineEquals(request,
"GET https://identity.blob.core.windows.net/?comp=list&maxresults=1&marker=marker&prefix=prefix 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, ParseSax.class);
@ -92,7 +92,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
assertRequestLineEquals(request,
"PUT https://identity.blob.core.windows.net/container?restype=container 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, ReturnTrueIf2xx.class);
@ -106,7 +106,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
assertRequestLineEquals(request,
"DELETE https://identity.blob.core.windows.net/container?restype=container 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, ReleasePayloadAndReturn.class);
@ -125,7 +125,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
assertNonPayloadHeadersEqual(request,
"x-ms-blob-public-access: blob\n" +
"x-ms-meta-foo: bar\n" +
"x-ms-version: 2012-02-12\n");
"x-ms-version: 2013-08-15\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
@ -139,7 +139,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(request, "PUT https://identity.blob.core.windows.net/$root?restype=container 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, ReturnTrueIf2xx.class);
@ -152,7 +152,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(request, "DELETE https://identity.blob.core.windows.net/$root?restype=container 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, ReleasePayloadAndReturn.class);
@ -169,7 +169,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
assertNonPayloadHeadersEqual(request,
"x-ms-blob-public-access: blob\n" +
"x-ms-meta-foo: bar\n" +
"x-ms-version: 2012-02-12\n");
"x-ms-version: 2013-08-15\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
@ -183,7 +183,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
assertRequestLineEquals(request,
"GET https://identity.blob.core.windows.net/container?restype=container&comp=list 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, ParseSax.class);
@ -197,7 +197,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
assertRequestLineEquals(request,
"GET https://identity.blob.core.windows.net/$root?restype=container&comp=list 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, ParseSax.class);
@ -211,7 +211,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
assertRequestLineEquals(request,
"HEAD https://identity.blob.core.windows.net/container?restype=container 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, ParseContainerPropertiesFromHeaders.class);
@ -225,7 +225,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
assertRequestLineEquals(request,
"HEAD https://identity.blob.core.windows.net/container?restype=container&comp=acl 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, ParsePublicAccessHeader.class);
@ -250,7 +250,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
"PUT https://identity.blob.core.windows.net/container?restype=container&comp=acl HTTP/1.1");
assertNonPayloadHeadersEqual(request,
expectedHeader +
"x-ms-version: 2012-02-12\n");
"x-ms-version: 2013-08-15\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseETagHeader.class);
@ -267,7 +267,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
"PUT https://identity.blob.core.windows.net/container?restype=container&comp=metadata HTTP/1.1");
assertNonPayloadHeadersEqual(request,
"x-ms-meta-key: value\n" +
"x-ms-version: 2012-02-12\n");
"x-ms-version: 2013-08-15\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -280,7 +280,7 @@ public class AzureBlobClientTest extends BaseRestAnnotationProcessingTest<AzureB
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> 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<AzureB
"PUT https://identity.blob.core.windows.net/container/blob?comp=metadata HTTP/1.1");
assertNonPayloadHeadersEqual(request,
"x-ms-meta-key: value\n" +
"x-ms-version: 2012-02-12\n");
"x-ms-version: 2013-08-15\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);

View File

@ -60,9 +60,9 @@ public class AzureBlobRequestSignerTest extends BaseRestAnnotationProcessingTest
assertRequestLineEquals(request, "GET https://identity.blob.core.windows.net/container/name HTTP/1.1");
assertNonPayloadHeadersEqual(
request,
"Authorization: SharedKeyLite identity:3rx56J9eAw/0GH2pym1hBmMGQmGju4DkVDcRsBWBtAk=\n" +
"Authorization: SharedKeyLite identity:cP8Cm4r3hBbhkD/OUg5t8nRwt3SkLKOIppKIb1lRce4=\n" +
"Date: Thu, 05 Jun 2008 16:38:19 GMT\n" +
"x-ms-version: 2012-02-12\n");
"x-ms-version: 2013-08-15\n");
assertPayloadEquals(request, null, null, false);
assertEquals(request.getFilters().size(), 0);
@ -75,9 +75,9 @@ public class AzureBlobRequestSignerTest extends BaseRestAnnotationProcessingTest
assertRequestLineEquals(request, "DELETE https://identity.blob.core.windows.net/container/name HTTP/1.1");
assertNonPayloadHeadersEqual(
request,
"Authorization: SharedKeyLite identity:EN3SE/jB9anhgqIqJMmrTCzZpuqjL41BIZnaE9PEBaU=\n" +
"Authorization: SharedKeyLite identity:G6nXsRjrJy8HoVF74MGnuDS358KkBz/GScBROvIZSls=\n" +
"Date: Thu, 05 Jun 2008 16:38:19 GMT\n" +
"x-ms-version: 2012-02-12\n");
"x-ms-version: 2013-08-15\n");
assertPayloadEquals(request, null, null, false);
assertEquals(request.getFilters().size(), 0);
@ -99,11 +99,11 @@ public class AzureBlobRequestSignerTest extends BaseRestAnnotationProcessingTest
assertRequestLineEquals(request, "PUT https://identity.blob.core.windows.net/container/name HTTP/1.1");
assertNonPayloadHeadersEqual(
request,
"Authorization: SharedKeyLite identity:V0gyrdMZzwQrCvxEfq6eBe8PL233yJ91+aNcISEzjfE=\n" +
"Authorization: SharedKeyLite identity:S2cKS4t1F8ZlLOxzgOZkO8bLeCP3vEko5CTsyIKlcJE=\n" +
"Date: Thu, 05 Jun 2008 16:38:19 GMT\n" +
"Expect: 100-continue\n" +
"x-ms-blob-type: BlockBlob\n" +
"x-ms-version: 2012-02-12\n");
"x-ms-version: 2013-08-15\n");
assertContentHeadersEqual(request, "text/plain", null, null, null, 2L, hashCode.asBytes(), new Date(1000));
assertEquals(request.getFilters().size(), 0);

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<EnumerationResults ContainerName="http://myaccount.blob.core.windows.net/mycontainer">
<EnumerationResults
ServiceEndpoint="http://myaccount.blob.core.windows.net/"
ContainerName="mycontainer">
<MaxResults>4</MaxResults>
<Blobs>
<Blob>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<EnumerationResults
ContainerName="https://jclouds.blob.core.windows.net/adriancole-blobstore3">
ServiceEndpoint="https://jclouds.blob.core.windows.net/"
ContainerName="adriancole-blobstore3">
<MaxResults>1</MaxResults>
<Delimiter>/</Delimiter>
<Blobs>

View File

@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<EnumerationResults AccountName=" http://myaccount.blob.core.windows.net">
<EnumerationResults ServiceEndpoint="http://myaccount.blob.core.windows.net">
<MaxResults>3</MaxResults>
<Containers>
<Container>
<Url>http://myaccount.blob.core.windows.net/audio</Url>
<Name>audio</Name>
<Last-Modified>Wed, 13 Aug 2008 20:39:39 GMT</Last-Modified>
<Etag>0x8CACB9BD7C6B1B2</Etag>
</Container>
<Container>
<Url>http://myaccount.blob.core.windows.net/images</Url>
<Name>images</Name>
<Last-Modified>Wed, 14 Aug 2008 20:39:39 GMT</Last-Modified>
<Etag>0x8CACB9BD7C1EEEC</Etag>
</Container>
<Container>
<Url>http://myaccount.blob.core.windows.net/textfiles</Url>
<Name>textfiles</Name>
<Last-Modified>Wed, 15 Aug 2008 20:39:39 GMT</Last-Modified>
<Etag>0x8CACB9BD7BACAC3</Etag>
</Container>

View File

@ -1,21 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<EnumerationResults AccountName=" http://myaccount.blob.core.windows.net">
<EnumerationResults ServiceEndpoint="http://myaccount.blob.core.windows.net">
<Prefix>prefix</Prefix>
<Marker>marker</Marker>
<MaxResults>1</MaxResults>
<Containers>
<Container>
<Url>http://myaccount.blob.core.windows.net/audio</Url>
<Name>audio</Name>
<Last-Modified>Wed, 13 Aug 2008 20:39:39 GMT</Last-Modified>
<Etag>0x8CACB9BD7C6B1B2</Etag>
</Container>
<Container>
<Url>http://myaccount.blob.core.windows.net/images</Url>
<Name>images</Name>
<Last-Modified>Wed, 14 Aug 2008 20:39:39 GMT</Last-Modified>
<Etag>0x8CACB9BD7C1EEEC</Etag>
</Container>
<Container>
<Url>http://myaccount.blob.core.windows.net/textfiles</Url>
<Name>textfiles</Name>
<Last-Modified>Wed, 15 Aug 2008 20:39:39 GMT</Last-Modified>
<Etag>0x8CACB9BD7BACAC3</Etag>
</Container>