diff --git a/aws/s3/core/src/main/java/org/jclouds/aws/s3/S3ContextBuilder.java b/aws/s3/core/src/main/java/org/jclouds/aws/s3/S3ContextBuilder.java index 355e21cf9a..1aed23fb16 100644 --- a/aws/s3/core/src/main/java/org/jclouds/aws/s3/S3ContextBuilder.java +++ b/aws/s3/core/src/main/java/org/jclouds/aws/s3/S3ContextBuilder.java @@ -26,6 +26,7 @@ package org.jclouds.aws.s3; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_ACCESSKEYID; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_SECRETACCESSKEY; +import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_SESSIONINTERVAL; import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; import java.net.URI; @@ -76,6 +77,8 @@ public class S3ContextBuilder extends }, props); properties.setProperty(S3Constants.PROPERTY_S3_ENDPOINT, "https://s3.amazonaws.com"); properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "x-amz-meta-"); + if (!properties.containsKey(PROPERTY_S3_SESSIONINTERVAL)) + this.withTimeStampExpiration(60); } public S3ContextBuilder(String id, String secret) { @@ -162,4 +165,8 @@ public class S3ContextBuilder extends modules.add(new RestS3ConnectionModule()); } + public S3ContextBuilder withTimeStampExpiration(long seconds) { + getProperties().setProperty(PROPERTY_S3_SESSIONINTERVAL, seconds + ""); + return this; + } } diff --git a/aws/s3/core/src/main/java/org/jclouds/aws/s3/config/RestS3ConnectionModule.java b/aws/s3/core/src/main/java/org/jclouds/aws/s3/config/RestS3ConnectionModule.java index 0313fb7387..a5df8feffc 100644 --- a/aws/s3/core/src/main/java/org/jclouds/aws/s3/config/RestS3ConnectionModule.java +++ b/aws/s3/core/src/main/java/org/jclouds/aws/s3/config/RestS3ConnectionModule.java @@ -24,6 +24,8 @@ package org.jclouds.aws.s3.config; import java.net.URI; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; import javax.inject.Named; import javax.inject.Singleton; @@ -48,7 +50,11 @@ import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; import org.jclouds.rest.RestClientFactory; +import org.jclouds.util.DateService; +import org.jclouds.util.TimeStamp; +import com.google.common.base.Function; +import com.google.common.collect.MapMaker; import com.google.inject.AbstractModule; import com.google.inject.Provides; import com.google.inject.Scopes; @@ -62,6 +68,28 @@ import com.google.inject.Scopes; @RequiresHttp public class RestS3ConnectionModule extends AbstractModule { + @Provides + @TimeStamp + protected String provideTimeStamp(@TimeStamp ConcurrentMap cache) { + return cache.get("doesn't matter"); + } + + /** + * borrowing concurrency code to ensure that caching takes place properly + */ + @Provides + @TimeStamp + ConcurrentMap provideTimeStampCache( + @Named(S3Constants.PROPERTY_S3_SESSIONINTERVAL) long seconds, + final DateService dateService) { + return new MapMaker().expiration(seconds, TimeUnit.SECONDS).makeComputingMap( + new Function() { + public String apply(String key) { + return dateService.rfc822DateFormat(); + } + }); + } + @Override protected void configure() { bind(RequestAuthorizeSignature.class).in(Scopes.SINGLETON); @@ -78,7 +106,8 @@ public class RestS3ConnectionModule extends AbstractModule { @Provides @Singleton - protected BlobStore provideS3BlobStore(RestClientFactory factory) { + protected BlobStore provideS3BlobStore( + RestClientFactory factory) { return factory.create(S3BlobStore.class); } diff --git a/aws/s3/core/src/main/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignature.java b/aws/s3/core/src/main/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignature.java index 29f29bc85a..a85b85ad8e 100644 --- a/aws/s3/core/src/main/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignature.java +++ b/aws/s3/core/src/main/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignature.java @@ -29,11 +29,10 @@ import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.TreeSet; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; import javax.inject.Named; +import javax.inject.Provider; import javax.inject.Singleton; import javax.ws.rs.core.HttpHeaders; @@ -42,12 +41,12 @@ import org.jclouds.http.HttpException; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.HttpUtils; -import org.jclouds.util.DateService; +import org.jclouds.util.TimeStamp; import com.google.common.annotations.VisibleForTesting; /** - * Signs the S3 request. This will update timestamps at most once per second. + * Signs the S3 request. * * @see * @author Adrian Cole @@ -60,46 +59,15 @@ public class RequestAuthorizeSignature implements HttpRequestFilter { private final String accessKey; private final String secretKey; - private final DateService dateService; - - public final long BILLION = 1000000000; - private final AtomicReference timeStamp; - private final AtomicLong trigger = new AtomicLong(System.nanoTime() + 1 * BILLION); - - /** - * Start the time update service. Amazon clocks need to be within 900 seconds of the request - * time. This method updates the clock every second. This is not performed per-request, as - * creation of the date object is a slow, synchronized command. - */ - synchronized void updateIfTimeOut() { - - if (trigger.get() - System.nanoTime() <= 0) { - timeStamp.set(createNewStamp()); - trigger.set(System.nanoTime() + 1 * BILLION); - } - - } - - // this is a hotspot when submitted concurrently, so be lazy. - // amazon is ok with up to 15 minutes off their time, so let's - // be as lazy as possible. - String createNewStamp() { - return dateService.rfc822DateFormat(); - } - - public String timestampAsHeaderString() { - updateIfTimeOut(); - return timeStamp.get(); - } + private final Provider timeStampProvider; @Inject public RequestAuthorizeSignature(@Named(S3Constants.PROPERTY_AWS_ACCESSKEYID) String accessKey, @Named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY) String secretKey, - DateService dateService) { + @TimeStamp Provider timeStampProvider) { this.accessKey = accessKey; this.secretKey = secretKey; - this.dateService = dateService; - timeStamp = new AtomicReference(createNewStamp()); + this.timeStampProvider = timeStampProvider; } public void filter(HttpRequest request) throws HttpException { @@ -142,7 +110,7 @@ public class RequestAuthorizeSignature implements HttpRequestFilter { private void replaceDateHeader(HttpRequest request) { request.getHeaders().replaceValues(HttpHeaders.DATE, - Collections.singletonList(timestampAsHeaderString())); + Collections.singletonList(timeStampProvider.get())); } private void appendAmzHeaders(HttpRequest request, StringBuilder toSign) { diff --git a/aws/s3/core/src/main/java/org/jclouds/aws/s3/reference/S3Constants.java b/aws/s3/core/src/main/java/org/jclouds/aws/s3/reference/S3Constants.java index da3a23d48a..bff00b10be 100644 --- a/aws/s3/core/src/main/java/org/jclouds/aws/s3/reference/S3Constants.java +++ b/aws/s3/core/src/main/java/org/jclouds/aws/s3/reference/S3Constants.java @@ -42,7 +42,10 @@ public interface S3Constants extends AWSConstants, S3Headers, BlobStoreConstants public static final String MARKER = "marker"; public static final String MAX_KEYS = "max-keys"; public static final String DELIMITER = "delimiter"; - public static final String PROPERTY_S3_ENDPOINT = "https://s3.amazonaws.com"; - + public static final String PROPERTY_S3_ENDPOINT = "jclouds.s3.endpoint"; + /** + * how long do we wait before obtaining a new timestamp for requests. + */ + public static final String PROPERTY_S3_SESSIONINTERVAL = "jclouds.s3.sessioninterval"; } diff --git a/aws/s3/core/src/test/java/org/jclouds/aws/s3/config/RestS3ConnectionModuleTest.java b/aws/s3/core/src/test/java/org/jclouds/aws/s3/config/RestS3ConnectionModuleTest.java index 7af19eef14..1e40a593dc 100644 --- a/aws/s3/core/src/test/java/org/jclouds/aws/s3/config/RestS3ConnectionModuleTest.java +++ b/aws/s3/core/src/test/java/org/jclouds/aws/s3/config/RestS3ConnectionModuleTest.java @@ -24,6 +24,9 @@ package org.jclouds.aws.s3.config; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; + +import java.util.concurrent.ConcurrentMap; import org.jclouds.aws.s3.handlers.AWSClientErrorRetryHandler; import org.jclouds.aws.s3.handlers.AWSRedirectionRetryHandler; @@ -32,6 +35,7 @@ import org.jclouds.aws.s3.reference.S3Constants; import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingRetryHandler; +import org.jclouds.util.DateService; import org.jclouds.util.Jsr330; import org.testng.annotations.Test; @@ -46,17 +50,33 @@ import com.google.inject.Injector; public class RestS3ConnectionModuleTest { Injector createInjector() { - return Guice.createInjector(new RestS3ConnectionModule(), new ParserModule(), new AbstractModule() { - @Override - protected void configure() { - bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to( - "user"); - bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)) - .to("key"); - bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_ENDPOINT)).to( - "http://localhost"); - } - }); + return Guice.createInjector(new RestS3ConnectionModule(), new ParserModule(), + new AbstractModule() { + @Override + protected void configure() { + bindConstant().annotatedWith( + Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to("user"); + bindConstant().annotatedWith( + Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)).to("key"); + bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_ENDPOINT)) + .to("http://localhost"); + bindConstant().annotatedWith( + Jsr330.named(S3Constants.PROPERTY_S3_SESSIONINTERVAL)).to("2"); + } + }); + } + + @Test + void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException { + RestS3ConnectionModule module = new RestS3ConnectionModule(); + + ConcurrentMap map = module.provideTimeStampCache(1, new DateService()); + String timeStamp = map.get("foo"); + for (int i = 0; i < 10; i++) + map.get("foo"); + assertEquals(timeStamp, map.get("foo")); + Thread.sleep(1001); + assertFalse(timeStamp.equals(map.get("foo"))); } @Test diff --git a/aws/s3/core/src/test/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignatureTest.java b/aws/s3/core/src/test/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignatureTest.java index abc79215ee..fc779dcdab 100644 --- a/aws/s3/core/src/test/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignatureTest.java +++ b/aws/s3/core/src/test/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignatureTest.java @@ -30,9 +30,10 @@ import java.net.URI; import javax.ws.rs.HttpMethod; import javax.ws.rs.core.HttpHeaders; +import org.jclouds.aws.s3.config.RestS3ConnectionModule; import org.jclouds.aws.s3.reference.S3Constants; import org.jclouds.http.HttpRequest; -import org.jclouds.util.DateService; +import org.jclouds.http.functions.config.ParserModule; import org.jclouds.util.Jsr330; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; @@ -132,36 +133,26 @@ public class RequestAuthorizeSignatureTest { assertEquals(builder.toString(), "/adriancole.s3int5"); } - @Test - void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException { - // filter.createNewStamp(); - String timeStamp = filter.timestampAsHeaderString(); - // replay(filter); - for (int i = 0; i < 10; i++) - filter.updateIfTimeOut(); - assert timeStamp.equals(filter.timestampAsHeaderString()); - Thread.sleep(1000); - assert !timeStamp.equals(filter.timestampAsHeaderString()); - // verify(filter); - } - /** * before class, as we need to ensure that the filter is threadsafe. * */ @BeforeClass protected void createFilter() { - injector = Guice.createInjector(new AbstractModule() { + injector = Guice.createInjector(new RestS3ConnectionModule(), new ParserModule(), + new AbstractModule() { - protected void configure() { - bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to( - "foo"); - bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)) - .to("bar"); - bind(DateService.class); - - } - }); + protected void configure() { + bindConstant().annotatedWith( + Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to("foo"); + bindConstant().annotatedWith( + Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)).to("bar"); + bindConstant().annotatedWith( + Jsr330.named(S3Constants.PROPERTY_S3_SESSIONINTERVAL)).to("2"); + bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_ENDPOINT)) + .to("https://s3.amazonaws.com"); + } + }); filter = injector.getInstance(RequestAuthorizeSignature.class); } diff --git a/aws/s3/core/src/test/java/org/jclouds/aws/s3/util/S3UtilsTest.java b/aws/s3/core/src/test/java/org/jclouds/aws/s3/util/S3UtilsTest.java index c77b4f54ab..6c760b6950 100644 --- a/aws/s3/core/src/test/java/org/jclouds/aws/s3/util/S3UtilsTest.java +++ b/aws/s3/core/src/test/java/org/jclouds/aws/s3/util/S3UtilsTest.java @@ -29,6 +29,7 @@ import java.io.IOException; import java.io.InputStream; import org.jclouds.aws.domain.AWSError; +import org.jclouds.aws.s3.config.RestS3ConnectionModule; import org.jclouds.aws.s3.reference.S3Constants; import org.jclouds.aws.s3.reference.S3Headers; import org.jclouds.http.HttpCommand; @@ -59,17 +60,22 @@ public class S3UtilsTest { @BeforeTest protected void setUpInjector() { - Injector injector = Guice.createInjector(new ParserModule(), new AbstractModule() { + Injector injector = Guice.createInjector(new RestS3ConnectionModule(), new ParserModule(), + new AbstractModule() { - @Override - protected void configure() { - bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to( - "user"); - bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)) - .to("key"); - } + @Override + protected void configure() { + bindConstant().annotatedWith( + Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to("user"); + bindConstant().annotatedWith( + Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)).to("key"); + bindConstant().annotatedWith( + Jsr330.named(S3Constants.PROPERTY_S3_SESSIONINTERVAL)).to("2"); + bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_ENDPOINT)) + .to("https://s3.amazonaws.com"); + } - }); + }); utils = injector.getInstance(S3Utils.class); response = new HttpResponse(); response.setStatusCode(400); diff --git a/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextBuilder.java b/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextBuilder.java index 9478f1a270..a52dbe948f 100755 --- a/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextBuilder.java +++ b/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextBuilder.java @@ -24,6 +24,7 @@ package org.jclouds.azure.storage.blob; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL; import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; import java.net.URI; @@ -76,14 +77,10 @@ public class AzureBlobContextBuilder extends properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "x-ms-meta-"); properties.setProperty(AzureBlobConstants.PROPERTY_AZUREBLOB_ENDPOINT, "https://{account}.blob.core.windows.net"); + if (!properties.containsKey(PROPERTY_AZURESTORAGE_SESSIONINTERVAL)) + this.withTimeStampExpiration(60); } - // @Override - // protected void addBlobStoreModule(List modules) { - // modules.add(BlobStoreMapsModule.Builder.newBuilder(containerMetadataType, blobMetadataType, - // blobType).withClearContainerStrategy(RecreateClearContainerStrategy.class).build()); - // } - public AzureBlobContextBuilder(String id, String secret) { this(new Properties()); properties.setProperty(AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT, checkNotNull(id, @@ -173,4 +170,8 @@ public class AzureBlobContextBuilder extends modules.add(new RestAzureBlobStoreModule()); } + public AzureBlobContextBuilder withTimeStampExpiration(long seconds) { + getProperties().setProperty(PROPERTY_AZURESTORAGE_SESSIONINTERVAL, seconds + ""); + return this; + } } diff --git a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/AzureBlobConnectionTest.java b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/AzureBlobConnectionTest.java index a10ebb2cbd..9db6f505a6 100644 --- a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/AzureBlobConnectionTest.java +++ b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/AzureBlobConnectionTest.java @@ -40,6 +40,7 @@ import org.jclouds.azure.storage.blob.functions.ParseContainerMetadataFromHeader import org.jclouds.azure.storage.blob.functions.ReturnTrueIfContainerAlreadyExists; import org.jclouds.azure.storage.blob.options.CreateContainerOptions; import org.jclouds.azure.storage.blob.options.ListBlobsOptions; +import org.jclouds.azure.storage.config.RestAzureStorageConnectionModule; import org.jclouds.azure.storage.options.ListOptions; import org.jclouds.azure.storage.reference.AzureStorageConstants; import org.jclouds.blobstore.functions.ReturnVoidOnNotFoundOr404; @@ -81,7 +82,8 @@ public class AzureBlobConnectionTest { Method method = AzureBlobConnection.class.getMethod("listContainers", Array.newInstance( ListOptions.class, 0).getClass()); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] {}); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] {}); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/"); assertEquals(httpMethod.getEndpoint().getQuery(), "comp=list"); @@ -89,8 +91,7 @@ public class AzureBlobConnectionTest { assertEquals(httpMethod.getHeaders().size(), 1); assertEquals(httpMethod.getHeaders().get("x-ms-version"), Collections .singletonList("2009-07-17")); - assertEquals(processor.createResponseParser(method, httpMethod).getClass(), - ParseSax.class); + assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class); // TODO check generic type of response parser assertEquals(processor.createExceptionParserOrNullIfNotFound(method), null); } @@ -99,8 +100,8 @@ public class AzureBlobConnectionTest { Method method = AzureBlobConnection.class.getMethod("listContainers", Array.newInstance( ListOptions.class, 0).getClass()); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { maxResults(1).marker( - "marker").prefix("prefix") }); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] { maxResults(1).marker("marker").prefix("prefix") }); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/"); assert httpMethod.getEndpoint().getQuery().contains("comp=list"); @@ -111,8 +112,7 @@ public class AzureBlobConnectionTest { assertEquals(httpMethod.getHeaders().size(), 1); assertEquals(httpMethod.getHeaders().get("x-ms-version"), Collections .singletonList("2009-07-17")); - assertEquals(processor.createResponseParser(method, httpMethod).getClass(), - ParseSax.class); + assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class); // TODO check generic type of response parser assertEquals(processor.createExceptionParserOrNullIfNotFound(method), null); } @@ -121,7 +121,8 @@ public class AzureBlobConnectionTest { Method method = AzureBlobConnection.class.getMethod("createContainer", String.class, Array .newInstance(CreateContainerOptions.class, 0).getClass()); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "container" }); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] { "container" }); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/container"); assertEquals(httpMethod.getEndpoint().getQuery(), "restype=container"); @@ -140,7 +141,8 @@ public class AzureBlobConnectionTest { public void testDeleteContainer() throws SecurityException, NoSuchMethodException { Method method = AzureBlobConnection.class.getMethod("deleteContainer", String.class); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "container" }); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] { "container" }); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/container"); assertEquals(httpMethod.getEndpoint().getQuery(), "restype=container"); @@ -159,8 +161,9 @@ public class AzureBlobConnectionTest { Method method = AzureBlobConnection.class.getMethod("createContainer", String.class, Array .newInstance(CreateContainerOptions.class, 0).getClass()); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "container", - withPublicAcl().withMetadata(ImmutableMultimap.of("foo", "bar")) }); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] { "container", + withPublicAcl().withMetadata(ImmutableMultimap.of("foo", "bar")) }); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/container"); assertEquals(httpMethod.getEndpoint().getQuery(), "restype=container"); @@ -183,7 +186,8 @@ public class AzureBlobConnectionTest { Method method = AzureBlobConnection.class.getMethod("createRootContainer", Array.newInstance( CreateContainerOptions.class, 0).getClass()); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] {}); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] {}); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/$root"); assertEquals(httpMethod.getEndpoint().getQuery(), "restype=container"); @@ -202,7 +206,8 @@ public class AzureBlobConnectionTest { public void testDeleteRootContainer() throws SecurityException, NoSuchMethodException { Method method = AzureBlobConnection.class.getMethod("deleteRootContainer"); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] {}); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] {}); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/$root"); assertEquals(httpMethod.getEndpoint().getQuery(), "restype=container"); @@ -221,8 +226,8 @@ public class AzureBlobConnectionTest { Method method = AzureBlobConnection.class.getMethod("createRootContainer", Array.newInstance( CreateContainerOptions.class, 0).getClass()); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { withPublicAcl() - .withMetadata(ImmutableMultimap.of("foo", "bar")) }); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] { withPublicAcl().withMetadata(ImmutableMultimap.of("foo", "bar")) }); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/$root"); assertEquals(httpMethod.getEndpoint().getQuery(), "restype=container"); @@ -245,7 +250,8 @@ public class AzureBlobConnectionTest { Method method = AzureBlobConnection.class.getMethod("listBlobs", String.class, Array .newInstance(ListBlobsOptions.class, 0).getClass()); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "container" }); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] { "container" }); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/container"); assertEquals(httpMethod.getEndpoint().getQuery(), "restype=container&comp=list"); @@ -253,8 +259,7 @@ public class AzureBlobConnectionTest { assertEquals(httpMethod.getHeaders().size(), 1); assertEquals(httpMethod.getHeaders().get("x-ms-version"), Collections .singletonList("2009-07-17")); - assertEquals(processor.createResponseParser(method, httpMethod).getClass(), - ParseSax.class); + assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class); // TODO check generic type of response parser assertEquals(processor.createExceptionParserOrNullIfNotFound(method), null); } @@ -263,7 +268,8 @@ public class AzureBlobConnectionTest { Method method = AzureBlobConnection.class.getMethod("listBlobs", Array.newInstance( ListBlobsOptions.class, 0).getClass()); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] {}); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] {}); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/$root"); assertEquals(httpMethod.getEndpoint().getQuery(), "restype=container&comp=list"); @@ -271,8 +277,7 @@ public class AzureBlobConnectionTest { assertEquals(httpMethod.getHeaders().size(), 1); assertEquals(httpMethod.getHeaders().get("x-ms-version"), Collections .singletonList("2009-07-17")); - assertEquals(processor.createResponseParser(method, httpMethod).getClass(), - ParseSax.class); + assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class); // TODO check generic type of response parser assertEquals(processor.createExceptionParserOrNullIfNotFound(method), null); } @@ -280,7 +285,8 @@ public class AzureBlobConnectionTest { public void testContainerProperties() throws SecurityException, NoSuchMethodException { Method method = AzureBlobConnection.class.getMethod("getContainerProperties", String.class); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "container" }); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] { "container" }); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/container"); assertEquals(httpMethod.getEndpoint().getQuery(), "restype=container"); @@ -297,8 +303,8 @@ public class AzureBlobConnectionTest { Method method = AzureBlobConnection.class.getMethod("setContainerMetadata", String.class, Multimap.class); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "container", - ImmutableMultimap.of("key", "value") }); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] { "container", ImmutableMultimap.of("key", "value") }); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/container"); assertEquals(httpMethod.getEndpoint().getQuery(), "restype=container&comp=metadata"); @@ -318,8 +324,8 @@ public class AzureBlobConnectionTest { public void testSetBlobMetadata() throws SecurityException, NoSuchMethodException { Method method = AzureBlobConnection.class.getMethod("setBlobMetadata", String.class, String.class, Multimap.class); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "container", "blob", - ImmutableMultimap.of("key", "value") }); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] { "container", "blob", ImmutableMultimap.of("key", "value") }); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/container/blob"); assertEquals(httpMethod.getEndpoint().getQuery(), "comp=metadata"); @@ -357,9 +363,12 @@ public class AzureBlobConnectionTest { return Logger.NULL; } }); + bindConstant().annotatedWith( + Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL)).to( + 1l); } - }, new RestModule(), new ExecutorServiceModule(new WithinThreadExecutorService()), - new JavaUrlHttpCommandExecutorServiceModule()); + }, new RestAzureStorageConnectionModule(), new RestModule(), new ExecutorServiceModule( + new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule()); processor = injector.getInstance(Key .get(new TypeLiteral>() { })); diff --git a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/AzureBlobStoreTest.java b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/AzureBlobStoreTest.java index bc50480e6c..2f9f3bbec1 100644 --- a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/AzureBlobStoreTest.java +++ b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/AzureBlobStoreTest.java @@ -37,6 +37,7 @@ import javax.ws.rs.core.HttpHeaders; import org.jclouds.azure.storage.AzureBlob; import org.jclouds.azure.storage.blob.domain.Blob; import org.jclouds.azure.storage.blob.functions.ReturnTrueIfContainerAlreadyExists; +import org.jclouds.azure.storage.config.RestAzureStorageConnectionModule; import org.jclouds.azure.storage.reference.AzureStorageConstants; import org.jclouds.blobstore.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.blobstore.reference.BlobStoreConstants; @@ -75,7 +76,8 @@ public class AzureBlobStoreTest { public void testListContainers() throws SecurityException, NoSuchMethodException { Method method = AzureBlobStore.class.getMethod("listContainers"); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] {}); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] {}); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/"); assertEquals(httpMethod.getEndpoint().getQuery(), "comp=list"); @@ -83,8 +85,7 @@ public class AzureBlobStoreTest { assertEquals(httpMethod.getHeaders().size(), 1); assertEquals(httpMethod.getHeaders().get("x-ms-version"), Collections .singletonList("2009-07-17")); - assertEquals(processor.createResponseParser(method, httpMethod).getClass(), - ParseSax.class); + assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class); // TODO check generic type of response parser assertEquals(processor.createExceptionParserOrNullIfNotFound(method), null); } @@ -92,7 +93,8 @@ public class AzureBlobStoreTest { public void testCreateContainer() throws SecurityException, NoSuchMethodException { Method method = AzureBlobStore.class.getMethod("createContainer", String.class); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "container" }); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] { "container" }); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/container"); assertEquals(httpMethod.getEndpoint().getQuery(), "restype=container"); @@ -111,7 +113,8 @@ public class AzureBlobStoreTest { public void testDeleteContainer() throws SecurityException, NoSuchMethodException { Method method = AzureBlobStore.class.getMethod("deleteContainer", String.class); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "container" }); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] { "container" }); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/container"); assertEquals(httpMethod.getEndpoint().getQuery(), "restype=container"); @@ -129,7 +132,8 @@ public class AzureBlobStoreTest { public void testListBlobs() throws SecurityException, NoSuchMethodException { Method method = AzureBlobStore.class.getMethod("listBlobs", String.class); - GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "container" }); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] { "container" }); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/container"); assertEquals(httpMethod.getEndpoint().getQuery(), "restype=container&comp=list"); @@ -137,8 +141,7 @@ public class AzureBlobStoreTest { assertEquals(httpMethod.getHeaders().size(), 1); assertEquals(httpMethod.getHeaders().get("x-ms-version"), Collections .singletonList("2009-07-17")); - assertEquals(processor.createResponseParser(method, httpMethod).getClass(), - ParseSax.class); + assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class); // TODO check generic type of response parser assertEquals(processor.createExceptionParserOrNullIfNotFound(method), null); } @@ -148,8 +151,8 @@ public class AzureBlobStoreTest { Blob blob = new Blob("test"); blob.setData("test"); - GeneratedHttpRequest httpMethod = processor - .createRequest(method, new Object[] { "mycontainer", blob }); + GeneratedHttpRequest httpMethod = processor.createRequest(method, + new Object[] { "mycontainer", blob }); assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net"); assertEquals(httpMethod.getEndpoint().getPath(), "/mycontainer/test"); assertEquals(httpMethod.getEndpoint().getQuery(), null); @@ -188,6 +191,9 @@ public class AzureBlobStoreTest { return Logger.NULL; } }); + bindConstant().annotatedWith( + Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL)).to( + 1l); } @SuppressWarnings("unused") @@ -202,8 +208,8 @@ public class AzureBlobStoreTest { }; } - }, new RestModule(), new ExecutorServiceModule(new WithinThreadExecutorService()), - new JavaUrlHttpCommandExecutorServiceModule()); + }, new RestAzureStorageConnectionModule(), new RestModule(), new ExecutorServiceModule( + new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule()); processor = injector.getInstance(Key .get(new TypeLiteral>() { })); diff --git a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/config/RestAzureBlobConnectionModuleTest.java b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/config/RestAzureBlobConnectionModuleTest.java index ba37e4a6e9..9b3afde0a4 100644 --- a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/config/RestAzureBlobConnectionModuleTest.java +++ b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/config/RestAzureBlobConnectionModuleTest.java @@ -28,6 +28,7 @@ import static org.testng.Assert.assertEquals; import org.jclouds.azure.storage.blob.handlers.AzureBlobClientErrorRetryHandler; import org.jclouds.azure.storage.blob.reference.AzureBlobConstants; import org.jclouds.azure.storage.handlers.ParseAzureStorageErrorFromXmlContent; +import org.jclouds.azure.storage.reference.AzureStorageConstants; import org.jclouds.http.HttpUtils; import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.handlers.DelegatingErrorHandler; @@ -60,6 +61,9 @@ public class RestAzureBlobConnectionModuleTest { bindConstant().annotatedWith( Jsr330.named(AzureBlobConstants.PROPERTY_AZUREBLOB_ENDPOINT)).to( "http://localhost"); + bindConstant().annotatedWith( + Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL)).to( + 1l); } }); } diff --git a/azure/storage/core/src/main/java/org/jclouds/azure/storage/config/RestAzureStorageConnectionModule.java b/azure/storage/core/src/main/java/org/jclouds/azure/storage/config/RestAzureStorageConnectionModule.java index 2187bf2fff..49deb8ab9f 100644 --- a/azure/storage/core/src/main/java/org/jclouds/azure/storage/config/RestAzureStorageConnectionModule.java +++ b/azure/storage/core/src/main/java/org/jclouds/azure/storage/config/RestAzureStorageConnectionModule.java @@ -23,6 +23,13 @@ */ package org.jclouds.azure.storage.config; +import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL; + +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; + +import javax.inject.Named; + import org.jclouds.azure.storage.handlers.ParseAzureStorageErrorFromXmlContent; import org.jclouds.cloud.ConfiguresCloudConnection; import org.jclouds.http.HttpErrorHandler; @@ -30,8 +37,13 @@ import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; +import org.jclouds.util.DateService; +import org.jclouds.util.TimeStamp; +import com.google.common.base.Function; +import com.google.common.collect.MapMaker; import com.google.inject.AbstractModule; +import com.google.inject.Provides; /** * Configures the AzureStorage connection, including logging and http transport. @@ -42,6 +54,28 @@ import com.google.inject.AbstractModule; @RequiresHttp public class RestAzureStorageConnectionModule extends AbstractModule { + @Provides + @TimeStamp + protected String provideTimeStamp(@TimeStamp ConcurrentMap cache) { + return cache.get("doesn't matter"); + } + + /** + * borrowing concurrency code to ensure that caching takes place properly + */ + @Provides + @TimeStamp + ConcurrentMap provideTimeStampCache( + @Named(PROPERTY_AZURESTORAGE_SESSIONINTERVAL) long seconds, + final DateService dateService) { + return new MapMaker().expiration(seconds, TimeUnit.SECONDS).makeComputingMap( + new Function() { + public String apply(String key) { + return dateService.rfc822DateFormat(); + } + }); + } + @Override protected void configure() { bindErrorHandlers(); diff --git a/azure/storage/core/src/main/java/org/jclouds/azure/storage/filters/SharedKeyAuthentication.java b/azure/storage/core/src/main/java/org/jclouds/azure/storage/filters/SharedKeyAuthentication.java index eff87bda36..bf229d08e0 100644 --- a/azure/storage/core/src/main/java/org/jclouds/azure/storage/filters/SharedKeyAuthentication.java +++ b/azure/storage/core/src/main/java/org/jclouds/azure/storage/filters/SharedKeyAuthentication.java @@ -27,11 +27,10 @@ import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.TreeSet; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; import javax.inject.Named; +import javax.inject.Provider; import javax.inject.Singleton; import javax.ws.rs.core.HttpHeaders; @@ -40,12 +39,12 @@ import org.jclouds.http.HttpException; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.HttpUtils; -import org.jclouds.util.DateService; +import org.jclouds.util.TimeStamp; import com.google.common.annotations.VisibleForTesting; /** - * Signs the Azure Storage request. This will update timestamps at most once per second. + * Signs the Azure Storage request. * * @see * @author Adrian Cole @@ -57,48 +56,17 @@ public class SharedKeyAuthentication implements HttpRequestFilter { HttpHeaders.CONTENT_TYPE, HttpHeaders.DATE }; private final String account; - private byte[] key; - private final DateService dateService; - - public final long BILLION = 1000000000; - private final AtomicReference timeStamp; - private final AtomicLong trigger = new AtomicLong(System.nanoTime() + 1 * BILLION); - - /** - * Start the time update service. Azure clocks need to be within 900 seconds of the request time. - * This method updates the clock every second. This is not performed per-request, as creation of - * the date object is a slow, synchronized command. - */ - synchronized void updateIfTimeOut() { - - if (trigger.get() - System.nanoTime() <= 0) { - timeStamp.set(createNewStamp()); - trigger.set(System.nanoTime() + 1 * BILLION); - } - - } - - // this is a hotspot when submitted concurrently, so be lazy. - // amazon is ok with up to 15 minutes off their time, so let's - // be as lazy as possible. - String createNewStamp() { - return dateService.rfc822DateFormat(); - } - - public String timestampAsHeaderString() { - updateIfTimeOut(); - return timeStamp.get(); - } + private final byte[] key; + private final Provider timeStampProvider; @Inject public SharedKeyAuthentication( @Named(AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT) String account, @Named(AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY) String encodedKey, - DateService dateService) { + @TimeStamp Provider timeStampProvider) { this.account = account; this.key = HttpUtils.fromBase64String(encodedKey); - this.dateService = dateService; - timeStamp = new AtomicReference(createNewStamp()); + this.timeStampProvider = timeStampProvider; } public void filter(HttpRequest request) throws HttpException { @@ -140,7 +108,7 @@ public class SharedKeyAuthentication implements HttpRequestFilter { private void replaceDateHeader(HttpRequest request) { request.getHeaders().replaceValues(HttpHeaders.DATE, - Collections.singletonList(timestampAsHeaderString())); + Collections.singletonList(timeStampProvider.get())); } private void appendCanonicalizedHeaders(HttpRequest request, StringBuilder toSign) { @@ -153,45 +121,6 @@ public class SharedKeyAuthentication implements HttpRequestFilter { toSign.deleteCharAt(toSign.lastIndexOf(",")); toSign.append("\n"); } - // } - // // Retrieve all headers for the resource that begin with x-ms-, including the x-ms-date - // // header. - // Set matchingHeaders = Sets.filter(request.getHeaders().keySet(), - // new Predicate() { - // public boolean apply(String input) { - // return input.startsWith("x-ms-"); - // } - // }); - // - // // Convert each HTTP header name to lowercase. - // // Sort the container of headers lexicographically by header name, in ascending order. - // SortedSet lowercaseHeaders = - // Sets.newTreeSet(Iterables.transform(matchingHeaders, - // new Function() { - // public String apply(String from) { - // return from.toLowerCase(); - // } - // })); - // - // for (String header : lowercaseHeaders) { - // // Combine headers with the same name into one header. The resulting header should be a - // // name-value pair of the format "header-name:comma-separated-value-list", without any - // // white - // // space between values. - // toSign.append(header).append(":"); - // // Trim any white space around the colon in the header. - // // TODO: not sure why there would be... - // for (String value : request.getHeaders().get(header)) - // // Replace any breaking white space with a single space. - // toSign.append(value.replaceAll("\r?\n", " ")).append(","); - // toSign.deleteCharAt(toSign.lastIndexOf(",")); - // // Finally, append a new line character to each canonicalized header in the resulting - // list. - // // Construct the CanonicalizedHeaders string by concatenating all headers in this list - // into - // // a - // // single string. - // toSign.append("\n"); } } diff --git a/azure/storage/core/src/main/java/org/jclouds/azure/storage/reference/AzureStorageConstants.java b/azure/storage/core/src/main/java/org/jclouds/azure/storage/reference/AzureStorageConstants.java index 6b5b6a4de7..5d28f4da50 100644 --- a/azure/storage/core/src/main/java/org/jclouds/azure/storage/reference/AzureStorageConstants.java +++ b/azure/storage/core/src/main/java/org/jclouds/azure/storage/reference/AzureStorageConstants.java @@ -31,4 +31,8 @@ package org.jclouds.azure.storage.reference; public interface AzureStorageConstants { public static final String PROPERTY_AZURESTORAGE_ACCOUNT = "jclouds.azure.storage.account"; public static final String PROPERTY_AZURESTORAGE_KEY = "jclouds.azure.storage.key"; + /** + * how long do we wait before obtaining a new timestamp for requests. + */ + public static final String PROPERTY_AZURESTORAGE_SESSIONINTERVAL = "jclouds.azure.storage.sessioninterval"; } diff --git a/azure/storage/core/src/test/java/org/jclouds/azure/storage/filters/SharedKeyAuthenticationLiveTest.java b/azure/storage/core/src/test/java/org/jclouds/azure/storage/filters/SharedKeyAuthenticationLiveTest.java index 6c3f659a09..ad125be9ac 100644 --- a/azure/storage/core/src/test/java/org/jclouds/azure/storage/filters/SharedKeyAuthenticationLiveTest.java +++ b/azure/storage/core/src/test/java/org/jclouds/azure/storage/filters/SharedKeyAuthenticationLiveTest.java @@ -32,6 +32,7 @@ import javax.ws.rs.GET; import javax.ws.rs.Path; import org.jclouds.azure.storage.AzureBlob; +import org.jclouds.azure.storage.config.RestAzureStorageConnectionModule; import org.jclouds.azure.storage.reference.AzureStorageConstants; import org.jclouds.concurrent.WithinThreadExecutorService; import org.jclouds.concurrent.config.ExecutorServiceModule; @@ -85,19 +86,29 @@ public class SharedKeyAuthenticationLiveTest { "jclouds.test.user"); final String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); uri = "http://" + account + ".blob.core.windows.net"; - injector = Guice.createInjector(new AbstractModule() { + injector = Guice.createInjector( + new AbstractModule() { - @Override - protected void configure() { - bind(URI.class).annotatedWith(AzureBlob.class).toInstance(URI.create(uri)); - bindConstant().annotatedWith( - Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT)).to(account); - bindConstant().annotatedWith( - Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY)).to(key); - } + @Override + protected void configure() { + bind(URI.class).annotatedWith(AzureBlob.class).toInstance(URI.create(uri)); + bindConstant().annotatedWith( + Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT)) + .to(account); + bindConstant().annotatedWith( + Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY)) + .to(key); + bindConstant() + .annotatedWith( + Jsr330 + .named(AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL)) + .to(1l); + } - }, new RestModule(), new Log4JLoggingModule(), new ExecutorServiceModule( - new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule()); + }, new RestAzureStorageConnectionModule(), new RestModule(), + new Log4JLoggingModule(), + new ExecutorServiceModule(new WithinThreadExecutorService()), + new JavaUrlHttpCommandExecutorServiceModule()); RestClientFactory factory = injector.getInstance(RestClientFactory.class); client = factory.create(IntegrationTestClient.class); } diff --git a/azure/storage/core/src/test/java/org/jclouds/azure/storage/filters/SharedKeyAuthenticationTest.java b/azure/storage/core/src/test/java/org/jclouds/azure/storage/filters/SharedKeyAuthenticationTest.java index 3633d50031..f1958cdde6 100755 --- a/azure/storage/core/src/test/java/org/jclouds/azure/storage/filters/SharedKeyAuthenticationTest.java +++ b/azure/storage/core/src/test/java/org/jclouds/azure/storage/filters/SharedKeyAuthenticationTest.java @@ -23,6 +23,7 @@ */ package org.jclouds.azure.storage.filters; +import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL; import static org.testng.Assert.assertEquals; import java.net.URI; @@ -30,10 +31,11 @@ import java.net.URI; import javax.ws.rs.HttpMethod; import javax.ws.rs.core.HttpHeaders; +import org.jclouds.azure.storage.config.RestAzureStorageConnectionModule; import org.jclouds.azure.storage.reference.AzureStorageConstants; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpUtils; -import org.jclouds.util.DateService; +import org.jclouds.http.functions.config.ParserModule; import org.jclouds.util.Jsr330; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; @@ -127,36 +129,27 @@ public class SharedKeyAuthenticationTest { assertEquals(builder.toString(), "/mycontainer?comp=list"); } - @Test - void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException { - // filter.createNewStamp(); - String timeStamp = filter.timestampAsHeaderString(); - // replay(filter); - for (int i = 0; i < 10; i++) - filter.updateIfTimeOut(); - assert timeStamp.equals(filter.timestampAsHeaderString()); - Thread.sleep(1000); - assert !timeStamp.equals(filter.timestampAsHeaderString()); - // verify(filter); - } - /** * before class, as we need to ensure that the filter is threadsafe. * */ @BeforeClass protected void createFilter() { - injector = Guice.createInjector(new AbstractModule() { + injector = Guice.createInjector(new ParserModule(), new RestAzureStorageConnectionModule(), + new AbstractModule() { - protected void configure() { - bindConstant().annotatedWith( - Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT)).to(ACCOUNT); - bindConstant().annotatedWith( - Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY)).to(KEY); - bind(DateService.class); + protected void configure() { + bindConstant().annotatedWith( + Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT)) + .to(ACCOUNT); + bindConstant().annotatedWith( + Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY)) + .to(KEY); + bindConstant().annotatedWith( + Jsr330.named(PROPERTY_AZURESTORAGE_SESSIONINTERVAL)).to("1"); + } - } - }); + }); filter = injector.getInstance(SharedKeyAuthentication.class); } diff --git a/azure/storage/queue/core/src/main/java/org/jclouds/azure/storage/queue/AzureQueueContextBuilder.java b/azure/storage/queue/core/src/main/java/org/jclouds/azure/storage/queue/AzureQueueContextBuilder.java index 838213b3c9..1b08877fed 100755 --- a/azure/storage/queue/core/src/main/java/org/jclouds/azure/storage/queue/AzureQueueContextBuilder.java +++ b/azure/storage/queue/core/src/main/java/org/jclouds/azure/storage/queue/AzureQueueContextBuilder.java @@ -24,6 +24,7 @@ package org.jclouds.azure.storage.queue; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL; import java.net.URI; import java.util.List; @@ -68,6 +69,8 @@ public class AzureQueueContextBuilder extends CloudContextBuilder>() { })); diff --git a/blobstore/core/src/test/java/org/jclouds/blobstore/functions/ParseBlobMetadataFromHeadersTest.java b/blobstore/core/src/test/java/org/jclouds/blobstore/functions/ParseBlobMetadataFromHeadersTest.java index 8f58f64933..5fe3693f4c 100644 --- a/blobstore/core/src/test/java/org/jclouds/blobstore/functions/ParseBlobMetadataFromHeadersTest.java +++ b/blobstore/core/src/test/java/org/jclouds/blobstore/functions/ParseBlobMetadataFromHeadersTest.java @@ -38,7 +38,6 @@ import javax.ws.rs.core.MediaType; import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.http.HttpException; import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpUtils; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.DateService; import org.testng.annotations.BeforeTest; diff --git a/blobstore/core/src/test/java/org/jclouds/blobstore/util/BlobStoreUtilsTest.java b/blobstore/core/src/test/java/org/jclouds/blobstore/util/BlobStoreUtilsTest.java index 21828ad328..30e5a0a9da 100644 --- a/blobstore/core/src/test/java/org/jclouds/blobstore/util/BlobStoreUtilsTest.java +++ b/blobstore/core/src/test/java/org/jclouds/blobstore/util/BlobStoreUtilsTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.blobstore.util; import static org.testng.Assert.assertEquals; diff --git a/core/src/main/java/org/jclouds/http/internal/Wire.java b/core/src/main/java/org/jclouds/http/internal/Wire.java index a27d83e1c8..1e9b74579f 100644 --- a/core/src/main/java/org/jclouds/http/internal/Wire.java +++ b/core/src/main/java/org/jclouds/http/internal/Wire.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.http.internal; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/core/src/main/java/org/jclouds/rest/internal/GeneratedHttpRequest.java b/core/src/main/java/org/jclouds/rest/internal/GeneratedHttpRequest.java index 6290f378f8..edf45b28e8 100644 --- a/core/src/main/java/org/jclouds/rest/internal/GeneratedHttpRequest.java +++ b/core/src/main/java/org/jclouds/rest/internal/GeneratedHttpRequest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.rest.internal; import java.lang.reflect.Method; diff --git a/core/src/main/java/org/jclouds/util/TimeStamp.java b/core/src/main/java/org/jclouds/util/TimeStamp.java new file mode 100644 index 0000000000..b3a3c9a7a7 --- /dev/null +++ b/core/src/main/java/org/jclouds/util/TimeStamp.java @@ -0,0 +1,44 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.util; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * Related to a TimeStamp + * + * @author Adrian Cole + * + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface TimeStamp { + +} \ No newline at end of file diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/binders/BindDataToEntity.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/binders/BindDataToEntity.java index 0c528e1b88..ae365d3b0c 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/binders/BindDataToEntity.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/binders/BindDataToEntity.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.mezeo.pcs2.binders; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/functions/AddEntryIntoMap.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/functions/AddEntryIntoMap.java index 99c66364bc..6f83ed95bf 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/functions/AddEntryIntoMap.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/functions/AddEntryIntoMap.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.mezeo.pcs2.functions; import static com.google.common.base.Preconditions.checkState; diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/options/PutBlockOptions.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/options/PutBlockOptions.java index 3d158f99c6..ad124d5906 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/options/PutBlockOptions.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/options/PutBlockOptions.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.mezeo.pcs2.options; import static com.google.common.base.Preconditions.checkArgument; diff --git a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/integration/PCSBlobMapIntegrationTest.java b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/integration/PCSBlobMapIntegrationTest.java index b398d6a411..5f9fcce6fb 100644 --- a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/integration/PCSBlobMapIntegrationTest.java +++ b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/integration/PCSBlobMapIntegrationTest.java @@ -40,13 +40,14 @@ import org.testng.annotations.Test; @Test(groups = { "integration", "live" }, testName = "cloudfiles.PCSBlobMapIntegrationTest") public class PCSBlobMapIntegrationTest extends BaseBlobMapIntegrationTest { - + @Test(enabled = false) @Override public void testEntrySet() throws IOException, InterruptedException, ExecutionException, TimeoutException { // fails on 400 errors } + @Test(enabled = false) @Override public void testContains() throws InterruptedException, ExecutionException, TimeoutException { // not supported diff --git a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/integration/PCSInputStreamMapIntegrationTest.java b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/integration/PCSInputStreamMapIntegrationTest.java index a61d0e36a8..8181ae6c60 100644 --- a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/integration/PCSInputStreamMapIntegrationTest.java +++ b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/integration/PCSInputStreamMapIntegrationTest.java @@ -41,30 +41,35 @@ import org.testng.annotations.Test; public class PCSInputStreamMapIntegrationTest extends BaseInputStreamMapIntegrationTest { + @Test(enabled = false) @Override public void testEntrySet() throws IOException, InterruptedException, ExecutionException, TimeoutException { // fails on 400 errors } - + + @Test(enabled = false) @Override public void testContainsBytesValue() throws InterruptedException, ExecutionException, TimeoutException { // not supported } + @Test(enabled = false) @Override public void testContainsFileValue() throws InterruptedException, ExecutionException, TimeoutException { // not supported } + @Test(enabled = false) @Override public void testContainsInputStreamValue() throws InterruptedException, ExecutionException, TimeoutException { // not supported } + @Test(enabled = false) @Override public void testContainsStringValue() throws InterruptedException, ExecutionException, TimeoutException { diff --git a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/options/PutBlockOptionsTest.java b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/options/PutBlockOptionsTest.java index 159f895793..ad01cabf44 100644 --- a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/options/PutBlockOptionsTest.java +++ b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/options/PutBlockOptionsTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.mezeo.pcs2.options; import static org.jclouds.mezeo.pcs2.options.PutBlockOptions.Builder.range; diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNContext.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNContext.java index a10f2f886c..0765b5e442 100644 --- a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNContext.java +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNContext.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.nirvanix.sdn; import org.jclouds.cloud.CloudContext; diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/binders/BindMetadataToQueryParams.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/binders/BindMetadataToQueryParams.java index 46428b52f6..fcc0934ba5 100644 --- a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/binders/BindMetadataToQueryParams.java +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/binders/BindMetadataToQueryParams.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.nirvanix.sdn.binders; import static com.google.common.base.Preconditions.checkArgument; diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/config/SDNContextModule.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/config/SDNContextModule.java index 5df20ba4da..65f7c52f3d 100644 --- a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/config/SDNContextModule.java +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/config/SDNContextModule.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.nirvanix.sdn.config; import java.net.URI; diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/domain/UploadInfo.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/domain/UploadInfo.java index bfca7fa2de..d018c6842d 100644 --- a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/domain/UploadInfo.java +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/domain/UploadInfo.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.nirvanix.sdn.domain; import java.net.URI; diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/filters/AddSessionTokenToRequest.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/filters/AddSessionTokenToRequest.java index 548d7a5e21..a8b06a906a 100644 --- a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/filters/AddSessionTokenToRequest.java +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/filters/AddSessionTokenToRequest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.nirvanix.sdn.filters; import static com.google.common.base.Preconditions.checkArgument; diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/filters/InsertUserContextIntoPath.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/filters/InsertUserContextIntoPath.java index 43ad12c5d0..d166184eab 100644 --- a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/filters/InsertUserContextIntoPath.java +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/filters/InsertUserContextIntoPath.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.nirvanix.sdn.filters; import static com.google.common.base.Preconditions.checkArgument; diff --git a/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/SDNConnectionLiveTest.java b/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/SDNConnectionLiveTest.java index 278f5b45bc..cbaa58bc80 100644 --- a/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/SDNConnectionLiveTest.java +++ b/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/SDNConnectionLiveTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.nirvanix.sdn; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/binders/BindMetadataToQueryParamsTest.java b/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/binders/BindMetadataToQueryParamsTest.java index bcc9f946f3..09fba7446a 100644 --- a/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/binders/BindMetadataToQueryParamsTest.java +++ b/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/binders/BindMetadataToQueryParamsTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * 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.nirvanix.sdn.binders; import static org.easymock.classextension.EasyMock.createMock;