diff --git a/common/rackspace/src/main/java/org/jclouds/rackspace/CloudFilesCDN.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CDNManagement.java similarity index 95% rename from common/rackspace/src/main/java/org/jclouds/rackspace/CloudFilesCDN.java rename to apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CDNManagement.java index eba00cd34f..80adc689bb 100755 --- a/common/rackspace/src/main/java/org/jclouds/rackspace/CloudFilesCDN.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CDNManagement.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.rackspace; +package org.jclouds.cloudfiles; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -36,6 +36,6 @@ import javax.inject.Qualifier; @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @Qualifier -public @interface CloudFilesCDN { +public @interface CDNManagement { } \ No newline at end of file diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java index 9a265f5903..d07a0e2b02 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java @@ -20,12 +20,10 @@ package org.jclouds.cloudfiles; import java.net.URI; -import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutionException; 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; @@ -35,45 +33,22 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.MediaType; -import org.jclouds.blobstore.binders.BindMapToHeadersWithPrefix; -import org.jclouds.blobstore.domain.PageSet; -import org.jclouds.blobstore.functions.ReturnFalseOnContainerNotFound; -import org.jclouds.blobstore.functions.ReturnFalseOnKeyNotFound; -import org.jclouds.blobstore.functions.ReturnNullOnKeyNotFound; import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404; -import org.jclouds.http.functions.ParseETagHeader; -import org.jclouds.http.options.GetOptions; -import org.jclouds.rackspace.CloudFiles; -import org.jclouds.rackspace.CloudFilesCDN; -import org.jclouds.cloudfiles.binders.BindCFObjectMetadataToRequest; -import org.jclouds.cloudfiles.domain.AccountMetadata; -import org.jclouds.cloudfiles.domain.CFObject; import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; -import org.jclouds.cloudfiles.domain.ContainerMetadata; -import org.jclouds.cloudfiles.domain.MutableObjectInfoWithMetadata; -import org.jclouds.cloudfiles.domain.ObjectInfo; -import org.jclouds.cloudfiles.functions.ObjectName; -import org.jclouds.cloudfiles.functions.ParseAccountMetadataResponseFromHeaders; import org.jclouds.cloudfiles.functions.ParseCdnUriFromHeaders; -import org.jclouds.cloudfiles.functions.ParseContainerCDNMetadataFromHeaders; -import org.jclouds.cloudfiles.functions.ParseObjectFromHeadersAndHttpContent; -import org.jclouds.cloudfiles.functions.ParseObjectInfoFromHeaders; -import org.jclouds.cloudfiles.functions.ParseObjectInfoListFromJsonResponse; -import org.jclouds.cloudfiles.functions.ReturnTrueOn404FalseOn409; import org.jclouds.cloudfiles.options.ListCdnContainerOptions; -import org.jclouds.cloudfiles.options.ListContainerOptions; import org.jclouds.cloudfiles.reference.CloudFilesHeaders; -import org.jclouds.rackspace.filters.AuthenticateRequest; -import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.swift.CommonSwiftAsyncClient; +import org.jclouds.openstack.swift.Storage; +import org.jclouds.openstack.swift.functions.ParseContainerCDNMetadataFromHeaders; import org.jclouds.rest.annotations.Endpoint; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.ParamParser; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -90,35 +65,8 @@ import com.google.common.util.concurrent.ListenableFuture; */ @SkipEncoding('/') @RequestFilters(AuthenticateRequest.class) -@Endpoint(CloudFiles.class) -public interface CloudFilesAsyncClient { - - CFObject newCFObject(); - - /** - * @see CloudFilesClient#getAccountStatistics - */ - @HEAD - @ResponseParser(ParseAccountMetadataResponseFromHeaders.class) - @Path("/") - ListenableFuture getAccountStatistics(); - - /** - * @see CloudFilesClient#listContainers - */ - @GET - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/") - ListenableFuture> listContainers(ListContainerOptions... options); - - /** - * @see CloudFilesClient#setObjectInfo - */ - @POST - @Path("/{container}/{name}") - ListenableFuture setObjectInfo(@PathParam("container") String container, @PathParam("name") String name, - @BinderParam(BindMapToHeadersWithPrefix.class) Map userMetadata); +@Endpoint(Storage.class) +public interface CloudFilesAsyncClient extends CommonSwiftAsyncClient { /** * @see CloudFilesClient#listCDNContainers @@ -127,7 +75,7 @@ public interface CloudFilesAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "format", values = "json") @Path("/") - @Endpoint(CloudFilesCDN.class) + @Endpoint(CDNManagement.class) ListenableFuture> listCDNContainers(ListCdnContainerOptions... options); // TODO: Container name is not included in CDN HEAD response headers, so we @@ -140,7 +88,7 @@ public interface CloudFilesAsyncClient { @ResponseParser(ParseContainerCDNMetadataFromHeaders.class) @ExceptionParser(ThrowContainerNotFoundOn404.class) @Path("/{container}") - @Endpoint(CloudFilesCDN.class) + @Endpoint(CDNManagement.class) ListenableFuture getCDNMetadata(@PathParam("container") String container); /** @@ -150,7 +98,7 @@ public interface CloudFilesAsyncClient { @Path("/{container}") @Headers(keys = CloudFilesHeaders.CDN_ENABLED, values = "True") @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CloudFilesCDN.class) + @Endpoint(CDNManagement.class) ListenableFuture enableCDN(@PathParam("container") String container, @HeaderParam(CloudFilesHeaders.CDN_TTL) long ttl); @@ -161,7 +109,7 @@ public interface CloudFilesAsyncClient { @Path("/{container}") @Headers(keys = CloudFilesHeaders.CDN_ENABLED, values = "True") @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CloudFilesCDN.class) + @Endpoint(CDNManagement.class) ListenableFuture enableCDN(@PathParam("container") String container); /** @@ -170,7 +118,7 @@ public interface CloudFilesAsyncClient { @POST @Path("/{container}") @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CloudFilesCDN.class) + @Endpoint(CDNManagement.class) ListenableFuture updateCDN(@PathParam("container") String container, @HeaderParam(CloudFilesHeaders.CDN_TTL) long ttl); @@ -180,86 +128,7 @@ public interface CloudFilesAsyncClient { @POST @Path("/{container}") @Headers(keys = CloudFilesHeaders.CDN_ENABLED, values = "False") - @Endpoint(CloudFilesCDN.class) + @Endpoint(CDNManagement.class) ListenableFuture disableCDN(@PathParam("container") String container); - /** - * @see CloudFilesClient#createContainer - */ - @PUT - @Path("/{container}") - ListenableFuture createContainer(@PathParam("container") String container); - - /** - * @see CloudFilesClient#deleteContainerIfEmpty - */ - @DELETE - @ExceptionParser(ReturnTrueOn404FalseOn409.class) - @Path("/{container}") - ListenableFuture deleteContainerIfEmpty(@PathParam("container") String container); - - /** - * @see CloudFilesClient#listObjects - */ - @GET - @QueryParams(keys = "format", values = "json") - @ResponseParser(ParseObjectInfoListFromJsonResponse.class) - @Path("/{container}") - ListenableFuture> listObjects(@PathParam("container") String container, - ListContainerOptions... options); - - /** - * @see CloudFilesClient#containerExists - */ - @HEAD - @Path("/{container}") - @ExceptionParser(ReturnFalseOnContainerNotFound.class) - ListenableFuture containerExists(@PathParam("container") String container); - - /** - * @see CloudFilesClient#putObject - */ - @PUT - @Path("/{container}/{name}") - @ResponseParser(ParseETagHeader.class) - ListenableFuture putObject( - @PathParam("container") String container, - @PathParam("name") @ParamParser(ObjectName.class) @BinderParam(BindCFObjectMetadataToRequest.class) CFObject object); - - /** - * @see CloudFilesClient#getObject - */ - @GET - @ResponseParser(ParseObjectFromHeadersAndHttpContent.class) - @ExceptionParser(ReturnNullOnKeyNotFound.class) - @Path("/{container}/{name}") - ListenableFuture getObject(@PathParam("container") String container, @PathParam("name") String name, - GetOptions... options); - - /** - * @see CloudFilesClient#getObjectInfo - */ - @HEAD - @ResponseParser(ParseObjectInfoFromHeaders.class) - @ExceptionParser(ReturnNullOnKeyNotFound.class) - @Path("/{container}/{name}") - ListenableFuture getObjectInfo(@PathParam("container") String container, - @PathParam("name") String name); - - /** - * @see CloudFilesClient#objectExists - */ - @HEAD - @ExceptionParser(ReturnFalseOnKeyNotFound.class) - @Path("/{container}/{name}") - ListenableFuture objectExists(@PathParam("container") String container, @PathParam("name") String name); - - /** - * @see CloudFilesClient#removeObject - */ - @DELETE - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) - @Path("/{container}/{name}") - ListenableFuture removeObject(@PathParam("container") String container, @PathParam("name") String name); - } 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 bc2aea5d7b..e9b7355615 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesClient.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesClient.java @@ -20,84 +20,27 @@ package org.jclouds.cloudfiles; import java.net.URI; -import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; -import org.jclouds.blobstore.ContainerNotFoundException; -import org.jclouds.blobstore.domain.PageSet; -import org.jclouds.concurrent.Timeout; -import org.jclouds.http.options.GetOptions; -import org.jclouds.cloudfiles.domain.AccountMetadata; -import org.jclouds.cloudfiles.domain.CFObject; import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; -import org.jclouds.cloudfiles.domain.ContainerMetadata; -import org.jclouds.cloudfiles.domain.MutableObjectInfoWithMetadata; -import org.jclouds.cloudfiles.domain.ObjectInfo; import org.jclouds.cloudfiles.options.ListCdnContainerOptions; -import org.jclouds.cloudfiles.options.ListContainerOptions; - -import java.util.concurrent.Future; +import org.jclouds.concurrent.Timeout; +import org.jclouds.openstack.swift.CommonSwiftClient; /** * Provides access to Cloud Files via their REST API. *

- * All commands return a Future of the result from Cloud Files. Any exceptions incurred - * during processing will be wrapped in an {@link ExecutionException} as documented in - * {@link Future#get()}. + * All commands return a Future of the result from Cloud Files. Any exceptions incurred during + * processing will be wrapped in an {@link ExecutionException} as documented in {@link Future#get()}. * * @see * @author Adrian Cole */ @Timeout(duration = 120, timeUnit = TimeUnit.SECONDS) -public interface CloudFilesClient { - - CFObject newCFObject(); - - /** - * HEAD operations against an identity are performed to retrieve the number of Containers and the - * total bytes stored in Cloud Files for the identity. - *

- * Determine the number of Containers within the identity and the total bytes stored. Since the - * storage system is designed to store large amounts of data, care should be taken when - * representing the total bytes response as an integer; when possible, convert it to a 64-bit - * unsigned integer if your platform supports that primitive flavor. - */ - AccountMetadata getAccountStatistics(); - - /** - * GET operations against the X-Storage-Url for an identity are performed to retrieve a list of - * existing storage - *

- * Containers ordered by name. The following list describes the optional query parameters that - * are supported with this request. - *

- *

- * At this time, a prex query parameter is not supported at the Account level. - * - *

Large Container Lists

- * The system will return a maximum of 10,000 Container names per request. To retrieve subsequent - * container names, another request must be made with a marker parameter. The marker indicates - * where the last list left off and the system will return container names greater than this - * marker, up to 10,000 again. Note that the marker value should be URL encoded prior to sending - * the HTTP request. - *

- * If 10,000 is larger than desired, a limit parameter may be given. - *

- * If the number of container names returned equals the limit given (or 10,000 if no limit is - * given), it can be assumed there are more container names to be listed. If the container name - * list is exactly divisible by the limit, the last request will simply have no content. - */ - Set listContainers(ListContainerOptions... options); - - boolean setObjectInfo(String container, String name, Map userMetadata); - +public interface CloudFilesClient extends CommonSwiftClient { Set listCDNContainers(ListCdnContainerOptions... options); ContainerCDNMetadata getCDNMetadata(String container); @@ -110,28 +53,4 @@ public interface CloudFilesClient { boolean disableCDN(String container); - boolean createContainer(String container); - - boolean deleteContainerIfEmpty(String container); - - PageSet listObjects(String container, ListContainerOptions... options); - - boolean containerExists(String container); - - @Timeout(duration = 5 * 1024 * 1024 / 128, timeUnit = TimeUnit.SECONDS) - String putObject(String container, CFObject object); - - @Timeout(duration = 5 * 1024 * 1024 / 512, timeUnit = TimeUnit.SECONDS) - CFObject getObject(String container, String name, GetOptions... options); - - MutableObjectInfoWithMetadata getObjectInfo(String container, String name); - - void removeObject(String container, String name); - - /** - * @throws ContainerNotFoundException - * if the container is not present. - */ - boolean objectExists(String container, String name); - } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java index 502f6f08ea..8603f8258d 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java @@ -25,7 +25,7 @@ import java.util.Properties; import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule; +import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule; import org.jclouds.cloudfiles.config.CloudFilesRestClientModule; import com.google.inject.Injector; @@ -53,7 +53,7 @@ public class CloudFilesContextBuilder extends @Override protected void addContextModule(List modules) { - modules.add(new CloudFilesBlobStoreContextModule()); + modules.add(new SwiftBlobStoreContextModule()); } @Override diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesPropertiesBuilder.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesPropertiesBuilder.java index bf1484ef77..26dbd2dc9b 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesPropertiesBuilder.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesPropertiesBuilder.java @@ -19,22 +19,27 @@ package org.jclouds.cloudfiles; -import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; +import static org.jclouds.Constants.PROPERTY_API_VERSION; +import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; -import org.jclouds.rackspace.RackspacePropertiesBuilder; +import org.jclouds.openstack.OpenStackAuthAsyncClient; +import org.jclouds.openstack.swift.SwiftPropertiesBuilder; /** * Builds properties used in CloudFiles Connections * * @author Adrian Cole */ -public class CloudFilesPropertiesBuilder extends RackspacePropertiesBuilder { +public class CloudFilesPropertiesBuilder extends SwiftPropertiesBuilder { @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-"); + properties.setProperty(PROPERTY_REGIONS, "US"); + properties.setProperty(PROPERTY_ENDPOINT, "https://auth.api.rackspacecloud.com"); + properties.setProperty(PROPERTY_API_VERSION, OpenStackAuthAsyncClient.VERSION); return properties; } @@ -42,8 +47,4 @@ public class CloudFilesPropertiesBuilder extends RackspacePropertiesBuilder { super(properties); } - protected CloudFilesPropertiesBuilder withMetaPrefix(String prefix) { - properties.setProperty(PROPERTY_USER_METADATA_PREFIX, prefix); - return this; - } } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java index d1649786f2..b8799df67f 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java @@ -19,19 +19,22 @@ package org.jclouds.cloudfiles.config; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; +import java.net.URI; + +import javax.inject.Singleton; + +import org.jclouds.cloudfiles.CDNManagement; import org.jclouds.cloudfiles.CloudFilesAsyncClient; import org.jclouds.cloudfiles.CloudFilesClient; -import org.jclouds.cloudfiles.handlers.ParseCloudFilesErrorFromHttpResponse; -import org.jclouds.rackspace.config.RackspaceAuthenticationRestModule; +import org.jclouds.http.RequiresHttp; +import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse; +import org.jclouds.openstack.reference.AuthHeaders; +import org.jclouds.openstack.swift.CommonSwiftAsyncClient; +import org.jclouds.openstack.swift.CommonSwiftClient; +import org.jclouds.openstack.swift.config.BaseSwiftRestClientModule; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; -import com.google.inject.Module; +import com.google.inject.Provides; /** * @@ -39,33 +42,28 @@ import com.google.inject.Module; */ @ConfiguresRestClient @RequiresHttp -public class CloudFilesRestClientModule extends - RestClientModule { - private Module authModule; +public class CloudFilesRestClientModule extends BaseSwiftRestClientModule { public CloudFilesRestClientModule() { - this(new RackspaceAuthenticationRestModule()); - } - - public CloudFilesRestClientModule(Module authModule) { super(CloudFilesClient.class, CloudFilesAsyncClient.class); - this.authModule = authModule; } - @Override - protected void configure() { - install(authModule); - install(new CFObjectModule()); - super.configure(); + @Provides + @Singleton + CommonSwiftClient provideCommonSwiftClient(CloudFilesClient in) { + return in; } - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to( - ParseCloudFilesErrorFromHttpResponse.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to( - ParseCloudFilesErrorFromHttpResponse.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to( - ParseCloudFilesErrorFromHttpResponse.class); + @Provides + @Singleton + CommonSwiftAsyncClient provideCommonSwiftClient(CloudFilesAsyncClient in) { + return in; + } + + @Provides + @Singleton + @CDNManagement + protected URI provideCDNUrl(AuthenticationResponse response) { + return response.getServices().get(AuthHeaders.CDN_MANAGEMENT_URL); } } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseCdnUriFromHeaders.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseCdnUriFromHeaders.java index c16b71dd41..4575885bcf 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseCdnUriFromHeaders.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseCdnUriFromHeaders.java @@ -24,7 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import org.jclouds.http.HttpResponse; -import org.jclouds.cloudfiles.domain.AccountMetadata; +import org.jclouds.openstack.swift.domain.AccountMetadata; import org.jclouds.cloudfiles.reference.CloudFilesHeaders; import com.google.common.base.Function; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/CloudFilesHeaders.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/CloudFilesHeaders.java index 451f55033b..9bbb17fb37 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/CloudFilesHeaders.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/CloudFilesHeaders.java @@ -19,6 +19,8 @@ package org.jclouds.cloudfiles.reference; +import org.jclouds.openstack.swift.reference.SwiftHeaders; + /** * Additional headers specified by Rackspace Cloud Files REST API. @@ -27,16 +29,11 @@ package org.jclouds.cloudfiles.reference; * @author Adrian Cole * */ -public interface CloudFilesHeaders { +public interface CloudFilesHeaders extends SwiftHeaders { - public static final String ACCOUNT_BYTES_USED = "X-Account-Bytes-Used"; - public static final String ACCOUNT_CONTAINER_COUNT = "X-Account-Container-Count"; public static final String CDN_ENABLED = "X-CDN-Enabled"; public static final String CDN_REFERRER_ACL = "X-Referrer-ACL "; public static final String CDN_TTL = "X-TTL"; public static final String CDN_URI = "X-CDN-URI"; public static final String CDN_USER_AGENT_ACL = "X-User-Agent-ACL"; - public static final String CONTAINER_BYTES_USED = "X-Container-Bytes-Used"; - public static final String CONTAINER_OBJECT_COUNT = "X-Container-Object-Count"; - public static final String USER_METADATA_PREFIX = "X-Object-Meta-"; } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/CommonSwiftAsyncClient.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/CommonSwiftAsyncClient.java new file mode 100644 index 0000000000..48f00dfe34 --- /dev/null +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/CommonSwiftAsyncClient.java @@ -0,0 +1,191 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutionException; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +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.binders.BindMapToHeadersWithPrefix; +import org.jclouds.blobstore.domain.PageSet; +import org.jclouds.blobstore.functions.ReturnFalseOnContainerNotFound; +import org.jclouds.blobstore.functions.ReturnFalseOnKeyNotFound; +import org.jclouds.blobstore.functions.ReturnNullOnKeyNotFound; +import org.jclouds.http.functions.ParseETagHeader; +import org.jclouds.http.options.GetOptions; +import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.swift.binders.BindSwiftObjectMetadataToRequest; +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.functions.ObjectName; +import org.jclouds.openstack.swift.functions.ParseAccountMetadataResponseFromHeaders; +import org.jclouds.openstack.swift.functions.ParseObjectFromHeadersAndHttpContent; +import org.jclouds.openstack.swift.functions.ParseObjectInfoFromHeaders; +import org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse; +import org.jclouds.openstack.swift.functions.ReturnTrueOn404FalseOn409; +import org.jclouds.openstack.swift.options.ListContainerOptions; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Endpoint; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.ParamParser; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; + +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 wrapped in an {@link ExecutionException} as documented in + * {@link ListenableFuture#get()}. + * + * @see CommonSwiftClient + * @see + * @author Adrian Cole + */ +@SkipEncoding('/') +@RequestFilters(AuthenticateRequest.class) +@Endpoint(Storage.class) +public interface CommonSwiftAsyncClient { + + SwiftObject newSwiftObject(); + + /** + * @see CommonSwiftClient#getAccountStatistics + */ + @HEAD + @ResponseParser(ParseAccountMetadataResponseFromHeaders.class) + @Path("/") + ListenableFuture getAccountStatistics(); + + /** + * @see CommonSwiftClient#listContainers + */ + @GET + @Consumes(MediaType.APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/") + ListenableFuture> listContainers(ListContainerOptions... options); + + /** + * @see CommonSwiftClient#setObjectInfo + */ + @POST + @Path("/{container}/{name}") + ListenableFuture setObjectInfo(@PathParam("container") String container, @PathParam("name") String name, + @BinderParam(BindMapToHeadersWithPrefix.class) Map userMetadata); + + /** + * @see CommonSwiftClient#createContainer + */ + @PUT + @Path("/{container}") + ListenableFuture createContainer(@PathParam("container") String container); + + /** + * @see CommonSwiftClient#deleteContainerIfEmpty + */ + @DELETE + @ExceptionParser(ReturnTrueOn404FalseOn409.class) + @Path("/{container}") + ListenableFuture deleteContainerIfEmpty(@PathParam("container") String container); + + /** + * @see CommonSwiftClient#listObjects + */ + @GET + @QueryParams(keys = "format", values = "json") + @ResponseParser(ParseObjectInfoListFromJsonResponse.class) + @Path("/{container}") + ListenableFuture> listObjects(@PathParam("container") String container, + ListContainerOptions... options); + + /** + * @see CommonSwiftClient#containerExists + */ + @HEAD + @Path("/{container}") + @ExceptionParser(ReturnFalseOnContainerNotFound.class) + ListenableFuture containerExists(@PathParam("container") String container); + + /** + * @see CommonSwiftClient#putObject + */ + @PUT + @Path("/{container}/{name}") + @ResponseParser(ParseETagHeader.class) + ListenableFuture putObject( + @PathParam("container") String container, + @PathParam("name") @ParamParser(ObjectName.class) @BinderParam(BindSwiftObjectMetadataToRequest.class) SwiftObject object); + + /** + * @see CommonSwiftClient#getObject + */ + @GET + @ResponseParser(ParseObjectFromHeadersAndHttpContent.class) + @ExceptionParser(ReturnNullOnKeyNotFound.class) + @Path("/{container}/{name}") + ListenableFuture getObject(@PathParam("container") String container, @PathParam("name") String name, + GetOptions... options); + + /** + * @see CommonSwiftClient#getObjectInfo + */ + @HEAD + @ResponseParser(ParseObjectInfoFromHeaders.class) + @ExceptionParser(ReturnNullOnKeyNotFound.class) + @Path("/{container}/{name}") + ListenableFuture getObjectInfo(@PathParam("container") String container, + @PathParam("name") String name); + + /** + * @see CommonSwiftClient#objectExists + */ + @HEAD + @ExceptionParser(ReturnFalseOnKeyNotFound.class) + @Path("/{container}/{name}") + ListenableFuture objectExists(@PathParam("container") String container, @PathParam("name") String name); + + /** + * @see CommonSwiftClient#removeObject + */ + @DELETE + @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @Path("/{container}/{name}") + ListenableFuture removeObject(@PathParam("container") String container, @PathParam("name") String name); + +} diff --git a/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/CommonSwiftClient.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/CommonSwiftClient.java new file mode 100644 index 0000000000..d49fb08e91 --- /dev/null +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/CommonSwiftClient.java @@ -0,0 +1,121 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; + +import org.jclouds.blobstore.ContainerNotFoundException; +import org.jclouds.blobstore.domain.PageSet; +import org.jclouds.concurrent.Timeout; +import org.jclouds.http.options.GetOptions; +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.ListContainerOptions; + +/** + * Provides access to Cloud Files via their REST API. + *

+ * All commands return a Future of the result from Cloud Files. Any exceptions incurred + * during processing will be wrapped in an {@link ExecutionException} as documented in + * {@link Future#get()}. + * + * @see + * @author Adrian Cole + */ +@Timeout(duration = 120, timeUnit = TimeUnit.SECONDS) +public interface CommonSwiftClient { + + SwiftObject newSwiftObject(); + + /** + * HEAD operations against an identity are performed to retrieve the number of Containers and the + * total bytes stored in Cloud Files for the identity. + *

+ * Determine the number of Containers within the identity and the total bytes stored. Since the + * storage system is designed to store large amounts of data, care should be taken when + * representing the total bytes response as an integer; when possible, convert it to a 64-bit + * unsigned integer if your platform supports that primitive flavor. + */ + AccountMetadata getAccountStatistics(); + + /** + * GET operations against the X-Storage-Url for an identity are performed to retrieve a list of + * existing storage + *

+ * Containers ordered by name. The following list describes the optional query parameters that + * are supported with this request. + *

+ *

+ * At this time, a prex query parameter is not supported at the Account level. + * + *

Large Container Lists

+ * The system will return a maximum of 10,000 Container names per request. To retrieve subsequent + * container names, another request must be made with a marker parameter. The marker indicates + * where the last list left off and the system will return container names greater than this + * marker, up to 10,000 again. Note that the marker value should be URL encoded prior to sending + * the HTTP request. + *

+ * If 10,000 is larger than desired, a limit parameter may be given. + *

+ * If the number of container names returned equals the limit given (or 10,000 if no limit is + * given), it can be assumed there are more container names to be listed. If the container name + * list is exactly divisible by the limit, the last request will simply have no content. + */ + Set listContainers(ListContainerOptions... options); + + boolean setObjectInfo(String container, String name, Map userMetadata); + + boolean createContainer(String container); + + boolean deleteContainerIfEmpty(String container); + + PageSet listObjects(String container, ListContainerOptions... options); + + boolean containerExists(String container); + + @Timeout(duration = 5 * 1024 * 1024 / 128, timeUnit = TimeUnit.SECONDS) + String putObject(String container, SwiftObject object); + + @Timeout(duration = 5 * 1024 * 1024 / 512, timeUnit = TimeUnit.SECONDS) + SwiftObject getObject(String container, String name, GetOptions... options); + + MutableObjectInfoWithMetadata getObjectInfo(String container, String name); + + void removeObject(String container, String name); + + /** + * @throws ContainerNotFoundException + * if the container is not present. + */ + boolean objectExists(String container, String name); + +} diff --git a/common/rackspace/src/main/java/org/jclouds/rackspace/CloudFiles.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/Storage.java similarity index 95% rename from common/rackspace/src/main/java/org/jclouds/rackspace/CloudFiles.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/Storage.java index 7beeda112f..154f651b99 100755 --- a/common/rackspace/src/main/java/org/jclouds/rackspace/CloudFiles.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/Storage.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.rackspace; +package org.jclouds.openstack.swift; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -36,6 +36,6 @@ import javax.inject.Qualifier; @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @Qualifier -public @interface CloudFiles { +public @interface Storage { } \ No newline at end of file diff --git a/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java new file mode 100644 index 0000000000..e5b4abdc13 --- /dev/null +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java @@ -0,0 +1,63 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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; + +import java.util.List; +import java.util.Properties; + +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; +import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule; +import org.jclouds.openstack.swift.config.BaseSwiftRestClientModule; + +import com.google.inject.Injector; +import com.google.inject.Module; + +/** + * Creates {@link CloudFilesBlobStoreContext} or {@link Injector} instances based on the most + * commonly requested arguments. + *

+ * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. + *

+ *

+ * If no Modules are specified, the default {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. + * + * @author Adrian Cole, Andrew Newdigate + * @see CloudFilesBlobStoreContext + */ +public class SwiftContextBuilder extends BlobStoreContextBuilder { + + public SwiftContextBuilder(Properties props) { + super(CommonSwiftClient.class, CommonSwiftAsyncClient.class, props); + } + + @Override + protected void addContextModule(List modules) { + modules.add(new SwiftBlobStoreContextModule()); + } + + @Override + protected void addClientModule(List modules) { + modules.add(new BaseSwiftRestClientModule(CommonSwiftClient.class, + CommonSwiftAsyncClient.class)); + } +} diff --git a/common/rackspace/src/main/java/org/jclouds/rackspace/RackspacePropertiesBuilder.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/SwiftPropertiesBuilder.java similarity index 62% rename from common/rackspace/src/main/java/org/jclouds/rackspace/RackspacePropertiesBuilder.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/SwiftPropertiesBuilder.java index abbcef4017..8ba1ad8576 100644 --- a/common/rackspace/src/main/java/org/jclouds/rackspace/RackspacePropertiesBuilder.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/SwiftPropertiesBuilder.java @@ -17,33 +17,33 @@ * ==================================================================== */ -package org.jclouds.rackspace; +package org.jclouds.openstack.swift; -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; +import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; import java.util.Properties; import org.jclouds.PropertiesBuilder; /** - * Builds properties used in Rackspace Connections + * Builds properties used in CloudFiles Connections * * @author Adrian Cole */ -public class RackspacePropertiesBuilder extends PropertiesBuilder { +public class SwiftPropertiesBuilder extends PropertiesBuilder { @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_REGIONS, "US"); - properties.setProperty(PROPERTY_ENDPOINT, "https://auth.api.rackspacecloud.com"); - properties.setProperty(PROPERTY_API_VERSION, RackspaceAuthAsyncClient.VERSION); + properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-"); return properties; } - public RackspacePropertiesBuilder(Properties properties) { + public SwiftPropertiesBuilder(Properties properties) { super(properties); } + protected SwiftPropertiesBuilder withMetaPrefix(String prefix) { + properties.setProperty(PROPERTY_USER_METADATA_PREFIX, prefix); + return this; + } } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/binders/BindCFObjectMetadataToRequest.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequest.java similarity index 81% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/binders/BindCFObjectMetadataToRequest.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequest.java index c25c5ef770..441e08717a 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/binders/BindCFObjectMetadataToRequest.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequest.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.binders; +package org.jclouds.openstack.swift.binders; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; @@ -29,28 +29,28 @@ import javax.ws.rs.core.MediaType; import org.jclouds.blobstore.binders.BindUserMetadataToHeadersWithPrefix; import org.jclouds.http.HttpRequest; import org.jclouds.http.utils.ModifyRequest; -import org.jclouds.cloudfiles.blobstore.functions.ObjectToBlob; -import org.jclouds.cloudfiles.domain.CFObject; +import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlob; +import org.jclouds.openstack.swift.domain.SwiftObject; import org.jclouds.rest.Binder; @Singleton -public class BindCFObjectMetadataToRequest implements Binder { +public class BindSwiftObjectMetadataToRequest implements Binder { private final BindUserMetadataToHeadersWithPrefix mdBinder; private final ObjectToBlob object2Blob; @Inject - public BindCFObjectMetadataToRequest(ObjectToBlob object2Blob, BindUserMetadataToHeadersWithPrefix mdBinder) { + public BindSwiftObjectMetadataToRequest(ObjectToBlob object2Blob, BindUserMetadataToHeadersWithPrefix mdBinder) { this.mdBinder = mdBinder; this.object2Blob = object2Blob; } @Override public R bindToRequest(R request, Object input) { - checkArgument(checkNotNull(input, "input") instanceof CFObject, "this binder is only valid for CFObject!"); + checkArgument(checkNotNull(input, "input") instanceof SwiftObject, "this binder is only valid for SwiftObject!"); checkNotNull(request, "request"); - CFObject object = (CFObject) input; + SwiftObject object = (SwiftObject) input; if (object.getPayload().getContentMetadata().getContentType() == null) object.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_OCTET_STREAM); diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java similarity index 79% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java index eb13326a92..84eeed2afe 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore; +package org.jclouds.openstack.swift.blobstore; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.blobstore.util.BlobStoreUtils.createParentIfNeededAsync; @@ -46,18 +46,18 @@ import org.jclouds.collect.Memoized; import org.jclouds.concurrent.Futures; import org.jclouds.domain.Location; import org.jclouds.http.options.GetOptions; -import org.jclouds.cloudfiles.CloudFilesAsyncClient; -import org.jclouds.cloudfiles.CloudFilesClient; -import org.jclouds.cloudfiles.blobstore.functions.BlobStoreListContainerOptionsToListContainerOptions; -import org.jclouds.cloudfiles.blobstore.functions.BlobToObject; -import org.jclouds.cloudfiles.blobstore.functions.ContainerToResourceList; -import org.jclouds.cloudfiles.blobstore.functions.ContainerToResourceMetadata; -import org.jclouds.cloudfiles.blobstore.functions.ObjectToBlob; -import org.jclouds.cloudfiles.blobstore.functions.ObjectToBlobMetadata; -import org.jclouds.cloudfiles.domain.CFObject; -import org.jclouds.cloudfiles.domain.ContainerMetadata; -import org.jclouds.cloudfiles.domain.MutableObjectInfoWithMetadata; -import org.jclouds.cloudfiles.domain.ObjectInfo; +import org.jclouds.openstack.swift.CommonSwiftAsyncClient; +import org.jclouds.openstack.swift.CommonSwiftClient; +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.domain.ContainerMetadata; +import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata; +import org.jclouds.openstack.swift.domain.ObjectInfo; +import org.jclouds.openstack.swift.domain.SwiftObject; import com.google.common.base.Function; import com.google.common.base.Supplier; @@ -69,9 +69,9 @@ import com.google.common.util.concurrent.ListenableFuture; * @author Adrian Cole */ @Singleton -public class CloudFilesAsyncBlobStore extends BaseAsyncBlobStore { - private final CloudFilesClient sync; - private final CloudFilesAsyncClient async; +public class SwiftAsyncBlobStore extends BaseAsyncBlobStore { + private final CommonSwiftClient sync; + private final CommonSwiftAsyncClient async; private final ContainerToResourceMetadata container2ResourceMd; private final BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions; private final ContainerToResourceList container2ResourceList; @@ -82,9 +82,9 @@ public class CloudFilesAsyncBlobStore extends BaseAsyncBlobStore { private final Provider fetchBlobMetadataProvider; @Inject - CloudFilesAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, + SwiftAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, - @Memoized Supplier> locations, CloudFilesClient sync, CloudFilesAsyncClient async, + @Memoized Supplier> locations, CommonSwiftClient sync, CommonSwiftAsyncClient async, ContainerToResourceMetadata container2ResourceMd, BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, ContainerToResourceList container2ResourceList, ObjectToBlob object2Blob, BlobToObject blob2Object, @@ -104,7 +104,7 @@ public class CloudFilesAsyncBlobStore extends BaseAsyncBlobStore { } /** - * This implementation invokes {@link CloudFilesAsyncClient#listContainers} + * This implementation invokes {@link CommonSwiftAsyncClient#listContainers} */ @Override public ListenableFuture> list() { @@ -118,7 +118,7 @@ public class CloudFilesAsyncBlobStore extends BaseAsyncBlobStore { } /** - * This implementation invokes {@link CloudFilesAsyncClient#containerExists} + * This implementation invokes {@link CommonSwiftAsyncClient#containerExists} * * @param container * container name @@ -137,14 +137,14 @@ public class CloudFilesAsyncBlobStore extends BaseAsyncBlobStore { } /** - * This implementation invokes {@link CloudFilesAsyncClient#listBucket} + * This implementation invokes {@link CommonSwiftAsyncClient#listBucket} * * @param container * container name */ @Override public ListenableFuture> list(String container, ListContainerOptions options) { - org.jclouds.cloudfiles.options.ListContainerOptions httpOptions = container2ContainerListOptions + org.jclouds.openstack.swift.options.ListContainerOptions httpOptions = container2ContainerListOptions .apply(options); ListenableFuture> returnVal = async.listObjects(container, httpOptions); ListenableFuture> list = Futures.compose(returnVal, container2ResourceList, @@ -154,7 +154,7 @@ public class CloudFilesAsyncBlobStore extends BaseAsyncBlobStore { } /** - * This implementation invokes {@link CloudFilesAsyncClient#objectExists} + * This implementation invokes {@link CommonSwiftAsyncClient#objectExists} * * @param container * container name @@ -167,7 +167,7 @@ public class CloudFilesAsyncBlobStore extends BaseAsyncBlobStore { } /** - * This implementation invokes {@link CloudFilesAsyncClient#headObject} + * This implementation invokes {@link CommonSwiftAsyncClient#headObject} * * @param container * container name @@ -188,7 +188,7 @@ public class CloudFilesAsyncBlobStore extends BaseAsyncBlobStore { } /** - * This implementation invokes {@link CloudFilesAsyncClient#getObject} + * This implementation invokes {@link CommonSwiftAsyncClient#getObject} * * @param container * container name @@ -198,12 +198,12 @@ public class CloudFilesAsyncBlobStore extends BaseAsyncBlobStore { @Override public ListenableFuture getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions options) { GetOptions httpOptions = blob2ObjectGetOptions.apply(options); - ListenableFuture returnVal = async.getObject(container, key, httpOptions); + ListenableFuture returnVal = async.getObject(container, key, httpOptions); return Futures.compose(returnVal, object2Blob, service); } /** - * This implementation invokes {@link CloudFilesAsyncClient#putObject} + * This implementation invokes {@link CommonSwiftAsyncClient#putObject} * * @param container * container name @@ -217,7 +217,7 @@ public class CloudFilesAsyncBlobStore extends BaseAsyncBlobStore { } /** - * This implementation invokes {@link CloudFilesAsyncClient#removeObject} + * This implementation invokes {@link CommonSwiftAsyncClient#removeObject} * * @param container * container name diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobRequestSigner.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobRequestSigner.java similarity index 72% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobRequestSigner.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobRequestSigner.java index eb019c388e..2046f015fd 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobRequestSigner.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobRequestSigner.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore; +package org.jclouds.openstack.swift.blobstore; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.blobstore.util.BlobStoreUtils.cleanRequest; @@ -31,9 +31,9 @@ import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.domain.Blob; import org.jclouds.http.HttpRequest; import org.jclouds.http.options.GetOptions; -import org.jclouds.cloudfiles.CloudFilesAsyncClient; -import org.jclouds.cloudfiles.blobstore.functions.BlobToObject; -import org.jclouds.cloudfiles.domain.CFObject; +import org.jclouds.openstack.swift.CommonSwiftAsyncClient; +import org.jclouds.openstack.swift.blobstore.functions.BlobToObject; +import org.jclouds.openstack.swift.domain.SwiftObject; import org.jclouds.rest.internal.RestAnnotationProcessor; /** @@ -41,21 +41,21 @@ import org.jclouds.rest.internal.RestAnnotationProcessor; * @author Adrian Cole */ @Singleton -public class CloudFilesBlobRequestSigner implements BlobRequestSigner { - private final RestAnnotationProcessor processor; +public class SwiftBlobRequestSigner implements BlobRequestSigner { + private final RestAnnotationProcessor processor; private final BlobToObject blobToObject; private final Method getMethod; private final Method deleteMethod; private final Method createMethod; @Inject - public CloudFilesBlobRequestSigner(RestAnnotationProcessor processor, BlobToObject blobToObject) + public SwiftBlobRequestSigner(RestAnnotationProcessor processor, BlobToObject blobToObject) throws SecurityException, NoSuchMethodException { this.processor = checkNotNull(processor, "processor"); this.blobToObject = checkNotNull(blobToObject, "blobToObject"); - this.getMethod = CloudFilesAsyncClient.class.getMethod("getObject", String.class, String.class, GetOptions[].class); - this.deleteMethod = CloudFilesAsyncClient.class.getMethod("removeObject", String.class, String.class); - this.createMethod = CloudFilesAsyncClient.class.getMethod("putObject", String.class, CFObject.class); + this.getMethod = CommonSwiftAsyncClient.class.getMethod("getObject", String.class, String.class, GetOptions[].class); + this.deleteMethod = CommonSwiftAsyncClient.class.getMethod("removeObject", String.class, String.class); + this.createMethod = CommonSwiftAsyncClient.class.getMethod("putObject", String.class, SwiftObject.class); } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java similarity index 80% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java index cc5ab8cc70..2f26cf5f6a 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore; +package org.jclouds.openstack.swift.blobstore; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.blobstore.util.BlobStoreUtils.createParentIfNeededAsync; @@ -42,14 +42,14 @@ import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; import org.jclouds.domain.Location; import org.jclouds.http.options.GetOptions; -import org.jclouds.cloudfiles.CloudFilesClient; -import org.jclouds.cloudfiles.blobstore.functions.BlobStoreListContainerOptionsToListContainerOptions; -import org.jclouds.cloudfiles.blobstore.functions.BlobToObject; -import org.jclouds.cloudfiles.blobstore.functions.ContainerToResourceList; -import org.jclouds.cloudfiles.blobstore.functions.ContainerToResourceMetadata; -import org.jclouds.cloudfiles.blobstore.functions.ObjectToBlob; -import org.jclouds.cloudfiles.blobstore.functions.ObjectToBlobMetadata; -import org.jclouds.cloudfiles.domain.ContainerMetadata; +import org.jclouds.openstack.swift.CommonSwiftClient; +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.domain.ContainerMetadata; import com.google.common.base.Function; import com.google.common.base.Supplier; @@ -60,8 +60,8 @@ import com.google.common.collect.Iterables; * @author Adrian Cole */ @Singleton -public class CloudFilesBlobStore extends BaseBlobStore { - private final CloudFilesClient sync; +public class SwiftBlobStore extends BaseBlobStore { + private final CommonSwiftClient sync; private final ContainerToResourceMetadata container2ResourceMd; private final BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions; private final ContainerToResourceList container2ResourceList; @@ -72,8 +72,8 @@ public class CloudFilesBlobStore extends BaseBlobStore { private final Provider fetchBlobMetadataProvider; @Inject - CloudFilesBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, - @Memoized Supplier> locations, CloudFilesClient sync, + SwiftBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + @Memoized Supplier> locations, CommonSwiftClient sync, ContainerToResourceMetadata container2ResourceMd, BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, ContainerToResourceList container2ResourceList, ObjectToBlob object2Blob, BlobToObject blob2Object, @@ -92,7 +92,7 @@ public class CloudFilesBlobStore extends BaseBlobStore { } /** - * This implementation invokes {@link CloudFilesClient#listContainers} + * This implementation invokes {@link CommonSwiftClient#listContainers} */ @Override public PageSet list() { @@ -104,7 +104,7 @@ public class CloudFilesBlobStore extends BaseBlobStore { } /** - * This implementation invokes {@link CloudFilesClient#containerExists} + * This implementation invokes {@link CommonSwiftClient#containerExists} * * @param container * container name @@ -115,7 +115,7 @@ public class CloudFilesBlobStore extends BaseBlobStore { } /** - * This implementation invokes {@link CloudFilesClient#putBucketInRegion} + * This implementation invokes {@link CommonSwiftClient#putBucketInRegion} * * @param location * currently ignored @@ -128,21 +128,21 @@ public class CloudFilesBlobStore extends BaseBlobStore { } /** - * This implementation invokes {@link CloudFilesClient#listObjects} + * This implementation invokes {@link CommonSwiftClient#listObjects} * * @param container * container name */ @Override public PageSet list(String container, ListContainerOptions options) { - org.jclouds.cloudfiles.options.ListContainerOptions httpOptions = container2ContainerListOptions + org.jclouds.openstack.swift.options.ListContainerOptions httpOptions = container2ContainerListOptions .apply(options); PageSet list = container2ResourceList.apply(sync.listObjects(container, httpOptions)); return options.isDetailed() ? fetchBlobMetadataProvider.get().setContainerName(container).apply(list) : list; } /** - * This implementation invokes {@link CloudFilesClient#blobExists} + * This implementation invokes {@link CommonSwiftClient#blobExists} * * @param container * container name @@ -155,7 +155,7 @@ public class CloudFilesBlobStore extends BaseBlobStore { } /** - * This implementation invokes {@link CloudFilesClient#getObjectInfo} + * This implementation invokes {@link CommonSwiftClient#getObjectInfo} * * @param container * container name @@ -168,7 +168,7 @@ public class CloudFilesBlobStore extends BaseBlobStore { } /** - * This implementation invokes {@link CloudFilesClient#getObject} + * This implementation invokes {@link CommonSwiftClient#getObject} * * @param container * container name @@ -182,7 +182,7 @@ public class CloudFilesBlobStore extends BaseBlobStore { } /** - * This implementation invokes {@link CloudFilesClient#putObject} + * This implementation invokes {@link CommonSwiftClient#putObject} * * @param container * container name @@ -196,7 +196,7 @@ public class CloudFilesBlobStore extends BaseBlobStore { } /** - * This implementation invokes {@link CloudFilesClient#removeObject} + * This implementation invokes {@link CommonSwiftClient#removeObject} * * @param container * container name diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/config/SwiftBlobStoreContextModule.java similarity index 77% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/config/SwiftBlobStoreContextModule.java index b06c628a82..f89cc468e5 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/config/SwiftBlobStoreContextModule.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore.config; +package org.jclouds.openstack.swift.blobstore.config; import java.util.Set; @@ -32,14 +32,14 @@ import org.jclouds.blobstore.config.BlobStoreMapModule; import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.collect.Memoized; import org.jclouds.domain.Location; -import org.jclouds.cloudfiles.CloudFilesAsyncClient; -import org.jclouds.cloudfiles.CloudFilesClient; -import org.jclouds.cloudfiles.blobstore.CloudFilesAsyncBlobStore; -import org.jclouds.cloudfiles.blobstore.CloudFilesBlobRequestSigner; -import org.jclouds.cloudfiles.blobstore.CloudFilesBlobStore; import org.jclouds.location.Region; import org.jclouds.location.config.ProvideRegionsViaProperties; import org.jclouds.location.suppliers.SupplyPredefinedRegions; +import org.jclouds.openstack.swift.CommonSwiftAsyncClient; +import org.jclouds.openstack.swift.CommonSwiftClient; +import org.jclouds.openstack.swift.blobstore.SwiftAsyncBlobStore; +import org.jclouds.openstack.swift.blobstore.SwiftBlobRequestSigner; +import org.jclouds.openstack.swift.blobstore.SwiftBlobStore; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; @@ -50,12 +50,12 @@ import com.google.inject.Scopes; import com.google.inject.TypeLiteral; /** - * Configures the {@link CloudFilesBlobStoreContext}; requires {@link CloudFilesAsyncBlobStore} + * Configures the {@link CloudFilesBlobStoreContext}; requires {@link SwiftAsyncBlobStore} * bound. * * @author Adrian Cole */ -public class CloudFilesBlobStoreContextModule extends AbstractModule { +public class SwiftBlobStoreContextModule extends AbstractModule { @Override protected void configure() { @@ -63,15 +63,15 @@ public class CloudFilesBlobStoreContextModule extends AbstractModule { bind(new TypeLiteral>>() { }).annotatedWith(Memoized.class).to(new TypeLiteral() { }); - - bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT); - bind(AsyncBlobStore.class).to(CloudFilesAsyncBlobStore.class).in(Scopes.SINGLETON); - bind(BlobStore.class).to(CloudFilesBlobStore.class).in(Scopes.SINGLETON); - bind(BlobStoreContext.class).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); - bind(BlobRequestSigner.class).to(CloudFilesBlobRequestSigner.class); bind(new TypeLiteral>() { }).annotatedWith(Region.class).toProvider(ProvideRegionsViaProperties.class).in(Scopes.SINGLETON); + + bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT); + bind(AsyncBlobStore.class).to(SwiftAsyncBlobStore.class).in(Scopes.SINGLETON); + bind(BlobStore.class).to(SwiftBlobStore.class).in(Scopes.SINGLETON); + bind(BlobStoreContext.class).to(new TypeLiteral>() { + }).in(Scopes.SINGLETON); + bind(BlobRequestSigner.class).to(SwiftBlobRequestSigner.class); } @Provides diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/BlobStoreListContainerOptionsToListContainerOptions.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/BlobStoreListContainerOptionsToListContainerOptions.java similarity index 84% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/BlobStoreListContainerOptionsToListContainerOptions.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/BlobStoreListContainerOptionsToListContainerOptions.java index baac0562e7..0793cfb5b6 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/BlobStoreListContainerOptionsToListContainerOptions.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/BlobStoreListContainerOptionsToListContainerOptions.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore.functions; +package org.jclouds.openstack.swift.blobstore.functions; import static com.google.common.base.Preconditions.checkNotNull; @@ -33,11 +33,11 @@ import com.google.common.base.Function; @Singleton public class BlobStoreListContainerOptionsToListContainerOptions implements - Function { - public org.jclouds.cloudfiles.options.ListContainerOptions apply( + Function { + public org.jclouds.openstack.swift.options.ListContainerOptions apply( ListContainerOptions from) { checkNotNull(from, "set options to instance NONE instead of passing null"); - org.jclouds.cloudfiles.options.ListContainerOptions options = new org.jclouds.cloudfiles.options.ListContainerOptions(); + org.jclouds.openstack.swift.options.ListContainerOptions options = new org.jclouds.openstack.swift.options.ListContainerOptions(); if ((from.getDir() == null) && (from.isRecursive())) { options.withPrefix(""); } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/BlobToObject.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/BlobToObject.java similarity index 71% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/BlobToObject.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/BlobToObject.java index 15573a4ad9..142c0374ed 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/BlobToObject.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/BlobToObject.java @@ -1,6 +1,6 @@ /** * - * Copyright (C) 2010 Cloud Conscious, LLC. +s * Copyright (C) 2010 Cloud Conscious, LLC. * * ==================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore.functions; +package org.jclouds.openstack.swift.blobstore.functions; import static com.google.common.base.Preconditions.checkNotNull; @@ -25,7 +25,7 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.blobstore.domain.Blob; -import org.jclouds.cloudfiles.domain.CFObject; +import org.jclouds.openstack.swift.domain.SwiftObject; import com.google.common.base.Function; @@ -33,20 +33,20 @@ import com.google.common.base.Function; * @author Adrian Cole */ @Singleton -public class BlobToObject implements Function { +public class BlobToObject implements Function { private final ResourceToObjectInfo blob2ObjectMd; - private final CFObject.Factory objectProvider; + private final SwiftObject.Factory objectProvider; @Inject - BlobToObject(ResourceToObjectInfo blob2ObjectMd, CFObject.Factory objectProvider) { + BlobToObject(ResourceToObjectInfo blob2ObjectMd, SwiftObject.Factory objectProvider) { this.blob2ObjectMd = blob2ObjectMd; this.objectProvider = objectProvider; } - public CFObject apply(Blob from) { + public SwiftObject apply(Blob from) { if (from == null) return null; - CFObject object = objectProvider.create(blob2ObjectMd.apply(from.getMetadata())); + SwiftObject object = objectProvider.create(blob2ObjectMd.apply(from.getMetadata())); object.setPayload(checkNotNull(from.getPayload(), "payload: " + from)); object.setAllHeaders(from.getAllHeaders()); return object; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/BlobToObjectGetOptions.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/BlobToObjectGetOptions.java similarity index 97% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/BlobToObjectGetOptions.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/BlobToObjectGetOptions.java index 745852dcb1..98668ca7f2 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/BlobToObjectGetOptions.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/BlobToObjectGetOptions.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore.functions; +package org.jclouds.openstack.swift.blobstore.functions; import javax.inject.Singleton; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ContainerToResourceList.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ContainerToResourceList.java similarity index 95% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ContainerToResourceList.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ContainerToResourceList.java index 977e5a5332..9de8427b7a 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ContainerToResourceList.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ContainerToResourceList.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore.functions; +package org.jclouds.openstack.swift.blobstore.functions; import javax.inject.Inject; import javax.inject.Singleton; @@ -28,7 +28,7 @@ import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.StorageType; import org.jclouds.blobstore.domain.internal.PageSetImpl; import org.jclouds.blobstore.domain.internal.StorageMetadataImpl; -import org.jclouds.cloudfiles.domain.ObjectInfo; +import org.jclouds.openstack.swift.domain.ObjectInfo; import com.google.common.base.Function; import com.google.common.collect.Iterables; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ContainerToResourceMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ContainerToResourceMetadata.java similarity index 93% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ContainerToResourceMetadata.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ContainerToResourceMetadata.java index a19fc47a54..37d289f3e4 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ContainerToResourceMetadata.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ContainerToResourceMetadata.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore.functions; +package org.jclouds.openstack.swift.blobstore.functions; import javax.inject.Inject; import javax.inject.Singleton; @@ -27,7 +27,7 @@ import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.StorageType; import org.jclouds.blobstore.domain.internal.MutableStorageMetadataImpl; import org.jclouds.domain.Location; -import org.jclouds.cloudfiles.domain.ContainerMetadata; +import org.jclouds.openstack.swift.domain.ContainerMetadata; import com.google.common.base.Function; import com.google.common.base.Supplier; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ObjectToBlob.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ObjectToBlob.java similarity index 88% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ObjectToBlob.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ObjectToBlob.java index da0a373065..cfbddcf2af 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ObjectToBlob.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ObjectToBlob.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore.functions; +package org.jclouds.openstack.swift.blobstore.functions; import static com.google.common.base.Preconditions.checkNotNull; @@ -26,7 +26,7 @@ import javax.inject.Singleton; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; -import org.jclouds.cloudfiles.domain.CFObject; +import org.jclouds.openstack.swift.domain.SwiftObject; import com.google.common.base.Function; @@ -34,7 +34,7 @@ import com.google.common.base.Function; * @author Adrian Cole */ @Singleton -public class ObjectToBlob implements Function { +public class ObjectToBlob implements Function { private final Blob.Factory blobFactory; private final ObjectToBlobMetadata object2BlobMd; @@ -44,7 +44,7 @@ public class ObjectToBlob implements Function { this.object2BlobMd = object2BlobMd; } - public Blob apply(CFObject from) { + public Blob apply(SwiftObject from) { if (from == null) return null; Blob blob = blobFactory.create(object2BlobMd.apply(from.getInfo())); diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ObjectToBlobMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ObjectToBlobMetadata.java similarity index 93% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ObjectToBlobMetadata.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ObjectToBlobMetadata.java index 277c2d8c0e..7123ab9e53 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ObjectToBlobMetadata.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ObjectToBlobMetadata.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore.functions; +package org.jclouds.openstack.swift.blobstore.functions; import javax.inject.Inject; import javax.inject.Singleton; @@ -27,8 +27,8 @@ import org.jclouds.blobstore.domain.StorageType; import org.jclouds.blobstore.domain.internal.MutableBlobMetadataImpl; import org.jclouds.blobstore.strategy.IfDirectoryReturnNameStrategy; import org.jclouds.crypto.CryptoStreams; -import org.jclouds.cloudfiles.domain.MutableObjectInfoWithMetadata; -import org.jclouds.cloudfiles.domain.ObjectInfo; +import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata; +import org.jclouds.openstack.swift.domain.ObjectInfo; import com.google.common.base.Function; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ResourceToObjectInfo.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ResourceToObjectInfo.java similarity index 91% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ResourceToObjectInfo.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ResourceToObjectInfo.java index 783a04e7cc..46aef3a70f 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/ResourceToObjectInfo.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/blobstore/functions/ResourceToObjectInfo.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore.functions; +package org.jclouds.openstack.swift.blobstore.functions; import java.util.Map.Entry; @@ -27,8 +27,8 @@ import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.StorageType; import org.jclouds.crypto.CryptoStreams; -import org.jclouds.cloudfiles.domain.MutableObjectInfoWithMetadata; -import org.jclouds.cloudfiles.domain.internal.MutableObjectInfoWithMetadataImpl; +import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata; +import org.jclouds.openstack.swift.domain.internal.MutableObjectInfoWithMetadataImpl; import com.google.common.base.Function; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/config/BaseSwiftRestClientModule.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/config/BaseSwiftRestClientModule.java new file mode 100644 index 0000000000..393b854401 --- /dev/null +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/config/BaseSwiftRestClientModule.java @@ -0,0 +1,86 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.config; + +import java.net.URI; + +import javax.inject.Singleton; + +import org.jclouds.http.HttpErrorHandler; +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.json.config.GsonModule.DateAdapter; +import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; +import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse; +import org.jclouds.openstack.config.OpenStackAuthenticationModule; +import org.jclouds.openstack.reference.AuthHeaders; +import org.jclouds.openstack.swift.CommonSwiftAsyncClient; +import org.jclouds.openstack.swift.CommonSwiftClient; +import org.jclouds.openstack.swift.Storage; +import org.jclouds.openstack.swift.handlers.ParseSwiftErrorFromHttpResponse; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.config.RestClientModule; + +import com.google.inject.Provides; + +/** + * + * @author Adrian Cole + */ +@ConfiguresRestClient +@RequiresHttp +public class BaseSwiftRestClientModule extends + RestClientModule { + private final OpenStackAuthenticationModule module; + + public BaseSwiftRestClientModule(Class syncClientType, Class asyncClientType) { + this(new OpenStackAuthenticationModule(), syncClientType, asyncClientType); + } + + public BaseSwiftRestClientModule(OpenStackAuthenticationModule module, Class syncClientType, + Class asyncClientType) { + super(syncClientType, asyncClientType); + this.module = module; + } + + @Override + protected void configure() { + install(module); + install(new SwiftObjectModule()); + bind(DateAdapter.class).to(Iso8601DateAdapter.class); + super.configure(); + } + + @Override + protected void bindErrorHandlers() { + bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseSwiftErrorFromHttpResponse.class); + bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseSwiftErrorFromHttpResponse.class); + bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseSwiftErrorFromHttpResponse.class); + } + + @Provides + @Singleton + @Storage + protected URI provideStorageUrl(AuthenticationResponse response) { + return response.getServices().get(AuthHeaders.STORAGE_URL); + } +} diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CFObjectModule.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/config/SwiftObjectModule.java similarity index 69% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CFObjectModule.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/config/SwiftObjectModule.java index 11f2050e7a..0aee6365a0 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CFObjectModule.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/config/SwiftObjectModule.java @@ -17,15 +17,15 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.config; +package org.jclouds.openstack.swift.config; import javax.inject.Inject; import javax.inject.Provider; import org.jclouds.blobstore.config.BlobStoreObjectModule; -import org.jclouds.cloudfiles.domain.CFObject; -import org.jclouds.cloudfiles.domain.MutableObjectInfoWithMetadata; -import org.jclouds.cloudfiles.domain.internal.CFObjectImpl; +import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata; +import org.jclouds.openstack.swift.domain.SwiftObject; +import org.jclouds.openstack.swift.domain.internal.SwiftObjectImpl; import com.google.inject.AbstractModule; import com.google.inject.Provides; @@ -36,7 +36,7 @@ import com.google.inject.Scopes; * * @author Adrian Cole */ -public class CFObjectModule extends AbstractModule { +public class SwiftObjectModule extends AbstractModule { /** * explicit factories are created here as it has been shown that Assisted Inject is extremely @@ -46,20 +46,20 @@ public class CFObjectModule extends AbstractModule { protected void configure() { // for converters to work. install(new BlobStoreObjectModule()); - bind(CFObject.Factory.class).to(CFObjectFactory.class).in(Scopes.SINGLETON); + bind(SwiftObject.Factory.class).to(SwiftObjectFactory.class).in(Scopes.SINGLETON); } - private static class CFObjectFactory implements CFObject.Factory { + private static class SwiftObjectFactory implements SwiftObject.Factory { @Inject Provider metadataProvider; - public CFObject create(MutableObjectInfoWithMetadata metadata) { - return new CFObjectImpl(metadata != null ? metadata : metadataProvider.get()); + public SwiftObject create(MutableObjectInfoWithMetadata metadata) { + return new SwiftObjectImpl(metadata != null ? metadata : metadataProvider.get()); } } @Provides - CFObject provideCFObject(CFObject.Factory factory) { + SwiftObject provideSwiftObject(SwiftObject.Factory factory) { return factory.create(null); } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/AccountMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/AccountMetadata.java similarity index 98% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/AccountMetadata.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/AccountMetadata.java index f4de15528d..0e20f66690 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/AccountMetadata.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/AccountMetadata.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.domain; +package org.jclouds.openstack.swift.domain; /** * diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/ContainerMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/ContainerMetadata.java similarity index 98% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/ContainerMetadata.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/ContainerMetadata.java index 0ed31a67a4..a3833363b4 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/ContainerMetadata.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/ContainerMetadata.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.domain; +package org.jclouds.openstack.swift.domain; /** diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/MutableObjectInfoWithMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/MutableObjectInfoWithMetadata.java similarity index 90% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/MutableObjectInfoWithMetadata.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/MutableObjectInfoWithMetadata.java index f9190cf821..99c5ef149f 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/MutableObjectInfoWithMetadata.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/MutableObjectInfoWithMetadata.java @@ -17,12 +17,12 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.domain; +package org.jclouds.openstack.swift.domain; import java.util.Date; import java.util.Map; -import org.jclouds.cloudfiles.domain.internal.MutableObjectInfoWithMetadataImpl; +import org.jclouds.openstack.swift.domain.internal.MutableObjectInfoWithMetadataImpl; import com.google.inject.ImplementedBy; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/ObjectInfo.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/ObjectInfo.java similarity index 95% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/ObjectInfo.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/ObjectInfo.java index 8457c15ca0..bf6632bea6 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/ObjectInfo.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/ObjectInfo.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.domain; +package org.jclouds.openstack.swift.domain; import java.util.Date; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/CFObject.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/SwiftObject.java similarity index 85% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/CFObject.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/SwiftObject.java index 3c22970d74..6a24c35007 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/CFObject.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/SwiftObject.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.domain; +package org.jclouds.openstack.swift.domain; import javax.annotation.Nullable; @@ -29,9 +29,9 @@ import com.google.common.collect.Multimap; * * @author Adrian Cole */ -public interface CFObject extends PayloadEnclosing, Comparable { +public interface SwiftObject extends PayloadEnclosing, Comparable { public interface Factory { - CFObject create(@Nullable MutableObjectInfoWithMetadata info); + SwiftObject create(@Nullable MutableObjectInfoWithMetadata info); } /** diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/internal/DelegatingMutableObjectInfoWithMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/internal/DelegatingMutableObjectInfoWithMetadata.java similarity index 94% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/internal/DelegatingMutableObjectInfoWithMetadata.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/internal/DelegatingMutableObjectInfoWithMetadata.java index 0add97d593..8a83d9aa38 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/internal/DelegatingMutableObjectInfoWithMetadata.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/internal/DelegatingMutableObjectInfoWithMetadata.java @@ -17,14 +17,14 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.domain.internal; +package org.jclouds.openstack.swift.domain.internal; import java.util.Date; import java.util.Map; import org.jclouds.io.payloads.BaseMutableContentMetadata; -import org.jclouds.cloudfiles.domain.MutableObjectInfoWithMetadata; -import org.jclouds.cloudfiles.domain.ObjectInfo; +import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata; +import org.jclouds.openstack.swift.domain.ObjectInfo; /** * diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/internal/MutableObjectInfoWithMetadataImpl.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/internal/MutableObjectInfoWithMetadataImpl.java similarity index 95% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/internal/MutableObjectInfoWithMetadataImpl.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/internal/MutableObjectInfoWithMetadataImpl.java index 2cfa527ba3..816d0e18ec 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/internal/MutableObjectInfoWithMetadataImpl.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/internal/MutableObjectInfoWithMetadataImpl.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.domain.internal; +package org.jclouds.openstack.swift.domain.internal; import java.util.Arrays; import java.util.Date; @@ -25,8 +25,8 @@ import java.util.Map; import javax.ws.rs.core.MediaType; -import org.jclouds.cloudfiles.domain.MutableObjectInfoWithMetadata; -import org.jclouds.cloudfiles.domain.ObjectInfo; +import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata; +import org.jclouds.openstack.swift.domain.ObjectInfo; import com.google.common.collect.Maps; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/internal/ObjectInfoImpl.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/internal/ObjectInfoImpl.java similarity index 96% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/internal/ObjectInfoImpl.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/internal/ObjectInfoImpl.java index ce7bbe23a5..2f0d16c2cc 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/internal/ObjectInfoImpl.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/internal/ObjectInfoImpl.java @@ -17,12 +17,12 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.domain.internal; +package org.jclouds.openstack.swift.domain.internal; import java.util.Arrays; import java.util.Date; -import org.jclouds.cloudfiles.domain.ObjectInfo; +import org.jclouds.openstack.swift.domain.ObjectInfo; public class ObjectInfoImpl implements ObjectInfo { String name; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/internal/CFObjectImpl.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/internal/SwiftObjectImpl.java similarity index 85% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/internal/CFObjectImpl.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/internal/SwiftObjectImpl.java index 18cf7d13bf..b0e4ccb1ce 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/internal/CFObjectImpl.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/domain/internal/SwiftObjectImpl.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.domain.internal; +package org.jclouds.openstack.swift.domain.internal; import static com.google.common.base.Preconditions.checkNotNull; @@ -26,24 +26,24 @@ import javax.inject.Inject; import org.jclouds.http.HttpUtils; import org.jclouds.http.internal.PayloadEnclosingImpl; import org.jclouds.io.Payload; -import org.jclouds.cloudfiles.domain.CFObject; -import org.jclouds.cloudfiles.domain.MutableObjectInfoWithMetadata; +import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata; +import org.jclouds.openstack.swift.domain.SwiftObject; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Multimap; /** - * Default Implementation of {@link CFObject}. + * Default Implementation of {@link SwiftObject}. * * @author Adrian Cole */ -public class CFObjectImpl extends PayloadEnclosingImpl implements CFObject, Comparable { +public class SwiftObjectImpl extends PayloadEnclosingImpl implements SwiftObject, Comparable { private final DelegatingMutableObjectInfoWithMetadata info; private Multimap allHeaders = LinkedHashMultimap.create(); @Inject - public CFObjectImpl(MutableObjectInfoWithMetadata info) { + public SwiftObjectImpl(MutableObjectInfoWithMetadata info) { super(); this.info = new DelegatingMutableObjectInfoWithMetadata(info); } @@ -76,7 +76,7 @@ public class CFObjectImpl extends PayloadEnclosingImpl implements CFObject, Comp * {@inheritDoc} */ @Override - public int compareTo(CFObject o) { + public int compareTo(SwiftObject o) { if (getInfo().getName() == null) return -1; return (this == o) ? 0 : getInfo().getName().compareTo(o.getInfo().getName()); @@ -98,7 +98,7 @@ public class CFObjectImpl extends PayloadEnclosingImpl implements CFObject, Comp return false; if (getClass() != obj.getClass()) return false; - CFObjectImpl other = (CFObjectImpl) obj; + SwiftObjectImpl other = (SwiftObjectImpl) obj; if (info == null) { if (other.info != null) return false; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ObjectName.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ObjectName.java similarity index 86% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ObjectName.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ObjectName.java index a427e288bd..134ed9d782 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ObjectName.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ObjectName.java @@ -17,9 +17,9 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.functions; +package org.jclouds.openstack.swift.functions; -import org.jclouds.cloudfiles.domain.CFObject; +import org.jclouds.openstack.swift.domain.SwiftObject; import com.google.common.base.Function; @@ -30,7 +30,7 @@ import com.google.common.base.Function; public class ObjectName implements Function { public String apply(Object from) { - return ((CFObject) from).getInfo().getName(); + return ((SwiftObject) from).getInfo().getName(); } } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseAccountMetadataResponseFromHeaders.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseAccountMetadataResponseFromHeaders.java similarity index 94% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseAccountMetadataResponseFromHeaders.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseAccountMetadataResponseFromHeaders.java index 72b8990d07..7ac91d5325 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseAccountMetadataResponseFromHeaders.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseAccountMetadataResponseFromHeaders.java @@ -17,12 +17,12 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.functions; +package org.jclouds.openstack.swift.functions; import static com.google.common.base.Preconditions.checkNotNull; import org.jclouds.http.HttpResponse; -import org.jclouds.cloudfiles.domain.AccountMetadata; +import org.jclouds.openstack.swift.domain.AccountMetadata; import org.jclouds.cloudfiles.reference.CloudFilesHeaders; import com.google.common.base.Function; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseContainerCDNMetadataFromHeaders.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseContainerCDNMetadataFromHeaders.java similarity index 95% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseContainerCDNMetadataFromHeaders.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseContainerCDNMetadataFromHeaders.java index 80927bd91b..c0735848c6 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseContainerCDNMetadataFromHeaders.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseContainerCDNMetadataFromHeaders.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.functions; +package org.jclouds.openstack.swift.functions; import static com.google.common.base.Preconditions.checkNotNull; @@ -25,9 +25,9 @@ import java.net.URI; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.cloudfiles.domain.AccountMetadata; import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; import org.jclouds.cloudfiles.reference.CloudFilesHeaders; +import org.jclouds.openstack.swift.domain.AccountMetadata; import org.jclouds.rest.InvocationContext; import com.google.common.base.Function; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseObjectFromHeadersAndHttpContent.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseObjectFromHeadersAndHttpContent.java similarity index 78% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseObjectFromHeadersAndHttpContent.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseObjectFromHeadersAndHttpContent.java index 47ed71127e..d8e209d8d2 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseObjectFromHeadersAndHttpContent.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseObjectFromHeadersAndHttpContent.java @@ -17,42 +17,42 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.functions; +package org.jclouds.openstack.swift.functions; import javax.inject.Inject; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.cloudfiles.domain.CFObject; -import org.jclouds.cloudfiles.domain.MutableObjectInfoWithMetadata; +import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata; +import org.jclouds.openstack.swift.domain.SwiftObject; import org.jclouds.rest.InvocationContext; import com.google.common.base.Function; /** - * Parses response headers and creates a new CFObject from them and the HTTP content. + * Parses response headers and creates a new SwiftObject from them and the HTTP content. * * @see ParseMetadataFromHeaders * @author Adrian Cole */ -public class ParseObjectFromHeadersAndHttpContent implements Function, +public class ParseObjectFromHeadersAndHttpContent implements Function, InvocationContext { private final ParseObjectInfoFromHeaders infoParser; - private final CFObject.Factory objectProvider; + private final SwiftObject.Factory objectProvider; @Inject public ParseObjectFromHeadersAndHttpContent(ParseObjectInfoFromHeaders infoParser, - CFObject.Factory objectProvider) { + SwiftObject.Factory objectProvider) { this.infoParser = infoParser; this.objectProvider = objectProvider; } - public CFObject apply(HttpResponse from) { + public SwiftObject apply(HttpResponse from) { MutableObjectInfoWithMetadata metadata = infoParser.apply(from); if (metadata.getHash() != null) from.getPayload().getContentMetadata().setContentMD5(metadata.getHash()); - CFObject object = objectProvider.create(metadata); + SwiftObject object = objectProvider.create(metadata); object.getAllHeaders().putAll(from.getHeaders()); object.setPayload(from.getPayload()); return object; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseObjectInfoFromHeaders.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseObjectInfoFromHeaders.java similarity index 92% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseObjectInfoFromHeaders.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseObjectInfoFromHeaders.java index e9eabb2cb3..fdcda5ca79 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseObjectInfoFromHeaders.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseObjectInfoFromHeaders.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.functions; +package org.jclouds.openstack.swift.functions; import static org.jclouds.http.HttpUtils.attemptToParseSizeAndRangeFromHeaders; @@ -28,8 +28,8 @@ import org.jclouds.blobstore.functions.ParseSystemAndUserMetadataFromHeaders; import org.jclouds.crypto.CryptoStreams; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.cloudfiles.blobstore.functions.ResourceToObjectInfo; -import org.jclouds.cloudfiles.domain.MutableObjectInfoWithMetadata; +import org.jclouds.openstack.swift.blobstore.functions.ResourceToObjectInfo; +import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata; import org.jclouds.rest.InvocationContext; import com.google.common.base.Function; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseObjectInfoListFromJsonResponse.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseObjectInfoListFromJsonResponse.java similarity index 94% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseObjectInfoListFromJsonResponse.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseObjectInfoListFromJsonResponse.java index 51f8567b05..3eb14f5d32 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseObjectInfoListFromJsonResponse.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ParseObjectInfoListFromJsonResponse.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.functions; +package org.jclouds.openstack.swift.functions; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; @@ -34,9 +34,9 @@ import org.jclouds.blobstore.domain.internal.PageSetImpl; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseJson; import org.jclouds.json.Json; -import org.jclouds.cloudfiles.domain.ObjectInfo; -import org.jclouds.cloudfiles.domain.internal.ObjectInfoImpl; -import org.jclouds.cloudfiles.options.ListContainerOptions; +import org.jclouds.openstack.swift.domain.ObjectInfo; +import org.jclouds.openstack.swift.domain.internal.ObjectInfoImpl; +import org.jclouds.openstack.swift.options.ListContainerOptions; import org.jclouds.rest.InvocationContext; import org.jclouds.rest.internal.GeneratedHttpRequest; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ReturnTrueOn404FalseOn409.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ReturnTrueOn404FalseOn409.java similarity index 96% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ReturnTrueOn404FalseOn409.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ReturnTrueOn404FalseOn409.java index 408117cd03..225dcefaac 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ReturnTrueOn404FalseOn409.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/functions/ReturnTrueOn404FalseOn409.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.functions; +package org.jclouds.openstack.swift.functions; import static com.google.common.base.Predicates.in; import static com.google.common.collect.ImmutableSet.of; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/handlers/ParseCloudFilesErrorFromHttpResponse.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/handlers/ParseSwiftErrorFromHttpResponse.java similarity index 96% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/handlers/ParseCloudFilesErrorFromHttpResponse.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/handlers/ParseSwiftErrorFromHttpResponse.java index 8b3bcefb94..f5adfa8f74 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/handlers/ParseCloudFilesErrorFromHttpResponse.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/handlers/ParseSwiftErrorFromHttpResponse.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.handlers; +package org.jclouds.openstack.swift.handlers; import static org.jclouds.http.HttpUtils.releasePayload; @@ -43,7 +43,7 @@ import org.jclouds.util.Strings2; * @author Adrian Cole * */ -public class ParseCloudFilesErrorFromHttpResponse implements HttpErrorHandler { +public class ParseSwiftErrorFromHttpResponse implements HttpErrorHandler { @Resource protected Logger logger = Logger.NULL; public static final String PREFIX = "^/v[0-9][^/]*/[a-zA-Z]+_[^/]+/"; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/options/ListContainerOptions.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/options/ListContainerOptions.java similarity index 99% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/options/ListContainerOptions.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/options/ListContainerOptions.java index 9651ec69f7..3204ff2b57 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/options/ListContainerOptions.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/options/ListContainerOptions.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.options; +package org.jclouds.openstack.swift.options; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/CloudFilesConstants.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/reference/SwiftConstants.java similarity index 94% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/CloudFilesConstants.java rename to apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/reference/SwiftConstants.java index ede9226234..23395dbe42 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/CloudFilesConstants.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/reference/SwiftConstants.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.reference; +package org.jclouds.openstack.swift.reference; /** @@ -25,7 +25,7 @@ package org.jclouds.cloudfiles.reference; * * @author Adrian Cole */ -public interface CloudFilesConstants { +public interface SwiftConstants { /** * For an integer value N, limits the number of results to at most N values. */ diff --git a/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/reference/SwiftHeaders.java b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/reference/SwiftHeaders.java new file mode 100644 index 0000000000..ddca664a40 --- /dev/null +++ b/apis/cloudfiles/src/main/java/org/jclouds/openstack/swift/reference/SwiftHeaders.java @@ -0,0 +1,33 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.reference; + +/** + * @author Adrian Cole + * + */ +public interface SwiftHeaders { + + public static final String ACCOUNT_BYTES_USED = "X-Account-Bytes-Used"; + public static final String ACCOUNT_CONTAINER_COUNT = "X-Account-Container-Count"; + public static final String CONTAINER_BYTES_USED = "X-Container-Bytes-Used"; + public static final String CONTAINER_OBJECT_COUNT = "X-Container-Object-Count"; + public static final String USER_METADATA_PREFIX = "X-Object-Meta-"; +} 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 28ded3cf96..285402b7d8 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java @@ -19,40 +19,21 @@ package org.jclouds.cloudfiles; -import static org.jclouds.cloudfiles.options.ListContainerOptions.Builder.underPath; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; -import java.io.ByteArrayInputStream; -import java.io.IOException; import java.net.URI; -import java.util.Map; import java.util.Set; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; import org.jclouds.blobstore.ContainerNotFoundException; -import org.jclouds.blobstore.domain.PageSet; -import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; -import org.jclouds.crypto.CryptoStreams; -import org.jclouds.http.HttpResponseException; -import org.jclouds.http.options.GetOptions; -import org.jclouds.io.Payloads; -import org.jclouds.cloudfiles.domain.AccountMetadata; -import org.jclouds.cloudfiles.domain.CFObject; import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; -import org.jclouds.cloudfiles.domain.ContainerMetadata; -import org.jclouds.cloudfiles.domain.MutableObjectInfoWithMetadata; -import org.jclouds.cloudfiles.domain.ObjectInfo; import org.jclouds.cloudfiles.options.ListCdnContainerOptions; -import org.jclouds.cloudfiles.options.ListContainerOptions; -import org.jclouds.util.Strings2; +import org.jclouds.http.HttpResponseException; +import org.jclouds.openstack.swift.SwiftClientLiveTest; import org.testng.annotations.Test; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import com.google.common.collect.Maps; /** * Tests behavior of {@code JaxrsAnnotationProcessor} @@ -60,20 +41,13 @@ import com.google.common.collect.Maps; * @author Adrian Cole */ @Test(groups = "live") -public class CloudFilesClientLiveTest extends BaseBlobStoreIntegrationTest { +public class CloudFilesClientLiveTest extends SwiftClientLiveTest { + @Override public CloudFilesClient getApi() { return (CloudFilesClient) context.getProviderSpecificContext().getApi(); } - /** - * this method overrides containerName to ensure it isn't found - */ - @Test(groups = { "integration", "live" }) - public void deleteContainerIfEmptyNotFound() throws Exception { - assert getApi().deleteContainerIfEmpty("dbienf"); - } - @Test public void testCDNOperations() throws Exception { final long minimumTTL = 60 * 60; // The minimum TTL is 1 hour @@ -174,219 +148,4 @@ public class CloudFilesClientLiveTest extends BaseBlobStoreIntegrationTest { } } - @Test - public void testListOwnedContainers() throws Exception { - String containerPrefix = getContainerName(); - try { - Set response = getApi().listContainers(); - assertNotNull(response); - long initialContainerCount = response.size(); - assertTrue(initialContainerCount >= 0); - - // Create test containers - String[] containerNames = new String[] { containerPrefix + ".testListOwnedContainers1", - containerPrefix + ".testListOwnedContainers2" }; - assertTrue(getApi().createContainer(containerNames[0])); - assertTrue(getApi().createContainer(containerNames[1])); - - // Test default listing - response = getApi().listContainers(); - // assertEquals(response.size(), initialContainerCount + 2);// if the - // containers already - // exist, this will fail - - // Test listing with options - response = getApi().listContainers( - ListContainerOptions.Builder.afterMarker( - containerNames[0].substring(0, containerNames[0].length() - 1)).maxResults(1)); - assertEquals(response.size(), 1); - assertEquals(Iterables.get(response, 0).getName(), containerNames[0]); - - response = getApi().listContainers(ListContainerOptions.Builder.afterMarker(containerNames[0]).maxResults(1)); - assertEquals(response.size(), 1); - assertEquals(Iterables.get(response, 0).getName(), containerNames[1]); - - // Cleanup and test containers have been removed - assertTrue(getApi().deleteContainerIfEmpty(containerNames[0])); - assertTrue(getApi().deleteContainerIfEmpty(containerNames[1])); - response = getApi().listContainers(); - // assertEquals(response.size(), initialContainerCount + 2);// if the - // containers already - // exist, this will fail - } finally { - returnContainer(containerPrefix); - } - } - - @Test - public void testHeadAccountMetadata() throws Exception { - String containerPrefix = getContainerName(); - String containerName = containerPrefix + ".testHeadAccountMetadata"; - try { - AccountMetadata metadata = getApi().getAccountStatistics(); - assertNotNull(metadata); - long initialContainerCount = metadata.getContainerCount(); - - assertTrue(getApi().createContainer(containerName)); - - metadata = getApi().getAccountStatistics(); - assertNotNull(metadata); - assertTrue(metadata.getContainerCount() >= initialContainerCount); - - assertTrue(getApi().deleteContainerIfEmpty(containerName)); - } finally { - returnContainer(containerPrefix); - } - } - - @Test - public void testPutContainers() throws Exception { - String containerName = getContainerName(); - try { - String containerName1 = containerName + ".hello"; - assertTrue(getApi().createContainer(containerName1)); - // List only the container just created, using a marker with the - // container name less 1 char - Set response = getApi().listContainers( - ListContainerOptions.Builder.afterMarker(containerName1.substring(0, containerName1.length() - 1)) - .maxResults(1)); - assertNotNull(response); - assertEquals(response.size(), 1); - assertEquals(Iterables.get(response, 0).getName(), containerName + ".hello"); - - String containerName2 = containerName + "?should-be-illegal-question-char"; - assert getApi().createContainer(containerName2); - - assert getApi().createContainer(containerName + "/illegal-slash-char"); - - assertTrue(getApi().deleteContainerIfEmpty(containerName1)); - assertTrue(getApi().deleteContainerIfEmpty(containerName2)); - } finally { - returnContainer(containerName); - } - } - - public void testListContainerPath() throws InterruptedException, ExecutionException, TimeoutException, IOException { - String containerName = getContainerName(); - try { - - String data = "foo"; - - getApi().putObject(containerName, newCFObject(data, "foo")); - getApi().putObject(containerName, newCFObject(data, "path/bar")); - - PageSet container = getApi().listObjects(containerName, underPath("")); - assert container.getNextMarker() == null; - assertEquals(container.size(), 1); - assertEquals(Iterables.get(container, 0).getName(), "foo"); - container = getApi().listObjects(containerName, underPath("path")); - assert container.getNextMarker() == null; - assertEquals(container.size(), 1); - assertEquals(Iterables.get(container, 0).getName(), "path/bar"); - } finally { - returnContainer(containerName); - } - - } - - @Test - public void testObjectOperations() throws Exception { - String containerName = getContainerName(); - try { - // Test PUT with string data, ETag hash, and a piece of metadata - String data = "Here is my data"; - String key = "object"; - CFObject object = newCFObject(data, key); - byte[] md5 = object.getPayload().getContentMetadata().getContentMD5(); - String newEtag = getApi().putObject(containerName, object); - assert newEtag != null; - assertEquals(CryptoStreams.hex(md5), CryptoStreams.hex(object.getPayload().getContentMetadata().getContentMD5())); - - // Test HEAD of missing object - assert getApi().getObjectInfo(containerName, "non-existent-object") == null; - - // Test HEAD of object - MutableObjectInfoWithMetadata metadata = getApi().getObjectInfo(containerName, object.getInfo().getName()); - assertEquals(metadata.getName(), object.getInfo().getName()); - - assertEquals(metadata.getBytes(), new Long(data.length())); - assertEquals(metadata.getContentType(), "text/plain; charset=UTF-8"); - - assertEquals(CryptoStreams.hex(md5), CryptoStreams.hex(metadata.getHash())); - assertEquals(metadata.getHash(), CryptoStreams.hex(newEtag)); - assertEquals(metadata.getMetadata().entrySet().size(), 1); - assertEquals(metadata.getMetadata().get("metadata"), "metadata-value"); - - // // Test POST to update object's metadata - Map userMetadata = Maps.newHashMap(); - userMetadata.put("New-Metadata-1", "value-1"); - userMetadata.put("New-Metadata-2", "value-2"); - assertTrue(getApi().setObjectInfo(containerName, object.getInfo().getName(), userMetadata)); - - // Test GET of missing object - assert getApi().getObject(containerName, "non-existent-object") == null; - // Test GET of object (including updated metadata) - CFObject getBlob = getApi().getObject(containerName, object.getInfo().getName()); - assertEquals(Strings2.toStringAndClose(getBlob.getPayload().getInput()), data); - // TODO assertEquals(getBlob.getName(), - // object.getMetadata().getName()); - assertEquals(getBlob.getInfo().getBytes(), new Long(data.length())); - assertEquals(getBlob.getInfo().getContentType(), "text/plain; charset=UTF-8"); - assertEquals(CryptoStreams.hex(md5), CryptoStreams.hex(getBlob.getInfo().getHash())); - assertEquals(CryptoStreams.hex(newEtag), getBlob.getInfo().getHash()); - assertEquals(getBlob.getInfo().getMetadata().entrySet().size(), 2); - assertEquals(getBlob.getInfo().getMetadata().get("new-metadata-1"), "value-1"); - assertEquals(getBlob.getInfo().getMetadata().get("new-metadata-2"), "value-2"); - - // Test PUT with invalid ETag (as if object's data was corrupted in - // transit) - String correctEtag = newEtag; - String incorrectEtag = "0" + correctEtag.substring(1); - object.getInfo().setHash(CryptoStreams.hex(incorrectEtag)); - try { - getApi().putObject(containerName, object); - } catch (HttpResponseException e) { - assertEquals(e.getResponse().getStatusCode(), 422); - } - - // Test PUT chunked/streamed upload with data of "unknown" length - ByteArrayInputStream bais = new ByteArrayInputStream(data.getBytes("UTF-8")); - CFObject blob = getApi().newCFObject(); - blob.getInfo().setName("chunked-object"); - blob.setPayload(bais); - newEtag = getApi().putObject(containerName, blob); - assertEquals(CryptoStreams.hex(md5), CryptoStreams.hex(getBlob.getInfo().getHash())); - - // Test GET with options - // Non-matching ETag - try { - getApi() - .getObject(containerName, object.getInfo().getName(), - GetOptions.Builder.ifETagDoesntMatch(newEtag)); - } catch (HttpResponseException e) { - assertEquals(e.getResponse().getStatusCode(), 304); - } - - // Matching ETag - getBlob = getApi().getObject(containerName, object.getInfo().getName(), - GetOptions.Builder.ifETagMatches(newEtag)); - assertEquals(getBlob.getInfo().getHash(), CryptoStreams.hex(newEtag)); - getBlob = getApi().getObject(containerName, object.getInfo().getName(), GetOptions.Builder.startAt(8)); - assertEquals(Strings2.toStringAndClose(getBlob.getPayload().getInput()), data.substring(8)); - - } finally { - returnContainer(containerName); - } - } - - private CFObject newCFObject(String data, String key) throws IOException { - CFObject object = getApi().newCFObject(); - object.getInfo().setName(key); - object.setPayload(data); - Payloads.calculateMD5(object); - object.getInfo().setContentType("text/plain"); - object.getInfo().getMetadata().put("Metadata", "metadata-value"); - return object; - } - } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java index 0e2b54de86..d7d59f3c98 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java @@ -19,36 +19,15 @@ package org.jclouds.cloudfiles.blobstore.integration; -import org.jclouds.blobstore.domain.Blob; -import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobIntegrationLiveTest; import org.testng.annotations.Test; /** * - * @author James Murty * @author Adrian Cole */ @Test(groups = "live") -public class CloudFilesBlobIntegrationLiveTest extends BaseBlobIntegrationTest { +public class CloudFilesBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest { - @Override - @Test(enabled = false) - public void testGetTwoRanges() { - // not supported in cloud files - } - - // not supported - @Override - protected void checkContentDisposition(Blob blob, String contentDisposition) { - assert blob.getPayload().getContentMetadata().getContentDisposition() == null; - assert blob.getMetadata().getContentMetadata().getContentDisposition() == null; - } - - // not supported - @Override - protected void checkContentLanguage(Blob blob, String contentLanguage) { - assert blob.getPayload().getContentMetadata().getContentLanguage() == null; - assert blob.getMetadata().getContentMetadata().getContentLanguage() == null; - } } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java index a95162c5c0..0840caf4a8 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java @@ -19,15 +19,14 @@ package org.jclouds.cloudfiles.blobstore.integration; -import org.jclouds.blobstore.integration.internal.BaseBlobLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobLiveTest; import org.testng.annotations.Test; /** * - * @author James Murty * @author Adrian Cole */ @Test(groups = { "live" }) -public class CloudFilesBlobLiveTest extends BaseBlobLiveTest { +public class CloudFilesBlobLiveTest extends SwiftBlobLiveTest { } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobMapIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobMapIntegrationLiveTest.java index e3df266d9e..a3ce11d47e 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobMapIntegrationLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobMapIntegrationLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.cloudfiles.blobstore.integration; -import org.jclouds.blobstore.integration.internal.BaseBlobMapIntegrationTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobMapIntegrationLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live") -public class CloudFilesBlobMapIntegrationLiveTest extends BaseBlobMapIntegrationTest { +public class CloudFilesBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest { } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java index 7186575c48..9066c2881f 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java @@ -19,7 +19,7 @@ package org.jclouds.cloudfiles.blobstore.integration; -import org.jclouds.blobstore.integration.internal.BaseBlobSignerLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobSignerLiveTest; import org.testng.annotations.Test; /** @@ -27,6 +27,6 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = { "live" }) -public class CloudFilesBlobSignerLiveTest extends BaseBlobSignerLiveTest { +public class CloudFilesBlobSignerLiveTest extends SwiftBlobSignerLiveTest { } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerIntegrationLiveTest.java index cfddc6dba2..0d0a5375fb 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerIntegrationLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerIntegrationLiveTest.java @@ -19,14 +19,13 @@ package org.jclouds.cloudfiles.blobstore.integration; -import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftContainerIntegrationLiveTest; import org.testng.annotations.Test; /** - * @author James Murty * @author Adrian Cole */ @Test(groups = "live") -public class CloudFilesContainerIntegrationLiveTest extends BaseContainerIntegrationTest { +public class CloudFilesContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest { } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerLiveTest.java index fa3d3054b6..d91a6a7d61 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerLiveTest.java @@ -19,14 +19,13 @@ package org.jclouds.cloudfiles.blobstore.integration; -import org.jclouds.blobstore.integration.internal.BaseContainerLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftContainerLiveTest; import org.testng.annotations.Test; /** - * @author James Murty * @author Adrian Cole */ @Test(groups = { "live" }) -public class CloudFilesContainerLiveTest extends BaseContainerLiveTest { +public class CloudFilesContainerLiveTest extends SwiftContainerLiveTest { } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesInputStreamMapIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesInputStreamMapIntegrationLiveTest.java index 3164db1c8a..023cf1ab36 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesInputStreamMapIntegrationLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesInputStreamMapIntegrationLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.cloudfiles.blobstore.integration; -import org.jclouds.blobstore.integration.internal.BaseInputStreamMapIntegrationTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftInputStreamMapIntegrationLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live") -public class CloudFilesInputStreamMapIntegrationLiveTest extends BaseInputStreamMapIntegrationTest { +public class CloudFilesInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest { } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java index 9e804eb5b3..c4638d2705 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.cloudfiles.blobstore.integration; -import org.jclouds.blobstore.integration.internal.BaseServiceIntegrationTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftServiceIntegrationLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live") -public class CloudFilesServiceIntegrationLiveTest extends BaseServiceIntegrationTest { +public class CloudFilesServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest { } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesTestInitializer.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesTestInitializer.java index 20d51a5cea..1fbccef88b 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesTestInitializer.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesTestInitializer.java @@ -19,31 +19,17 @@ package org.jclouds.cloudfiles.blobstore.integration; -import java.io.IOException; - -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; -import org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; +import org.jclouds.openstack.swift.blobstore.integration.SwiftTestInitializer; /** * * @author Adrian Cole */ -public class CloudFilesTestInitializer extends TransientBlobStoreTestInitializer { +public class CloudFilesTestInitializer extends SwiftTestInitializer { public CloudFilesTestInitializer() { provider = "cloudfiles"; } - @Override - protected BlobStoreContext createLiveContext(Module configurationModule, String endpoint, String apiversion, - String app, String identity, String credential) throws IOException { - return new BlobStoreContextFactory().createContext(provider, ImmutableSet.of(configurationModule, - new Log4JLoggingModule()), setupProperties(endpoint, apiversion, identity, credential)); - } } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/functions/ParseContainerCDNMetadataListFromJsonResponseTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/functions/ParseContainerCDNMetadataListFromJsonResponseTest.java index c2fd177406..fca141bbc0 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/functions/ParseContainerCDNMetadataListFromJsonResponseTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/functions/ParseContainerCDNMetadataListFromJsonResponseTest.java @@ -26,12 +26,11 @@ import java.net.URI; import java.util.Set; import java.util.SortedSet; +import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.ParseJson; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; -import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; -import org.jclouds.rackspace.config.RackspaceParserModule; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSortedSet; @@ -47,7 +46,7 @@ import com.google.inject.TypeLiteral; */ @Test(groups = "unit") public class ParseContainerCDNMetadataListFromJsonResponseTest { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new GsonModule()); @Test public void testApplyInputStream() { @@ -56,13 +55,13 @@ public class ParseContainerCDNMetadataListFromJsonResponseTest { Set expects = ImmutableSortedSet.of( new ContainerCDNMetadata("adriancole-blobstore.testCDNOperationsContainerWithCDN", false, 3600, URI - .create("http://c0354712.cdn.cloudfiles.rackspacecloud.com")), new ContainerCDNMetadata( - "adriancole-blobstore5", true, 28800, URI.create("http://c0404671.cdn.cloudfiles.rackspacecloud.com")), - new ContainerCDNMetadata("adriancole-cfcdnint.testCDNOperationsContainerWithCDN", false, 3600, URI - .create("http://c0320431.cdn.cloudfiles.rackspacecloud.com"))); + .create("http://c0354712.cdn.cloudfiles.rackspacecloud.com")), new ContainerCDNMetadata( + "adriancole-blobstore5", true, 28800, URI.create("http://c0404671.cdn.cloudfiles.rackspacecloud.com")), + new ContainerCDNMetadata("adriancole-cfcdnint.testCDNOperationsContainerWithCDN", false, 3600, URI + .create("http://c0320431.cdn.cloudfiles.rackspacecloud.com"))); ParseJson> parser = i.getInstance(Key - .get(new TypeLiteral>>() { - })); + .get(new TypeLiteral>>() { + })); assertEquals(parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))), expects); } } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java new file mode 100644 index 0000000000..ff3dd60f92 --- /dev/null +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java @@ -0,0 +1,289 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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; + +import static org.jclouds.openstack.swift.options.ListContainerOptions.Builder.underPath; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; + +import org.jclouds.blobstore.domain.PageSet; +import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; +import org.jclouds.crypto.CryptoStreams; +import org.jclouds.http.HttpResponseException; +import org.jclouds.http.options.GetOptions; +import org.jclouds.io.Payloads; +import org.jclouds.openstack.swift.CommonSwiftClient; +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.ListContainerOptions; +import org.jclouds.util.Strings2; +import org.testng.annotations.Test; + +import com.google.common.collect.Iterables; +import com.google.common.collect.Maps; + +/** + * Tests behavior of {@code JaxrsAnnotationProcessor} + * + * @author Adrian Cole + */ +@Test(groups = "live") +public class SwiftClientLiveTest extends BaseBlobStoreIntegrationTest { + + public CommonSwiftClient getApi() { + return (CommonSwiftClient) context.getProviderSpecificContext().getApi(); + } + + /** + * this method overrides containerName to ensure it isn't found + */ + @Test(groups = { "integration", "live" }) + public void deleteContainerIfEmptyNotFound() throws Exception { + assert getApi().deleteContainerIfEmpty("dbienf"); + } + + @Test + public void testListOwnedContainers() throws Exception { + String containerPrefix = getContainerName(); + try { + Set response = getApi().listContainers(); + assertNotNull(response); + long initialContainerCount = response.size(); + assertTrue(initialContainerCount >= 0); + + // Create test containers + String[] containerNames = new String[] { containerPrefix + ".testListOwnedContainers1", + containerPrefix + ".testListOwnedContainers2" }; + assertTrue(getApi().createContainer(containerNames[0])); + assertTrue(getApi().createContainer(containerNames[1])); + + // Test default listing + response = getApi().listContainers(); + // assertEquals(response.size(), initialContainerCount + 2);// if the + // containers already + // exist, this will fail + + // Test listing with options + response = getApi().listContainers( + ListContainerOptions.Builder.afterMarker( + containerNames[0].substring(0, containerNames[0].length() - 1)).maxResults(1)); + assertEquals(response.size(), 1); + assertEquals(Iterables.get(response, 0).getName(), containerNames[0]); + + response = getApi().listContainers(ListContainerOptions.Builder.afterMarker(containerNames[0]).maxResults(1)); + assertEquals(response.size(), 1); + assertEquals(Iterables.get(response, 0).getName(), containerNames[1]); + + // Cleanup and test containers have been removed + assertTrue(getApi().deleteContainerIfEmpty(containerNames[0])); + assertTrue(getApi().deleteContainerIfEmpty(containerNames[1])); + response = getApi().listContainers(); + // assertEquals(response.size(), initialContainerCount + 2);// if the + // containers already + // exist, this will fail + } finally { + returnContainer(containerPrefix); + } + } + + @Test + public void testHeadAccountMetadata() throws Exception { + String containerPrefix = getContainerName(); + String containerName = containerPrefix + ".testHeadAccountMetadata"; + try { + AccountMetadata metadata = getApi().getAccountStatistics(); + assertNotNull(metadata); + long initialContainerCount = metadata.getContainerCount(); + + assertTrue(getApi().createContainer(containerName)); + + metadata = getApi().getAccountStatistics(); + assertNotNull(metadata); + assertTrue(metadata.getContainerCount() >= initialContainerCount); + + assertTrue(getApi().deleteContainerIfEmpty(containerName)); + } finally { + returnContainer(containerPrefix); + } + } + + @Test + public void testPutContainers() throws Exception { + String containerName = getContainerName(); + try { + String containerName1 = containerName + ".hello"; + assertTrue(getApi().createContainer(containerName1)); + // List only the container just created, using a marker with the + // container name less 1 char + Set response = getApi().listContainers( + ListContainerOptions.Builder.afterMarker(containerName1.substring(0, containerName1.length() - 1)) + .maxResults(1)); + assertNotNull(response); + assertEquals(response.size(), 1); + assertEquals(Iterables.get(response, 0).getName(), containerName + ".hello"); + + String containerName2 = containerName + "?should-be-illegal-question-char"; + assert getApi().createContainer(containerName2); + + assert getApi().createContainer(containerName + "/illegal-slash-char"); + + assertTrue(getApi().deleteContainerIfEmpty(containerName1)); + assertTrue(getApi().deleteContainerIfEmpty(containerName2)); + } finally { + returnContainer(containerName); + } + } + + public void testListContainerPath() throws InterruptedException, ExecutionException, TimeoutException, IOException { + String containerName = getContainerName(); + try { + + String data = "foo"; + + getApi().putObject(containerName, newSwiftObject(data, "foo")); + getApi().putObject(containerName, newSwiftObject(data, "path/bar")); + + PageSet container = getApi().listObjects(containerName, underPath("")); + assert container.getNextMarker() == null; + assertEquals(container.size(), 1); + assertEquals(Iterables.get(container, 0).getName(), "foo"); + container = getApi().listObjects(containerName, underPath("path")); + assert container.getNextMarker() == null; + assertEquals(container.size(), 1); + assertEquals(Iterables.get(container, 0).getName(), "path/bar"); + } finally { + returnContainer(containerName); + } + + } + + @Test + public void testObjectOperations() throws Exception { + String containerName = getContainerName(); + try { + // Test PUT with string data, ETag hash, and a piece of metadata + String data = "Here is my data"; + String key = "object"; + SwiftObject object = newSwiftObject(data, key); + byte[] md5 = object.getPayload().getContentMetadata().getContentMD5(); + String newEtag = getApi().putObject(containerName, object); + assert newEtag != null; + assertEquals(CryptoStreams.hex(md5), CryptoStreams.hex(object.getPayload().getContentMetadata() + .getContentMD5())); + + // Test HEAD of missing object + assert getApi().getObjectInfo(containerName, "non-existent-object") == null; + + // Test HEAD of object + MutableObjectInfoWithMetadata metadata = getApi().getObjectInfo(containerName, object.getInfo().getName()); + assertEquals(metadata.getName(), object.getInfo().getName()); + + assertEquals(metadata.getBytes(), new Long(data.length())); + assertEquals(metadata.getContentType(), "text/plain; charset=UTF-8"); + + assertEquals(CryptoStreams.hex(md5), CryptoStreams.hex(metadata.getHash())); + assertEquals(metadata.getHash(), CryptoStreams.hex(newEtag)); + assertEquals(metadata.getMetadata().entrySet().size(), 1); + assertEquals(metadata.getMetadata().get("metadata"), "metadata-value"); + + // // Test POST to update object's metadata + Map userMetadata = Maps.newHashMap(); + userMetadata.put("New-Metadata-1", "value-1"); + userMetadata.put("New-Metadata-2", "value-2"); + assertTrue(getApi().setObjectInfo(containerName, object.getInfo().getName(), userMetadata)); + + // Test GET of missing object + assert getApi().getObject(containerName, "non-existent-object") == null; + // Test GET of object (including updated metadata) + SwiftObject getBlob = getApi().getObject(containerName, object.getInfo().getName()); + assertEquals(Strings2.toStringAndClose(getBlob.getPayload().getInput()), data); + // TODO assertEquals(getBlob.getName(), + // object.getMetadata().getName()); + assertEquals(getBlob.getInfo().getBytes(), new Long(data.length())); + assertEquals(getBlob.getInfo().getContentType(), "text/plain; charset=UTF-8"); + assertEquals(CryptoStreams.hex(md5), CryptoStreams.hex(getBlob.getInfo().getHash())); + assertEquals(CryptoStreams.hex(newEtag), getBlob.getInfo().getHash()); + assertEquals(getBlob.getInfo().getMetadata().entrySet().size(), 2); + assertEquals(getBlob.getInfo().getMetadata().get("new-metadata-1"), "value-1"); + assertEquals(getBlob.getInfo().getMetadata().get("new-metadata-2"), "value-2"); + + // Test PUT with invalid ETag (as if object's data was corrupted in + // transit) + String correctEtag = newEtag; + String incorrectEtag = "0" + correctEtag.substring(1); + object.getInfo().setHash(CryptoStreams.hex(incorrectEtag)); + try { + getApi().putObject(containerName, object); + } catch (HttpResponseException e) { + assertEquals(e.getResponse().getStatusCode(), 422); + } + + // Test PUT chunked/streamed upload with data of "unknown" length + ByteArrayInputStream bais = new ByteArrayInputStream(data.getBytes("UTF-8")); + SwiftObject blob = getApi().newSwiftObject(); + blob.getInfo().setName("chunked-object"); + blob.setPayload(bais); + newEtag = getApi().putObject(containerName, blob); + assertEquals(CryptoStreams.hex(md5), CryptoStreams.hex(getBlob.getInfo().getHash())); + + // Test GET with options + // Non-matching ETag + try { + getApi() + .getObject(containerName, object.getInfo().getName(), + GetOptions.Builder.ifETagDoesntMatch(newEtag)); + } catch (HttpResponseException e) { + assertEquals(e.getResponse().getStatusCode(), 304); + } + + // Matching ETag + getBlob = getApi().getObject(containerName, object.getInfo().getName(), + GetOptions.Builder.ifETagMatches(newEtag)); + assertEquals(getBlob.getInfo().getHash(), CryptoStreams.hex(newEtag)); + getBlob = getApi().getObject(containerName, object.getInfo().getName(), GetOptions.Builder.startAt(8)); + assertEquals(Strings2.toStringAndClose(getBlob.getPayload().getInput()), data.substring(8)); + + } finally { + returnContainer(containerName); + } + } + + private SwiftObject newSwiftObject(String data, String key) throws IOException { + SwiftObject object = getApi().newSwiftObject(); + object.getInfo().setName(key); + object.setPayload(data); + Payloads.calculateMD5(object); + object.getInfo().setContentType("text/plain"); + object.getInfo().getMetadata().put("Metadata", "metadata-value"); + return object; + } + +} diff --git a/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/SwiftClientTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/SwiftClientTest.java new file mode 100644 index 0000000000..a1a3879bb4 --- /dev/null +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/SwiftClientTest.java @@ -0,0 +1,93 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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; + +import static org.jclouds.Constants.PROPERTY_API_VERSION; +import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.RequiresHttp; +import org.jclouds.openstack.TestOpenStackAuthenticationModule; +import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse; +import org.jclouds.openstack.swift.CommonSwiftAsyncClient; +import org.jclouds.openstack.swift.CommonSwiftClient; +import org.jclouds.openstack.swift.config.BaseSwiftRestClientModule; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.RestClientTest; +import org.jclouds.rest.RestContextFactory; +import org.jclouds.rest.RestContextSpec; +import org.testng.annotations.Test; + +import com.google.inject.Module; + +/** + * Tests behavior of {@code BindSwiftObjectMetadataToRequest} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "SwiftClientTest") +public abstract class SwiftClientTest extends RestClientTest { + + @Override + protected void checkFilters(HttpRequest request) { + } + + @Override + protected Module createModule() { + return new TestSwiftRestClientModule(); + } + + @ConfiguresRestClient + @RequiresHttp + protected static class TestSwiftRestClientModule extends + BaseSwiftRestClientModule { + private TestSwiftRestClientModule() { + super(new TestOpenStackAuthenticationModule(), CommonSwiftClient.class, CommonSwiftAsyncClient.class); + } + + @Override + protected URI provideStorageUrl(AuthenticationResponse response) { + return URI.create("http://storage"); + } + + } + + protected String provider = "swift"; + + @Override + public RestContextSpec createContextSpec() { + return new RestContextFactory().createContextSpec(provider, "user", "password", new Properties()); + } + + @Override + protected Properties getProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_REGIONS, "US"); + properties.setProperty(PROPERTY_ENDPOINT, "https://auth"); + properties.setProperty(PROPERTY_API_VERSION, "1"); + return properties; + } + +} \ No newline at end of file diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/binders/BindCFObjectMetadataToRequestTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequestTest.java similarity index 58% rename from apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/binders/BindCFObjectMetadataToRequestTest.java rename to apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequestTest.java index 6dda5d2e10..6660739e97 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/binders/BindCFObjectMetadataToRequestTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequestTest.java @@ -17,24 +17,21 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.binders; +package org.jclouds.openstack.swift.binders; import static org.testng.Assert.assertEquals; import java.io.File; import java.net.URI; -import java.util.Properties; import javax.ws.rs.HttpMethod; import org.jclouds.http.HttpRequest; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; -import org.jclouds.cloudfiles.CloudFilesAsyncClient; -import org.jclouds.cloudfiles.domain.CFObject; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.openstack.swift.CommonSwiftAsyncClient; +import org.jclouds.openstack.swift.SwiftClientTest; +import org.jclouds.openstack.swift.domain.SwiftObject; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -43,32 +40,37 @@ import com.google.common.collect.ImmutableMultimap; import com.google.inject.TypeLiteral; /** - * Tests behavior of {@code BindCFObjectMetadataToRequest} + * Tests behavior of {@code BindSwiftObjectMetadataToRequest} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "BindCFObjectMetadataToRequestTest") -public class BindCFObjectMetadataToRequestTest extends RestClientTest { +@Test(groups = "unit", testName = "BindSwiftObjectMetadataToRequestTest") +public class BindSwiftObjectMetadataToRequestTest extends SwiftClientTest { + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } @Test public void testPassWithMinimumDetailsAndPayload5GB() { - CFObject object = injector.getInstance(CFObject.Factory.class).create(null); + SwiftObject object = injector.getInstance(SwiftObject.Factory.class).create(null); Payload payload = Payloads.newStringPayload(""); payload.getContentMetadata().setContentLength(5 * 1024 * 1024 * 1024l); object.setPayload(payload); object.getInfo().setName("foo"); HttpRequest request = HttpRequest.builder().method("PUT").endpoint(URI.create("http://localhost")).build(); - BindCFObjectMetadataToRequest binder = injector.getInstance(BindCFObjectMetadataToRequest.class); + BindSwiftObjectMetadataToRequest binder = injector.getInstance(BindSwiftObjectMetadataToRequest.class); - assertEquals(binder.bindToRequest(request, object), - HttpRequest.builder().method("PUT").endpoint(URI.create("http://localhost")).build()); + assertEquals(binder.bindToRequest(request, object), HttpRequest.builder().method("PUT").endpoint( + URI.create("http://localhost")).build()); } @Test public void testExtendedPropertiesBind() { - CFObject object = injector.getInstance(CFObject.Factory.class).create(null); + SwiftObject object = injector.getInstance(SwiftObject.Factory.class).create(null); Payload payload = Payloads.newStringPayload(""); payload.getContentMetadata().setContentLength(5 * 1024 * 1024 * 1024l); object.setPayload(payload); @@ -76,80 +78,62 @@ public class BindCFObjectMetadataToRequestTest extends RestClientTest> createTypeLiteral() { - return new TypeLiteral>() { - }; - } - - @Override - public RestContextSpec createContextSpec() { - return new RestContextFactory().createContextSpec("cloudfiles", "identity", "credential", new Properties()); - } } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobRequestSignerTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobRequestSignerTest.java similarity index 69% rename from apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobRequestSignerTest.java rename to apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobRequestSignerTest.java index 935b45c307..4134862bed 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobRequestSignerTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobRequestSignerTest.java @@ -17,38 +17,37 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore; +package org.jclouds.openstack.swift.blobstore; import static org.testng.Assert.assertEquals; import java.io.IOException; -import java.util.Properties; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; -import org.jclouds.cloudfiles.CloudFilesAsyncClient; -import org.jclouds.cloudfiles.config.CloudFilesRestClientModule; import org.jclouds.http.HttpRequest; -import org.jclouds.rackspace.TestRackspaceAuthenticationRestClientModule; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.openstack.swift.CommonSwiftAsyncClient; +import org.jclouds.openstack.swift.SwiftClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.inject.Module; import com.google.inject.TypeLiteral; /** - * Tests behavior of {@code CloudFilesBlobRequestSigner} + * Tests behavior of {@code CommonSwiftBlobRequestSigner} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "CloudFilesBlobRequestSignerTest") -public class CloudFilesBlobRequestSignerTest extends RestClientTest { +@Test(groups = "unit", testName = "SwiftBlobRequestSignerTest") +public class SwiftBlobRequestSignerTest extends SwiftClientTest { + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } private BlobRequestSigner signer; private Factory blobFactory; @@ -57,7 +56,7 @@ public class CloudFilesBlobRequestSignerTest extends RestClientTest> createTypeLiteral() { - return new TypeLiteral>() { - }; - } - - @Override - protected Module createModule() { - return new CloudFilesRestClientModule(new TestRackspaceAuthenticationRestClientModule()); - } - - @Override - public RestContextSpec createContextSpec() { - return new RestContextFactory().createContextSpec("cloudfiles", "identity", "credential", new Properties()); - } - } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/functions/ListContainerOptionsToBlobStoreListContainerOptions.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/functions/ListContainerOptionsToBlobStoreListContainerOptions.java similarity index 87% rename from apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/functions/ListContainerOptionsToBlobStoreListContainerOptions.java rename to apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/functions/ListContainerOptionsToBlobStoreListContainerOptions.java index f1bc9dbd64..827fa75358 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/functions/ListContainerOptionsToBlobStoreListContainerOptions.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/functions/ListContainerOptionsToBlobStoreListContainerOptions.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore.functions; +package org.jclouds.openstack.swift.blobstore.functions; import javax.inject.Singleton; @@ -31,9 +31,9 @@ import com.google.common.base.Function; @Singleton public class ListContainerOptionsToBlobStoreListContainerOptions implements - Function { + Function { public ListContainerOptions apply( - org.jclouds.cloudfiles.options.ListContainerOptions[] optionsList) { + org.jclouds.openstack.swift.options.ListContainerOptions[] optionsList) { ListContainerOptions options = new ListContainerOptions(); if (optionsList.length != 0) { if (optionsList[0].getPath() != null && !optionsList[0].getPath().equals("")) { diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/functions/ResourceToObjectList.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/functions/ResourceToObjectList.java similarity index 90% rename from apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/functions/ResourceToObjectList.java rename to apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/functions/ResourceToObjectList.java index a042d6372d..7e8966411b 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/functions/ResourceToObjectList.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/functions/ResourceToObjectList.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.blobstore.functions; +package org.jclouds.openstack.swift.blobstore.functions; import javax.inject.Inject; import javax.inject.Singleton; @@ -25,7 +25,8 @@ import javax.inject.Singleton; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.internal.PageSetImpl; -import org.jclouds.cloudfiles.domain.ObjectInfo; +import org.jclouds.openstack.swift.blobstore.functions.ResourceToObjectInfo; +import org.jclouds.openstack.swift.domain.ObjectInfo; import com.google.common.base.Function; import com.google.common.collect.Iterables; diff --git a/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java new file mode 100644 index 0000000000..b3cb1fb94b --- /dev/null +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java @@ -0,0 +1,54 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.blobstore.integration; + +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest; +import org.testng.annotations.Test; + +/** + * + * @author James Murty + * @author Adrian Cole + */ +@Test(groups = "live") +public class SwiftBlobIntegrationLiveTest extends BaseBlobIntegrationTest { + + @Override + @Test(enabled = false) + public void testGetTwoRanges() { + // not supported in cloud files + } + + // not supported + @Override + protected void checkContentDisposition(Blob blob, String contentDisposition) { + assert blob.getPayload().getContentMetadata().getContentDisposition() == null; + assert blob.getMetadata().getContentMetadata().getContentDisposition() == null; + } + + // not supported + @Override + protected void checkContentLanguage(Blob blob, String contentLanguage) { + assert blob.getPayload().getContentMetadata().getContentLanguage() == null; + assert blob.getMetadata().getContentMetadata().getContentLanguage() == null; + } + +} diff --git a/common/rackspace/src/main/java/org/jclouds/rackspace/config/RackspaceParserModule.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobLiveTest.java similarity index 68% rename from common/rackspace/src/main/java/org/jclouds/rackspace/config/RackspaceParserModule.java rename to apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobLiveTest.java index 4c15552a6b..5c00b4dd4c 100644 --- a/common/rackspace/src/main/java/org/jclouds/rackspace/config/RackspaceParserModule.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobLiveTest.java @@ -17,22 +17,17 @@ * ==================================================================== */ -package org.jclouds.rackspace.config; +package org.jclouds.openstack.swift.blobstore.integration; -import org.jclouds.json.config.GsonModule.DateAdapter; -import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; - -import com.google.inject.AbstractModule; +import org.jclouds.blobstore.integration.internal.BaseBlobLiveTest; +import org.testng.annotations.Test; /** * + * @author James Murty * @author Adrian Cole */ -public class RackspaceParserModule extends AbstractModule { +@Test(groups = { "live" }) +public class SwiftBlobLiveTest extends BaseBlobLiveTest { - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - } - -} \ No newline at end of file +} diff --git a/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobMapIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobMapIntegrationLiveTest.java new file mode 100644 index 0000000000..ffa8c90363 --- /dev/null +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobMapIntegrationLiveTest.java @@ -0,0 +1,31 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.blobstore.integration; + +import org.jclouds.blobstore.integration.internal.BaseBlobMapIntegrationTest; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "live") +public class SwiftBlobMapIntegrationLiveTest extends BaseBlobMapIntegrationTest { + +} diff --git a/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobSignerLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobSignerLiveTest.java new file mode 100644 index 0000000000..f55d5cb13f --- /dev/null +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobSignerLiveTest.java @@ -0,0 +1,32 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.blobstore.integration; + +import org.jclouds.blobstore.integration.internal.BaseBlobSignerLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = { "live" }) +public class SwiftBlobSignerLiveTest extends BaseBlobSignerLiveTest { + +} diff --git a/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerIntegrationLiveTest.java new file mode 100644 index 0000000000..7a63d26405 --- /dev/null +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerIntegrationLiveTest.java @@ -0,0 +1,32 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.blobstore.integration; + +import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest; +import org.testng.annotations.Test; + +/** + * @author James Murty + * @author Adrian Cole + */ +@Test(groups = "live") +public class SwiftContainerIntegrationLiveTest extends BaseContainerIntegrationTest { + +} diff --git a/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java new file mode 100644 index 0000000000..b24808b277 --- /dev/null +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java @@ -0,0 +1,32 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.blobstore.integration; + +import org.jclouds.blobstore.integration.internal.BaseContainerLiveTest; +import org.testng.annotations.Test; + +/** + * @author James Murty + * @author Adrian Cole + */ +@Test(groups = { "live" }) +public class SwiftContainerLiveTest extends BaseContainerLiveTest { + +} diff --git a/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftInputStreamMapIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftInputStreamMapIntegrationLiveTest.java new file mode 100644 index 0000000000..c881ce69ca --- /dev/null +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftInputStreamMapIntegrationLiveTest.java @@ -0,0 +1,31 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.blobstore.integration; + +import org.jclouds.blobstore.integration.internal.BaseInputStreamMapIntegrationTest; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "live") +public class SwiftInputStreamMapIntegrationLiveTest extends BaseInputStreamMapIntegrationTest { + +} diff --git a/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftServiceIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftServiceIntegrationLiveTest.java new file mode 100644 index 0000000000..81dffccf66 --- /dev/null +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftServiceIntegrationLiveTest.java @@ -0,0 +1,31 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.blobstore.integration; + +import org.jclouds.blobstore.integration.internal.BaseServiceIntegrationTest; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "live") +public class SwiftServiceIntegrationLiveTest extends BaseServiceIntegrationTest { + +} diff --git a/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftTestInitializer.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftTestInitializer.java new file mode 100644 index 0000000000..2413ee3ccd --- /dev/null +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftTestInitializer.java @@ -0,0 +1,49 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.blobstore.integration; + +import java.io.IOException; + +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer; +import org.jclouds.logging.log4j.config.Log4JLoggingModule; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; + +/** + * + * @author Adrian Cole + */ +public class SwiftTestInitializer extends TransientBlobStoreTestInitializer { + + public SwiftTestInitializer() { + provider = "swift"; + } + + @Override + protected BlobStoreContext createLiveContext(Module configurationModule, String endpoint, String apiversion, + String app, String identity, String credential) throws IOException { + return new BlobStoreContextFactory().createContext(provider, ImmutableSet.of(configurationModule, + new Log4JLoggingModule()), setupProperties(endpoint, apiversion, identity, credential)); + } + +} diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/domain/internal/ParseObjectInfoListFromJsonResponseTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/domain/internal/ParseObjectInfoListFromJsonResponseTest.java similarity index 80% rename from apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/domain/internal/ParseObjectInfoListFromJsonResponseTest.java rename to apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/domain/internal/ParseObjectInfoListFromJsonResponseTest.java index f8bfa4cc14..06df1d4d3f 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/domain/internal/ParseObjectInfoListFromJsonResponseTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/domain/internal/ParseObjectInfoListFromJsonResponseTest.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.domain.internal; +package org.jclouds.openstack.swift.domain.internal; import static org.easymock.EasyMock.expect; import static org.easymock.classextension.EasyMock.createMock; @@ -30,15 +30,17 @@ import java.util.Set; import org.jclouds.crypto.CryptoStreams; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.config.GsonModule; -import org.jclouds.cloudfiles.domain.ObjectInfo; -import org.jclouds.cloudfiles.functions.ParseObjectInfoListFromJsonResponse; -import org.jclouds.cloudfiles.options.ListContainerOptions; -import org.jclouds.rackspace.config.RackspaceParserModule; +import org.jclouds.json.config.GsonModule.DateAdapter; +import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; +import org.jclouds.openstack.swift.domain.ObjectInfo; +import org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse; +import org.jclouds.openstack.swift.options.ListContainerOptions; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; +import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; @@ -50,7 +52,14 @@ import com.google.inject.Injector; @Test(groups = "unit") public class ParseObjectInfoListFromJsonResponseTest { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new AbstractModule() { + + @Override + protected void configure() { + bind(DateAdapter.class).to(Iso8601DateAdapter.class); + } + + }, new GsonModule()); public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/test_list_container.json"); @@ -72,7 +81,7 @@ public class ParseObjectInfoListFromJsonResponseTest { GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); ListContainerOptions options = new ListContainerOptions(); expect(request.getArgs()).andReturn( - ImmutableList. of("containter", new ListContainerOptions[] { options })).atLeastOnce(); + ImmutableList. of("containter", new ListContainerOptions[] { options })).atLeastOnce(); replay(request); ParseObjectInfoListFromJsonResponse parser = i.getInstance(ParseObjectInfoListFromJsonResponse.class); parser.setContext(request); diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/functions/ParseAuthenticationResponseFromHeadersTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/functions/ParseAuthenticationResponseFromHeadersTest.java similarity index 77% rename from apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/functions/ParseAuthenticationResponseFromHeadersTest.java rename to apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/functions/ParseAuthenticationResponseFromHeadersTest.java index 8ec27cfc12..3835a68586 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/functions/ParseAuthenticationResponseFromHeadersTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/functions/ParseAuthenticationResponseFromHeadersTest.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.functions; +package org.jclouds.openstack.swift.functions; import static org.testng.Assert.assertEquals; @@ -27,12 +27,12 @@ import javax.ws.rs.core.UriBuilder; import org.jclouds.Constants; import org.jclouds.blobstore.reference.BlobStoreConstants; -import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.rackspace.RackspaceAuthAsyncClient.AuthenticationResponse; -import org.jclouds.rackspace.functions.ParseAuthenticationResponseFromHeaders; +import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse; +import org.jclouds.openstack.functions.ParseAuthenticationResponseFromHeaders; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.inject.AbstractModule; import com.google.inject.Guice; @@ -61,16 +61,12 @@ public class ParseAuthenticationResponseFromHeadersTest { public void testReplaceLocalhost() { ParseAuthenticationResponseFromHeaders parser = i.getInstance(ParseAuthenticationResponseFromHeaders.class); - HttpRequest request = new HttpRequest("GET", URI.create("http://realhost:11000/v1.0")); - parser.setContext(request); HttpResponse response = new HttpResponse(204, "No Content", null, ImmutableMultimap. of( - "X-Auth-Token", "token", "X-Storage-Token", "token", "X-Storage-Url", "http://127.0.0.1:8080/v1/token")); + "X-Auth-Token", "token", "X-Storage-Token", "token", "X-Storage-Url", "http://127.0.0.1:8080/v1/token")); AuthenticationResponse md = parser.apply(response); - assertEquals( - md, - new ParseAuthenticationResponseFromHeaders.AuthenticationResponseImpl("token", null, null, URI - .create("http://realhost:8080/v1/token"))); + assertEquals(md, new AuthenticationResponse("token", ImmutableMap. of("X-Storage-Url", URI + .create("http://127.0.0.1:8080/v1/token")))); } } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/functions/ParseContainerListFromJsonResponseTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/functions/ParseContainerListFromJsonResponseTest.java similarity index 77% rename from apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/functions/ParseContainerListFromJsonResponseTest.java rename to apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/functions/ParseContainerListFromJsonResponseTest.java index cec7416e3f..b295770d54 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/functions/ParseContainerListFromJsonResponseTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/functions/ParseContainerListFromJsonResponseTest.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.functions; +package org.jclouds.openstack.swift.functions; import static org.testng.Assert.assertEquals; @@ -28,8 +28,7 @@ import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.ParseJson; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; -import org.jclouds.cloudfiles.domain.ContainerMetadata; -import org.jclouds.rackspace.config.RackspaceParserModule; +import org.jclouds.openstack.swift.domain.ContainerMetadata; import org.jclouds.util.Strings2; import org.testng.annotations.Test; @@ -46,18 +45,18 @@ import com.google.inject.TypeLiteral; */ @Test(groups = "unit") public class ParseContainerListFromJsonResponseTest { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new GsonModule()); @Test public void testApplyInputStream() { InputStream is = Strings2 - .toInputStream("[ {\"name\":\"test_container_1\",\"count\":2,\"bytes\":78}, {\"name\":\"test_container_2\",\"count\":1,\"bytes\":17} ] "); + .toInputStream("[ {\"name\":\"test_container_1\",\"count\":2,\"bytes\":78}, {\"name\":\"test_container_2\",\"count\":1,\"bytes\":17} ] "); List expects = ImmutableList.of(new ContainerMetadata("test_container_1", 2, 78), - new ContainerMetadata("test_container_2", 1, 17)); + new ContainerMetadata("test_container_2", 1, 17)); ParseJson> parser = i.getInstance(Key - .get(new TypeLiteral>>() { - })); + .get(new TypeLiteral>>() { + })); assertEquals(parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))), expects); } } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/functions/ParseObjectInfoFromHeadersTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoFromHeadersTest.java similarity index 93% rename from apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/functions/ParseObjectInfoFromHeadersTest.java rename to apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoFromHeadersTest.java index d970371611..cd6e11c896 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/functions/ParseObjectInfoFromHeadersTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoFromHeadersTest.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.functions; +package org.jclouds.openstack.swift.functions; import static org.easymock.EasyMock.expect; import static org.easymock.classextension.EasyMock.createMock; @@ -30,7 +30,8 @@ import org.jclouds.Constants; import org.jclouds.blobstore.reference.BlobStoreConstants; import org.jclouds.http.HttpResponse; import org.jclouds.io.Payloads; -import org.jclouds.cloudfiles.domain.MutableObjectInfoWithMetadata; +import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata; +import org.jclouds.openstack.swift.functions.ParseObjectInfoFromHeaders; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/handlers/ParseCloudFilesErrorFromHttpResponseTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/handlers/ParseSwiftErrorFromHttpResponseTest.java similarity index 76% rename from apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/handlers/ParseCloudFilesErrorFromHttpResponseTest.java rename to apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/handlers/ParseSwiftErrorFromHttpResponseTest.java index d4fff3592c..6afc645978 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/handlers/ParseCloudFilesErrorFromHttpResponseTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/handlers/ParseSwiftErrorFromHttpResponseTest.java @@ -1,4 +1,23 @@ -package org.jclouds.cloudfiles.handlers; +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.handlers; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.reportMatcher; @@ -15,6 +34,7 @@ import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.io.Payloads; +import org.jclouds.openstack.swift.handlers.ParseSwiftErrorFromHttpResponse; import org.jclouds.util.Strings2; import org.testng.annotations.Test; @@ -23,7 +43,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = { "unit" }) -public class ParseCloudFilesErrorFromHttpResponseTest { +public class ParseSwiftErrorFromHttpResponseTest { @Test public void test404SetsKeyNotFoundExceptionMosso() { @@ -61,7 +81,7 @@ public class ParseCloudFilesErrorFromHttpResponseTest { private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType, String content, Class expected) { - ParseCloudFilesErrorFromHttpResponse function = new ParseCloudFilesErrorFromHttpResponse(); + ParseSwiftErrorFromHttpResponse function = new ParseSwiftErrorFromHttpResponse(); HttpCommand command = createMock(HttpCommand.class); HttpRequest request = new HttpRequest(method, uri); diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/internal/StubCloudFilesAsyncClient.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/internal/StubSwiftAsyncClient.java similarity index 81% rename from apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/internal/StubCloudFilesAsyncClient.java rename to apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/internal/StubSwiftAsyncClient.java index 9241924990..073bdd42db 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/internal/StubCloudFilesAsyncClient.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/internal/StubSwiftAsyncClient.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.internal; +package org.jclouds.openstack.swift.internal; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.util.concurrent.Futures.immediateFuture; @@ -39,21 +39,21 @@ import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; +import org.jclouds.cloudfiles.options.ListCdnContainerOptions; import org.jclouds.concurrent.Futures; import org.jclouds.http.options.GetOptions; -import org.jclouds.cloudfiles.CloudFilesAsyncClient; -import org.jclouds.cloudfiles.blobstore.functions.BlobToObject; -import org.jclouds.cloudfiles.blobstore.functions.ListContainerOptionsToBlobStoreListContainerOptions; -import org.jclouds.cloudfiles.blobstore.functions.ObjectToBlob; -import org.jclouds.cloudfiles.blobstore.functions.ResourceToObjectInfo; -import org.jclouds.cloudfiles.blobstore.functions.ResourceToObjectList; -import org.jclouds.cloudfiles.domain.AccountMetadata; -import org.jclouds.cloudfiles.domain.CFObject; -import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; -import org.jclouds.cloudfiles.domain.ContainerMetadata; -import org.jclouds.cloudfiles.domain.MutableObjectInfoWithMetadata; -import org.jclouds.cloudfiles.domain.ObjectInfo; -import org.jclouds.cloudfiles.options.ListCdnContainerOptions; +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 com.google.common.base.Function; import com.google.common.collect.Iterables; @@ -61,15 +61,15 @@ import com.google.common.collect.Sets; import com.google.common.util.concurrent.ListenableFuture; /** - * Implementation of {@link CloudFilesAsyncClient} which keeps all data in a local Map object. + * Implementation of {@link SwiftAsyncClient} which keeps all data in a local Map object. * * @author Adrian Cole */ @Singleton -public class StubCloudFilesAsyncClient implements CloudFilesAsyncClient { +public class StubSwiftAsyncClient implements CommonSwiftAsyncClient { private final HttpGetOptionsListToGetOptions httpGetOptionsConverter; private final TransientAsyncBlobStore blobStore; - private final CFObject.Factory objectProvider; + private final SwiftObject.Factory objectProvider; private final ObjectToBlob object2Blob; private final BlobToObject blob2Object; private final ResourceToObjectInfo blob2ObjectInfo; @@ -79,9 +79,9 @@ public class StubCloudFilesAsyncClient implements CloudFilesAsyncClient { private final ExecutorService service; @Inject - private StubCloudFilesAsyncClient(@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, + private StubSwiftAsyncClient(@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, TransientAsyncBlobStore blobStore, ConcurrentMap> containerToBlobs, - CFObject.Factory objectProvider, HttpGetOptionsListToGetOptions httpGetOptionsConverter, + SwiftObject.Factory objectProvider, HttpGetOptionsListToGetOptions httpGetOptionsConverter, ObjectToBlob object2Blob, BlobToObject blob2Object, ResourceToObjectInfo blob2ObjectInfo, ListContainerOptionsToBlobStoreListContainerOptions container2ContainerListOptions, ResourceToObjectList resource2ContainerList) { @@ -130,7 +130,7 @@ public class StubCloudFilesAsyncClient implements CloudFilesAsyncClient { throw new UnsupportedOperationException(); } - public ListenableFuture getObject(String container, String key, GetOptions... options) { + public ListenableFuture getObject(String container, String key, GetOptions... options) { org.jclouds.blobstore.options.GetOptions getOptions = httpGetOptionsConverter.apply(options); return Futures.compose(blobStore.getBlob(container, key, getOptions), blob2Object, service); } @@ -153,7 +153,7 @@ public class StubCloudFilesAsyncClient implements CloudFilesAsyncClient { } public ListenableFuture> listContainers( - org.jclouds.cloudfiles.options.ListContainerOptions... options) { + org.jclouds.openstack.swift.options.ListContainerOptions... options) { return immediateFuture(Sets.newHashSet(Iterables.transform(blobStore.getContainerToBlobs().keySet(), new Function() { public ContainerMetadata apply(String name) { @@ -163,12 +163,12 @@ public class StubCloudFilesAsyncClient implements CloudFilesAsyncClient { } public ListenableFuture> listObjects(String container, - org.jclouds.cloudfiles.options.ListContainerOptions... optionsList) { + org.jclouds.openstack.swift.options.ListContainerOptions... optionsList) { ListContainerOptions options = container2ContainerListOptions.apply(optionsList); return Futures.compose(blobStore.list(container, options), resource2ObjectList, service); } - public ListenableFuture putObject(String container, CFObject object) { + public ListenableFuture putObject(String container, SwiftObject object) { return blobStore.putBlob(container, object2Blob.apply(object)); } @@ -184,7 +184,7 @@ public class StubCloudFilesAsyncClient implements CloudFilesAsyncClient { throw new UnsupportedOperationException(); } - public CFObject newCFObject() { + public SwiftObject newSwiftObject() { return objectProvider.create(null); } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/options/ListContainerOptionsTest.java b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/options/ListContainerOptionsTest.java similarity index 72% rename from apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/options/ListContainerOptionsTest.java rename to apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/options/ListContainerOptionsTest.java index 8d1a65634c..3b59ffe698 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/options/ListContainerOptionsTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/openstack/swift/options/ListContainerOptionsTest.java @@ -17,19 +17,19 @@ * ==================================================================== */ -package org.jclouds.cloudfiles.options; +package org.jclouds.openstack.swift.options; -import static org.jclouds.cloudfiles.options.ListContainerOptions.Builder.afterMarker; -import static org.jclouds.cloudfiles.options.ListContainerOptions.Builder.underPath; -import static org.jclouds.cloudfiles.options.ListContainerOptions.Builder.maxResults; -import static org.jclouds.cloudfiles.options.ListContainerOptions.Builder.withPrefix; +import static org.jclouds.openstack.swift.options.ListContainerOptions.Builder.afterMarker; +import static org.jclouds.openstack.swift.options.ListContainerOptions.Builder.maxResults; +import static org.jclouds.openstack.swift.options.ListContainerOptions.Builder.underPath; +import static org.jclouds.openstack.swift.options.ListContainerOptions.Builder.withPrefix; import static org.testng.Assert.assertEquals; import java.io.UnsupportedEncodingException; import java.util.Collections; -import org.jclouds.cloudfiles.reference.CloudFilesConstants; import org.jclouds.http.options.HttpRequestOptions; +import org.jclouds.openstack.swift.reference.SwiftConstants; import org.testng.annotations.Test; import com.google.common.collect.Multimap; @@ -51,8 +51,7 @@ public class ListContainerOptionsTest { public void testPrefix() throws UnsupportedEncodingException { ListContainerOptions options = new ListContainerOptions(); options.withPrefix("test"); - assertEquals(options.buildQueryParameters().get(CloudFilesConstants.PREFIX), Collections - .singletonList("test")); + assertEquals(options.buildQueryParameters().get(SwiftConstants.PREFIX), Collections.singletonList("test")); } @Test @@ -94,14 +93,13 @@ public class ListContainerOptionsTest { @Test public void testNullPrefix() { ListContainerOptions options = new ListContainerOptions(); - assertEquals(options.buildQueryParameters().get(CloudFilesConstants.PREFIX), Collections.EMPTY_LIST); + assertEquals(options.buildQueryParameters().get(SwiftConstants.PREFIX), Collections.EMPTY_LIST); } @Test public void testPrefixStatic() throws UnsupportedEncodingException { ListContainerOptions options = withPrefix("test"); - assertEquals(options.buildQueryParameters().get(CloudFilesConstants.PREFIX), Collections - .singletonList("test")); + assertEquals(options.buildQueryParameters().get(SwiftConstants.PREFIX), Collections.singletonList("test")); } @Test(expectedExceptions = NullPointerException.class) @@ -113,21 +111,19 @@ public class ListContainerOptionsTest { public void testMarker() throws UnsupportedEncodingException { ListContainerOptions options = new ListContainerOptions(); options.afterMarker("test"); - assertEquals(options.buildQueryParameters().get(CloudFilesConstants.MARKER), Collections - .singletonList("test")); + assertEquals(options.buildQueryParameters().get(SwiftConstants.MARKER), Collections.singletonList("test")); } @Test public void testNullMarker() { ListContainerOptions options = new ListContainerOptions(); - assertEquals(options.buildQueryParameters().get(CloudFilesConstants.MARKER), Collections.EMPTY_LIST); + assertEquals(options.buildQueryParameters().get(SwiftConstants.MARKER), Collections.EMPTY_LIST); } @Test public void testMarkerStatic() throws UnsupportedEncodingException { ListContainerOptions options = afterMarker("test"); - assertEquals(options.buildQueryParameters().get(CloudFilesConstants.MARKER), Collections - .singletonList("test")); + assertEquals(options.buildQueryParameters().get(SwiftConstants.MARKER), Collections.singletonList("test")); } @Test(expectedExceptions = NullPointerException.class) @@ -139,21 +135,19 @@ public class ListContainerOptionsTest { public void testMaxKeys() { ListContainerOptions options = new ListContainerOptions(); options.maxResults(1000); - assertEquals(options.buildQueryParameters().get(CloudFilesConstants.LIMIT), Collections - .singletonList("1000")); + assertEquals(options.buildQueryParameters().get(SwiftConstants.LIMIT), Collections.singletonList("1000")); } @Test public void testNullMaxKeys() { ListContainerOptions options = new ListContainerOptions(); - assertEquals(options.buildQueryParameters().get(CloudFilesConstants.LIMIT), Collections.EMPTY_LIST); + assertEquals(options.buildQueryParameters().get(SwiftConstants.LIMIT), Collections.EMPTY_LIST); } @Test public void testMaxKeysStatic() { ListContainerOptions options = maxResults(1000); - assertEquals(options.buildQueryParameters().get(CloudFilesConstants.LIMIT), Collections - .singletonList("1000")); + assertEquals(options.buildQueryParameters().get(SwiftConstants.LIMIT), Collections.singletonList("1000")); } @Test(expectedExceptions = IllegalStateException.class) @@ -165,22 +159,19 @@ public class ListContainerOptionsTest { public void testPath() throws UnsupportedEncodingException { ListContainerOptions options = new ListContainerOptions(); options.underPath("test"); - assertEquals(options.buildQueryParameters().get(CloudFilesConstants.PATH), Collections - .singletonList("test")); + assertEquals(options.buildQueryParameters().get(SwiftConstants.PATH), Collections.singletonList("test")); } @Test public void testNullPath() { ListContainerOptions options = new ListContainerOptions(); - assertEquals(options.buildQueryParameters().get(CloudFilesConstants.PATH), - Collections.EMPTY_LIST); + assertEquals(options.buildQueryParameters().get(SwiftConstants.PATH), Collections.EMPTY_LIST); } @Test public void testPathStatic() throws UnsupportedEncodingException { ListContainerOptions options = underPath("test"); - assertEquals(options.buildQueryParameters().get(CloudFilesConstants.PATH), Collections - .singletonList("test")); + assertEquals(options.buildQueryParameters().get(SwiftConstants.PATH), Collections.singletonList("test")); } @Test(expectedExceptions = NullPointerException.class) diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java index a8bada5d3b..9b9009779e 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java @@ -33,7 +33,6 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jclouds.http.functions.ReturnFalseOn404; -import org.jclouds.rackspace.CloudServers; import org.jclouds.cloudservers.binders.BindAdminPassToJsonPayload; import org.jclouds.cloudservers.binders.BindBackupScheduleToJsonPayload; import org.jclouds.cloudservers.binders.BindConfirmResizeToJsonPayload; @@ -54,8 +53,8 @@ import org.jclouds.cloudservers.options.CreateServerOptions; import org.jclouds.cloudservers.options.CreateSharedIpGroupOptions; import org.jclouds.cloudservers.options.ListOptions; import org.jclouds.cloudservers.options.RebuildServerOptions; -import org.jclouds.rackspace.filters.AddTimestampQuery; -import org.jclouds.rackspace.filters.AuthenticateRequest; +import org.jclouds.openstack.filters.AddTimestampQuery; +import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Endpoint; import org.jclouds.rest.annotations.ExceptionParser; @@ -85,7 +84,7 @@ import com.google.common.util.concurrent.ListenableFuture; */ @SkipEncoding( { '/', '=' }) @RequestFilters( { AuthenticateRequest.class, AddTimestampQuery.class }) -@Endpoint(CloudServers.class) +@Endpoint(ServerManagement.class) public interface CloudServersAsyncClient { /** diff --git a/common/rackspace/src/main/java/org/jclouds/rackspace/CloudServers.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/ServerManagement.java similarity index 94% rename from common/rackspace/src/main/java/org/jclouds/rackspace/CloudServers.java rename to apis/cloudservers/src/main/java/org/jclouds/cloudservers/ServerManagement.java index 2608be2272..2ffb163422 100644 --- a/common/rackspace/src/main/java/org/jclouds/rackspace/CloudServers.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/ServerManagement.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.rackspace; +package org.jclouds.cloudservers; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -36,6 +36,6 @@ import javax.inject.Qualifier; @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @Qualifier -public @interface CloudServers { +public @interface ServerManagement { } \ No newline at end of file diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java index 469eaa3bb7..f7f640810d 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java @@ -19,19 +19,28 @@ package org.jclouds.cloudservers.config; +import java.net.URI; + +import javax.inject.Singleton; + +import org.jclouds.cloudservers.CloudServersAsyncClient; +import org.jclouds.cloudservers.CloudServersClient; +import org.jclouds.cloudservers.ServerManagement; +import org.jclouds.cloudservers.handlers.ParseCloudServersErrorFromHttpResponse; import org.jclouds.http.HttpErrorHandler; 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.cloudservers.CloudServersAsyncClient; -import org.jclouds.cloudservers.CloudServersClient; -import org.jclouds.cloudservers.handlers.ParseCloudServersErrorFromHttpResponse; -import org.jclouds.rackspace.config.RackspaceAuthenticationRestModule; +import org.jclouds.json.config.GsonModule.DateAdapter; +import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; +import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse; +import org.jclouds.openstack.config.OpenStackAuthenticationModule; +import org.jclouds.openstack.reference.AuthHeaders; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.config.RestClientModule; -import com.google.inject.Module; +import com.google.inject.Provides; /** * @@ -39,34 +48,38 @@ import com.google.inject.Module; */ @ConfiguresRestClient @RequiresHttp -public class CloudServersRestClientModule extends - RestClientModule { +public class CloudServersRestClientModule extends RestClientModule { - private Module authModule; + private final OpenStackAuthenticationModule module; - public CloudServersRestClientModule() { - this(new RackspaceAuthenticationRestModule()); + public CloudServersRestClientModule(OpenStackAuthenticationModule module) { + super(CloudServersClient.class, CloudServersAsyncClient.class); + this.module = module; } - public CloudServersRestClientModule(Module authModule) { - super(CloudServersClient.class, CloudServersAsyncClient.class); - this.authModule = authModule; + public CloudServersRestClientModule() { + this(new OpenStackAuthenticationModule()); } @Override protected void configure() { - install(authModule); + install(module); + bind(DateAdapter.class).to(Iso8601DateAdapter.class); super.configure(); } - + @Override protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to( - ParseCloudServersErrorFromHttpResponse.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to( - ParseCloudServersErrorFromHttpResponse.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to( - ParseCloudServersErrorFromHttpResponse.class); + bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseCloudServersErrorFromHttpResponse.class); + bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseCloudServersErrorFromHttpResponse.class); + bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseCloudServersErrorFromHttpResponse.class); + } + + @Provides + @Singleton + @ServerManagement + protected URI provideServerUrl(AuthenticationResponse response) { + return response.getServices().get(AuthHeaders.SERVER_MANAGEMENT_URL); } } diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/ListOptions.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/ListOptions.java index 3eafe9c58a..6e95826eb0 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/ListOptions.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/ListOptions.java @@ -21,7 +21,7 @@ package org.jclouds.cloudservers.options; import java.util.Date; -import org.jclouds.rackspace.options.BaseListOptions; +import org.jclouds.openstack.options.BaseListOptions; /** * Options used to control the amount of detail in the request. diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java index bcbb9d89fe..a625496ea4 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java @@ -19,6 +19,8 @@ package org.jclouds.cloudservers; +import static org.jclouds.Constants.PROPERTY_API_VERSION; +import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withFile; import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withMetadata; import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withSharedIpGroup; @@ -26,21 +28,18 @@ import static org.jclouds.cloudservers.options.CreateSharedIpGroupOptions.Builde import static org.jclouds.cloudservers.options.ListOptions.Builder.changesSince; import static org.jclouds.cloudservers.options.ListOptions.Builder.withDetails; import static org.jclouds.cloudservers.options.RebuildServerOptions.Builder.withImage; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; +import java.net.URI; import java.net.UnknownHostException; import java.util.Date; import java.util.Properties; import javax.ws.rs.core.MediaType; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.http.functions.ReturnFalseOn404; -import org.jclouds.http.functions.ReturnTrueIf2xx; -import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.cloudservers.config.CloudServersRestClientModule; import org.jclouds.cloudservers.domain.BackupSchedule; import org.jclouds.cloudservers.domain.DailyBackup; @@ -50,9 +49,17 @@ import org.jclouds.cloudservers.options.CreateServerOptions; import org.jclouds.cloudservers.options.CreateSharedIpGroupOptions; import org.jclouds.cloudservers.options.ListOptions; import org.jclouds.cloudservers.options.RebuildServerOptions; -import org.jclouds.rackspace.TestRackspaceAuthenticationRestClientModule; -import org.jclouds.rackspace.filters.AddTimestampQuery; -import org.jclouds.rackspace.filters.AuthenticateRequest; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.RequiresHttp; +import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.http.functions.ReturnFalseOn404; +import org.jclouds.http.functions.ReturnTrueIf2xx; +import org.jclouds.http.functions.UnwrapOnlyJsonValue; +import org.jclouds.openstack.TestOpenStackAuthenticationModule; +import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse; +import org.jclouds.openstack.filters.AddTimestampQuery; +import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextSpec; @@ -860,13 +867,38 @@ public class CloudServersAsyncClientTest extends RestClientTest createContextSpec() { - return new RestContextFactory().createContextSpec("cloudservers", "user", "password", new Properties()); + return new RestContextFactory().createContextSpec(provider, "user", "password", new Properties()); } + @Override + protected Properties getProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_REGIONS, "US"); + properties.setProperty(PROPERTY_ENDPOINT, "https://auth"); + properties.setProperty(PROPERTY_API_VERSION, "1"); + return properties; + } } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseAddressesFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseAddressesFromJsonResponseTest.java index 0cebf0a7c4..5bcf36f3ce 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseAddressesFromJsonResponseTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseAddressesFromJsonResponseTest.java @@ -25,12 +25,11 @@ import java.io.InputStream; import java.net.UnknownHostException; import java.util.List; +import org.jclouds.cloudservers.domain.Addresses; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; -import org.jclouds.cloudservers.domain.Addresses; -import org.jclouds.rackspace.config.RackspaceParserModule; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -46,7 +45,7 @@ import com.google.inject.TypeLiteral; */ @Test(groups = "unit") public class ParseAddressesFromJsonResponseTest { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new GsonModule()); public void testApplyInputStreamDetails() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/test_list_addresses.json"); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseBackupScheduleFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseBackupScheduleFromJsonResponseTest.java index c18cb89f1c..ba8b958aa4 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseBackupScheduleFromJsonResponseTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseBackupScheduleFromJsonResponseTest.java @@ -24,14 +24,13 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.net.UnknownHostException; +import org.jclouds.cloudservers.domain.BackupSchedule; +import org.jclouds.cloudservers.domain.DailyBackup; +import org.jclouds.cloudservers.domain.WeeklyBackup; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; -import org.jclouds.cloudservers.domain.BackupSchedule; -import org.jclouds.cloudservers.domain.DailyBackup; -import org.jclouds.cloudservers.domain.WeeklyBackup; -import org.jclouds.rackspace.config.RackspaceParserModule; import org.testng.annotations.Test; import com.google.inject.Guice; @@ -46,14 +45,14 @@ import com.google.inject.TypeLiteral; */ @Test(groups = "unit") public class ParseBackupScheduleFromJsonResponseTest { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new GsonModule()); public void testApplyInputStreamDetails() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/test_list_backupschedule.json"); UnwrapOnlyJsonValue parser = i.getInstance(Key - .get(new TypeLiteral>() { - })); + .get(new TypeLiteral>() { + })); BackupSchedule response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); assertEquals(new BackupSchedule(WeeklyBackup.THURSDAY, DailyBackup.H_0400_0600, true), response); } @@ -61,10 +60,10 @@ public class ParseBackupScheduleFromJsonResponseTest { public void testNoSchedule() throws UnknownHostException { UnwrapOnlyJsonValue parser = i.getInstance(Key - .get(new TypeLiteral>() { - })); + .get(new TypeLiteral>() { + })); BackupSchedule response = parser.apply(new HttpResponse(200, "ok", Payloads - .newStringPayload("{\"backupSchedule\":{\"enabled\" : false}}"))); + .newStringPayload("{\"backupSchedule\":{\"enabled\" : false}}"))); assertEquals(new BackupSchedule(), response); } } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorFromJsonResponseTest.java index 2969217288..6621a73585 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorFromJsonResponseTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorFromJsonResponseTest.java @@ -23,12 +23,11 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; +import org.jclouds.cloudservers.domain.Flavor; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; -import org.jclouds.cloudservers.domain.Flavor; -import org.jclouds.rackspace.config.RackspaceParserModule; import org.testng.annotations.Test; import com.google.gson.Gson; @@ -53,10 +52,9 @@ public class ParseFlavorFromJsonResponseTest { } public static Flavor parseFlavor() { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new GsonModule()); - InputStream is = ParseFlavorFromJsonResponseTest.class - .getResourceAsStream("/test_get_flavor_details.json"); + InputStream is = ParseFlavorFromJsonResponseTest.class.getResourceAsStream("/test_get_flavor_details.json"); UnwrapOnlyJsonValue parser = i.getInstance(Key.get(new TypeLiteral>() { })); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorListFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorListFromJsonResponseTest.java index a3c94af867..0b00fed3b0 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorListFromJsonResponseTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorListFromJsonResponseTest.java @@ -25,12 +25,11 @@ import java.io.InputStream; import java.net.UnknownHostException; import java.util.List; +import org.jclouds.cloudservers.domain.Flavor; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; -import org.jclouds.cloudservers.domain.Flavor; -import org.jclouds.rackspace.config.RackspaceParserModule; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -47,7 +46,7 @@ import com.google.inject.TypeLiteral; @Test(groups = "unit") public class ParseFlavorListFromJsonResponseTest { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new GsonModule()); public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/test_list_flavors.json"); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageFromJsonResponseTest.java index 63d022bbd2..8f1f752b4e 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageFromJsonResponseTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageFromJsonResponseTest.java @@ -24,16 +24,18 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.net.UnknownHostException; +import org.jclouds.cloudservers.domain.Image; +import org.jclouds.cloudservers.domain.ImageStatus; import org.jclouds.date.DateService; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; -import org.jclouds.cloudservers.domain.Image; -import org.jclouds.cloudservers.domain.ImageStatus; -import org.jclouds.rackspace.config.RackspaceParserModule; +import org.jclouds.json.config.GsonModule.DateAdapter; +import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; import org.testng.annotations.Test; +import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; @@ -46,7 +48,14 @@ import com.google.inject.TypeLiteral; */ @Test(groups = "unit") public class ParseImageFromJsonResponseTest { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new AbstractModule() { + + @Override + protected void configure() { + bind(DateAdapter.class).to(Iso8601DateAdapter.class); + } + + }, new GsonModule()); DateService dateService = i.getInstance(DateService.class); @@ -64,10 +73,16 @@ public class ParseImageFromJsonResponseTest { } public static Image parseImage() { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new AbstractModule() { - InputStream is = ParseImageFromJsonResponseTest.class - .getResourceAsStream("/test_get_image_details.json"); + @Override + protected void configure() { + bind(DateAdapter.class).to(Iso8601DateAdapter.class); + } + + }, new GsonModule()); + + InputStream is = ParseImageFromJsonResponseTest.class.getResourceAsStream("/test_get_image_details.json"); UnwrapOnlyJsonValue parser = i.getInstance(Key.get(new TypeLiteral>() { })); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageListFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageListFromJsonResponseTest.java index 4f92b59de8..0eb48f9a10 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageListFromJsonResponseTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageListFromJsonResponseTest.java @@ -25,17 +25,19 @@ import java.io.InputStream; import java.net.UnknownHostException; import java.util.List; +import org.jclouds.cloudservers.domain.Image; +import org.jclouds.cloudservers.domain.ImageStatus; import org.jclouds.date.DateService; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; -import org.jclouds.cloudservers.domain.Image; -import org.jclouds.cloudservers.domain.ImageStatus; -import org.jclouds.rackspace.config.RackspaceParserModule; +import org.jclouds.json.config.GsonModule.DateAdapter; +import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; +import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; @@ -48,7 +50,14 @@ import com.google.inject.TypeLiteral; */ @Test(groups = "unit") public class ParseImageListFromJsonResponseTest { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new AbstractModule() { + + @Override + protected void configure() { + bind(DateAdapter.class).to(Iso8601DateAdapter.class); + } + + },new GsonModule()); DateService dateService = i.getInstance(DateService.class); public void testApplyInputStream() { diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseInetAddressListFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseInetAddressListFromJsonResponseTest.java index 4325b10c18..e9c3ca27e9 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseInetAddressListFromJsonResponseTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseInetAddressListFromJsonResponseTest.java @@ -29,7 +29,6 @@ import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; -import org.jclouds.rackspace.config.RackspaceParserModule; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -46,7 +45,7 @@ import com.google.inject.TypeLiteral; @Test(groups = "unit") public class ParseInetAddressListFromJsonResponseTest { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new GsonModule()); public void testPublic() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/test_list_addresses_public.json"); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseServerFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseServerFromJsonResponseTest.java index b7352a073c..6dbbbaf9ac 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseServerFromJsonResponseTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseServerFromJsonResponseTest.java @@ -25,14 +25,13 @@ import java.io.InputStream; import java.net.UnknownHostException; import java.util.List; +import org.jclouds.cloudservers.domain.Addresses; +import org.jclouds.cloudservers.domain.Server; +import org.jclouds.cloudservers.domain.ServerStatus; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; -import org.jclouds.cloudservers.domain.Addresses; -import org.jclouds.cloudservers.domain.Server; -import org.jclouds.cloudservers.domain.ServerStatus; -import org.jclouds.rackspace.config.RackspaceParserModule; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; @@ -71,7 +70,7 @@ public class ParseServerFromJsonResponseTest { } public static Server parseServer() { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new GsonModule()); InputStream is = ParseServerFromJsonResponseTest.class.getResourceAsStream("/test_get_server_detail.json"); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseServerListFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseServerListFromJsonResponseTest.java index c183d4a522..feefbbb61c 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseServerListFromJsonResponseTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseServerListFromJsonResponseTest.java @@ -25,14 +25,13 @@ import java.io.InputStream; import java.net.UnknownHostException; import java.util.List; +import org.jclouds.cloudservers.domain.Addresses; +import org.jclouds.cloudservers.domain.Server; +import org.jclouds.cloudservers.domain.ServerStatus; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; -import org.jclouds.cloudservers.domain.Addresses; -import org.jclouds.cloudservers.domain.Server; -import org.jclouds.cloudservers.domain.ServerStatus; -import org.jclouds.rackspace.config.RackspaceParserModule; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -51,7 +50,7 @@ import com.google.inject.TypeLiteral; @Test(groups = "unit") public class ParseServerListFromJsonResponseTest { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new GsonModule()); public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/test_list_servers.json"); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseSharedIpGroupFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseSharedIpGroupFromJsonResponseTest.java index d60305dd1a..db91e11ae7 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseSharedIpGroupFromJsonResponseTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseSharedIpGroupFromJsonResponseTest.java @@ -24,12 +24,11 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.net.UnknownHostException; +import org.jclouds.cloudservers.domain.SharedIpGroup; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; -import org.jclouds.cloudservers.domain.SharedIpGroup; -import org.jclouds.rackspace.config.RackspaceParserModule; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -46,7 +45,7 @@ import com.google.inject.TypeLiteral; @Test(groups = "unit") public class ParseSharedIpGroupFromJsonResponseTest { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new GsonModule()); public void testApplyInputStreamDetails() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/test_get_sharedipgroup_details.json"); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseSharedIpGroupListFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseSharedIpGroupListFromJsonResponseTest.java index 15f3779b24..df1b1f83e9 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseSharedIpGroupListFromJsonResponseTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseSharedIpGroupListFromJsonResponseTest.java @@ -25,12 +25,11 @@ import java.io.InputStream; import java.net.UnknownHostException; import java.util.List; +import org.jclouds.cloudservers.domain.SharedIpGroup; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; -import org.jclouds.cloudservers.domain.SharedIpGroup; -import org.jclouds.rackspace.config.RackspaceParserModule; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -47,7 +46,7 @@ import com.google.inject.TypeLiteral; @Test(groups = "unit") public class ParseSharedIpGroupListFromJsonResponseTest { - Injector i = Guice.createInjector(new RackspaceParserModule(), new GsonModule()); + Injector i = Guice.createInjector(new GsonModule()); public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/test_list_sharedipgroups.json"); diff --git a/common/rackspace/src/main/java/org/jclouds/rackspace/Authentication.java b/common/rackspace/src/main/java/org/jclouds/openstack/Authentication.java similarity index 97% rename from common/rackspace/src/main/java/org/jclouds/rackspace/Authentication.java rename to common/rackspace/src/main/java/org/jclouds/openstack/Authentication.java index 413bc5201c..7925e44e05 100644 --- a/common/rackspace/src/main/java/org/jclouds/rackspace/Authentication.java +++ b/common/rackspace/src/main/java/org/jclouds/openstack/Authentication.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.rackspace; +package org.jclouds.openstack; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/common/rackspace/src/main/java/org/jclouds/openstack/OpenStackAuthAsyncClient.java b/common/rackspace/src/main/java/org/jclouds/openstack/OpenStackAuthAsyncClient.java new file mode 100755 index 0000000000..c0cdf48af2 --- /dev/null +++ b/common/rackspace/src/main/java/org/jclouds/openstack/OpenStackAuthAsyncClient.java @@ -0,0 +1,96 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Map; + +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.Path; + +import org.jclouds.openstack.functions.ParseAuthenticationResponseFromHeaders; +import org.jclouds.openstack.reference.AuthHeaders; +import org.jclouds.rest.annotations.ResponseParser; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableMap; +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides access to Rackspace resources via their REST API. + *

+ * + * @see + * @author Adrian Cole + */ +@Path("/v" + OpenStackAuthAsyncClient.VERSION) +public interface OpenStackAuthAsyncClient { + public static final String VERSION = "1.0"; + + public static class AuthenticationResponse { + private final String authToken; + private Map services; + + public AuthenticationResponse(String authToken, Map services) { + this.authToken = checkNotNull(authToken, "authToken"); + this.services = ImmutableMap.copyOf(checkNotNull(services, "services")); + } + + public Map getServices() { + return services; + } + + public void setEndpoints(Map services) { + this.services = services; + } + + public String getAuthToken() { + return authToken; + } + + // performance isn't a concern on a infrequent object like this, so using shortcuts; + + @Override + public int hashCode() { + return Objects.hashCode(authToken, services); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + return Objects.equal(this.toString(), that.toString()); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).add("authToken", authToken).add("services", services).toString(); + } + + } + + @GET + @ResponseParser(ParseAuthenticationResponseFromHeaders.class) + ListenableFuture authenticate(@HeaderParam(AuthHeaders.AUTH_USER) String user, + @HeaderParam(AuthHeaders.AUTH_KEY) String key); +} diff --git a/common/rackspace/src/main/java/org/jclouds/rackspace/config/RackspaceAuthenticationRestModule.java b/common/rackspace/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java similarity index 59% rename from common/rackspace/src/main/java/org/jclouds/rackspace/config/RackspaceAuthenticationRestModule.java rename to common/rackspace/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java index 0fd6f69c8a..5e86d7ccad 100755 --- a/common/rackspace/src/main/java/org/jclouds/rackspace/config/RackspaceAuthenticationRestModule.java +++ b/common/rackspace/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java @@ -17,11 +17,11 @@ * ==================================================================== */ -package org.jclouds.rackspace.config; +package org.jclouds.openstack.config; -import java.net.URI; import java.util.Date; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -32,33 +32,27 @@ import org.jclouds.Constants; import org.jclouds.concurrent.RetryOnTimeOutExceptionSupplier; import org.jclouds.date.TimeStamp; import org.jclouds.http.RequiresHttp; -import org.jclouds.rackspace.Authentication; -import org.jclouds.rackspace.CloudFiles; -import org.jclouds.rackspace.CloudFilesCDN; -import org.jclouds.rackspace.CloudServers; -import org.jclouds.rackspace.RackspaceAuthAsyncClient; -import org.jclouds.rackspace.RackspaceAuthAsyncClient.AuthenticationResponse; +import org.jclouds.openstack.Authentication; +import org.jclouds.openstack.OpenStackAuthAsyncClient; +import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse; import org.jclouds.rest.AsyncClientFactory; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.google.common.base.Throwables; -import java.util.concurrent.Future; import com.google.inject.AbstractModule; import com.google.inject.Provides; /** - * Configures the Rackspace authentication service connection, including logging - * and http transport. + * Configures the Rackspace authentication service connection, including logging and http transport. * * @author Adrian Cole */ @RequiresHttp -public class RackspaceAuthenticationRestModule extends AbstractModule { +public class OpenStackAuthenticationModule extends AbstractModule { @Override protected void configure() { - install(new RackspaceParserModule()); } /** @@ -68,7 +62,7 @@ public class RackspaceAuthenticationRestModule extends AbstractModule { @Singleton @Authentication protected Supplier provideAuthenticationTokenCache(final Supplier supplier) - throws InterruptedException, ExecutionException, TimeoutException { + throws InterruptedException, ExecutionException, TimeoutException { return new Supplier() { public String get() { return supplier.get().getAuthToken(); @@ -79,21 +73,22 @@ public class RackspaceAuthenticationRestModule extends AbstractModule { @Provides @Singleton Supplier provideAuthenticationResponseCache(final AsyncClientFactory factory, - @Named(Constants.PROPERTY_IDENTITY) final String user, @Named(Constants.PROPERTY_CREDENTIAL) final String key) { + @Named(Constants.PROPERTY_IDENTITY) final String user, + @Named(Constants.PROPERTY_CREDENTIAL) final String key) { return Suppliers.memoizeWithExpiration(new RetryOnTimeOutExceptionSupplier( - new Supplier() { - public AuthenticationResponse get() { - try { - Future response = factory.create(RackspaceAuthAsyncClient.class) - .authenticate(user, key); - return response.get(30, TimeUnit.SECONDS); - } catch (Exception e) { - Throwables.propagate(e); - assert false : e; - return null; + new Supplier() { + public AuthenticationResponse get() { + try { + Future response = factory.create(OpenStackAuthAsyncClient.class) + .authenticate(user, key); + return response.get(30, TimeUnit.SECONDS); + } catch (Exception e) { + Throwables.propagate(e); + assert false : e; + return null; + } } - } - }), 23, TimeUnit.HOURS); + }), 23, TimeUnit.HOURS); } @Provides @@ -110,28 +105,8 @@ public class RackspaceAuthenticationRestModule extends AbstractModule { @Provides @Singleton protected AuthenticationResponse provideAuthenticationResponse(Supplier supplier) - throws InterruptedException, ExecutionException, TimeoutException { + throws InterruptedException, ExecutionException, TimeoutException { return supplier.get(); } - @Provides - @Singleton - @CloudFiles - protected URI providestroageUrl(AuthenticationResponse response) { - return response.getStorageUrl(); - } - - @Provides - @Singleton - @CloudServers - protected URI provideServerUrl(AuthenticationResponse response) { - return response.getServerManagementUrl(); - } - - @Provides - @Singleton - @CloudFilesCDN - protected URI provideCDNUrl(AuthenticationResponse response) { - return response.getCDNManagementUrl(); - } } \ No newline at end of file diff --git a/common/rackspace/src/main/java/org/jclouds/rackspace/filters/AddTimestampQuery.java b/common/rackspace/src/main/java/org/jclouds/openstack/filters/AddTimestampQuery.java similarity index 97% rename from common/rackspace/src/main/java/org/jclouds/rackspace/filters/AddTimestampQuery.java rename to common/rackspace/src/main/java/org/jclouds/openstack/filters/AddTimestampQuery.java index 47f3bc3db9..2cae2c3eeb 100644 --- a/common/rackspace/src/main/java/org/jclouds/rackspace/filters/AddTimestampQuery.java +++ b/common/rackspace/src/main/java/org/jclouds/openstack/filters/AddTimestampQuery.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.rackspace.filters; +package org.jclouds.openstack.filters; import java.util.Date; diff --git a/common/rackspace/src/main/java/org/jclouds/rackspace/filters/AuthenticateRequest.java b/common/rackspace/src/main/java/org/jclouds/openstack/filters/AuthenticateRequest.java similarity index 86% rename from common/rackspace/src/main/java/org/jclouds/rackspace/filters/AuthenticateRequest.java rename to common/rackspace/src/main/java/org/jclouds/openstack/filters/AuthenticateRequest.java index 82adf4d2d5..03f00d1fa6 100755 --- a/common/rackspace/src/main/java/org/jclouds/rackspace/filters/AuthenticateRequest.java +++ b/common/rackspace/src/main/java/org/jclouds/openstack/filters/AuthenticateRequest.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.rackspace.filters; +package org.jclouds.openstack.filters; import javax.inject.Inject; import javax.inject.Singleton; @@ -26,8 +26,8 @@ import org.jclouds.http.HttpException; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.utils.ModifyRequest; -import org.jclouds.rackspace.Authentication; -import org.jclouds.rackspace.reference.RackspaceHeaders; +import org.jclouds.openstack.Authentication; +import org.jclouds.openstack.reference.AuthHeaders; import com.google.common.base.Supplier; @@ -49,7 +49,7 @@ public class AuthenticateRequest implements HttpRequestFilter { @Override public HttpRequest filter(HttpRequest request) throws HttpException { - return ModifyRequest.replaceHeader(request, RackspaceHeaders.AUTH_TOKEN, authTokenProvider.get()); + return ModifyRequest.replaceHeader(request, AuthHeaders.AUTH_TOKEN, authTokenProvider.get()); } } \ No newline at end of file diff --git a/common/rackspace/src/main/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeaders.java b/common/rackspace/src/main/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeaders.java new file mode 100755 index 0000000000..6f5ae88ae6 --- /dev/null +++ b/common/rackspace/src/main/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeaders.java @@ -0,0 +1,67 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.functions; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.http.HttpUtils.releasePayload; +import static org.jclouds.openstack.reference.AuthHeaders.AUTH_TOKEN; +import static org.jclouds.openstack.reference.AuthHeaders.URL_SUFFIX; + +import java.net.URI; +import java.util.Map.Entry; + +import javax.annotation.Resource; +import javax.inject.Singleton; + +import org.jclouds.http.HttpResponse; +import org.jclouds.logging.Logger; +import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; + +/** + * This parses {@link AuthenticationResponse} from HTTP headers. + * + * @author Adrian Cole + */ +@Singleton +public class ParseAuthenticationResponseFromHeaders implements Function { + + @Resource + protected Logger logger = Logger.NULL; + + /** + * parses the http response headers to create a new {@link AuthenticationResponse} object. + */ + public AuthenticationResponse apply(HttpResponse from) { + releasePayload(from); + Builder builder = ImmutableMap. builder(); + for (Entry entry : from.getHeaders().entries()) { + if (entry.getKey().endsWith(URL_SUFFIX)) + builder.put(entry.getKey(), URI.create(entry.getValue())); + } + AuthenticationResponse response = new AuthenticationResponse(checkNotNull(from.getFirstHeaderOrNull(AUTH_TOKEN), + AUTH_TOKEN), builder.build()); + logger.debug("will connect to: ", response); + return response; + } +} \ No newline at end of file diff --git a/common/rackspace/src/main/java/org/jclouds/rackspace/options/BaseListOptions.java b/common/rackspace/src/main/java/org/jclouds/openstack/options/BaseListOptions.java similarity index 98% rename from common/rackspace/src/main/java/org/jclouds/rackspace/options/BaseListOptions.java rename to common/rackspace/src/main/java/org/jclouds/openstack/options/BaseListOptions.java index 819d7a24dc..3f8633f757 100644 --- a/common/rackspace/src/main/java/org/jclouds/rackspace/options/BaseListOptions.java +++ b/common/rackspace/src/main/java/org/jclouds/openstack/options/BaseListOptions.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.rackspace.options; +package org.jclouds.openstack.options; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; diff --git a/common/rackspace/src/main/java/org/jclouds/rackspace/reference/RackspaceHeaders.java b/common/rackspace/src/main/java/org/jclouds/openstack/reference/AuthHeaders.java similarity index 83% rename from common/rackspace/src/main/java/org/jclouds/rackspace/reference/RackspaceHeaders.java rename to common/rackspace/src/main/java/org/jclouds/openstack/reference/AuthHeaders.java index 56ded6e261..6f92851d08 100644 --- a/common/rackspace/src/main/java/org/jclouds/rackspace/reference/RackspaceHeaders.java +++ b/common/rackspace/src/main/java/org/jclouds/openstack/reference/AuthHeaders.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.rackspace.reference; +package org.jclouds.openstack.reference; /** * Headers common to Rackspace apis. @@ -26,13 +26,15 @@ package org.jclouds.rackspace.reference; * @author Adrian Cole * */ -public interface RackspaceHeaders { +public interface AuthHeaders { public static final String AUTH_USER = "X-Auth-User"; public static final String AUTH_KEY = "X-Auth-Key"; public static final String AUTH_TOKEN = "X-Auth-Token"; - public static final String CDN_MANAGEMENT_URL = "X-CDN-Management-Url"; - public static final String SERVER_MANAGEMENT_URL = "X-Server-Management-Url"; - public static final String STORAGE_URL = "X-Storage-Url"; + public static final String URL_SUFFIX = "-Url"; + + public static final String CDN_MANAGEMENT_URL = "X-CDN-Management" + URL_SUFFIX; + public static final String SERVER_MANAGEMENT_URL = "X-Server-Management" + URL_SUFFIX; + public static final String STORAGE_URL = "X-Storage" + URL_SUFFIX; } \ No newline at end of file diff --git a/common/rackspace/src/main/java/org/jclouds/rackspace/reference/package-info.java b/common/rackspace/src/main/java/org/jclouds/openstack/reference/package-info.java similarity index 95% rename from common/rackspace/src/main/java/org/jclouds/rackspace/reference/package-info.java rename to common/rackspace/src/main/java/org/jclouds/openstack/reference/package-info.java index 852e94dd31..81cb802375 100755 --- a/common/rackspace/src/main/java/org/jclouds/rackspace/reference/package-info.java +++ b/common/rackspace/src/main/java/org/jclouds/openstack/reference/package-info.java @@ -21,4 +21,4 @@ * This package contains properties and reference data used in Rackspace. * @author Adrian Cole */ -package org.jclouds.rackspace.reference; \ No newline at end of file +package org.jclouds.openstack.reference; \ No newline at end of file diff --git a/common/rackspace/src/main/java/org/jclouds/rackspace/RackspaceAuthAsyncClient.java b/common/rackspace/src/main/java/org/jclouds/rackspace/RackspaceAuthAsyncClient.java deleted file mode 100755 index 7f65d76302..0000000000 --- a/common/rackspace/src/main/java/org/jclouds/rackspace/RackspaceAuthAsyncClient.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed 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.rackspace; - -import java.net.URI; - -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.Path; - -import org.jclouds.rackspace.functions.ParseAuthenticationResponseFromHeaders; -import org.jclouds.rackspace.reference.RackspaceHeaders; -import org.jclouds.rest.annotations.ResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Rackspace resources via their REST API. - *

- * - * @see - * @author Adrian Cole - */ -@Path("/v" + RackspaceAuthAsyncClient.VERSION) -public interface RackspaceAuthAsyncClient { - public static final String VERSION = "1.0"; - - public interface AuthenticationResponse { - @CloudFiles - URI getStorageUrl(); - - @CloudFilesCDN - URI getCDNManagementUrl(); - - @CloudServers - URI getServerManagementUrl(); - - @Authentication - String getAuthToken(); - } - - @GET - @ResponseParser(ParseAuthenticationResponseFromHeaders.class) - ListenableFuture authenticate(@HeaderParam(RackspaceHeaders.AUTH_USER) String user, - @HeaderParam(RackspaceHeaders.AUTH_KEY) String key); -} diff --git a/common/rackspace/src/main/java/org/jclouds/rackspace/functions/ParseAuthenticationResponseFromHeaders.java b/common/rackspace/src/main/java/org/jclouds/rackspace/functions/ParseAuthenticationResponseFromHeaders.java deleted file mode 100755 index c17f7bea90..0000000000 --- a/common/rackspace/src/main/java/org/jclouds/rackspace/functions/ParseAuthenticationResponseFromHeaders.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed 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.rackspace.functions; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.http.HttpUtils.releasePayload; -import static org.jclouds.rackspace.reference.RackspaceHeaders.AUTH_TOKEN; -import static org.jclouds.rackspace.reference.RackspaceHeaders.CDN_MANAGEMENT_URL; -import static org.jclouds.rackspace.reference.RackspaceHeaders.SERVER_MANAGEMENT_URL; -import static org.jclouds.rackspace.reference.RackspaceHeaders.STORAGE_URL; - -import java.net.URI; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Provider; -import javax.ws.rs.core.UriBuilder; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.logging.Logger; -import org.jclouds.rackspace.RackspaceAuthAsyncClient.AuthenticationResponse; -import org.jclouds.rest.InvocationContext; - -import com.google.common.base.Function; -import com.google.common.base.Objects; - -/** - * This parses {@link AuthenticationResponse} from HTTP headers. - * - * @author Adrian Cole - */ -public class ParseAuthenticationResponseFromHeaders implements Function, - InvocationContext { - - public static final class AuthenticationResponseImpl implements AuthenticationResponse { - - private final String authToken; - private final URI CDNManagementUrl; - private final URI serverManagementUrl; - private final URI storageUrl; - - public AuthenticationResponseImpl(String authToken, URI CDNManagementUrl, URI serverManagementUrl, URI storageUrl) { - this.authToken = authToken; - this.CDNManagementUrl = CDNManagementUrl; - this.serverManagementUrl = serverManagementUrl; - this.storageUrl = storageUrl; - } - - public String getAuthToken() { - return authToken; - } - - public URI getCDNManagementUrl() { - return CDNManagementUrl; - } - - public URI getServerManagementUrl() { - return serverManagementUrl; - } - - public URI getStorageUrl() { - return storageUrl; - } - - // performance isn't a concern on a infrequent object like this, so using shortcuts; - - @Override - public int hashCode() { - return Objects.hashCode(CDNManagementUrl, authToken, serverManagementUrl, storageUrl); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - return Objects.equal(this.toString(), that.toString()); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).add("CDNManagementUrl", CDNManagementUrl) - .add("serverManagementUrl", serverManagementUrl).add("storageUrl", storageUrl).toString(); - } - - } - - @Resource - protected Logger logger = Logger.NULL; - - private final Provider uriBuilderProvider; - private String hostToReplace; - - @Inject - public ParseAuthenticationResponseFromHeaders(Provider uriBuilderProvider) { - this.uriBuilderProvider = uriBuilderProvider; - } - - /** - * parses the http response headers to create a new {@link AuthenticationResponse} object. - */ - public AuthenticationResponse apply(HttpResponse from) { - releasePayload(from); - AuthenticationResponse response = new AuthenticationResponseImpl(checkNotNull( - from.getFirstHeaderOrNull(AUTH_TOKEN), AUTH_TOKEN), getURI(from, CDN_MANAGEMENT_URL), getURI(from, - SERVER_MANAGEMENT_URL), getURI(from, STORAGE_URL)); - logger.debug("will connect to: ", response); - return response; - } - - protected URI getURI(HttpResponse from, String header) { - String headerValue = from.getFirstHeaderOrNull(header); - if (headerValue == null) - return null; - URI toReturn = URI.create(headerValue); - if (!"127.0.0.1".equals(toReturn.getHost())) - return toReturn; - return uriBuilderProvider.get().uri(toReturn).host(hostToReplace).build(); - } - - @Override - public ParseAuthenticationResponseFromHeaders setContext(HttpRequest request) { - hostToReplace = request.getEndpoint().getHost(); - return this; - } -} \ No newline at end of file diff --git a/common/rackspace/src/test/java/org/jclouds/rackspace/RackspaceAuthAsyncClientTest.java b/common/rackspace/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java similarity index 75% rename from common/rackspace/src/test/java/org/jclouds/rackspace/RackspaceAuthAsyncClientTest.java rename to common/rackspace/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java index daeeebdba7..357bbb8553 100755 --- a/common/rackspace/src/test/java/org/jclouds/rackspace/RackspaceAuthAsyncClientTest.java +++ b/common/rackspace/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.rackspace; +package org.jclouds.openstack; import static org.jclouds.rest.RestContextFactory.contextSpec; @@ -27,8 +27,9 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.http.HttpRequest; -import org.jclouds.rackspace.RackspaceAuthAsyncClient.AuthenticationResponse; -import org.jclouds.rackspace.functions.ParseAuthenticationResponseFromHeaders; +import org.jclouds.openstack.OpenStackAuthAsyncClient; +import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse; +import org.jclouds.openstack.functions.ParseAuthenticationResponseFromHeaders; import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; @@ -38,16 +39,16 @@ import org.testng.annotations.Test; import com.google.inject.TypeLiteral; /** - * Tests behavior of {@code RackspaceAuthAsyncClient} + * Tests behavior of {@code OpenStackAuthAsyncClient} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "RackspaceAuthAsyncClientTest") -public class RackspaceAuthAsyncClientTest extends RestClientTest { +@Test(groups = "unit", testName = "OpenStackAuthAsyncClientTest") +public class OpenStackAuthAsyncClientTest extends RestClientTest { public void testAuthenticate() throws SecurityException, NoSuchMethodException, IOException { - Method method = RackspaceAuthAsyncClient.class.getMethod("authenticate", String.class, String.class); + Method method = OpenStackAuthAsyncClient.class.getMethod("authenticate", String.class, String.class); HttpRequest httpRequest = processor.createRequest(method, "foo", "bar"); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/v1.0 HTTP/1.1"); @@ -61,9 +62,9 @@ public class RackspaceAuthAsyncClientTest extends RestClientTest createContextSpec() { - return contextSpec("test", "http://localhost:8080", "1", "identity", "credential", RackspaceAuthClient.class, - RackspaceAuthAsyncClient.class); + public RestContextSpec createContextSpec() { + return contextSpec("test", "http://localhost:8080", "1", "identity", "credential", OpenStackAuthClient.class, + OpenStackAuthAsyncClient.class); } @Override @@ -71,13 +72,13 @@ public class RackspaceAuthAsyncClientTest extends RestClientTest> createTypeLiteral() { - return new TypeLiteral>() { + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { }; } @Timeout(duration = 10, timeUnit = TimeUnit.SECONDS) - public interface RackspaceAuthClient { + public interface OpenStackAuthClient { AuthenticationResponse authenticate(String user, String key); } diff --git a/common/rackspace/src/test/java/org/jclouds/rackspace/TestRackspaceAuthenticationRestClientModule.java b/common/rackspace/src/test/java/org/jclouds/openstack/TestOpenStackAuthenticationModule.java similarity index 69% rename from common/rackspace/src/test/java/org/jclouds/rackspace/TestRackspaceAuthenticationRestClientModule.java rename to common/rackspace/src/test/java/org/jclouds/openstack/TestOpenStackAuthenticationModule.java index 7c70ab5d50..1f039bcff8 100644 --- a/common/rackspace/src/test/java/org/jclouds/rackspace/TestRackspaceAuthenticationRestClientModule.java +++ b/common/rackspace/src/test/java/org/jclouds/openstack/TestOpenStackAuthenticationModule.java @@ -17,22 +17,22 @@ * ==================================================================== */ -package org.jclouds.rackspace; +package org.jclouds.openstack; import java.net.URI; import java.util.Date; -import org.jclouds.http.RequiresHttp; -import org.jclouds.rackspace.RackspaceAuthAsyncClient.AuthenticationResponse; -import org.jclouds.rackspace.config.RackspaceAuthenticationRestModule; -import org.jclouds.rackspace.functions.ParseAuthenticationResponseFromHeaders.AuthenticationResponseImpl; -import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse; +import org.jclouds.openstack.config.OpenStackAuthenticationModule; import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableMap; -@RequiresHttp -@ConfiguresRestClient -public class TestRackspaceAuthenticationRestClientModule extends RackspaceAuthenticationRestModule { +/** + * + * @author Adrian Cole + */ +public class TestOpenStackAuthenticationModule extends OpenStackAuthenticationModule { @Override protected void configure() { super.configure(); @@ -40,8 +40,7 @@ public class TestRackspaceAuthenticationRestClientModule extends RackspaceAuthen @Override protected AuthenticationResponse provideAuthenticationResponse(Supplier supplier) { - return new AuthenticationResponseImpl("authToken", URI.create("http://CDNManagementUrl"), - URI.create("http://serverManagementUrl"), URI.create("http://storageUrl")); + return new AuthenticationResponse("authToken", ImmutableMap. of()); } @Override diff --git a/common/rackspace/src/test/java/org/jclouds/rackspace/filters/AddTimestampQueryTest.java b/common/rackspace/src/test/java/org/jclouds/openstack/filters/AddTimestampQueryTest.java similarity index 95% rename from common/rackspace/src/test/java/org/jclouds/rackspace/filters/AddTimestampQueryTest.java rename to common/rackspace/src/test/java/org/jclouds/openstack/filters/AddTimestampQueryTest.java index 461631919b..b4844ac5c2 100644 --- a/common/rackspace/src/test/java/org/jclouds/rackspace/filters/AddTimestampQueryTest.java +++ b/common/rackspace/src/test/java/org/jclouds/openstack/filters/AddTimestampQueryTest.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.rackspace.filters; +package org.jclouds.openstack.filters; import static org.testng.Assert.assertEquals; @@ -28,6 +28,7 @@ import javax.inject.Provider; import javax.ws.rs.core.UriBuilder; import org.jclouds.http.HttpRequest; +import org.jclouds.openstack.filters.AddTimestampQuery; import org.testng.annotations.Test; import com.google.common.base.Supplier; diff --git a/common/rackspace/src/test/java/org/jclouds/rackspace/options/BaseListOptionsTest.java b/common/rackspace/src/test/java/org/jclouds/openstack/options/BaseListOptionsTest.java similarity index 90% rename from common/rackspace/src/test/java/org/jclouds/rackspace/options/BaseListOptionsTest.java rename to common/rackspace/src/test/java/org/jclouds/openstack/options/BaseListOptionsTest.java index f8ff0b76cd..0c27b46fde 100644 --- a/common/rackspace/src/test/java/org/jclouds/rackspace/options/BaseListOptionsTest.java +++ b/common/rackspace/src/test/java/org/jclouds/openstack/options/BaseListOptionsTest.java @@ -17,15 +17,16 @@ * ==================================================================== */ -package org.jclouds.rackspace.options; +package org.jclouds.openstack.options; -import static org.jclouds.rackspace.options.BaseListOptions.Builder.changesSince; -import static org.jclouds.rackspace.options.BaseListOptions.Builder.maxResults; -import static org.jclouds.rackspace.options.BaseListOptions.Builder.startAt; +import static org.jclouds.openstack.options.BaseListOptions.Builder.changesSince; +import static org.jclouds.openstack.options.BaseListOptions.Builder.maxResults; +import static org.jclouds.openstack.options.BaseListOptions.Builder.startAt; import static org.testng.Assert.assertEquals; import java.util.Date; +import org.jclouds.openstack.options.BaseListOptions; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; diff --git a/common/rackspace/src/test/resources/log4j.xml b/common/rackspace/src/test/resources/log4j.xml deleted file mode 100755 index 5b548a0f48..0000000000 --- a/common/rackspace/src/test/resources/log4j.xml +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/core/src/main/resources/rest.properties b/core/src/main/resources/rest.properties index 0f4dbceee2..3fa98ff2ba 100644 --- a/core/src/main/resources/rest.properties +++ b/core/src/main/resources/rest.properties @@ -99,7 +99,6 @@ nova-ec2.contextbuilder=org.jclouds.ec2.EC2ContextBuilder nova-ec2.propertiesbuilder=org.jclouds.nova.ec2.NovaEC2PropertiesBuilder cloudservers.contextbuilder=org.jclouds.cloudservers.CloudServersContextBuilder -cloudservers.propertiesbuilder=org.jclouds.rackspace.RackspacePropertiesBuilder cloudservers-uk.contextbuilder=org.jclouds.cloudservers.CloudServersContextBuilder cloudservers-uk.propertiesbuilder=org.jclouds.rackspace.cloudservers.CloudServersUKPropertiesBuilder @@ -159,6 +158,9 @@ peer1-storage.apiversion=1.3.0 # TODO hostedsolutions use atmos +swift.contextbuilder=org.jclouds.openstack.swift.SwiftContextBuilder +swift.propertiesbuilder=org.jclouds.openstack.swift.SwiftPropertiesBuilder + cloudfiles.contextbuilder=org.jclouds.cloudfiles.CloudFilesContextBuilder cloudfiles.propertiesbuilder=org.jclouds.cloudfiles.CloudFilesPropertiesBuilder diff --git a/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKPropertiesBuilder.java b/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKPropertiesBuilder.java index ef037347a6..f20e176361 100644 --- a/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKPropertiesBuilder.java +++ b/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKPropertiesBuilder.java @@ -24,13 +24,13 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; -import org.jclouds.cloudfiles.CloudFilesPropertiesBuilder; +import org.jclouds.openstack.swift.SwiftPropertiesBuilder; /** * * @author Adrian Cole */ -public class CloudFilesUKPropertiesBuilder extends CloudFilesPropertiesBuilder { +public class CloudFilesUKPropertiesBuilder extends SwiftPropertiesBuilder { @Override protected Properties defaultProperties() { diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobIntegrationLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobIntegrationLiveTest.java index 46702ec1db..a00aa14ec2 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobIntegrationLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobIntegrationLiveTest.java @@ -19,14 +19,14 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobIntegrationLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobIntegrationLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUKBlobIntegrationLiveTest") -public class CloudFilesUKBlobIntegrationLiveTest extends CloudFilesBlobIntegrationLiveTest { +public class CloudFilesUKBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest { } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobLiveTest.java index 9109a36bd9..5c49c09b0d 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUKBlobLiveTest") -public class CloudFilesUKBlobLiveTest extends CloudFilesBlobLiveTest { +public class CloudFilesUKBlobLiveTest extends SwiftBlobLiveTest { } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobMapIntegrationLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobMapIntegrationLiveTest.java index 2c9eb336bb..4f0c05f84c 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobMapIntegrationLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobMapIntegrationLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobMapIntegrationLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobMapIntegrationLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUKBlobMapIntegrationLiveTest") -public class CloudFilesUKBlobMapIntegrationLiveTest extends CloudFilesBlobMapIntegrationLiveTest { +public class CloudFilesUKBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest { } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobSignerLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobSignerLiveTest.java index beeeefdb67..6a9590ebd6 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobSignerLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobSignerLiveTest.java @@ -19,7 +19,7 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobSignerLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobSignerLiveTest; import org.testng.annotations.Test; /** @@ -27,6 +27,6 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUKBlobSignerLiveTest") -public class CloudFilesUKBlobSignerLiveTest extends CloudFilesBlobSignerLiveTest { +public class CloudFilesUKBlobSignerLiveTest extends SwiftBlobSignerLiveTest { } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerIntegrationLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerIntegrationLiveTest.java index f42f0b0fe3..4ad615ca98 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerIntegrationLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerIntegrationLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesContainerIntegrationLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftContainerIntegrationLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUKContainerIntegrationLiveTest") -public class CloudFilesUKContainerIntegrationLiveTest extends CloudFilesContainerIntegrationLiveTest { +public class CloudFilesUKContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest { } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerLiveTest.java index 9db18199d7..050c741b13 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesContainerLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftContainerLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUKContainerLiveTest") -public class CloudFilesUKContainerLiveTest extends CloudFilesContainerLiveTest { +public class CloudFilesUKContainerLiveTest extends SwiftContainerLiveTest { } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKInputStreamMapIntegrationLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKInputStreamMapIntegrationLiveTest.java index 5a825bb8c2..fc3f4b317d 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKInputStreamMapIntegrationLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKInputStreamMapIntegrationLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesInputStreamMapIntegrationLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftInputStreamMapIntegrationLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUKInputStreamMapIntegrationLiveTest") -public class CloudFilesUKInputStreamMapIntegrationLiveTest extends CloudFilesInputStreamMapIntegrationLiveTest { +public class CloudFilesUKInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest { } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKServiceIntegrationLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKServiceIntegrationLiveTest.java index 51f682cadb..96d83d3bd3 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKServiceIntegrationLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKServiceIntegrationLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesServiceIntegrationLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftServiceIntegrationLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUKServiceIntegrationLiveTest") -public class CloudFilesUKServiceIntegrationLiveTest extends CloudFilesServiceIntegrationLiveTest { +public class CloudFilesUKServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest { } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKTestInitializer.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKTestInitializer.java index ae2511c567..3e73132fb4 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKTestInitializer.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKTestInitializer.java @@ -19,13 +19,13 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesTestInitializer; +import org.jclouds.openstack.swift.blobstore.integration.SwiftTestInitializer; /** * * @author Adrian Cole */ -public class CloudFilesUKTestInitializer extends CloudFilesTestInitializer { +public class CloudFilesUKTestInitializer extends SwiftTestInitializer { public CloudFilesUKTestInitializer() { provider = "cloudfiles-uk"; diff --git a/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSPropertiesBuilder.java b/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSPropertiesBuilder.java index 5144acb5fb..2db429c1c7 100644 --- a/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSPropertiesBuilder.java +++ b/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSPropertiesBuilder.java @@ -24,13 +24,13 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; -import org.jclouds.cloudfiles.CloudFilesPropertiesBuilder; +import org.jclouds.openstack.swift.SwiftPropertiesBuilder; /** * * @author Adrian Cole */ -public class CloudFilesUSPropertiesBuilder extends CloudFilesPropertiesBuilder { +public class CloudFilesUSPropertiesBuilder extends SwiftPropertiesBuilder { @Override protected Properties defaultProperties() { diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobIntegrationLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobIntegrationLiveTest.java index 3b287b5432..281576f240 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobIntegrationLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobIntegrationLiveTest.java @@ -19,14 +19,14 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobIntegrationLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobIntegrationLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUSBlobIntegrationLiveTest") -public class CloudFilesUSBlobIntegrationLiveTest extends CloudFilesBlobIntegrationLiveTest { +public class CloudFilesUSBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest { } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobLiveTest.java index 59d0103527..b1158fadf4 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUSBlobLiveTest") -public class CloudFilesUSBlobLiveTest extends CloudFilesBlobLiveTest { +public class CloudFilesUSBlobLiveTest extends SwiftBlobLiveTest { } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobMapIntegrationLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobMapIntegrationLiveTest.java index 1540ef9bd4..7175e14a6b 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobMapIntegrationLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobMapIntegrationLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobMapIntegrationLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobMapIntegrationLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUSBlobMapIntegrationLiveTest") -public class CloudFilesUSBlobMapIntegrationLiveTest extends CloudFilesBlobMapIntegrationLiveTest { +public class CloudFilesUSBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest { } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobSignerLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobSignerLiveTest.java index 0541046fb0..d0d1350612 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobSignerLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobSignerLiveTest.java @@ -19,7 +19,7 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobSignerLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobSignerLiveTest; import org.testng.annotations.Test; /** @@ -27,6 +27,6 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUSBlobSignerLiveTest") -public class CloudFilesUSBlobSignerLiveTest extends CloudFilesBlobSignerLiveTest { +public class CloudFilesUSBlobSignerLiveTest extends SwiftBlobSignerLiveTest { } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerIntegrationLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerIntegrationLiveTest.java index db03070640..a7de0c89f6 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerIntegrationLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerIntegrationLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesContainerIntegrationLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftContainerIntegrationLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUSContainerIntegrationLiveTest") -public class CloudFilesUSContainerIntegrationLiveTest extends CloudFilesContainerIntegrationLiveTest { +public class CloudFilesUSContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest { } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerLiveTest.java index b7cb9150d3..94ceb5e773 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesContainerLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftContainerLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUSContainerLiveTest") -public class CloudFilesUSContainerLiveTest extends CloudFilesContainerLiveTest { +public class CloudFilesUSContainerLiveTest extends SwiftContainerLiveTest { } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSInputStreamMapIntegrationLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSInputStreamMapIntegrationLiveTest.java index 84f4121398..20c10cfb67 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSInputStreamMapIntegrationLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSInputStreamMapIntegrationLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesInputStreamMapIntegrationLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftInputStreamMapIntegrationLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUSInputStreamMapIntegrationLiveTest") -public class CloudFilesUSInputStreamMapIntegrationLiveTest extends CloudFilesInputStreamMapIntegrationLiveTest { +public class CloudFilesUSInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest { } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSServiceIntegrationLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSServiceIntegrationLiveTest.java index 593a343890..534904a076 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSServiceIntegrationLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSServiceIntegrationLiveTest.java @@ -19,13 +19,13 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesServiceIntegrationLiveTest; +import org.jclouds.openstack.swift.blobstore.integration.SwiftServiceIntegrationLiveTest; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = "live", testName = "CloudFilesUSServiceIntegrationLiveTest") -public class CloudFilesUSServiceIntegrationLiveTest extends CloudFilesServiceIntegrationLiveTest { +public class CloudFilesUSServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest { } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSTestInitializer.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSTestInitializer.java index 0e63ec20fc..7f9420d9e6 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSTestInitializer.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSTestInitializer.java @@ -19,13 +19,13 @@ package org.jclouds.rackspace.cloudfiles.blobstore.integration; -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesTestInitializer; +import org.jclouds.openstack.swift.blobstore.integration.SwiftTestInitializer; /** * * @author Adrian Cole */ -public class CloudFilesUSTestInitializer extends CloudFilesTestInitializer { +public class CloudFilesUSTestInitializer extends SwiftTestInitializer { public CloudFilesUSTestInitializer() { provider = "cloudfiles-us"; diff --git a/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKPropertiesBuilder.java b/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKPropertiesBuilder.java index 47cd0363d4..81df7d9e66 100644 --- a/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKPropertiesBuilder.java +++ b/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKPropertiesBuilder.java @@ -19,24 +19,27 @@ package org.jclouds.rackspace.cloudservers; +import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; -import org.jclouds.rackspace.RackspacePropertiesBuilder; +import org.jclouds.PropertiesBuilder; +import org.jclouds.openstack.OpenStackAuthAsyncClient; /** * * @author Adrian Cole */ -public class CloudServersUKPropertiesBuilder extends RackspacePropertiesBuilder { +public class CloudServersUKPropertiesBuilder extends PropertiesBuilder { @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_REGIONS, "UK"); properties.setProperty(PROPERTY_ENDPOINT, "https://lon.auth.api.rackspacecloud.com"); + properties.setProperty(PROPERTY_API_VERSION, OpenStackAuthAsyncClient.VERSION); return properties; } diff --git a/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSPropertiesBuilder.java b/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSPropertiesBuilder.java index 490db8ca92..688b685b9e 100644 --- a/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSPropertiesBuilder.java +++ b/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSPropertiesBuilder.java @@ -19,24 +19,27 @@ package org.jclouds.rackspace.cloudservers; +import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; -import org.jclouds.rackspace.RackspacePropertiesBuilder; +import org.jclouds.PropertiesBuilder; +import org.jclouds.openstack.OpenStackAuthAsyncClient; /** * * @author Adrian Cole */ -public class CloudServersUSPropertiesBuilder extends RackspacePropertiesBuilder { +public class CloudServersUSPropertiesBuilder extends PropertiesBuilder { @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_REGIONS, "US"); properties.setProperty(PROPERTY_ENDPOINT, "https://auth.api.rackspacecloud.com"); + properties.setProperty(PROPERTY_API_VERSION, OpenStackAuthAsyncClient.VERSION); return properties; }