You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/10/04 08:18:13 UTC

[3/9] JCLOUDS-296 unasync legacy swift provider.

http://git-wip-us.apache.org/repos/asf/jclouds/blob/bbad831c/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/KeystoneTemporaryUrlKeyApi.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/KeystoneTemporaryUrlKeyApi.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/KeystoneTemporaryUrlKeyApi.java
new file mode 100644
index 0000000..6c71dfe
--- /dev/null
+++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/KeystoneTemporaryUrlKeyApi.java
@@ -0,0 +1,31 @@
+/*
+ * 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.openstack.swift.extensions;
+
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.swift.Storage;
+import org.jclouds.rest.annotations.Endpoint;
+import org.jclouds.rest.annotations.RequestFilters;
+
+/**
+ * Only purpose is to override the auth filter with one that works in keystone
+ */
+@RequestFilters(AuthenticateRequest.class)
+@Endpoint(Storage.class)
+public interface KeystoneTemporaryUrlKeyApi extends TemporaryUrlKeyApi {
+
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/bbad831c/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/KeystoneTemporaryUrlKeyAsyncApi.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/KeystoneTemporaryUrlKeyAsyncApi.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/KeystoneTemporaryUrlKeyAsyncApi.java
deleted file mode 100644
index 57c69f3..0000000
--- a/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/KeystoneTemporaryUrlKeyAsyncApi.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.openstack.swift.extensions;
-
-import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
-import org.jclouds.openstack.swift.Storage;
-import org.jclouds.rest.annotations.Endpoint;
-import org.jclouds.rest.annotations.RequestFilters;
-
-/**
- * Only purpose is to override the auth filter with one that works in keystone
- *
- * @see TemporaryUrlKeyApi
- */
-@RequestFilters(AuthenticateRequest.class)
-@Endpoint(Storage.class)
-public interface KeystoneTemporaryUrlKeyAsyncApi extends TemporaryUrlKeyAsyncApi {
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/bbad831c/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/TemporaryUrlKeyApi.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/TemporaryUrlKeyApi.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/TemporaryUrlKeyApi.java
index ca20531..0a96960 100644
--- a/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/TemporaryUrlKeyApi.java
+++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/TemporaryUrlKeyApi.java
@@ -16,17 +16,38 @@
  */
 package org.jclouds.openstack.swift.extensions;
 
+import static org.jclouds.openstack.swift.reference.SwiftHeaders.ACCOUNT_TEMPORARY_URL_KEY;
+
+import java.io.Closeable;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.HEAD;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+import org.jclouds.openstack.filters.AuthenticateRequest;
+import org.jclouds.openstack.swift.Storage;
+import org.jclouds.openstack.swift.functions.ParseTemporaryUrlKeyFromHeaders;
+import org.jclouds.rest.annotations.Endpoint;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+
+@RequestFilters(AuthenticateRequest.class)
+@Endpoint(Storage.class)
+public interface TemporaryUrlKeyApi extends Closeable {
 
-/**
- * @see <a href="http://docs.rackspace.com/files/api/v1/cf-devguide/content/Public_Access_to_Account-d1a4440.html" />
- */
-public interface TemporaryUrlKeyApi {
    /**
     * Retrieve the key used to generate Temporary object access URLs
     *
     * @return shared secret key or null
-    * @see <a href="http://docs.rackspace.com/files/api/v1/cf-devguide/content/Set_Account_Metadata-d1a4460.html" />
     */
+   @Named("GetAccountMetadata")
+   @HEAD
+   @Path("/")
+   @Consumes
+   @ResponseParser(ParseTemporaryUrlKeyFromHeaders.class)
    String getTemporaryUrlKey();
 
    /**
@@ -36,9 +57,9 @@ public interface TemporaryUrlKeyApi {
     * able to access your temporary URL. If you change it, the TempURL becomes invalid
     * (within 60 seconds, which is the cache time for a key) and others will not be allowed
     * to access it.
-    *
-    * @param temporaryUrlKey
-    * @see <a href="http://docs.rackspace.com/files/api/v1/cf-devguide/content/Set_Account_Metadata-d1a4460.html" />
     */
-   void setTemporaryUrlKey(String temporaryUrlKey);
+   @Named("UpdateAccountMetadata")
+   @POST
+   @Path("/")
+   void setTemporaryUrlKey(@HeaderParam(ACCOUNT_TEMPORARY_URL_KEY) String key);
 }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/bbad831c/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/TemporaryUrlKeyAsyncApi.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/TemporaryUrlKeyAsyncApi.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/TemporaryUrlKeyAsyncApi.java
deleted file mode 100644
index ca92c12..0000000
--- a/apis/swift/src/main/java/org/jclouds/openstack/swift/extensions/TemporaryUrlKeyAsyncApi.java
+++ /dev/null
@@ -1,62 +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.openstack.swift.extensions;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import org.jclouds.openstack.filters.AuthenticateRequest;
-import org.jclouds.openstack.swift.Storage;
-import org.jclouds.openstack.swift.functions.ParseTemporaryUrlKeyFromHeaders;
-import org.jclouds.openstack.swift.reference.SwiftHeaders;
-import org.jclouds.rest.annotations.Endpoint;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.MediaType;
-
-/**
- * @see TemporaryUrlKeyApi
- * @see <a href="http://docs.openstack.org/trunk/openstack-object-storage/admin/content/swift-tempurl.html">docs</a>
- */
-@RequestFilters(AuthenticateRequest.class)
-@Endpoint(Storage.class)
-public interface TemporaryUrlKeyAsyncApi {
-
-   /**
-    * @see TemporaryUrlKeyApi#getTemporaryUrlKey
-    */
-   @Named("GetAccountMetadata")
-   @HEAD
-   @Path("/")
-   @Consumes(MediaType.WILDCARD)
-   @ResponseParser(ParseTemporaryUrlKeyFromHeaders.class)
-   ListenableFuture<String> getTemporaryUrlKey();
-
-   /**
-    * @see TemporaryUrlKeyApi#setTemporaryUrlKey
-    */
-   @Named("UpdateAccountMetadata")
-   @POST
-   @Path("/")
-   ListenableFuture<Void> setTemporaryUrlKey(@HeaderParam(SwiftHeaders.ACCOUNT_TEMPORARY_URL_KEY) String key);
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/bbad831c/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java
index 796eb48..d021eb5 100644
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java
+++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java
@@ -34,7 +34,7 @@ import org.jclouds.openstack.reference.AuthHeaders;
 import org.jclouds.openstack.swift.blobstore.SwiftBlobSigner;
 import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule;
 import org.jclouds.openstack.swift.blobstore.config.TemporaryUrlExtensionModule;
-import org.jclouds.openstack.swift.config.SwiftRestClientModule;
+import org.jclouds.openstack.swift.config.SwiftHttpApiModule;
 import org.jclouds.rest.internal.BaseAsyncClientTest;
 import org.testng.annotations.Test;
 
@@ -50,7 +50,7 @@ import com.google.inject.TypeLiteral;
  */
 // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
 @Test(groups = "unit", testName = "CommonSwiftClientTest")
-public abstract class CommonSwiftClientTest extends BaseAsyncClientTest<SwiftAsyncClient> {
+public abstract class CommonSwiftClientTest extends BaseAsyncClientTest<SwiftClient> {
 
    public static final long UNIX_EPOCH_TIMESTAMP = 123456789L;
    public static final String TEMPORARY_URL_KEY = "get-or-set-X-Account-Meta-Temp-Url-Key";
@@ -70,7 +70,7 @@ public abstract class CommonSwiftClientTest extends BaseAsyncClientTest<SwiftAsy
       }
    }
 
-   public static class StaticTimeAndTemporaryUrlKeyModule extends TemporaryUrlExtensionModule<SwiftAsyncClient> {
+   public static class StaticTimeAndTemporaryUrlKeyModule extends TemporaryUrlExtensionModule<SwiftClient> {
       @Override
       protected Long unixEpochTimestampProvider() {
          return UNIX_EPOCH_TIMESTAMP;
@@ -85,7 +85,7 @@ public abstract class CommonSwiftClientTest extends BaseAsyncClientTest<SwiftAsy
 
       @Override
       protected void bindRequestSigner() {
-         bind(BlobRequestSigner.class).to(new TypeLiteral<SwiftBlobSigner<SwiftAsyncClient>>() {
+         bind(BlobRequestSigner.class).to(new TypeLiteral<SwiftBlobSigner<SwiftClient>>() {
          });
       }
    }
@@ -95,7 +95,7 @@ public abstract class CommonSwiftClientTest extends BaseAsyncClientTest<SwiftAsy
       return new SwiftApiMetadata().toBuilder()
                                    .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
                                          .add(StorageEndpointModule.class)
-                                         .add(SwiftRestClientModule.class)
+                                         .add(SwiftHttpApiModule.class)
                                          .add(SwiftBlobStoreContextModule.class)
                                          .add(StaticTimeAndTemporaryUrlKeyModule.class).build()).build();
    }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/bbad831c/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java
index bed0859..ef4bafc 100644
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java
+++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java
@@ -27,7 +27,6 @@ public class SwiftClientLiveTest extends CommonSwiftClientLiveTest<CommonSwiftCl
    
    @Override
    public CommonSwiftClient getApi() {
-      return view.unwrap(SwiftApiMetadata.CONTEXT_TOKEN).getApi();
+      return view.unwrapApi(CommonSwiftClient.class);
    }
-
 }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/bbad831c/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftKeystoneClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftKeystoneClientLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftKeystoneClientLiveTest.java
index 58128dc..9ae96e4 100644
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftKeystoneClientLiveTest.java
+++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftKeystoneClientLiveTest.java
@@ -27,6 +27,6 @@ public class SwiftKeystoneClientLiveTest extends CommonSwiftClientLiveTest<Commo
    
    @Override
    public CommonSwiftClient getApi() {
-      return view.unwrap(SwiftKeystoneApiMetadata.CONTEXT_TOKEN).getApi();
+      return view.unwrapApi(CommonSwiftClient.class);
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/bbad831c/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSignerExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSignerExpectTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSignerExpectTest.java
index 32d66a5..85c9b6b 100644
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSignerExpectTest.java
+++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSignerExpectTest.java
@@ -30,7 +30,7 @@ import org.jclouds.openstack.swift.CommonSwiftClientTest.StorageEndpointModule;
 import org.jclouds.openstack.swift.SwiftApiMetadata;
 import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule;
 import org.jclouds.openstack.swift.blobstore.config.TemporaryUrlExtensionModule.SwiftTemporaryUrlExtensionModule;
-import org.jclouds.openstack.swift.config.SwiftRestClientModule;
+import org.jclouds.openstack.swift.config.SwiftHttpApiModule;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableMap;
@@ -139,7 +139,7 @@ public class SwiftBlobSignerExpectTest extends BaseBlobSignerExpectTest {
             .defaultModules(
                   ImmutableSet.<Class<? extends Module>> builder()
                         .add(StorageEndpointModule.class)
-                        .add(SwiftRestClientModule.class)
+                        .add(SwiftHttpApiModule.class)
                         .add(SwiftBlobStoreContextModule.class)
                         .add(StaticTimeAndTemporaryUrlKeyModule.class).build()).build();
    }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/bbad831c/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftKeystoneBlobSignerExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftKeystoneBlobSignerExpectTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftKeystoneBlobSignerExpectTest.java
index af087b4..5e761ba 100644
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftKeystoneBlobSignerExpectTest.java
+++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftKeystoneBlobSignerExpectTest.java
@@ -26,13 +26,13 @@ import org.jclouds.apis.ApiMetadata;
 import org.jclouds.blobstore.internal.BaseBlobSignerExpectTest;
 import org.jclouds.http.HttpRequest;
 import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule;
 import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
-import org.jclouds.openstack.keystone.v2_0.config.MappedAuthenticationApiModule;
 import org.jclouds.openstack.swift.SwiftKeystoneApiMetadata;
 import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule;
 import org.jclouds.openstack.swift.blobstore.config.TemporaryUrlExtensionModule.SwiftKeystoneTemporaryUrlExtensionModule;
-import org.jclouds.openstack.swift.config.SwiftKeystoneRestClientModule;
-import org.jclouds.openstack.swift.config.SwiftRestClientModule.KeystoneStorageEndpointModule;
+import org.jclouds.openstack.swift.config.SwiftHttpApiModule.KeystoneStorageEndpointModule;
+import org.jclouds.openstack.swift.config.SwiftKeystoneHttpApiModule;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableMap;
@@ -139,10 +139,10 @@ public class SwiftKeystoneBlobSignerExpectTest extends BaseBlobSignerExpectTest
    protected ApiMetadata createApiMetadata() {
       return new SwiftKeystoneApiMetadata().toBuilder()
                                    .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
-                                         .add(MappedAuthenticationApiModule.class)
+                                         .add(AuthenticationApiModule.class)
                                          .add(KeystoneStorageEndpointModule.class)
                                          .add(KeystoneAuthenticationModule.RegionModule.class)
-                                         .add(SwiftKeystoneRestClientModule.class)
+                                         .add(SwiftKeystoneHttpApiModule.class)
                                          .add(SwiftBlobStoreContextModule.class)
                                          .add(StaticTimeAndTemporaryUrlKeyModule.class).build()).build();
    }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/bbad831c/apis/swift/src/test/java/org/jclouds/openstack/swift/config/KeystoneStorageEndpointModuleTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/config/KeystoneStorageEndpointModuleTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/config/KeystoneStorageEndpointModuleTest.java
index 24e2aa8..3ca670f 100644
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/config/KeystoneStorageEndpointModuleTest.java
+++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/config/KeystoneStorageEndpointModuleTest.java
@@ -32,7 +32,7 @@ import java.util.Map;
 
 import org.jclouds.location.suppliers.RegionIdToURISupplier;
 import org.jclouds.openstack.services.ServiceType;
-import org.jclouds.openstack.swift.config.SwiftRestClientModule.KeystoneStorageEndpointModule;
+import org.jclouds.openstack.swift.config.SwiftHttpApiModule.KeystoneStorageEndpointModule;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 

http://git-wip-us.apache.org/repos/asf/jclouds/blob/bbad831c/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/StubSwiftAsyncClient.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/StubSwiftAsyncClient.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/StubSwiftAsyncClient.java
deleted file mode 100644
index 4c30b84..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/StubSwiftAsyncClient.java
+++ /dev/null
@@ -1,224 +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.openstack.swift.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.util.concurrent.Futures.immediateFuture;
-import static com.google.common.util.concurrent.Futures.transform;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.Constants;
-import org.jclouds.blobstore.LocalAsyncBlobStore;
-import org.jclouds.blobstore.domain.BlobMetadata;
-import org.jclouds.blobstore.domain.PageSet;
-import org.jclouds.blobstore.domain.StorageMetadata;
-import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions;
-import org.jclouds.blobstore.options.ListContainerOptions;
-import org.jclouds.http.options.GetOptions;
-import org.jclouds.lifecycle.Closer;
-import org.jclouds.openstack.swift.CommonSwiftAsyncClient;
-import org.jclouds.openstack.swift.blobstore.functions.BlobToObject;
-import org.jclouds.openstack.swift.blobstore.functions.ListContainerOptionsToBlobStoreListContainerOptions;
-import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlob;
-import org.jclouds.openstack.swift.blobstore.functions.ResourceToObjectInfo;
-import org.jclouds.openstack.swift.blobstore.functions.ResourceToObjectList;
-import org.jclouds.openstack.swift.domain.AccountMetadata;
-import org.jclouds.openstack.swift.domain.ContainerMetadata;
-import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata;
-import org.jclouds.openstack.swift.domain.ObjectInfo;
-import org.jclouds.openstack.swift.domain.SwiftObject;
-import org.jclouds.openstack.swift.options.CreateContainerOptions;
-
-import com.google.common.base.Function;
-import com.google.common.base.Throwables;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-
-/**
- * Implementation of {@link SwiftAsyncClient} which keeps all data in a local Map object.
- */
-@Singleton
-public class StubSwiftAsyncClient implements CommonSwiftAsyncClient {
-   private final HttpGetOptionsListToGetOptions httpGetOptionsConverter;
-   private final LocalAsyncBlobStore blobStore;
-   private final SwiftObject.Factory objectProvider;
-   private final ObjectToBlob object2Blob;
-   private final BlobToObject blob2Object;
-   private final ResourceToObjectInfo blob2ObjectInfo;
-   private final ListContainerOptionsToBlobStoreListContainerOptions container2ContainerListOptions;
-   private final ResourceToObjectList resource2ObjectList;
-   private final ListeningExecutorService userExecutor;
-   private final Closer closer;
-
-   @Inject
-   private StubSwiftAsyncClient(@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
-            LocalAsyncBlobStore blobStore,
-            SwiftObject.Factory objectProvider, HttpGetOptionsListToGetOptions httpGetOptionsConverter,
-            ObjectToBlob object2Blob, BlobToObject blob2Object, ResourceToObjectInfo blob2ObjectInfo,
-            ListContainerOptionsToBlobStoreListContainerOptions container2ContainerListOptions,
-            ResourceToObjectList resource2ContainerList, Closer closer) {
-      this.userExecutor = userExecutor;
-      this.blobStore = blobStore;
-      this.objectProvider = objectProvider;
-      this.httpGetOptionsConverter = httpGetOptionsConverter;
-      this.object2Blob = checkNotNull(object2Blob, "object2Blob");
-      this.blob2Object = checkNotNull(blob2Object, "blob2Object");
-      this.blob2ObjectInfo = checkNotNull(blob2ObjectInfo, "blob2ObjectInfo");
-      this.container2ContainerListOptions = checkNotNull(container2ContainerListOptions,
-               "container2ContainerListOptions");
-      this.resource2ObjectList = checkNotNull(resource2ContainerList, "resource2ContainerList");
-      this.closer = checkNotNull(closer, "closer");
-   }
-
-   public ListenableFuture<Boolean> containerExists(final String container) {
-      return blobStore.containerExists(container);
-   }
-
-   public ListenableFuture<Boolean> createContainer(String container) {
-      return blobStore.createContainerInLocation(null, container);
-   }
-
-   public ListenableFuture<Boolean> deleteContainerIfEmpty(String container) {
-      return blobStore.deleteContainerIfEmpty(container);
-   }
-
-   public ListenableFuture<Boolean> disableCDN(String container) {
-      throw new UnsupportedOperationException();
-   }
-
-   public ListenableFuture<URI> enableCDN(String container, long ttl) {
-      throw new UnsupportedOperationException();
-   }
-
-   public ListenableFuture<URI> enableCDN(String container) {
-      throw new UnsupportedOperationException();
-   }
-
-   public ListenableFuture<AccountMetadata> getAccountStatistics() {
-      throw new UnsupportedOperationException();
-   }
-
-   public ListenableFuture<SwiftObject> getObject(String container, String key, GetOptions... options) {
-      org.jclouds.blobstore.options.GetOptions getOptions = httpGetOptionsConverter.apply(options);
-      return transform(blobStore.getBlob(container, key, getOptions), blob2Object, userExecutor);
-   }
-
-   public ListenableFuture<MutableObjectInfoWithMetadata> getObjectInfo(String container, String key) {
-      return transform(blobStore.blobMetadata(container, key),
-               new Function<BlobMetadata, MutableObjectInfoWithMetadata>() {
-
-                  @Override
-                  public MutableObjectInfoWithMetadata apply(BlobMetadata from) {
-
-                     return blob2ObjectInfo.apply(from);
-                  }
-
-               }, userExecutor);
-   }
-
-   public ListenableFuture<? extends Set<ContainerMetadata>> listContainers(
-            org.jclouds.openstack.swift.options.ListContainerOptions... options) {
-      PageSet<? extends StorageMetadata> listing;
-      try {
-         listing = blobStore.list().get();
-      } catch (ExecutionException ee) {
-         throw Throwables.propagate(ee);
-      } catch (InterruptedException ie) {
-         throw Throwables.propagate(ie);
-      }
-      return immediateFuture(Sets.newHashSet(Iterables.transform(listing,
-               new Function<StorageMetadata, ContainerMetadata>() {
-                  public ContainerMetadata apply(StorageMetadata md) {
-                     return ContainerMetadata.builder().name(md.getName()).count(-1).bytes(-1).metadata(new HashMap<String, String>()).build();
-                  }
-               })));
-   }
-
-   @Override
-   public ListenableFuture<ContainerMetadata> getContainerMetadata(String container) {
-      throw new UnsupportedOperationException();
-   }
-
-   public ListenableFuture<Boolean> setContainerMetadata(String container, Map<String, String> containerMetadata) {
-      throw new UnsupportedOperationException();
-   }
-
-   public ListenableFuture<Boolean> deleteContainerMetadata(String container, Iterable<String> metadataKeys) {
-      throw new UnsupportedOperationException();
-   }
-
-   public ListenableFuture<Boolean> createContainer(String container, CreateContainerOptions... options) {
-      throw new UnsupportedOperationException();
-   }
-
-   public ListenableFuture<PageSet<ObjectInfo>> listObjects(String container,
-            org.jclouds.openstack.swift.options.ListContainerOptions... optionsList) {
-      ListContainerOptions options = container2ContainerListOptions.apply(optionsList);
-      return transform(blobStore.list(container, options), resource2ObjectList, userExecutor);
-   }
-
-   public ListenableFuture<Boolean> copyObject(String sourceContainer, String sourceObject, String destinationContainer, String destinationObject) {
-      throw new UnsupportedOperationException();
-   }
-
-   public ListenableFuture<String> putObject(String container, SwiftObject object) {
-      return blobStore.putBlob(container, object2Blob.apply(object));
-   }
-
-   public ListenableFuture<Void> removeObject(String container, String key) {
-      return blobStore.removeBlob(container, key);
-   }
-
-    @Override
-    public ListenableFuture<String> putObjectManifest(String container, String name) {
-        return null;
-    }
-
-   public ListenableFuture<Boolean> setObjectInfo(String container, String key, Map<String, String> userMetadata) {
-      throw new UnsupportedOperationException();
-   }
-
-   public ListenableFuture<URI> updateCDN(String container, long ttl) {
-      throw new UnsupportedOperationException();
-   }
-
-   public SwiftObject newSwiftObject() {
-      return objectProvider.create(null);
-   }
-
-   @Override
-   public ListenableFuture<Boolean> objectExists(String bucketName, String key) {
-      return blobStore.blobExists(bucketName, key);
-   }
-
-   @Override
-   public void close() throws IOException {
-      closer.close();
-   }
-}