JCLOUDS-40 unasync azureblob; plus fold otherwise unused azure-common into it.
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/4c95a578 Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/4c95a578 Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/4c95a578 Branch: refs/heads/use-agentproxy-008 Commit: 4c95a57880d939f2fedee5d33a85a1852646d4c7 Parents: 9b71a9d Author: Adrian Cole <[email protected]> Authored: Fri Oct 3 17:35:37 2014 -0700 Committer: Adrian Cole <[email protected]> Committed: Fri Oct 3 22:15:01 2014 -0700 ---------------------------------------------------------------------- common/azure/README.txt | 6 - common/azure/pom.xml | 54 --- .../storage/AzureStorageResponseException.java | 72 ---- .../config/AzureStorageParserModule.java | 31 -- .../config/AzureStorageRestClientModule.java | 98 ------ .../azure/storage/domain/AzureStorageError.java | 114 ------- .../azure/storage/domain/BoundedSet.java | 33 -- .../storage/domain/internal/BoundedHashSet.java | 64 ---- .../filters/SharedKeyLiteAuthentication.java | 207 ------------ .../AzureStorageClientErrorRetryHandler.java | 89 ----- .../ParseAzureStorageErrorFromXmlContent.java | 115 ------- .../azure/storage/options/CreateOptions.java | 74 ----- .../azure/storage/options/ListOptions.java | 131 -------- .../storage/reference/AzureStorageHeaders.java | 33 -- .../azure/storage/util/AzureStorageUtils.java | 59 ---- .../jclouds/azure/storage/xml/ErrorHandler.java | 53 --- .../SharedKeyLiteAuthenticationTest.java | 142 -------- .../ParseAzureErrorFromXmlContentTest.java | 116 ------- .../storage/options/CreateOptionsTest.java | 54 --- .../azure/storage/options/ListOptionsTest.java | 71 ---- .../azure/storage/xml/ErrorHandlerTest.java | 47 --- common/azure/src/test/resources/log4j.xml | 118 ------- common/azure/src/test/resources/test_error.xml | 15 - common/pom.xml | 1 - providers/azureblob/pom.xml | 2 +- .../storage/AzureStorageResponseException.java | 72 ++++ .../azure/storage/domain/AzureStorageError.java | 114 +++++++ .../azure/storage/domain/BoundedSet.java | 33 ++ .../storage/domain/internal/BoundedHashSet.java | 64 ++++ .../filters/SharedKeyLiteAuthentication.java | 207 ++++++++++++ .../AzureStorageClientErrorRetryHandler.java | 89 +++++ .../ParseAzureStorageErrorFromXmlContent.java | 115 +++++++ .../azure/storage/options/CreateOptions.java | 74 +++++ .../azure/storage/options/ListOptions.java | 131 ++++++++ .../storage/reference/AzureStorageHeaders.java | 33 ++ .../azure/storage/util/AzureStorageUtils.java | 59 ++++ .../jclouds/azure/storage/xml/ErrorHandler.java | 53 +++ .../jclouds/azureblob/AzureBlobApiMetadata.java | 28 +- .../jclouds/azureblob/AzureBlobAsyncClient.java | 328 ------------------- .../org/jclouds/azureblob/AzureBlobClient.java | 245 +++++++++++--- .../blobstore/AzureAsyncBlobStore.java | 307 ----------------- .../blobstore/AzureBlobRequestSigner.java | 8 +- .../config/AzureBlobStoreContextModule.java | 7 +- .../config/AzureBlobHttpApiModule.java | 88 +++++ .../config/AzureBlobRestClientModule.java | 48 --- .../SharedKeyLiteAuthenticationTest.java | 142 ++++++++ .../ParseAzureErrorFromXmlContentTest.java | 116 +++++++ .../storage/options/CreateOptionsTest.java | 54 +++ .../azure/storage/options/ListOptionsTest.java | 71 ++++ .../azure/storage/xml/ErrorHandlerTest.java | 47 +++ .../azureblob/AzureBlobAsyncClientTest.java | 294 ----------------- .../azureblob/AzureBlobClientLiveTest.java | 15 +- .../jclouds/azureblob/AzureBlobClientTest.java | 291 ++++++++++++++++ .../BindAzureBlobMetadataToRequestTest.java | 8 +- .../blobstore/AzureBlobRequestSignerTest.java | 14 +- .../azureblob/src/test/resources/test_error.xml | 15 + 56 files changed, 2098 insertions(+), 2871 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/README.txt ---------------------------------------------------------------------- diff --git a/common/azure/README.txt b/common/azure/README.txt deleted file mode 100644 index 46ef3fc..0000000 --- a/common/azure/README.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -# The jclouds provider for Microsoft Windows Azure (http://www.microsoft.com/windowsazure/). -# -# TODO: Implementation status. -# TODO: Supported features. -# TODO: Usage example. http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/pom.xml ---------------------------------------------------------------------- diff --git a/common/azure/pom.xml b/common/azure/pom.xml deleted file mode 100644 index d262593..0000000 --- a/common/azure/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-project</artifactId> - <version>2.0.0-SNAPSHOT</version> - <relativePath>../../project/pom.xml</relativePath> - </parent> - <groupId>org.apache.jclouds.common</groupId> - <artifactId>azure-common</artifactId> - <name>jclouds Azure Components Core</name> - <description>jclouds Core components to access Azure</description> - <packaging>bundle</packaging> - - <properties> - <jclouds.osgi.export>org.jclouds.azure*;version="${project.version}"</jclouds.osgi.export> - <jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-core</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-core</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageResponseException.java ---------------------------------------------------------------------- diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageResponseException.java b/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageResponseException.java deleted file mode 100644 index 744de08..0000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageResponseException.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage; - -import org.jclouds.azure.storage.domain.AzureStorageError; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; - -/** - * Encapsulates an Error from Azure Storage Services. - * - * @see <a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/UsingRESTError.html" /> - * @see AzureStorageError - * @see org.jclouds.aws.handlers.ParseAzureStorageErrorFromXmlContent - */ -public class AzureStorageResponseException extends HttpResponseException { - - private AzureStorageError error = new AzureStorageError(); - - public AzureStorageResponseException(HttpCommand command, HttpResponse response, AzureStorageError error) { - super(String.format("command %s failed with code %s, error: %s", command.toString(), response - .getStatusCode(), error.toString()), command, response); - this.setError(error); - - } - - public AzureStorageResponseException(HttpCommand command, HttpResponse response, AzureStorageError error, - Throwable cause) { - super(String.format("command %1$s failed with error: %2$s", command.toString(), error - .toString()), command, response, cause); - this.setError(error); - - } - - public AzureStorageResponseException(String message, HttpCommand command, HttpResponse response, - AzureStorageError error) { - super(message, command, response); - this.setError(error); - - } - - public AzureStorageResponseException(String message, HttpCommand command, HttpResponse response, - AzureStorageError error, Throwable cause) { - super(message, command, response, cause); - this.setError(error); - - } - - public void setError(AzureStorageError error) { - this.error = error; - } - - public AzureStorageError getError() { - return error; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageParserModule.java ---------------------------------------------------------------------- diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageParserModule.java b/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageParserModule.java deleted file mode 100644 index a7bdd24..0000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageParserModule.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.config; - -import org.jclouds.json.config.GsonModule.DateAdapter; -import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; - -import com.google.inject.AbstractModule; - -public class AzureStorageParserModule extends AbstractModule { - - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageRestClientModule.java ---------------------------------------------------------------------- diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageRestClientModule.java b/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageRestClientModule.java deleted file mode 100644 index 5f2e885..0000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageRestClientModule.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.config; - -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; - -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import javax.inject.Named; - -import org.jclouds.azure.storage.handlers.AzureStorageClientErrorRetryHandler; -import org.jclouds.azure.storage.handlers.ParseAzureStorageErrorFromXmlContent; -import org.jclouds.date.DateService; -import org.jclouds.date.TimeStamp; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.reflect.TypeToken; -import com.google.inject.Provides; - -/** - * Configures the AzureStorage connection, including logging and http transport. - */ -@ConfiguresRestClient -public class AzureStorageRestClientModule<S, A> extends RestClientModule<S, A> { - protected AzureStorageRestClientModule() { - - } - - public AzureStorageRestClientModule(Map<Class<?>, Class<?>> delegate) { - super(delegate); - } - - public AzureStorageRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType) { - super(syncClientType, asyncClientType); - } - - @Provides - @TimeStamp - protected String provideTimeStamp(@TimeStamp Supplier<String> cache) { - return cache.get(); - } - - /** - * borrowing concurrency code to ensure that caching takes place properly - */ - @Provides - @TimeStamp - protected Supplier<String> provideTimeStampCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final DateService dateService) { - return Suppliers.memoizeWithExpiration(new Supplier<String>() { - public String get() { - return dateService.rfc822DateFormat(); - } - }, seconds, TimeUnit.SECONDS); - } - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseAzureStorageErrorFromXmlContent.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseAzureStorageErrorFromXmlContent.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseAzureStorageErrorFromXmlContent.class); - } - - @Override - protected void bindRetryHandlers() { - bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(AzureStorageClientErrorRetryHandler.class); - } - - @Override - protected void configure() { - install(new AzureStorageParserModule()); - super.configure(); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/main/java/org/jclouds/azure/storage/domain/AzureStorageError.java ---------------------------------------------------------------------- diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/domain/AzureStorageError.java b/common/azure/src/main/java/org/jclouds/azure/storage/domain/AzureStorageError.java deleted file mode 100644 index ec57979..0000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/domain/AzureStorageError.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.domain; - -import java.util.Map; - -import com.google.common.collect.Maps; - -/** - * When an Azure Storage request is in error, the client receives an error response. - * - * @see <a href="http://msdn.microsoft.com/en-us/library/dd573365.aspx" /> - */ -public class AzureStorageError { - private String code; - private String message; - private String requestId; - private Map<String, String> details = Maps.newHashMap(); - private String stringSigned; - private String signature; - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("AzureError"); - sb.append("{requestId='").append(requestId).append('\''); - if (code != null) - sb.append(", code='").append(code).append('\''); - if (message != null) - sb.append(", message='").append(message).append('\''); - if (stringSigned != null) - sb.append(", stringSigned='").append(stringSigned).append('\''); - if (getSignature() != null) - sb.append(", signature='").append(getSignature()).append('\''); - if (!details.isEmpty()) - sb.append(", context='").append(details.toString()).append('\'').append('}'); - return sb.toString(); - } - - public void setCode(String code) { - this.code = code; - } - - public String getCode() { - return code; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - /** - * If a request is consistently failing and you have verified that the request is properly - * formulated, you may use this value to report the error to Microsoft. In your report, include - * the value of x-ms-request-id, the approximate time that the request was made, the storage - * service against which the request was made, and the type of operation that the request - * attempted - */ - public String getRequestId() { - return requestId; - } - - public void setStringSigned(String stringSigned) { - this.stringSigned = stringSigned; - } - - /** - * @return what jclouds signed before sending the request. - */ - public String getStringSigned() { - return stringSigned; - } - - public void setDetails(Map<String, String> context) { - this.details = context; - } - - /** - * @return additional details surrounding the error. - */ - public Map<String, String> getDetails() { - return details; - } - - public void setSignature(String signature) { - this.signature = signature; - } - - public String getSignature() { - return signature; - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/main/java/org/jclouds/azure/storage/domain/BoundedSet.java ---------------------------------------------------------------------- diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/domain/BoundedSet.java b/common/azure/src/main/java/org/jclouds/azure/storage/domain/BoundedSet.java deleted file mode 100644 index 8778ae6..0000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/domain/BoundedSet.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.domain; - -import java.net.URI; -import java.util.Set; - -public interface BoundedSet<T> extends Set<T> { - URI getUrl(); - - String getPrefix(); - - String getMarker(); - - int getMaxResults(); - - String getNextMarker(); - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/main/java/org/jclouds/azure/storage/domain/internal/BoundedHashSet.java ---------------------------------------------------------------------- diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/domain/internal/BoundedHashSet.java b/common/azure/src/main/java/org/jclouds/azure/storage/domain/internal/BoundedHashSet.java deleted file mode 100644 index b9767ec..0000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/domain/internal/BoundedHashSet.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.domain.internal; - -import java.net.URI; -import java.util.HashSet; - -import org.jclouds.azure.storage.domain.BoundedSet; - -import com.google.common.collect.Iterables; - -public class BoundedHashSet<T> extends HashSet<T> implements BoundedSet<T> { - - protected final URI url; - protected final String prefix; - protected final String marker; - protected final Integer maxResults; - protected final String nextMarker; - - public BoundedHashSet(Iterable<T> contents, URI url, String prefix, String marker, - Integer maxResults, String nextMarker) { - Iterables.addAll(this, contents); - this.url = url; - this.prefix = prefix; - this.nextMarker = nextMarker; - this.maxResults = maxResults; - this.marker = marker; - } - - public String getPrefix() { - return prefix; - } - - public String getMarker() { - return marker; - } - - public int getMaxResults() { - return maxResults; - } - - public String getNextMarker() { - return nextMarker; - } - - public URI getUrl() { - return url; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java ---------------------------------------------------------------------- diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java b/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java deleted file mode 100644 index 8e56390..0000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.filters; - -import static com.google.common.io.BaseEncoding.base64; -import static com.google.common.io.ByteStreams.readBytes; -import static org.jclouds.crypto.Macs.asByteProcessor; -import static org.jclouds.util.Patterns.NEWLINE_PATTERN; -import static org.jclouds.util.Strings2.toInputStream; - -import java.util.Collection; -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.crypto.Crypto; -import org.jclouds.date.TimeStamp; -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpException; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpRequestFilter; -import org.jclouds.http.HttpUtils; -import org.jclouds.http.internal.SignatureWire; -import org.jclouds.logging.Logger; -import org.jclouds.util.Strings2; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Strings; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import com.google.common.collect.Multimaps; -import com.google.common.collect.Sets; -import com.google.common.io.ByteProcessor; -import com.google.common.net.HttpHeaders; - -/** - * Signs the Azure Storage request. - * - * @see <a href= "http://msdn.microsoft.com/en-us/library/dd179428.aspx" /> - */ -@Singleton -public class SharedKeyLiteAuthentication implements HttpRequestFilter { - private static final Collection<String> FIRST_HEADERS_TO_SIGN = ImmutableList.of(HttpHeaders.DATE); - - private final SignatureWire signatureWire; - private final Supplier<Credentials> creds; - private final Provider<String> timeStampProvider; - private final Crypto crypto; - private final HttpUtils utils; - - @Resource - @Named(Constants.LOGGER_SIGNATURE) - Logger signatureLog = Logger.NULL; - - @Inject - public SharedKeyLiteAuthentication(SignatureWire signatureWire, - @org.jclouds.location.Provider Supplier<Credentials> creds, @TimeStamp Provider<String> timeStampProvider, - Crypto crypto, HttpUtils utils) { - this.crypto = crypto; - this.utils = utils; - this.signatureWire = signatureWire; - this.creds = creds; - this.timeStampProvider = timeStampProvider; - } - - public HttpRequest filter(HttpRequest request) throws HttpException { - request = replaceDateHeader(request); - String signature = calculateSignature(createStringToSign(request)); - request = replaceAuthorizationHeader(request, signature); - utils.logRequest(signatureLog, request, "<<"); - return request; - } - - HttpRequest replaceAuthorizationHeader(HttpRequest request, String signature) { - return request.toBuilder() - .replaceHeader(HttpHeaders.AUTHORIZATION, "SharedKeyLite " + creds.get().identity + ":" + signature) - .build(); - } - - HttpRequest replaceDateHeader(HttpRequest request) { - Builder<String, String> builder = ImmutableMap.builder(); - String date = timeStampProvider.get(); - builder.put(HttpHeaders.DATE, date); - request = request.toBuilder().replaceHeaders(Multimaps.forMap(builder.build())).build(); - return request; - } - - public String createStringToSign(HttpRequest request) { - utils.logRequest(signatureLog, request, ">>"); - StringBuilder buffer = new StringBuilder(); - // re-sign the request - appendMethod(request, buffer); - appendPayloadMetadata(request, buffer); - appendHttpHeaders(request, buffer); - appendCanonicalizedHeaders(request, buffer); - appendCanonicalizedResource(request, buffer); - if (signatureWire.enabled()) - signatureWire.output(buffer.toString()); - return buffer.toString(); - } - - private void appendPayloadMetadata(HttpRequest request, StringBuilder buffer) { - buffer.append( - HttpUtils.nullToEmpty(request.getPayload() == null ? null : request.getPayload().getContentMetadata() - .getContentMD5())).append("\n"); - buffer.append( - Strings.nullToEmpty(request.getPayload() == null ? null : request.getPayload().getContentMetadata() - .getContentType())).append("\n"); - } - - private String calculateSignature(String toSign) throws HttpException { - String signature = signString(toSign); - if (signatureWire.enabled()) - signatureWire.input(Strings2.toInputStream(signature)); - return signature; - } - - public String signString(String toSign) { - try { - ByteProcessor<byte[]> hmacSHA256 = asByteProcessor(crypto.hmacSHA256(base64().decode(creds.get().credential))); - return base64().encode(readBytes(toInputStream(toSign), hmacSHA256)); - } catch (Exception e) { - throw new HttpException("error signing request", e); - } - } - - private void appendMethod(HttpRequest request, StringBuilder toSign) { - toSign.append(request.getMethod()).append("\n"); - } - - private void appendCanonicalizedHeaders(HttpRequest request, StringBuilder toSign) { - // TreeSet == Sort the headers alphabetically. - Set<String> headers = Sets.newTreeSet(request.getHeaders().keySet()); - for (String header : headers) { - if (header.startsWith("x-ms-")) { - toSign.append(header.toLowerCase()).append(":"); - for (String value : request.getHeaders().get(header)) { - toSign.append(NEWLINE_PATTERN.matcher(value).replaceAll("")).append(","); - } - toSign.deleteCharAt(toSign.lastIndexOf(",")); - toSign.append("\n"); - } - } - } - - private void appendHttpHeaders(HttpRequest request, StringBuilder toSign) { - for (String header : FIRST_HEADERS_TO_SIGN) - toSign.append(HttpUtils.nullToEmpty(request.getHeaders().get(header))).append("\n"); - } - - @VisibleForTesting - void appendCanonicalizedResource(HttpRequest request, StringBuilder toSign) { - // 1. Beginning with an empty string (""), append a forward slash (/), followed by the name of - // the identity that owns the resource being accessed. - toSign.append("/").append(creds.get().identity); - appendUriPath(request, toSign); - } - - @VisibleForTesting - void appendUriPath(HttpRequest request, StringBuilder toSign) { - // 2. Append the resource's encoded URI path - toSign.append(request.getEndpoint().getRawPath()); - - // If the request URI addresses a component of the - // resource, append the appropriate query string. The query string should include the question - // mark and the comp parameter (for example, ?comp=metadata). No other parameters should be - // included on the query string. - if (request.getEndpoint().getQuery() != null) { - StringBuilder paramsToSign = new StringBuilder("?"); - - String[] params = request.getEndpoint().getQuery().split("&"); - for (String param : params) { - String[] paramNameAndValue = param.split("="); - - if ("comp".equals(paramNameAndValue[0])) { - paramsToSign.append(param); - } - } - - if (paramsToSign.length() > 1) { - toSign.append(paramsToSign); - } - } - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/main/java/org/jclouds/azure/storage/handlers/AzureStorageClientErrorRetryHandler.java ---------------------------------------------------------------------- diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/handlers/AzureStorageClientErrorRetryHandler.java b/common/azure/src/main/java/org/jclouds/azure/storage/handlers/AzureStorageClientErrorRetryHandler.java deleted file mode 100644 index fadc772..0000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/handlers/AzureStorageClientErrorRetryHandler.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.handlers; - -import java.io.ByteArrayInputStream; - -import javax.annotation.Resource; -import javax.inject.Named; - -import org.jclouds.Constants; -import org.jclouds.azure.storage.domain.AzureStorageError; -import org.jclouds.azure.storage.util.AzureStorageUtils; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpException; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.HttpUtils; -import org.jclouds.http.handlers.BackoffLimitedRetryHandler; -import org.jclouds.logging.Logger; - -import com.google.inject.Inject; - -/** - * Handles Retryable responses with error codes in the 4xx range - */ -public class AzureStorageClientErrorRetryHandler implements HttpRetryHandler { - - @Inject(optional = true) - @Named(Constants.PROPERTY_MAX_RETRIES) - private int retryCountLimit = 5; - - private final AzureStorageUtils utils; - private final BackoffLimitedRetryHandler backoffHandler; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public AzureStorageClientErrorRetryHandler(BackoffLimitedRetryHandler backoffHandler, - AzureStorageUtils utils) { - this.backoffHandler = backoffHandler; - this.utils = utils; - } - - public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { - byte[] content = HttpUtils.closeClientButKeepContentStream(response); - command.incrementFailureCount(); - if (!command.isReplayable()) { - logger.warn("Cannot retry after server error, command is not replayable: %1$s", command); - return false; - } else if (command.getFailureCount() > retryCountLimit) { - logger.warn( - "Cannot retry after server error, command has exceeded retry limit %1$d: %2$s", - retryCountLimit, command); - return false; - } else if (response.getStatusCode() == 409) { - // Content can be null in the case of HEAD requests - if (content != null) { - try { - AzureStorageError error = utils.parseAzureStorageErrorFromContent(command, response, - new ByteArrayInputStream(content)); - if ("ContainerBeingDeleted".equals(error.getCode())) { - backoffHandler.imposeBackoffExponentialDelay(100L, 3, retryCountLimit, command - .getFailureCount(), command.toString()); - return true; - } - } catch (HttpException e) { - logger.warn(e, "error parsing response: %s", new String(content)); - } - } - } - return false; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/main/java/org/jclouds/azure/storage/handlers/ParseAzureStorageErrorFromXmlContent.java ---------------------------------------------------------------------- diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/handlers/ParseAzureStorageErrorFromXmlContent.java b/common/azure/src/main/java/org/jclouds/azure/storage/handlers/ParseAzureStorageErrorFromXmlContent.java deleted file mode 100644 index ece8176..0000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/handlers/ParseAzureStorageErrorFromXmlContent.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.handlers; - -import static org.jclouds.http.HttpUtils.releasePayload; - -import java.io.IOException; -import java.util.regex.Pattern; - -import javax.annotation.Resource; -import javax.inject.Inject; - -import org.jclouds.azure.storage.AzureStorageResponseException; -import org.jclouds.azure.storage.domain.AzureStorageError; -import org.jclouds.azure.storage.util.AzureStorageUtils; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.logging.Logger; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; -import org.jclouds.util.Strings2; - -/** - * This will parse and set an appropriate exception on the command object. - * - * @see AzureStorageError - */ -public class ParseAzureStorageErrorFromXmlContent implements HttpErrorHandler { - @Resource - protected Logger logger = Logger.NULL; - - private final AzureStorageUtils utils; - - @Inject - public ParseAzureStorageErrorFromXmlContent(AzureStorageUtils utils) { - this.utils = utils; - } - - public static final Pattern CONTAINER_PATH = Pattern.compile("^[/]?([^/]+)$"); - public static final Pattern CONTAINER_KEY_PATH = Pattern.compile("^[/]?([^/]+)/(.*)$"); - - public void handleError(HttpCommand command, HttpResponse response) { - Exception exception = new HttpResponseException(command, response); - String message = null; - AzureStorageError error = null; - try { - if (response.getPayload() != null) { - String contentType = response.getPayload().getContentMetadata().getContentType(); - if (contentType != null && (contentType.indexOf("xml") != -1 || contentType.indexOf("unknown") != -1) - && !Long.valueOf(0).equals(response.getPayload().getContentMetadata().getContentLength())) { - try { - error = utils.parseAzureStorageErrorFromContent(command, response, response.getPayload().getInput()); - if (error != null) { - message = error.getMessage(); - exception = new AzureStorageResponseException(command, response, error); - } - } catch (RuntimeException e) { - try { - message = Strings2.toStringAndClose(response.getPayload().openStream()); - exception = new HttpResponseException(command, response, message); - } catch (IOException e1) { - } - } - } else { - try { - message = Strings2.toStringAndClose(response.getPayload().openStream()); - exception = new HttpResponseException(command, response, message); - } catch (IOException e) { - } - } - } - message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), - response.getStatusLine()); - exception = refineException(command, response, exception, error, message); - } finally { - releasePayload(response); - command.setException(exception); - } - } - - protected Exception refineException(HttpCommand command, HttpResponse response, Exception exception, - AzureStorageError error, String message) { - switch (response.getStatusCode()) { - case 401: - exception = new AuthorizationException(message, exception); - break; - case 404: - if (!command.getCurrentRequest().getMethod().equals("DELETE")) { - exception = new ResourceNotFoundException(message, exception); - } - break; - case 411: - exception = new IllegalArgumentException(message); - break; - } - return exception; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/main/java/org/jclouds/azure/storage/options/CreateOptions.java ---------------------------------------------------------------------- diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/options/CreateOptions.java b/common/azure/src/main/java/org/jclouds/azure/storage/options/CreateOptions.java deleted file mode 100644 index 3fed43b..0000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/options/CreateOptions.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.options; - -import java.util.Map.Entry; - -import org.jclouds.azure.storage.reference.AzureStorageHeaders; -import org.jclouds.http.options.BaseHttpRequestOptions; - -import com.google.common.collect.Multimap; - -/** - * Contains common options supported in the REST API for the Create operation. <h2> - * Usage</h2> The recommended way to instantiate a CreateOptions object is to statically import - * CreateOptions.* and invoke a static creation method followed by an instance mutator (if - * needed): - * <p/> - * <code> - * import static org.jclouds.azure.storage.options.CreateOptions.Builder.* - * import org.jclouds.azure.storage.queue.AzureQueueClient; - * <p/> - * AzureQueueClient connection = // get connection - * Multimap<String,String> metadata = // ... - * boolean createdWithPublicAcl = connection.createQueue("containerName", withMetadata(metadata)); - * <code> * - * - * @see <a href="http://msdn.microsoft.com/en-us/library/dd179466.aspx" /> - */ -public class CreateOptions extends BaseHttpRequestOptions { - public static final CreateOptions NONE = new CreateOptions(); - - /** - * A name-value pair to associate with the container as metadata. - * - * Note that these are stored at the server under the prefix: x-ms-meta- - */ - public CreateOptions withMetadata(Multimap<String, String> metadata) { - for (Entry<String, String> entry : metadata.entries()) { - if (entry.getKey().startsWith(AzureStorageHeaders.USER_METADATA_PREFIX)) - headers.put(entry.getKey(), entry.getValue()); - else - headers - .put(AzureStorageHeaders.USER_METADATA_PREFIX + entry.getKey(), entry - .getValue()); - } - return this; - } - - public static class Builder { - - /** - * @see CreateOptions#withMetadata(Multimap<String, String>) - */ - public static CreateOptions withMetadata(Multimap<String, String> metadata) { - CreateOptions options = new CreateOptions(); - return options.withMetadata(metadata); - } - - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/main/java/org/jclouds/azure/storage/options/ListOptions.java ---------------------------------------------------------------------- diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/options/ListOptions.java b/common/azure/src/main/java/org/jclouds/azure/storage/options/ListOptions.java deleted file mode 100644 index fba5f39..0000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/options/ListOptions.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.options; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -import com.google.common.collect.ImmutableSet; - -/** - * Options used to control paginated results (aka list commands). - * - * @see <a href="http://msdn.microsoft.com/en-us/library/dd179466.aspx" /> - */ -public class ListOptions extends BaseHttpRequestOptions { - public static final ListOptions NONE = new ListOptions(); - - /** - * Include this parameter to specify that the container's metadata be returned as part of the - * response body. - * - * Note that metadata requested with this parameter must be stored in accordance with the naming - * restrictions imposed by the 2009-09-19 version of the Blob service. Beginning with this - * version, all metadata names must adhere to the naming conventions for C# identifiers. - */ - public ListOptions includeMetadata() { - this.queryParameters.replaceValues("include", ImmutableSet.of("metadata")); - return this; - } - - public boolean getIncludeMetadata() { - return getFirstQueryOrNull("include").equals("metadata"); - } - - /** - * Filters the results to return only objects whose name begins with the specified prefix. - */ - public ListOptions prefix(String prefix) { - this.queryParameters.put("prefix", checkNotNull(prefix, "prefix")); - return this; - } - - public String getPrefix() { - return getFirstQueryOrNull("prefix"); - } - - /** - * A string value that identifies the portion of the list to be returned with the next list - * operation. The operation returns a marker value within the response body if the list returned - * was not complete. The marker value may then be used in a subsequent call to request the next - * set of list items. - * <p/> - * The marker value is opaque to the client. - */ - public ListOptions marker(String marker) { - this.queryParameters.put("marker", checkNotNull(marker, "marker")); - return this; - } - - public String getMarker() { - return getFirstQueryOrNull("marker"); - } - - /** - * Specifies the maximum number of containers to return. If maxresults is not specified, the - * server will return up to 5,000 items. If the parameter is set to a value greater than 5,000, - * the server will return a Bad Request (400) error - */ - public ListOptions maxResults(int maxresults) { - checkState(maxresults >= 0, "maxresults must be >= 0"); - checkState(maxresults <= 10000, "maxresults must be <= 5000"); - queryParameters.put("maxresults", Integer.toString(maxresults)); - return this; - } - - public Integer getMaxResults() { - String maxresults = getFirstQueryOrNull("maxresults"); - return (maxresults != null) ? Integer.valueOf(maxresults) : null; - } - - public static class Builder { - /** - * @see ListOptions#includeMetadata() - */ - public static ListOptions includeMetadata() { - ListOptions options = new ListOptions(); - return options.includeMetadata(); - } - - /** - * @see ListOptions#prefix(String) - */ - public static ListOptions prefix(String prefix) { - ListOptions options = new ListOptions(); - return options.prefix(prefix); - } - - /** - * @see ListOptions#marker(String) - */ - public static ListOptions marker(String marker) { - ListOptions options = new ListOptions(); - return options.marker(marker); - } - - /** - * @see ListOptions#maxResults(long) - */ - public static ListOptions maxResults(int maxKeys) { - ListOptions options = new ListOptions(); - return options.maxResults(maxKeys); - } - - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/main/java/org/jclouds/azure/storage/reference/AzureStorageHeaders.java ---------------------------------------------------------------------- diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/reference/AzureStorageHeaders.java b/common/azure/src/main/java/org/jclouds/azure/storage/reference/AzureStorageHeaders.java deleted file mode 100644 index 0c60e51..0000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/reference/AzureStorageHeaders.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.reference; - -/** - * Additional headers specified by Azure Storage REST API. - * - * @see <a href="http://msdn.microsoft.com/en-us/library/dd179357.aspx" /> - */ -public final class AzureStorageHeaders { - - public static final String USER_METADATA_PREFIX = "x-ms-meta-"; - public static final String REQUEST_ID = "x-ms-request-id"; - public static final String VERSION = "x-ms-version"; - - private AzureStorageHeaders() { - throw new AssertionError("intentionally unimplemented"); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/main/java/org/jclouds/azure/storage/util/AzureStorageUtils.java ---------------------------------------------------------------------- diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/util/AzureStorageUtils.java b/common/azure/src/main/java/org/jclouds/azure/storage/util/AzureStorageUtils.java deleted file mode 100644 index bf62ff82a..0000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/util/AzureStorageUtils.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.util; - -import java.io.InputStream; - -import javax.inject.Inject; -import javax.inject.Provider; - -import org.jclouds.azure.storage.domain.AzureStorageError; -import org.jclouds.azure.storage.filters.SharedKeyLiteAuthentication; -import org.jclouds.azure.storage.reference.AzureStorageHeaders; -import org.jclouds.azure.storage.xml.ErrorHandler; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpException; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseSax; - -/** - * Encryption, Hashing, and IO Utilities needed to sign and verify Azure Storage requests and - * responses. - */ -public class AzureStorageUtils { - - @Inject - SharedKeyLiteAuthentication signer; - - @Inject - ParseSax.Factory factory; - - @Inject - Provider<ErrorHandler> errorHandlerProvider; - - public AzureStorageError parseAzureStorageErrorFromContent(HttpCommand command, - HttpResponse response, InputStream content) throws HttpException { - AzureStorageError error = factory.create(errorHandlerProvider.get()).parse(content); - error.setRequestId(response.getFirstHeaderOrNull(AzureStorageHeaders.REQUEST_ID)); - if ("AuthenticationFailed".equals(error.getCode())) { - error.setStringSigned(signer.createStringToSign(command.getCurrentRequest())); - error.setSignature(signer.signString(error.getStringSigned())); - } - return error; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/main/java/org/jclouds/azure/storage/xml/ErrorHandler.java ---------------------------------------------------------------------- diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/xml/ErrorHandler.java b/common/azure/src/main/java/org/jclouds/azure/storage/xml/ErrorHandler.java deleted file mode 100644 index 2467fe7..0000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/xml/ErrorHandler.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.xml; - -import org.jclouds.azure.storage.domain.AzureStorageError; -import org.jclouds.http.functions.ParseSax; - -/** - * Parses the error from the Amazon S3 REST API. - * - * @see <a - * href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html?UsingRESTError.html" - * /> - */ -public class ErrorHandler extends ParseSax.HandlerWithResult<AzureStorageError> { - - private AzureStorageError error = new AzureStorageError(); - private StringBuilder currentText = new StringBuilder(); - - public AzureStorageError getResult() { - return error; - } - - public void endElement(String uri, String name, String qName) { - - if (qName.equals("Code")) { - error.setCode(currentText.toString().trim()); - } else if (qName.equals("Message")) { - error.setMessage(currentText.toString().trim()); - } else if (!qName.equals("Error")) { - error.getDetails().put(qName, currentText.toString()); - } - currentText.setLength(0); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java ---------------------------------------------------------------------- diff --git a/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java b/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java deleted file mode 100644 index 5bea836..0000000 --- a/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.filters; - -import static org.jclouds.reflect.Reflection2.typeToken; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.net.URI; - -import javax.ws.rs.HttpMethod; - -import org.jclouds.ContextBuilder; -import org.jclouds.azure.storage.config.AzureStorageRestClientModule; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.IntegrationTestAsyncClient; -import org.jclouds.http.IntegrationTestClient; -import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.AnonymousRestApiMetadata; -import org.jclouds.rest.internal.BaseRestApiTest.MockModule; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.common.net.HttpHeaders; -import com.google.inject.Injector; -import com.google.inject.Module; - -@Test(groups = "unit") -public class SharedKeyLiteAuthenticationTest { - - private static final String ACCOUNT = "foo"; - private Injector injector; - private SharedKeyLiteAuthentication filter; - - @DataProvider(parallel = true) - public Object[][] dataProvider() { - return new Object[][] { - { HttpRequest.builder().method(HttpMethod.PUT).endpoint("http://" + ACCOUNT - + ".blob.core.windows.net/movies/MOV1.avi?comp=block&blockid=BlockId1&timeout=60").build() }, - { HttpRequest.builder().method(HttpMethod.PUT).endpoint("http://" + ACCOUNT - + ".blob.core.windows.net/movies/MOV1.avi?comp=blocklist&timeout=120").build() }, - { HttpRequest.builder().method(HttpMethod.GET).endpoint("http://" + ACCOUNT + ".blob.core.windows.net/movies/MOV1.avi").build() } }; - } - - /** - * NOTE this test is dependent on how frequently the timestamp updates. At - * the time of writing, this was once per second. If this timestamp update - * interval is increased, it could make this test appear to hang for a long - * time. - */ - @Test(threadPoolSize = 3, dataProvider = "dataProvider", timeOut = 3000) - void testIdempotent(HttpRequest request) { - request = filter.filter(request); - String signature = request.getFirstHeaderOrNull(HttpHeaders.AUTHORIZATION); - String date = request.getFirstHeaderOrNull(HttpHeaders.DATE); - int iterations = 1; - while (request.getFirstHeaderOrNull(HttpHeaders.DATE).equals(date)) { - date = request.getFirstHeaderOrNull(HttpHeaders.DATE); - iterations++; - assertEquals(signature, request.getFirstHeaderOrNull(HttpHeaders.AUTHORIZATION)); - request = filter.filter(request); - } - System.out.printf("%s: %d iterations before the timestamp updated %n", Thread.currentThread().getName(), - iterations); - } - - @Test - void testAclQueryStringRoot() { - URI host = URI.create("http://" + ACCOUNT + ".blob.core.windows.net/?comp=list"); - HttpRequest request = HttpRequest.builder().method(HttpMethod.GET).endpoint(host).build(); - StringBuilder builder = new StringBuilder(); - filter.appendUriPath(request, builder); - assertEquals(builder.toString(), "/?comp=list"); - } - - @Test - void testAclQueryStringResTypeNotSignificant() { - URI host = URI.create("http://" + ACCOUNT + ".blob.core.windows.net/mycontainer?restype=container"); - HttpRequest request = HttpRequest.builder().method(HttpMethod.GET).endpoint(host).build(); - StringBuilder builder = new StringBuilder(); - filter.appendUriPath(request, builder); - assertEquals(builder.toString(), "/mycontainer"); - } - - @Test - void testAclQueryStringComp() { - URI host = URI.create("http://" + ACCOUNT + ".blob.core.windows.net/mycontainer?comp=list"); - HttpRequest request = HttpRequest.builder().method(HttpMethod.GET).endpoint(host).build(); - StringBuilder builder = new StringBuilder(); - filter.appendUriPath(request, builder); - assertEquals(builder.toString(), "/mycontainer?comp=list"); - } - - @Test - void testAclQueryStringRelativeWithExtraJunk() { - URI host = URI.create("http://" + ACCOUNT - + ".blob.core.windows.net/mycontainer?comp=list&marker=marker&maxresults=1&prefix=prefix"); - HttpRequest request = HttpRequest.builder().method(HttpMethod.GET).endpoint(host).build(); - StringBuilder builder = new StringBuilder(); - filter.appendUriPath(request, builder); - assertEquals(builder.toString(), "/mycontainer?comp=list"); - } - - /** - * before class, as we need to ensure that the filter is threadsafe. - * - * @throws IOException - * - */ - @BeforeClass - protected void createFilter() throws IOException { - injector = ContextBuilder - .newBuilder( - AnonymousRestApiMetadata - .forClientMappedToAsyncClient(IntegrationTestClient.class, IntegrationTestAsyncClient.class) - .toBuilder().build()) - .endpoint("https://${jclouds.identity}.blob.core.windows.net") - .credentials(ACCOUNT, "credential") - .modules( - ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule(), - new AzureStorageRestClientModule<IntegrationTestClient, IntegrationTestAsyncClient>( - typeToken(IntegrationTestClient.class), typeToken(IntegrationTestAsyncClient.class)))) - .buildInjector(); - filter = injector.getInstance(SharedKeyLiteAuthentication.class); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/test/java/org/jclouds/azure/storage/handlers/ParseAzureErrorFromXmlContentTest.java ---------------------------------------------------------------------- diff --git a/common/azure/src/test/java/org/jclouds/azure/storage/handlers/ParseAzureErrorFromXmlContentTest.java b/common/azure/src/test/java/org/jclouds/azure/storage/handlers/ParseAzureErrorFromXmlContentTest.java deleted file mode 100644 index 5cfbffe..0000000 --- a/common/azure/src/test/java/org/jclouds/azure/storage/handlers/ParseAzureErrorFromXmlContentTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.handlers; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.reportMatcher; -import static org.easymock.EasyMock.verify; - -import java.net.URI; - -import org.easymock.IArgumentMatcher; -import org.jclouds.azure.storage.AzureStorageResponseException; -import org.jclouds.azure.storage.filters.SharedKeyLiteAuthentication; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.config.SaxParserModule; -import org.testng.annotations.Test; - -import com.google.inject.AbstractModule; -import com.google.inject.Guice; - -@Test(groups = { "unit" }) -public class ParseAzureErrorFromXmlContentTest { - - @Test - public void test411WithTextHtmlIllegalArgumentException() { - assertCodeMakes("PUT", - URI.create("https://jclouds.blob.core.windows.net/adriancole-azureblob-413790770?restype=container"), 411, - "Length Required", "text/html; charset=us-ascii", "<HTML><HEAD><TITLE>Length Required</TITLE>\r\n", - IllegalArgumentException.class); - } - - @Test - public void test304WithNoContentIllegalArgumentException() { - assertCodeMakes("GET", URI.create("https://jclouds.blob.core.windows.net/adriancole-blobstore0/apples"), 411, - "HTTP/1.1 304 The condition specified using HTTP conditional header(s) is not met.", "application/unknown", - "", IllegalArgumentException.class); - } - - - @Test - public void test412WithTextHtmlHttpResponseException() { - assertCodeMakes( - "GET", - URI.create("https://jclouds.blob.core.windows.net/adriancole-blobstore2?restype=container&comp=list&prefix=apps/apps/apps/&include=metadata"), - 412, - "HTTP/1.1 412 The condition specified using HTTP conditional header(s) is not met.", - "application/xml", - "<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>ConditionNotMet</Code><Message>The condition specified using HTTP conditional header(s) is not met.\nRequestId:921efcad-84bc-4e0a-863d-24810d1096e1\nTime:2010-11-04T15:03:07.8694513Z</Message></Error>", - AzureStorageResponseException.class); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType, - String content, Class<? extends Exception> expected) { - - ParseAzureStorageErrorFromXmlContent function = Guice.createInjector(new SaxParserModule(), new AbstractModule() { - - @Override - protected void configure() { - bind(SharedKeyLiteAuthentication.class).toInstance(createMock(SharedKeyLiteAuthentication.class)); - } - - }).getInstance(ParseAzureStorageErrorFromXmlContent.class); - - HttpCommand command = createMock(HttpCommand.class); - HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build(); - HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build(); - response.getPayload().getContentMetadata().setContentType(contentType); - - expect(command.getCurrentRequest()).andReturn(request).atLeastOnce(); - command.setException(classEq(expected)); - - replay(command); - - function.handleError(command, response); - - verify(command); - } - - public static Exception classEq(final Class<? extends Exception> in) { - reportMatcher(new IArgumentMatcher() { - - @Override - public void appendTo(StringBuffer buffer) { - buffer.append("classEq("); - buffer.append(in); - buffer.append(")"); - } - - @Override - public boolean matches(Object arg) { - return arg.getClass() == in; - } - - }); - return null; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/test/java/org/jclouds/azure/storage/options/CreateOptionsTest.java ---------------------------------------------------------------------- diff --git a/common/azure/src/test/java/org/jclouds/azure/storage/options/CreateOptionsTest.java b/common/azure/src/test/java/org/jclouds/azure/storage/options/CreateOptionsTest.java deleted file mode 100644 index b582783..0000000 --- a/common/azure/src/test/java/org/jclouds/azure/storage/options/CreateOptionsTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.options; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.azure.storage.reference.AzureStorageHeaders; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMultimap; - -/** - * Tests behavior of {@code CreateOptions} - */ -@Test(groups = "unit") -public class CreateOptionsTest { - - public void testMetadata() { - CreateOptions options = new CreateOptions().withMetadata(ImmutableMultimap.of( - "test", "foo")); - assertEquals(ImmutableList.of("foo"), options.buildRequestHeaders().get( - AzureStorageHeaders.USER_METADATA_PREFIX + "test")); - } - - public void testMetadataAlreadyPrefixed() { - CreateOptions options = new CreateOptions().withMetadata(ImmutableMultimap.of( - AzureStorageHeaders.USER_METADATA_PREFIX + "test", "foo")); - assertEquals(ImmutableList.of("foo"), options.buildRequestHeaders().get( - AzureStorageHeaders.USER_METADATA_PREFIX + "test")); - } - - public void testMetadataStatic() { - CreateOptions options = CreateOptions.Builder.withMetadata(ImmutableMultimap.of( - "test", "foo")); - assertEquals(ImmutableList.of("foo"), options.buildRequestHeaders().get( - AzureStorageHeaders.USER_METADATA_PREFIX + "test")); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/test/java/org/jclouds/azure/storage/options/ListOptionsTest.java ---------------------------------------------------------------------- diff --git a/common/azure/src/test/java/org/jclouds/azure/storage/options/ListOptionsTest.java b/common/azure/src/test/java/org/jclouds/azure/storage/options/ListOptionsTest.java deleted file mode 100644 index 67fc768..0000000 --- a/common/azure/src/test/java/org/jclouds/azure/storage/options/ListOptionsTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.options; - -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; - -/** - * Tests behavior of {@code ListOptions} - */ -@Test(groups = "unit") -public class ListOptionsTest { - public void testIncludeMetadata() { - ListOptions options = new ListOptions().includeMetadata(); - assertEquals(ImmutableList.of("metadata"), options.buildQueryParameters().get("include")); - } - - public void testIncludeMetadataStatic() { - ListOptions options = ListOptions.Builder.includeMetadata(); - assertEquals(ImmutableList.of("metadata"), options.buildQueryParameters().get("include")); - } - - public void testPrefix() { - ListOptions options = new ListOptions().prefix("a"); - assertEquals(ImmutableList.of("a"), options.buildQueryParameters().get("prefix")); - } - - public void testMarker() { - ListOptions options = new ListOptions().marker("a"); - assertEquals(ImmutableList.of("a"), options.buildQueryParameters().get("marker")); - } - - public void testMaxResults() { - int limit = 1; - ListOptions options = new ListOptions().maxResults(limit); - assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("maxresults")); - } - - public void testPrefixStatic() { - ListOptions options = ListOptions.Builder.prefix("a"); - assertEquals(ImmutableList.of("a"), options.buildQueryParameters().get("prefix")); - } - - public void testMarkerStatic() { - ListOptions options = ListOptions.Builder.marker("a"); - assertEquals(ImmutableList.of("a"), options.buildQueryParameters().get("marker")); - } - - public void testMaxResultsStatic() { - int limit = 1; - ListOptions options = ListOptions.Builder.maxResults(limit); - assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("maxresults")); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/test/java/org/jclouds/azure/storage/xml/ErrorHandlerTest.java ---------------------------------------------------------------------- diff --git a/common/azure/src/test/java/org/jclouds/azure/storage/xml/ErrorHandlerTest.java b/common/azure/src/test/java/org/jclouds/azure/storage/xml/ErrorHandlerTest.java deleted file mode 100644 index 1698cd6..0000000 --- a/common/azure/src/test/java/org/jclouds/azure/storage/xml/ErrorHandlerTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.azure.storage.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.azure.storage.domain.AzureStorageError; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.http.functions.ParseSax; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code ErrorHandler} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ErrorHandlerTest") -public class ErrorHandlerTest extends BaseHandlerTest { - - ParseSax<AzureStorageError> createParser() { - ParseSax<AzureStorageError> parser = factory.create(injector - .getInstance(ErrorHandler.class)); - return parser; - } - - public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/test_error.xml"); - ParseSax<AzureStorageError> parser = createParser(); - AzureStorageError result = parser.parse(is); - assertEquals(result.getCode(), "AuthenticationFailed"); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/test/resources/log4j.xml ---------------------------------------------------------------------- diff --git a/common/azure/src/test/resources/log4j.xml b/common/azure/src/test/resources/log4j.xml deleted file mode 100644 index acaa72d..0000000 --- a/common/azure/src/test/resources/log4j.xml +++ /dev/null @@ -1,118 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> - - <!-- - For more configuration infromation and examples see the Apache - Log4j website: http://logging.apache.org/log4j/ - --> -<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" - debug="false"> - - <!-- A time/date based rolling appender --> - <appender name="WIREFILE" class="org.apache.log4j.DailyRollingFileAppender"> - <param name="File" value="target/test-data/jclouds-wire.log" /> - <param name="Append" value="true" /> - - <!-- Rollover at midnight each day --> - <param name="DatePattern" value="'.'yyyy-MM-dd" /> - - <param name="Threshold" value="TRACE" /> - - <layout class="org.apache.log4j.PatternLayout"> - <!-- The default pattern: Date Priority [Category] Message\n --> - <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" /> - - <!-- - The full pattern: Date MS Priority [Category] - (Thread:NDC) Message\n <param name="ConversionPattern" - value="%d %-5r %-5p [%c] (%t:%x) %m%n"/> - --> - </layout> - </appender> - - <!-- A time/date based rolling appender --> - <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender"> - <param name="File" value="target/test-data/jclouds.log" /> - <param name="Append" value="true" /> - - <!-- Rollover at midnight each day --> - <param name="DatePattern" value="'.'yyyy-MM-dd" /> - - <param name="Threshold" value="TRACE" /> - - <layout class="org.apache.log4j.PatternLayout"> - <!-- The default pattern: Date Priority [Category] Message\n --> - <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" /> - - <!-- - The full pattern: Date MS Priority [Category] - (Thread:NDC) Message\n <param name="ConversionPattern" - value="%d %-5r %-5p [%c] (%t:%x) %m%n"/> - --> - </layout> - </appender> - - <appender name="ASYNC" class="org.apache.log4j.AsyncAppender"> - <appender-ref ref="FILE" /> - </appender> - - <appender name="ASYNCWIRE" class="org.apache.log4j.AsyncAppender"> - <appender-ref ref="WIREFILE" /> - </appender> - - <!-- A time/date based rolling appender --> - <appender name="BLOBSTOREFILE" class="org.apache.log4j.DailyRollingFileAppender"> - <param name="File" value="target/test-data/jclouds-blobstore.log" /> - <param name="Append" value="true" /> - - <!-- Rollover at midnight each day --> - <param name="DatePattern" value="'.'yyyy-MM-dd" /> - - <param name="Threshold" value="TRACE" /> - - <layout class="org.apache.log4j.PatternLayout"> - <!-- The default pattern: Date Priority [Category] Message\n --> - <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" /> - - <!-- - The full pattern: Date MS Priority [Category] - (Thread:NDC) Message\n <param name="ConversionPattern" - value="%d %-5r %-5p [%c] (%t:%x) %m%n"/> - --> - </layout> - </appender> - - <appender name="ASYNCBLOBSTORE" class="org.apache.log4j.AsyncAppender"> - <appender-ref ref="BLOBSTOREFILE" /> - </appender> - <!-- ================ --> - <!-- Limit categories --> - <!-- ================ --> - <category name="jclouds.blobstore"> - <priority value="TRACE" /> - <appender-ref ref="ASYNCBLOBSTORE" /> - </category> - - <category name="org.jclouds"> - <priority value="DEBUG" /> - <appender-ref ref="ASYNC" /> - </category> - - <category name="jclouds.headers"> - <priority value="DEBUG" /> - <appender-ref ref="ASYNCWIRE" /> - </category> - - <category name="jclouds.wire"> - <priority value="DEBUG" /> - <appender-ref ref="ASYNCWIRE" /> - </category> - <!-- ======================= --> - <!-- Setup the Root category --> - <!-- ======================= --> - - <root> - <priority value="WARN" /> - </root> - -</log4j:configuration> http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/azure/src/test/resources/test_error.xml ---------------------------------------------------------------------- diff --git a/common/azure/src/test/resources/test_error.xml b/common/azure/src/test/resources/test_error.xml deleted file mode 100644 index 6c12fac..0000000 --- a/common/azure/src/test/resources/test_error.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Error> - <Code>AuthenticationFailed</Code> - <Message>Server failed to authenticate the request. Make sure the value - of Authorization header is formed correctly including the signature. - RequestId:7859e884-e8b9-4ed0-aa62-ac6963b91bf6 - Time:2009-09-02T23:32:36.7507749Z</Message> - <AuthenticationErrorDetail>The MAC signature found in the HTTP request - 'XEv0NqP+zePZxlrHmxy2F6MiyoRD8LIJt1f/Swgzn1U=' is not the same as any - computed signature. Server used following string to sign: 'GET - - - Wed, 02 Sep 2009 23:32:34 GMT - /jclouds/?comp=list'.</AuthenticationErrorDetail> -</Error> http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/common/pom.xml ---------------------------------------------------------------------- diff --git a/common/pom.xml b/common/pom.xml index a19ce3d..d12c7b8 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -30,7 +30,6 @@ <packaging>pom</packaging> <name>jclouds commons project</name> <modules> - <module>azure</module> <module>openstack</module> </modules> </project> http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c95a578/providers/azureblob/pom.xml ---------------------------------------------------------------------- diff --git a/providers/azureblob/pom.xml b/providers/azureblob/pom.xml index c80c59d..bbeef91 100644 --- a/providers/azureblob/pom.xml +++ b/providers/azureblob/pom.xml @@ -38,7 +38,7 @@ <test.azureblob.identity>${test.azure.identity}</test.azureblob.identity> <test.azureblob.credential>${test.azure.credential}</test.azureblob.credential> - <jclouds.osgi.export>org.jclouds.azureblob*;version="${project.version}"</jclouds.osgi.export> + <jclouds.osgi.export>org.jclouds.azureblob*;version="${project.version}",org.jclouds.azure.storage*;version="${project.version}"</jclouds.osgi.export> <jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import> </properties>
