From 896cc7037425474f6903704f1a4097d938ab0161 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 3 Oct 2014 19:12:56 -0700 Subject: [PATCH] JCLOUDS-296 unasync legacy cloudfiles provider. --- .../cloudfiles/CloudFilesApiMetadata.java | 30 +-- .../cloudfiles/CloudFilesAsyncClient.java | 214 ------------------ .../jclouds/cloudfiles/CloudFilesClient.java | 144 ++++++++++-- .../blobstore/CloudFilesAsyncBlobStore.java | 98 -------- .../CloudFilesBlobStoreContextModule.java | 3 - ...dule.java => CloudFilesHttpApiModule.java} | 19 +- .../cloudfiles/CloudFilesClientLiveTest.java | 2 +- .../CloudFilesBlobSignerExpectTest.java | 6 +- .../CloudFilesRestClientModuleTest.java | 12 +- .../CloudFilesUKClientLiveTest.java | 3 +- 10 files changed, 149 insertions(+), 382 deletions(-) delete mode 100644 apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java delete mode 100644 apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java rename apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/{CloudFilesRestClientModule.java => CloudFilesHttpApiModule.java} (80%) diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java index ce8f2619dc..1c81946e09 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java @@ -21,31 +21,18 @@ import java.util.Properties; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule; -import org.jclouds.cloudfiles.config.CloudFilesRestClientModule; -import org.jclouds.cloudfiles.config.CloudFilesRestClientModule.StorageAndCDNManagementEndpointModule; +import org.jclouds.cloudfiles.config.CloudFilesHttpApiModule; +import org.jclouds.cloudfiles.config.CloudFilesHttpApiModule.StorageAndCDNManagementEndpointModule; import org.jclouds.openstack.swift.SwiftApiMetadata; import org.jclouds.openstack.swift.blobstore.SwiftBlobSigner; import org.jclouds.openstack.swift.blobstore.config.TemporaryUrlExtensionModule; import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; import com.google.inject.Module; import com.google.inject.TypeLiteral; -/** - * Implementation of {@link ApiMetadata} for Rackspace Cloud Files API - */ public class CloudFilesApiMetadata extends SwiftApiMetadata { - /** - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudFilesClient.class)} as - * {@link CloudFilesAsyncClient} interface will be removed in jclouds 1.7. - */ - @Deprecated - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -64,20 +51,19 @@ public class CloudFilesApiMetadata extends SwiftApiMetadata { return properties; } - public static class Builder extends SwiftApiMetadata.Builder { - @SuppressWarnings("deprecation") + public static class Builder extends SwiftApiMetadata.Builder { + protected Builder() { - super(CloudFilesClient.class, CloudFilesAsyncClient.class); + super(CloudFilesClient.class); id("cloudfiles") .name("Rackspace Cloud Files API") .identityName("Username") .credentialName("API Key") .documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html")) .defaultProperties(CloudFilesApiMetadata.defaultProperties()) - .context(CONTEXT_TOKEN) .defaultModules(ImmutableSet.>builder() .add(StorageAndCDNManagementEndpointModule.class) - .add(CloudFilesRestClientModule.class) + .add(CloudFilesHttpApiModule.class) .add(CloudFilesBlobStoreContextModule.class) .add(CloudFilesTemporaryUrlExtensionModule.class).build()); } @@ -93,10 +79,10 @@ public class CloudFilesApiMetadata extends SwiftApiMetadata { } } - public static class CloudFilesTemporaryUrlExtensionModule extends TemporaryUrlExtensionModule { + public static class CloudFilesTemporaryUrlExtensionModule extends TemporaryUrlExtensionModule { @Override protected void bindRequestSigner() { - bind(BlobRequestSigner.class).to(new TypeLiteral>() { + bind(BlobRequestSigner.class).to(new TypeLiteral>() { }); } } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java deleted file mode 100644 index 388534b4ae..0000000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java +++ /dev/null @@ -1,214 +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.cloudfiles; - -import java.net.URI; -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HEAD; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.blobstore.BlobStoreFallbacks.NullOnContainerNotFound; -import org.jclouds.cloudfiles.binders.BindIterableToHeadersWithPurgeCDNObjectEmail; -import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; -import org.jclouds.cloudfiles.functions.ParseCdnUriFromHeaders; -import org.jclouds.cloudfiles.functions.ParseContainerCDNMetadataFromHeaders; -import org.jclouds.cloudfiles.options.ListCdnContainerOptions; -import org.jclouds.cloudfiles.reference.CloudFilesHeaders; -import org.jclouds.openstack.filters.AuthenticateRequest; -import org.jclouds.openstack.swift.Storage; -import org.jclouds.openstack.swift.SwiftAsyncClient; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Endpoint; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Cloud Files via their REST API. - *

- * All commands return a ListenableFuture of the result from Cloud Files. Any exceptions incurred - * during processing will be backend in an {@link ExecutionException} as documented in - * {@link ListenableFuture#get()}. - * - * @see CloudFilesClient - * @see - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudFilesClient.class)} as - * {@link CloudFilesAsyncClient} interface will be removed in jclouds 1.7. - */ -@Deprecated -@RequestFilters(AuthenticateRequest.class) -@Endpoint(Storage.class) -public interface CloudFilesAsyncClient extends SwiftAsyncClient { - - /** - * @see CloudFilesClient#listCDNContainers - */ - @Named("ListCDNEnabledContainers") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/") - @Endpoint(CDNManagement.class) - ListenableFuture> listCDNContainers(ListCdnContainerOptions... options); - - /** - * @see CloudFilesClient#getCDNMetadata - */ - @Named("ListCDNEnabledContainerMetadata") - @HEAD - @ResponseParser(ParseContainerCDNMetadataFromHeaders.class) - @Fallback(NullOnContainerNotFound.class) - @Path("/{container}") - @Endpoint(CDNManagement.class) - ListenableFuture getCDNMetadata(@PathParam("container") String container); - - /** - * @see CloudFilesClient#enableCDN(String, long, boolean); - */ - @Named("CDNEnableContainer") - @PUT - @Path("/{container}") - @Headers(keys = CloudFilesHeaders.CDN_ENABLED, values = "True") - @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CDNManagement.class) - ListenableFuture enableCDN(@PathParam("container") String container, - @HeaderParam(CloudFilesHeaders.CDN_TTL) long ttl, - @HeaderParam(CloudFilesHeaders.CDN_LOG_RETENTION) boolean logRetention); - - /** - * @see CloudFilesClient#enableCDN(String, long); - */ - @Named("CDNEnableContainer") - @PUT - @Path("/{container}") - @Headers(keys = CloudFilesHeaders.CDN_ENABLED, values = "True") - @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CDNManagement.class) - ListenableFuture enableCDN(@PathParam("container") String container, - @HeaderParam(CloudFilesHeaders.CDN_TTL) long ttl); - - /** - * @see CloudFilesClient#enableCDN(String) - */ - @Named("CDNEnableContainer") - @PUT - @Path("/{container}") - @Headers(keys = CloudFilesHeaders.CDN_ENABLED, values = "True") - @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CDNManagement.class) - ListenableFuture enableCDN(@PathParam("container") String container); - - /** - * @see CloudFilesClient#updateCDN(long, boolean) - */ - @Named("UpdateCDNEnabledContainerMetadata") - @POST - @Path("/{container}") - @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CDNManagement.class) - ListenableFuture updateCDN(@PathParam("container") String container, - @HeaderParam(CloudFilesHeaders.CDN_TTL) long ttl, - @HeaderParam(CloudFilesHeaders.CDN_LOG_RETENTION) boolean logRetention); - - /** - * @see CloudFilesClient#updateCDN(boolean) - */ - @Named("UpdateCDNEnabledContainerMetadata") - @POST - @Path("/{container}") - @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CDNManagement.class) - ListenableFuture updateCDN(@PathParam("container") String container, - @HeaderParam(CloudFilesHeaders.CDN_LOG_RETENTION) boolean logRetention); - - /** - * @see CloudFilesClient#updateCDN(long) - */ - @Named("UpdateCDNEnabledContainerMetadata") - @POST - @Path("/{container}") - @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CDNManagement.class) - ListenableFuture updateCDN(@PathParam("container") String container, - @HeaderParam(CloudFilesHeaders.CDN_TTL) long ttl); - - /** - * @see CloudFilesClient#disableCDN - */ - @Named("DisableCDNEnabledContainer") - @POST - @Path("/{container}") - @Headers(keys = CloudFilesHeaders.CDN_ENABLED, values = "False") - @Endpoint(CDNManagement.class) - ListenableFuture disableCDN(@PathParam("container") String container); - - /** - * @see CloudFilesClient#purgeCDNObject(String, String, Iterable) - */ - @Named("PurgeCDNEnabledObject") - @DELETE - @Path("/{container}/{object}") - @Headers(keys = CloudFilesHeaders.CDN_CONTAINER_PURGE_OBJECT_EMAIL, values = "{email}") - @Endpoint(CDNManagement.class) - ListenableFuture purgeCDNObject(@PathParam("container") String container, - @PathParam("object") String object, - @BinderParam(BindIterableToHeadersWithPurgeCDNObjectEmail.class) Iterable emails); - - /** - * @see CloudFilesClient#purgeCDNObject(String, String) - */ - @Named("PurgeCDNEnabledObject") - @DELETE - @Path("/{container}/{object}") - @Endpoint(CDNManagement.class) - ListenableFuture purgeCDNObject(@PathParam("container") String container, - @PathParam("object") String object); - - /** - * @see CloudFilesClient#setCDNStaticWebsiteIndex - */ - @Named("UpdateCDNEnabledContainerMetadata") - @POST - @Path("/{container}") - @Headers(keys = CloudFilesHeaders.CDN_WEBSITE_INDEX, values = "{index}") - ListenableFuture setCDNStaticWebsiteIndex(@PathParam("container") String container, - @PathParam("index") String index); - - /** - * @see CloudFilesClient#setCDNStaticWebsiteError - */ - @Named("UpdateCDNEnabledContainerMetadata") - @POST - @Path("/{container}") - @Headers(keys = CloudFilesHeaders.CDN_WEBSITE_ERROR, values = "{error}") - ListenableFuture setCDNStaticWebsiteError(@PathParam("container") String container, - @PathParam("error") String error); -} diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesClient.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesClient.java index 8adcb807c5..9834133e9f 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesClient.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesClient.java @@ -16,23 +16,59 @@ */ package org.jclouds.cloudfiles; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +import static org.jclouds.blobstore.BlobStoreFallbacks.NullOnContainerNotFound; +import static org.jclouds.cloudfiles.reference.CloudFilesHeaders.CDN_CONTAINER_PURGE_OBJECT_EMAIL; +import static org.jclouds.cloudfiles.reference.CloudFilesHeaders.CDN_ENABLED; +import static org.jclouds.cloudfiles.reference.CloudFilesHeaders.CDN_LOG_RETENTION; +import static org.jclouds.cloudfiles.reference.CloudFilesHeaders.CDN_TTL; +import static org.jclouds.cloudfiles.reference.CloudFilesHeaders.CDN_WEBSITE_ERROR; +import static org.jclouds.cloudfiles.reference.CloudFilesHeaders.CDN_WEBSITE_INDEX; + import java.net.URI; import java.util.Set; -import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; -import org.jclouds.cloudfiles.options.ListCdnContainerOptions; -import org.jclouds.openstack.swift.SwiftClient; +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; -/** - * Provides access to Cloud Files via their REST API. - * - * @see Cloud Files - */ +import org.jclouds.cloudfiles.binders.BindIterableToHeadersWithPurgeCDNObjectEmail; +import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; +import org.jclouds.cloudfiles.functions.ParseCdnUriFromHeaders; +import org.jclouds.cloudfiles.functions.ParseContainerCDNMetadataFromHeaders; +import org.jclouds.cloudfiles.options.ListCdnContainerOptions; +import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.swift.Storage; +import org.jclouds.openstack.swift.SwiftClient; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Endpoint; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.Headers; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; + +/** Provides access to Cloud Files via their REST API. */ +@RequestFilters(AuthenticateRequest.class) +@Endpoint(Storage.class) public interface CloudFilesClient extends SwiftClient { /** * Retrieve a list of existing CDN-enabled containers. */ + @Named("ListCDNEnabledContainers") + @GET + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/") + @Endpoint(CDNManagement.class) Set listCDNContainers(ListCdnContainerOptions... options); /** @@ -45,7 +81,13 @@ public interface CloudFilesClient extends SwiftClient { * whether the container is currently marked to allow public serving of objects via CDN. The log_retention setting * specifies whether the CDN access logs should be collected and stored in the Cloud Files storage system. */ - ContainerCDNMetadata getCDNMetadata(String container); + @Named("ListCDNEnabledContainerMetadata") + @HEAD + @ResponseParser(ParseContainerCDNMetadataFromHeaders.class) + @Fallback(NullOnContainerNotFound.class) + @Path("/{container}") + @Endpoint(CDNManagement.class) + ContainerCDNMetadata getCDNMetadata(@PathParam("container") String container); /** * Before a container can be CDN-enabled, it must exist in the storage system. When a container is CDN-enabled, any @@ -62,37 +104,80 @@ public interface CloudFilesClient extends SwiftClient { * will stay populated on CDN edge servers for the entire period. The most popular objects stay cached based on the * edge location's logic. */ - URI enableCDN(String container, long ttl, boolean logRetention); + @Named("CDNEnableContainer") + @PUT + @Path("/{container}") + @Headers(keys = CDN_ENABLED, values = "True") + @ResponseParser(ParseCdnUriFromHeaders.class) + @Endpoint(CDNManagement.class) + URI enableCDN(@PathParam("container") String container, + @HeaderParam(CDN_TTL) long ttl, + @HeaderParam(CDN_LOG_RETENTION) boolean logRetention); + /** * @see CloudFilesClient#enableCDN(String, long, boolean) */ - URI enableCDN(String container, long ttl); + @Named("CDNEnableContainer") + @PUT + @Path("/{container}") + @Headers(keys = CDN_ENABLED, values = "True") + @ResponseParser(ParseCdnUriFromHeaders.class) + @Endpoint(CDNManagement.class) + URI enableCDN(@PathParam("container") String container, @HeaderParam(CDN_TTL) long ttl); /** * @see CloudFilesClient#enableCDN(String, long, boolean) */ - URI enableCDN(String container); + @Named("CDNEnableContainer") + @PUT + @Path("/{container}") + @Headers(keys = CDN_ENABLED, values = "True") + @ResponseParser(ParseCdnUriFromHeaders.class) + @Endpoint(CDNManagement.class) + URI enableCDN(@PathParam("container") String container); /** * @see CloudFilesClient#enableCDN(String, long, boolean) */ - URI updateCDN(String container, long ttl, boolean logRetention); + @Named("UpdateCDNEnabledContainerMetadata") + @POST + @Path("/{container}") + @ResponseParser(ParseCdnUriFromHeaders.class) + @Endpoint(CDNManagement.class) + URI updateCDN(@PathParam("container") String container, + @HeaderParam(CDN_TTL) long ttl, + @HeaderParam(CDN_LOG_RETENTION) boolean logRetention); /** * @see CloudFilesClient#enableCDN(String, long, boolean) */ - URI updateCDN(String container, boolean logRetention); + @Named("UpdateCDNEnabledContainerMetadata") + @POST + @Path("/{container}") + @ResponseParser(ParseCdnUriFromHeaders.class) + @Endpoint(CDNManagement.class) + URI updateCDN(@PathParam("container") String container, @HeaderParam(CDN_LOG_RETENTION) boolean logRetention); /** * @see CloudFilesClient#enableCDN(String, long, boolean) */ - URI updateCDN(String container, long ttl); + @Named("UpdateCDNEnabledContainerMetadata") + @POST + @Path("/{container}") + @ResponseParser(ParseCdnUriFromHeaders.class) + @Endpoint(CDNManagement.class) + URI updateCDN(@PathParam("container") String container, @HeaderParam(CDN_TTL) long ttl); /** * Remove the container from the CDN. Please note, however, that objects remain public until their TTL expires. */ - boolean disableCDN(String container); + @Named("DisableCDNEnabledContainer") + @POST + @Path("/{container}") + @Headers(keys = CDN_ENABLED, values = "False") + @Endpoint(CDNManagement.class) + boolean disableCDN(@PathParam("container") String container); /** * You can purge a CDN-enabled object when you find it absolutely necessary to remove the object from public access @@ -107,12 +192,23 @@ public interface CloudFilesClient extends SwiftClient { * (2) by creating a support ticket to purge entire containers. The 25-object limit does not apply when purging an * entire container via Support. */ - boolean purgeCDNObject(String container, String object, Iterable emails); + @Named("PurgeCDNEnabledObject") + @DELETE + @Path("/{container}/{object}") + @Headers(keys = CDN_CONTAINER_PURGE_OBJECT_EMAIL, values = "{email}") + @Endpoint(CDNManagement.class) + boolean purgeCDNObject(@PathParam("container") String container, @PathParam("object") String object, + @BinderParam(BindIterableToHeadersWithPurgeCDNObjectEmail.class) Iterable emails); + /** * @see CloudFilesClient#purgeCDNObject(String, String, Iterable) */ - boolean purgeCDNObject(String container, String object); + @Named("PurgeCDNEnabledObject") + @DELETE + @Path("/{container}/{object}") + @Endpoint(CDNManagement.class) + boolean purgeCDNObject(@PathParam("container") String container, @PathParam("object") String object); /** * You may use your Cloud Files account to create a static website on the World Wide Web. First, you must CDN-enable @@ -130,7 +226,11 @@ public interface CloudFilesClient extends SwiftClient { * is outside the scope of this documentation. Once you have your CNAME established, map your domain name to your * Cloud Files CDN URL to get your site up and running on the Web. */ - boolean setCDNStaticWebsiteIndex(String container, String index); + @Named("UpdateCDNEnabledContainerMetadata") + @POST + @Path("/{container}") + @Headers(keys = CDN_WEBSITE_INDEX, values = "{index}") + boolean setCDNStaticWebsiteIndex(@PathParam("container") String container, @PathParam("index") String index); /** * You may create and set custom error pages for visitors to your website; currently, only 401 (Unauthorized) and @@ -143,5 +243,9 @@ public interface CloudFilesClient extends SwiftClient { * * You need only set the error parameter once for your entire static website. */ - boolean setCDNStaticWebsiteError(String container, String error); + @Named("UpdateCDNEnabledContainerMetadata") + @POST + @Path("/{container}") + @Headers(keys = CDN_WEBSITE_ERROR, values = "{error}") + boolean setCDNStaticWebsiteError(@PathParam("container") String container, @PathParam("error") String error); } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java deleted file mode 100644 index 1f1912c3d3..0000000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.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.cloudfiles.blobstore; - -import static com.google.common.util.concurrent.Futures.transform; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.functions.BlobToHttpGetOptions; -import org.jclouds.blobstore.options.CreateContainerOptions; -import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata; -import org.jclouds.blobstore.util.BlobUtils; -import org.jclouds.cloudfiles.CloudFilesAsyncClient; -import org.jclouds.cloudfiles.CloudFilesClient; -import org.jclouds.cloudfiles.blobstore.functions.EnableCDNAndCache; -import org.jclouds.collect.Memoized; -import org.jclouds.domain.Location; -import org.jclouds.openstack.swift.blobstore.SwiftAsyncBlobStore; -import org.jclouds.openstack.swift.blobstore.functions.BlobStoreListContainerOptionsToListContainerOptions; -import org.jclouds.openstack.swift.blobstore.functions.BlobToObject; -import org.jclouds.openstack.swift.blobstore.functions.ContainerToResourceList; -import org.jclouds.openstack.swift.blobstore.functions.ContainerToResourceMetadata; -import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlob; -import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata; -import org.jclouds.openstack.swift.blobstore.strategy.internal.AsyncMultipartUploadStrategy; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; - -/** - * - * @deprecated will be removed in jclouds 1.7, as async interfaces are no longer - * supported. Please use {@link CloudFilesBlobStore} - */ -@Deprecated -@Singleton -public class CloudFilesAsyncBlobStore extends SwiftAsyncBlobStore { - private final EnableCDNAndCache enableCDNAndCache; - - @Inject - protected CloudFilesAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, - @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, Supplier defaultLocation, - @Memoized Supplier> locations, CloudFilesClient sync, CloudFilesAsyncClient async, - ContainerToResourceMetadata container2ResourceMd, - BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, - ContainerToResourceList container2ResourceList, ObjectToBlob object2Blob, BlobToObject blob2Object, - ObjectToBlobMetadata object2BlobMd, BlobToHttpGetOptions blob2ObjectGetOptions, - Provider fetchBlobMetadataProvider, EnableCDNAndCache enableCDNAndCache, - Provider multipartUploadStrategy) { - super(context, blobUtils, userExecutor, defaultLocation, locations, sync, async, container2ResourceMd, - container2ContainerListOptions, container2ResourceList, object2Blob, blob2Object, object2BlobMd, - blob2ObjectGetOptions, fetchBlobMetadataProvider, multipartUploadStrategy); - this.enableCDNAndCache = enableCDNAndCache; - } - - @Override - public ListenableFuture createContainerInLocation(Location location, final String container, - CreateContainerOptions options) { - - ListenableFuture returnVal = createContainerInLocation(location, container); - if (options.isPublicRead()) - return transform(createContainerInLocation(location, container), new Function() { - - @Override - public Boolean apply(Boolean input) { - if (Boolean.TRUE.equals(input)) { - return enableCDNAndCache.apply(container) != null; - } - return false; - } - - }, userExecutor); - return returnVal; - } -} diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java index 7113a42d4a..6454c50c22 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java @@ -22,11 +22,9 @@ import java.util.concurrent.TimeUnit; import javax.inject.Singleton; import org.jclouds.cloudfiles.CloudFilesClient; -import org.jclouds.cloudfiles.blobstore.CloudFilesAsyncBlobStore; import org.jclouds.cloudfiles.blobstore.CloudFilesBlobStore; import org.jclouds.cloudfiles.blobstore.functions.CloudFilesObjectToBlobMetadata; import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; -import org.jclouds.openstack.swift.blobstore.SwiftAsyncBlobStore; import org.jclouds.openstack.swift.blobstore.SwiftBlobStore; import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule; import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata; @@ -59,7 +57,6 @@ public class CloudFilesBlobStoreContextModule extends SwiftBlobStoreContextModul protected void configure() { super.configure(); bind(SwiftBlobStore.class).to(CloudFilesBlobStore.class); - bind(SwiftAsyncBlobStore.class).to(CloudFilesAsyncBlobStore.class); bind(ObjectToBlobMetadata.class).to(CloudFilesObjectToBlobMetadata.class); } } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesHttpApiModule.java similarity index 80% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java rename to apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesHttpApiModule.java index 25c5042225..3ce8c3a8e5 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesHttpApiModule.java @@ -16,42 +16,35 @@ */ package org.jclouds.cloudfiles.config; -import static org.jclouds.reflect.Reflection2.typeToken; - import java.net.URI; import java.util.Map; import javax.inject.Singleton; import org.jclouds.cloudfiles.CDNManagement; -import org.jclouds.cloudfiles.CloudFilesAsyncClient; import org.jclouds.cloudfiles.CloudFilesClient; import org.jclouds.location.suppliers.RegionIdToURISupplier; import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule; import org.jclouds.openstack.keystone.v1_1.suppliers.V1DefaultRegionIdSupplier; -import org.jclouds.openstack.swift.CommonSwiftAsyncClient; import org.jclouds.openstack.swift.CommonSwiftClient; import org.jclouds.openstack.swift.Storage; -import org.jclouds.openstack.swift.config.SwiftRestClientModule; -import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.openstack.swift.config.SwiftHttpApiModule; +import org.jclouds.rest.ConfiguresHttpApi; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; import com.google.inject.Provides; import com.google.inject.Scopes; -@ConfiguresRestClient -public class CloudFilesRestClientModule extends SwiftRestClientModule { - public CloudFilesRestClientModule() { - super(typeToken(CloudFilesClient.class), typeToken(CloudFilesAsyncClient.class), ImmutableMap - ., Class> of()); +@ConfiguresHttpApi +public class CloudFilesHttpApiModule extends SwiftHttpApiModule { + public CloudFilesHttpApiModule() { + super(CloudFilesClient.class); } @Override protected void bindResolvedClientsToCommonSwift() { bind(CommonSwiftClient.class).to(CloudFilesClient.class).in(Scopes.SINGLETON); - bind(CommonSwiftAsyncClient.class).to(CloudFilesAsyncClient.class).in(Scopes.SINGLETON); } public static class StorageAndCDNManagementEndpointModule extends AuthenticationServiceModule { diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java index b0c8751d6d..3ccdb4463b 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java @@ -45,7 +45,7 @@ public class CloudFilesClientLiveTest extends CommonSwiftClientLiveTest> builder() .add(StorageAndCDNManagementEndpointModule.class) - .add(CloudFilesRestClientModule.class) + .add(CloudFilesHttpApiModule.class) .add(CloudFilesBlobStoreContextModule.class) .add(StaticTimeAndTemporaryUrlKeyModule.class).build()).build(); } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModuleTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModuleTest.java index 80c1632391..a0066c8140 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModuleTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModuleTest.java @@ -31,16 +31,16 @@ public class CloudFilesRestClientModuleTest { @Test public void testWithKey() { assertEquals( - CloudFilesRestClientModule. valueForKey( - Suppliers.>> ofInstance(ImmutableMap.of("foo", - Suppliers.ofInstance("bar"))), Suppliers.ofInstance("foo")).get(), "bar"); + CloudFilesHttpApiModule. valueForKey(Suppliers + .>>ofInstance(ImmutableMap.of("foo", Suppliers.ofInstance("bar"))), + Suppliers.ofInstance("foo")).get(), "bar"); } @Test public void testWithKeyUnmatchedIsNull() { assertEquals( - CloudFilesRestClientModule. valueForKey( - Suppliers.>> ofInstance(ImmutableMap.of("boo", - Suppliers.ofInstance("bar"))), Suppliers.ofInstance("foo")).get(), null); + CloudFilesHttpApiModule. valueForKey(Suppliers + .>>ofInstance(ImmutableMap.of("boo", Suppliers.ofInstance("bar"))), + Suppliers.ofInstance("foo")).get(), null); } } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java index d36ca44615..57bb3c10d6 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java @@ -18,7 +18,6 @@ package org.jclouds.rackspace.cloudfiles; import static org.testng.Assert.assertEquals; -import org.jclouds.cloudfiles.CloudFilesApiMetadata; import org.jclouds.cloudfiles.CloudFilesClient; import org.jclouds.cloudfiles.CloudFilesClientLiveTest; import org.jclouds.openstack.swift.domain.SwiftObject; @@ -37,7 +36,7 @@ public class CloudFilesUKClientLiveTest extends CloudFilesClientLiveTest { @Override public CloudFilesClient getApi() { - return view.unwrap(CloudFilesApiMetadata.CONTEXT_TOKEN).getApi(); + return view.unwrapApi(CloudFilesClient.class); } @Override