Remove old cloudfiles providers
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/87b88530 Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/87b88530 Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/87b88530 Branch: refs/heads/master Commit: 87b885306b3e42820697be0f31c3cb66d684a1be Parents: 7787b50 Author: Zack Shoylev <zack.shoy...@rackspace.com> Authored: Thu Jun 25 11:40:59 2015 -0500 Committer: Zack Shoylev <zack.shoy...@rackspace.com> Committed: Fri Jun 26 02:32:16 2015 -0500 ---------------------------------------------------------------------- apis/cloudfiles/README.txt | 6 - apis/cloudfiles/pom.xml | 137 ---------- .../org/jclouds/cloudfiles/CDNManagement.java | 36 --- .../cloudfiles/CloudFilesApiMetadata.java | 92 ------- .../jclouds/cloudfiles/CloudFilesClient.java | 251 ------------------- ...terableToHeadersWithPurgeCDNObjectEmail.java | 48 ---- .../blobstore/CloudFilesBlobStore.java | 81 ------ .../CloudFilesBlobStoreContextModule.java | 62 ----- .../CloudFilesObjectToBlobMetadata.java | 45 ---- .../blobstore/functions/EnableCDNAndCache.java | 47 ---- .../functions/PublicUriForObjectInfo.java | 68 ----- .../config/CloudFilesHttpApiModule.java | 92 ------- .../cloudfiles/domain/ContainerCDNMetadata.java | 137 ---------- .../functions/ParseCdnUriFromHeaders.java | 41 --- .../ParseContainerCDNMetadataFromHeaders.java | 75 ------ .../options/ListCdnContainerOptions.java | 84 ------- .../org/jclouds/cloudfiles/package-info.java | 22 -- .../cloudfiles/reference/CloudFilesHeaders.java | 44 ---- .../cloudfiles/reference/package-info.java | 20 -- .../cloudfiles/CloudFilesApiMetadataTest.java | 28 --- .../cloudfiles/CloudFilesClientExpectTest.java | 249 ------------------ .../cloudfiles/CloudFilesClientLiveTest.java | 169 ------------- ...bleToHeadersWithPurgeCDNObjectEmailTest.java | 72 ------ .../CloudFilesBlobSignerExpectTest.java | 149 ----------- .../CloudFilesBlobIntegrationLiveTest.java | 60 ----- .../integration/CloudFilesBlobLiveTest.java | 49 ---- .../CloudFilesBlobSignerLiveTest.java | 27 -- .../CloudFilesContainerIntegrationLiveTest.java | 27 -- .../CloudFilesContainerLiveTest.java | 27 -- .../CloudFilesServiceIntegrationLiveTest.java | 27 -- .../config/CloudFilesRestClientModuleTest.java | 46 ---- ...inerCDNMetadataListFromJsonResponseTest.java | 83 ------ .../BaseCloudFilesRestClientExpectTest.java | 47 ---- .../src/test/resources/test_list_cdn.json | 32 --- apis/pom.xml | 1 - providers/cloudfiles-uk/README.txt | 8 - providers/cloudfiles-uk/pom.xml | 136 ---------- .../CloudFilesUKProviderMetadata.java | 83 ------ .../cloudfiles/CloudFilesUKClientLiveTest.java | 48 ---- .../cloudfiles/CloudFilesUKProviderTest.java | 29 --- .../CloudFilesUKBlobIntegrationLiveTest.java | 28 --- .../integration/CloudFilesUKBlobLiveTest.java | 28 --- .../CloudFilesUKBlobSignerLiveTest.java | 27 -- ...loudFilesUKContainerIntegrationLiveTest.java | 28 --- .../CloudFilesUKContainerLiveTest.java | 28 --- .../CloudFilesUKServiceIntegrationLiveTest.java | 36 --- providers/cloudfiles-us/README.txt | 8 - providers/cloudfiles-us/pom.xml | 138 ---------- .../CloudFilesUSProviderMetadata.java | 84 ------- .../cloudfiles/CloudFilesUSClientLiveTest.java | 30 --- .../cloudfiles/CloudFilesUSProviderTest.java | 29 --- .../CloudFilesUSBlobIntegrationLiveTest.java | 27 -- .../integration/CloudFilesUSBlobLiveTest.java | 27 -- .../CloudFilesUSBlobSignerLiveTest.java | 27 -- ...loudFilesUSContainerIntegrationLiveTest.java | 27 -- .../CloudFilesUSContainerLiveTest.java | 27 -- .../CloudFilesUSServiceIntegrationLiveTest.java | 35 --- providers/pom.xml | 2 - 58 files changed, 3421 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/README.txt ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/README.txt b/apis/cloudfiles/README.txt deleted file mode 100644 index 00318db..0000000 --- a/apis/cloudfiles/README.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -# The jclouds API for Rackspace's Cloud Files (http://www.rackspacecloud.com/cloud_hosting_products/files/). -# -# TODO: Implementation status. -# TODO: Supported features. -# TODO: Usage example. http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/pom.xml ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/pom.xml b/apis/cloudfiles/pom.xml deleted file mode 100644 index 97c04b6..0000000 --- a/apis/cloudfiles/pom.xml +++ /dev/null @@ -1,137 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-project</artifactId> - <version>2.0.0-SNAPSHOT</version> - <relativePath>../../project/pom.xml</relativePath> - </parent> - <groupId>org.apache.jclouds.api</groupId> - <artifactId>cloudfiles</artifactId> - <name>jclouds cloudfiles api</name> - <description>jclouds components to access an implementation of CloudFiles</description> - <packaging>bundle</packaging> - - <properties> - <test.blobstore.container-count>15</test.blobstore.container-count> - <test.cloudfiles.endpoint>https://auth.api.rackspacecloud.com</test.cloudfiles.endpoint> - <test.cloudfiles.api-version>1.0</test.cloudfiles.api-version> - <test.cloudfiles.build-version /> - <test.cloudfiles.identity>${test.rackspace.identity}</test.cloudfiles.identity> - <test.cloudfiles.credential>${test.rackspace.credential}</test.cloudfiles.credential> - <jclouds.osgi.export>org.jclouds.cloudfiles*;version="${project.version}"</jclouds.osgi.export> - <jclouds.osgi.import> - org.jclouds*;version="${project.version}", - org.jclouds.openstack.swift.options;version="${project.version}", - * - </jclouds.osgi.import> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.jclouds.api</groupId> - <artifactId>swift</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-core</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.jclouds.common</groupId> - <artifactId>openstack-common</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-blobstore</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.jclouds.api</groupId> - <artifactId>swift</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.jclouds.driver</groupId> - <artifactId>jclouds-log4j</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.auto.service</groupId> - <artifactId>auto-service</artifactId> - <optional>true</optional> - </dependency> - </dependencies> - - <profiles> - <profile> - <id>live</id> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <executions> - <execution> - <id>integration</id> - <phase>integration-test</phase> - <goals> - <goal>test</goal> - </goals> - <configuration> - <systemPropertyVariables> - <test.blobstore.container-count>${test.blobstore.container-count}</test.blobstore.container-count> - <jclouds.blobstore.httpstream.url>${jclouds.blobstore.httpstream.url}</jclouds.blobstore.httpstream.url> - <jclouds.blobstore.httpstream.md5>${jclouds.blobstore.httpstream.md5}</jclouds.blobstore.httpstream.md5> - <test.cloudfiles.endpoint>${test.cloudfiles.endpoint}</test.cloudfiles.endpoint> - <test.cloudfiles.api-version>${test.cloudfiles.api-version}</test.cloudfiles.api-version> - <test.cloudfiles.build-version>${test.cloudfiles.build-version}</test.cloudfiles.build-version> - <test.cloudfiles.identity>${test.cloudfiles.identity}</test.cloudfiles.identity> - <test.cloudfiles.credential>${test.cloudfiles.credential}</test.cloudfiles.credential> - </systemPropertyVariables> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> - -</project> - http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CDNManagement.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CDNManagement.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CDNManagement.java deleted file mode 100644 index 14e38c5..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CDNManagement.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * Represents a component related to Rackspace Cloud Files Content delivery network. - * - * @see <a href="http://www.rackspacecloud.com/cf-devguide-20090311.pdf" /> - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Qualifier -public @interface CDNManagement { - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java deleted file mode 100644 index 7d4de81..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.blobstore.BlobRequestSigner; -import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule; -import org.jclouds.cloudfiles.config.CloudFilesHttpApiModule; -import org.jclouds.cloudfiles.config.CloudFilesHttpApiModule.StorageAndCDNManagementEndpointModule; -import org.jclouds.openstack.swift.SwiftApiMetadata; -import org.jclouds.openstack.swift.blobstore.SwiftBlobSigner; -import org.jclouds.openstack.swift.blobstore.config.TemporaryUrlExtensionModule; - -import com.google.auto.service.AutoService; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; -import com.google.inject.TypeLiteral; - -@AutoService(ApiMetadata.class) -public class CloudFilesApiMetadata extends SwiftApiMetadata { - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public CloudFilesApiMetadata() { - this(new Builder()); - } - - protected CloudFilesApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = SwiftApiMetadata.defaultProperties(); - return properties; - } - - public static class Builder extends SwiftApiMetadata.Builder<CloudFilesClient, Builder> { - - protected Builder() { - super(CloudFilesClient.class); - id("cloudfiles") - .name("Rackspace Cloud Files API") - .identityName("Username") - .credentialName("API Key") - .documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html")) - .defaultProperties(CloudFilesApiMetadata.defaultProperties()) - .defaultModules(ImmutableSet.<Class<? extends Module>>builder() - .add(StorageAndCDNManagementEndpointModule.class) - .add(CloudFilesHttpApiModule.class) - .add(CloudFilesBlobStoreContextModule.class) - .add(CloudFilesTemporaryUrlExtensionModule.class).build()); - } - - @Override - public CloudFilesApiMetadata build() { - return new CloudFilesApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } - - public static class CloudFilesTemporaryUrlExtensionModule extends TemporaryUrlExtensionModule<CloudFilesClient> { - @Override - protected void bindRequestSigner() { - bind(BlobRequestSigner.class).to(new TypeLiteral<SwiftBlobSigner<CloudFilesClient>>() { - }); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesClient.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesClient.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesClient.java deleted file mode 100644 index 9834133..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesClient.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles; - -import static javax.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.jclouds.blobstore.BlobStoreFallbacks.NullOnContainerNotFound; -import static org.jclouds.cloudfiles.reference.CloudFilesHeaders.CDN_CONTAINER_PURGE_OBJECT_EMAIL; -import static org.jclouds.cloudfiles.reference.CloudFilesHeaders.CDN_ENABLED; -import static org.jclouds.cloudfiles.reference.CloudFilesHeaders.CDN_LOG_RETENTION; -import static org.jclouds.cloudfiles.reference.CloudFilesHeaders.CDN_TTL; -import static org.jclouds.cloudfiles.reference.CloudFilesHeaders.CDN_WEBSITE_ERROR; -import static org.jclouds.cloudfiles.reference.CloudFilesHeaders.CDN_WEBSITE_INDEX; - -import java.net.URI; -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HEAD; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; - -import org.jclouds.cloudfiles.binders.BindIterableToHeadersWithPurgeCDNObjectEmail; -import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; -import org.jclouds.cloudfiles.functions.ParseCdnUriFromHeaders; -import org.jclouds.cloudfiles.functions.ParseContainerCDNMetadataFromHeaders; -import org.jclouds.cloudfiles.options.ListCdnContainerOptions; -import org.jclouds.openstack.filters.AuthenticateRequest; -import org.jclouds.openstack.swift.Storage; -import org.jclouds.openstack.swift.SwiftClient; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Endpoint; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; - -/** Provides access to Cloud Files via their REST API. */ -@RequestFilters(AuthenticateRequest.class) -@Endpoint(Storage.class) -public interface CloudFilesClient extends SwiftClient { - - /** - * Retrieve a list of existing CDN-enabled containers. - */ - @Named("ListCDNEnabledContainers") - @GET - @Consumes(APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/") - @Endpoint(CDNManagement.class) - Set<ContainerCDNMetadata> listCDNContainers(ListCdnContainerOptions... options); - - /** - * Get the CDN attributes of the container. - * - * If the container is (or ever has been) CDN-enabled, the URL, TTL, enabled status, and log retention status are - * returned in the response headers. Its CDN URL can be combined with any object name within the container to form - * the publicly accessible URL for that object for distribution over a CDN system. The TTL value is the number of - * seconds that the object will be cached in the CDN system before being refetched. The enabled status indicates - * whether the container is currently marked to allow public serving of objects via CDN. The log_retention setting - * specifies whether the CDN access logs should be collected and stored in the Cloud Files storage system. - */ - @Named("ListCDNEnabledContainerMetadata") - @HEAD - @ResponseParser(ParseContainerCDNMetadataFromHeaders.class) - @Fallback(NullOnContainerNotFound.class) - @Path("/{container}") - @Endpoint(CDNManagement.class) - ContainerCDNMetadata getCDNMetadata(@PathParam("container") String container); - - /** - * Before a container can be CDN-enabled, it must exist in the storage system. When a container is CDN-enabled, any - * objects stored in it are publicly accessible over the Content Delivery Network by combining the container's CDN - * URL with the object name. - * - * Any CDN-accessed objects are cached in the CDN for the specified amount of time called the TTL, or Time to Live. - * The default TTL value is 259200 seconds, or 72 hours. Each time the object is accessed after the TTL expires, the - * CDN refetches and caches the object for the TTL period. - * - * You specify the TTL for an object via the ttl parameter. Setting the TTL is the same as setting the HTTP Expires - * and Cache-Control headers for the cached object. The minimum TTL is 15 minutes and the maximum is 1 year for a - * range of 900 to 31536000 seconds. Setting a TTL for a long time, however, does not guarantee that the content - * will stay populated on CDN edge servers for the entire period. The most popular objects stay cached based on the - * edge location's logic. - */ - @Named("CDNEnableContainer") - @PUT - @Path("/{container}") - @Headers(keys = CDN_ENABLED, values = "True") - @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CDNManagement.class) - URI enableCDN(@PathParam("container") String container, - @HeaderParam(CDN_TTL) long ttl, - @HeaderParam(CDN_LOG_RETENTION) boolean logRetention); - - - /** - * @see CloudFilesClient#enableCDN(String, long, boolean) - */ - @Named("CDNEnableContainer") - @PUT - @Path("/{container}") - @Headers(keys = CDN_ENABLED, values = "True") - @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CDNManagement.class) - URI enableCDN(@PathParam("container") String container, @HeaderParam(CDN_TTL) long ttl); - - /** - * @see CloudFilesClient#enableCDN(String, long, boolean) - */ - @Named("CDNEnableContainer") - @PUT - @Path("/{container}") - @Headers(keys = CDN_ENABLED, values = "True") - @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CDNManagement.class) - URI enableCDN(@PathParam("container") String container); - - /** - * @see CloudFilesClient#enableCDN(String, long, boolean) - */ - @Named("UpdateCDNEnabledContainerMetadata") - @POST - @Path("/{container}") - @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CDNManagement.class) - URI updateCDN(@PathParam("container") String container, - @HeaderParam(CDN_TTL) long ttl, - @HeaderParam(CDN_LOG_RETENTION) boolean logRetention); - - /** - * @see CloudFilesClient#enableCDN(String, long, boolean) - */ - @Named("UpdateCDNEnabledContainerMetadata") - @POST - @Path("/{container}") - @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CDNManagement.class) - URI updateCDN(@PathParam("container") String container, @HeaderParam(CDN_LOG_RETENTION) boolean logRetention); - - /** - * @see CloudFilesClient#enableCDN(String, long, boolean) - */ - @Named("UpdateCDNEnabledContainerMetadata") - @POST - @Path("/{container}") - @ResponseParser(ParseCdnUriFromHeaders.class) - @Endpoint(CDNManagement.class) - URI updateCDN(@PathParam("container") String container, @HeaderParam(CDN_TTL) long ttl); - - /** - * Remove the container from the CDN. Please note, however, that objects remain public until their TTL expires. - */ - @Named("DisableCDNEnabledContainer") - @POST - @Path("/{container}") - @Headers(keys = CDN_ENABLED, values = "False") - @Endpoint(CDNManagement.class) - boolean disableCDN(@PathParam("container") String container); - - /** - * You can purge a CDN-enabled object when you find it absolutely necessary to remove the object from public access - * and you cannot wait for the TTL to expire. You should limit object purges to situations where there could be - * serious personal, business, or security consequences if it remained in the CDN. For example, someone published - * your company's quarterly earnings too early. You can manually purge CDN-enabled objects without having to wait - * for the TTL to expire, and you can optionally be notified by email that the object has been purged. However, you - * may only DELETE up to 25 objects per day. Any attempt to delete more than this will result in a 498 status code - * error (Rate Limited). - * - * There are two ways you may purge objects from the edge: (1) individually using purgeCDNObject() in the API or - * (2) by creating a support ticket to purge entire containers. The 25-object limit does not apply when purging an - * entire container via Support. - */ - @Named("PurgeCDNEnabledObject") - @DELETE - @Path("/{container}/{object}") - @Headers(keys = CDN_CONTAINER_PURGE_OBJECT_EMAIL, values = "{email}") - @Endpoint(CDNManagement.class) - boolean purgeCDNObject(@PathParam("container") String container, @PathParam("object") String object, - @BinderParam(BindIterableToHeadersWithPurgeCDNObjectEmail.class) Iterable<String> emails); - - - /** - * @see CloudFilesClient#purgeCDNObject(String, String, Iterable) - */ - @Named("PurgeCDNEnabledObject") - @DELETE - @Path("/{container}/{object}") - @Endpoint(CDNManagement.class) - boolean purgeCDNObject(@PathParam("container") String container, @PathParam("object") String object); - - /** - * You may use your Cloud Files account to create a static website on the World Wide Web. First, you must CDN-enable - * a storage container. Any HTML or static web pages in the container will become available through a static website - * once you set the parameter index to "index.html" or other index page of your choice. You may also create - * subdirectories in your website by creating pseudo-directories (objects with a '/' in the name). - * - * The page you set for index becomes the index page for every subdirectory in your website; each of your - * pseudo-directories should contain a file with that name. So, if you set index to "index.html", you should have an - * index.html page in each pseudo-directory. If you do not have the named index page, visits to myhost/subdir/ will - * return a 404 error. - * - * To setup a domain name for your static website, create a CNAME with your DNS Server (or name server). This is the - * domain name of your site (such as www.example.com). Your CNAME is set up with your individual DNS Server, which - * is outside the scope of this documentation. Once you have your CNAME established, map your domain name to your - * Cloud Files CDN URL to get your site up and running on the Web. - */ - @Named("UpdateCDNEnabledContainerMetadata") - @POST - @Path("/{container}") - @Headers(keys = CDN_WEBSITE_INDEX, values = "{index}") - boolean setCDNStaticWebsiteIndex(@PathParam("container") String container, @PathParam("index") String index); - - /** - * You may create and set custom error pages for visitors to your website; currently, only 401 (Unauthorized) and - * 404 (Not Found) errors are supported. To do this, set the error parameter. - * - * Error pages are served with the <status> code prepended to the name of the error page you set. For instance, if - * you set error to "error.html", 401 errors will display the page 401error.html. Similarly, 404 errors will display - * 404error.html. You must have both of these pages created in your container when you set the error parameter, or - * your site will display generic error pages. - * - * You need only set the error parameter once for your entire static website. - */ - @Named("UpdateCDNEnabledContainerMetadata") - @POST - @Path("/{container}") - @Headers(keys = CDN_WEBSITE_ERROR, values = "{error}") - boolean setCDNStaticWebsiteError(@PathParam("container") String container, @PathParam("error") String error); -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/binders/BindIterableToHeadersWithPurgeCDNObjectEmail.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/binders/BindIterableToHeadersWithPurgeCDNObjectEmail.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/binders/BindIterableToHeadersWithPurgeCDNObjectEmail.java deleted file mode 100644 index a439814..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/binders/BindIterableToHeadersWithPurgeCDNObjectEmail.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; - -import javax.inject.Singleton; - -import org.jclouds.cloudfiles.reference.CloudFilesHeaders; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableMultimap; - -@Singleton -public class BindIterableToHeadersWithPurgeCDNObjectEmail implements Binder { - @SuppressWarnings("unchecked") - @Override - public <R extends HttpRequest> R bindToRequest(R request, Object input) { - checkArgument(checkNotNull(input, "input") instanceof Iterable<?>, "this binder is only valid for Iterable!"); - checkNotNull(request, "request"); - - Iterable<String> emails = (Iterable<String>) input; - String emailCSV = Joiner.on(", ").join((List<String>) emails); - ImmutableMultimap<String, String> headers = - ImmutableMultimap.<String, String> of(CloudFilesHeaders.CDN_CONTAINER_PURGE_OBJECT_EMAIL, emailCSV); - - return (R) request.toBuilder().replaceHeaders(headers).build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java deleted file mode 100644 index 176dfec..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles.blobstore; - -import static org.jclouds.Constants.PROPERTY_USER_THREADS; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; - -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.functions.BlobToHttpGetOptions; -import org.jclouds.blobstore.options.CreateContainerOptions; -import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata; -import org.jclouds.blobstore.util.BlobUtils; -import org.jclouds.cloudfiles.blobstore.functions.EnableCDNAndCache; -import org.jclouds.collect.Memoized; -import org.jclouds.domain.Location; -import org.jclouds.io.PayloadSlicer; -import org.jclouds.openstack.swift.CommonSwiftClient; -import org.jclouds.openstack.swift.blobstore.SwiftBlobStore; -import org.jclouds.openstack.swift.blobstore.functions.BlobStoreListContainerOptionsToListContainerOptions; -import org.jclouds.openstack.swift.blobstore.functions.BlobToObject; -import org.jclouds.openstack.swift.blobstore.functions.ContainerToResourceList; -import org.jclouds.openstack.swift.blobstore.functions.ContainerToResourceMetadata; -import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlob; -import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata; -import org.jclouds.openstack.swift.blobstore.strategy.internal.MultipartUploadStrategy; - -import com.google.common.base.Supplier; -import com.google.common.util.concurrent.ListeningExecutorService; - -@Singleton -public class CloudFilesBlobStore extends SwiftBlobStore { - - private EnableCDNAndCache enableCDNAndCache; - - @Inject - protected CloudFilesBlobStore(@Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, - BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation, - @Memoized Supplier<Set<? extends Location>> locations, PayloadSlicer slicer, CommonSwiftClient sync, - ContainerToResourceMetadata container2ResourceMd, - BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, - ContainerToResourceList container2ResourceList, ObjectToBlob object2Blob, BlobToObject blob2Object, - ObjectToBlobMetadata object2BlobMd, BlobToHttpGetOptions blob2ObjectGetOptions, - Provider<FetchBlobMetadata> fetchBlobMetadataProvider, EnableCDNAndCache enableCDNAndCache, - Provider<MultipartUploadStrategy> multipartUploadStrategy) { - super(userExecutor, context, blobUtils, defaultLocation, locations, slicer, sync, container2ResourceMd, - container2ContainerListOptions, container2ResourceList, object2Blob, blob2Object, object2BlobMd, - blob2ObjectGetOptions, fetchBlobMetadataProvider, multipartUploadStrategy); - this.enableCDNAndCache = enableCDNAndCache; - - } - - @Override - public boolean createContainerInLocation(Location location, String container, CreateContainerOptions options) { - try { - return createContainerInLocation(location, container); - } finally { - if (options.isPublicRead()) - enableCDNAndCache.apply(container); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java deleted file mode 100644 index 6454c50..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles.blobstore.config; - -import java.net.URI; -import java.util.concurrent.TimeUnit; - -import javax.inject.Singleton; - -import org.jclouds.cloudfiles.CloudFilesClient; -import org.jclouds.cloudfiles.blobstore.CloudFilesBlobStore; -import org.jclouds.cloudfiles.blobstore.functions.CloudFilesObjectToBlobMetadata; -import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; -import org.jclouds.openstack.swift.blobstore.SwiftBlobStore; -import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule; -import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata; - -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.inject.Provides; - -public class CloudFilesBlobStoreContextModule extends SwiftBlobStoreContextModule { - - @Provides - @Singleton - protected LoadingCache<String, URI> cdnContainer(final CloudFilesClient client) { - return CacheBuilder.newBuilder().expireAfterWrite(30, TimeUnit.SECONDS).build(new CacheLoader<String, URI>() { - @Override - public URI load(String container) { - ContainerCDNMetadata md = client.getCDNMetadata(container); - return md != null ? md.getCDNUri() : null; - } - - @Override - public String toString() { - return "getCDNMetadata()"; - } - }); - } - - @Override - protected void configure() { - super.configure(); - bind(SwiftBlobStore.class).to(CloudFilesBlobStore.class); - bind(ObjectToBlobMetadata.class).to(CloudFilesObjectToBlobMetadata.class); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/CloudFilesObjectToBlobMetadata.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/CloudFilesObjectToBlobMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/CloudFilesObjectToBlobMetadata.java deleted file mode 100644 index bf17e49..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/CloudFilesObjectToBlobMetadata.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles.blobstore.functions; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.blobstore.domain.MutableBlobMetadata; -import org.jclouds.blobstore.strategy.IfDirectoryReturnNameStrategy; -import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata; -import org.jclouds.openstack.swift.domain.ObjectInfo; - -@Singleton -public class CloudFilesObjectToBlobMetadata extends ObjectToBlobMetadata { - private final PublicUriForObjectInfo publicUriForObjectInfo; - - @Inject - public CloudFilesObjectToBlobMetadata(IfDirectoryReturnNameStrategy ifDirectoryReturnName, - PublicUriForObjectInfo publicUriForObjectInfo) { - super(ifDirectoryReturnName); - this.publicUriForObjectInfo = publicUriForObjectInfo; - } - - public MutableBlobMetadata apply(ObjectInfo from) { - if (from == null) - return null; - MutableBlobMetadata to = super.apply(from); - to.setPublicUri(publicUriForObjectInfo.apply(from)); - return to; - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/EnableCDNAndCache.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/EnableCDNAndCache.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/EnableCDNAndCache.java deleted file mode 100644 index 1f46a70..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/EnableCDNAndCache.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles.blobstore.functions; - -import java.net.URI; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudfiles.CloudFilesClient; - -import com.google.common.base.Function; -import com.google.common.cache.LoadingCache; - -@Singleton -public class EnableCDNAndCache implements Function<String, URI> { - private final LoadingCache<String, URI> cdnContainer; - private final CloudFilesClient sync; - - @Inject - public EnableCDNAndCache(CloudFilesClient sync, LoadingCache<String, URI> cdnContainer) { - this.sync = sync; - this.cdnContainer = cdnContainer; - } - - @Override - public URI apply(String input) { - URI uri = sync.enableCDN(input); - cdnContainer.put(input, uri); - return uri; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/PublicUriForObjectInfo.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/PublicUriForObjectInfo.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/PublicUriForObjectInfo.java deleted file mode 100644 index 55e1afd..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/functions/PublicUriForObjectInfo.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles.blobstore.functions; - -import static org.jclouds.http.Uris.uriBuilder; - -import java.net.URI; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.openstack.swift.domain.ObjectInfo; - -import com.google.common.base.Function; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; - -@Singleton -public class PublicUriForObjectInfo implements Function<ObjectInfo, URI> { - - private final LoadingCache<String, URI> cdnContainer; - - @Inject - public PublicUriForObjectInfo(LoadingCache<String, URI> cdnContainer) { - this.cdnContainer = cdnContainer; - } - - private static final URI NEGATIVE_ENTRY = URI.create("http://127.0.0.1"); - - public URI apply(ObjectInfo from) { - if (from == null) - return null; - String containerName = from.getContainer(); - if (containerName == null) - return null; - try { - URI uri = cdnContainer.getUnchecked(containerName); - if (uri == NEGATIVE_ENTRY) { // intentionally use reference equality - // TODO: GetCDNMetadata.load returns null on failure cases. We use - // a negative entry to avoid repeatedly issuing failed CDN queries. - // The LoadingCache removes this value after its normal expiry. - return null; - } - return uriBuilder(uri).clearQuery().appendPath(from.getName()).build(); - } catch (CacheLoader.InvalidCacheLoadException e) { - // nulls not permitted from cache loader - cdnContainer.put(containerName, NEGATIVE_ENTRY); - return null; - } catch (NullPointerException e) { - // nulls not permitted from cache loader - return null; - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesHttpApiModule.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesHttpApiModule.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesHttpApiModule.java deleted file mode 100644 index 3ce8c3a..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesHttpApiModule.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles.config; - -import java.net.URI; -import java.util.Map; - -import javax.inject.Singleton; - -import org.jclouds.cloudfiles.CDNManagement; -import org.jclouds.cloudfiles.CloudFilesClient; -import org.jclouds.location.suppliers.RegionIdToURISupplier; -import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule; -import org.jclouds.openstack.keystone.v1_1.suppliers.V1DefaultRegionIdSupplier; -import org.jclouds.openstack.swift.CommonSwiftClient; -import org.jclouds.openstack.swift.Storage; -import org.jclouds.openstack.swift.config.SwiftHttpApiModule; -import org.jclouds.rest.ConfiguresHttpApi; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Supplier; -import com.google.inject.Provides; -import com.google.inject.Scopes; - -@ConfiguresHttpApi -public class CloudFilesHttpApiModule extends SwiftHttpApiModule<CloudFilesClient> { - public CloudFilesHttpApiModule() { - super(CloudFilesClient.class); - } - - @Override - protected void bindResolvedClientsToCommonSwift() { - bind(CommonSwiftClient.class).to(CloudFilesClient.class).in(Scopes.SINGLETON); - } - - public static class StorageAndCDNManagementEndpointModule extends AuthenticationServiceModule { - @Provides - @Singleton - @CDNManagement - protected Supplier<URI> provideCDNUrl(RegionIdToURISupplier.Factory factory, - V1DefaultRegionIdSupplier.Factory defaultRegion) { - return valueForKey(factory.createForApiTypeAndVersion("cloudFilesCDN", null), - defaultRegion.createForApiType("cloudFilesCDN")); - } - - @Provides - @Singleton - @Storage - protected Supplier<URI> provideStorageUrl(RegionIdToURISupplier.Factory factory, - V1DefaultRegionIdSupplier.Factory defaultRegion) { - return valueForKey(factory.createForApiTypeAndVersion("cloudFiles", null), - defaultRegion.createForApiType("cloudFiles")); - } - - } - - /** - * Supplies a value that corresponds to a particular key in a map, or null, if not found - */ - @VisibleForTesting - static <K, V> Supplier<V> valueForKey(final Supplier<Map<K, Supplier<V>>> input, final Supplier<K> key) { - return new Supplier<V>() { - - @Override - public V get() { - K keyToFind = key.get(); - Supplier<V> value = input.get().get(keyToFind); - return value != null ? value.get() : null; - } - - @Override - public String toString() { - return "withKey()"; - } - }; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/ContainerCDNMetadata.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/ContainerCDNMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/ContainerCDNMetadata.java deleted file mode 100644 index 36c500b..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/ContainerCDNMetadata.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; -import java.net.URI; - -import javax.inject.Named; - -import org.jclouds.javax.annotation.Nullable; - -public class ContainerCDNMetadata implements Comparable<ContainerCDNMetadata> { - - private String name; - @Named("cdn_enabled") - private boolean cdnEnabled; - @Named("log_retention") - private boolean logRetention; - private long ttl; - @Named("cdn_uri") - private URI cdnUri; - @Named("cdn_ssl_uri") - private URI cdnSslUri; - @Named("cdn_streaming_uri") - private URI cdnStreamingUri; - @Named("cdn_ios_uri") - private URI cdnIosUri; - - @ConstructorProperties({ "name", "cdn_enabled", "log_retention", "ttl", "cdn_uri", "cdn_ssl_uri", - "cdn_streaming_uri", "cdn_ios_uri"}) - public ContainerCDNMetadata(String name, boolean cdnEnabled, boolean logRetention, long ttl, - @Nullable URI cdnUri, @Nullable URI cdnSslUri, @Nullable URI cdnStreamingUri, @Nullable URI cdnIosUri) { - this.name = checkNotNull(name, "name"); - this.cdnEnabled = cdnEnabled; - this.logRetention = logRetention; - this.ttl = ttl; - this.cdnUri = cdnUri; - this.cdnSslUri = cdnSslUri; - this.cdnStreamingUri = cdnStreamingUri; - this.cdnIosUri = cdnIosUri; - } - - public ContainerCDNMetadata() { - } - - /** - * Beware: The container name is not available from HEAD CDN responses and will be null. return - * the name of the container to which these CDN settings apply. - */ - public String getName() { - return name; - } - - public boolean isCDNEnabled() { - return cdnEnabled; - } - - public boolean isLogRetention() { - return logRetention; - } - - public long getTTL() { - return ttl; - } - - public URI getCDNUri() { - return cdnUri; - } - - public URI getCDNSslUri() { - return cdnSslUri; - } - - public URI getCDNStreamingUri() { - return cdnStreamingUri; - } - - public URI getCDNIosUri() { - return cdnIosUri; - } - - public int compareTo(ContainerCDNMetadata o) { - if (getName() == null) - return -1; - return (this == o) ? 0 : getName().compareTo(o.getName()); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((cdnUri == null) ? 0 : cdnUri.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - - ContainerCDNMetadata other = (ContainerCDNMetadata) obj; - if (cdnUri == null) { - if (other.cdnUri != null) - return false; - } else if (!cdnUri.equals(other.cdnUri)) - return false; - - return true; - } - - @Override - public String toString() { - return String.format( - "[name=%s, cdnEnabled=%s, logRetention=%s, ttl=%s, cdnUri=%s, cdnSslUri=%s, cdnStreamingUri=%s, cdnIosUri=%s]", - name, cdnEnabled, logRetention, ttl, cdnUri, cdnSslUri, cdnStreamingUri, cdnIosUri); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseCdnUriFromHeaders.java ---------------------------------------------------------------------- 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 deleted file mode 100644 index e6333af..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseCdnUriFromHeaders.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import org.jclouds.cloudfiles.reference.CloudFilesHeaders; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; - -/** - * This parses {@link AccountMetadata} from HTTP headers. - */ -public class ParseCdnUriFromHeaders implements Function<HttpResponse, URI> { - - /** - * parses the http response headers to provide the CDN URI string. - */ - public URI apply(final HttpResponse from) { - String cdnUri = checkNotNull(from.getFirstHeaderOrNull(CloudFilesHeaders.CDN_URI), - CloudFilesHeaders.CDN_URI); - return URI.create(cdnUri); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseContainerCDNMetadataFromHeaders.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseContainerCDNMetadataFromHeaders.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseContainerCDNMetadataFromHeaders.java deleted file mode 100644 index 065b674..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/functions/ParseContainerCDNMetadataFromHeaders.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles.functions; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Lists.newArrayList; - -import java.net.URI; -import java.util.List; - -import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; -import org.jclouds.cloudfiles.reference.CloudFilesHeaders; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.rest.InvocationContext; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; -import com.google.common.collect.Iterables; - -/** - * This parses {@link AccountMetadata} from HTTP headers. - */ -public class ParseContainerCDNMetadataFromHeaders implements - Function<HttpResponse, ContainerCDNMetadata>, InvocationContext<ParseContainerCDNMetadataFromHeaders> { - - private HttpRequest request; - - /** - * parses the http response headers to create a new {@link ContainerCDNMetadata} object. - */ - public ContainerCDNMetadata apply(final HttpResponse from) { - String cdnEnabled = checkNotNull(from.getFirstHeaderOrNull(CloudFilesHeaders.CDN_ENABLED), CloudFilesHeaders.CDN_ENABLED); - String cdnLogRetention = checkNotNull(from.getFirstHeaderOrNull(CloudFilesHeaders.CDN_LOG_RETENTION), CloudFilesHeaders.CDN_LOG_RETENTION); - String cdnTTL = checkNotNull(from.getFirstHeaderOrNull(CloudFilesHeaders.CDN_TTL), CloudFilesHeaders.CDN_TTL); - String cdnUri = checkNotNull(from.getFirstHeaderOrNull(CloudFilesHeaders.CDN_URI), CloudFilesHeaders.CDN_URI); - String cdnSslUri = checkNotNull(from.getFirstHeaderOrNull(CloudFilesHeaders.CDN_SSL_URI), CloudFilesHeaders.CDN_SSL_URI); - String cdnStreamingUri = checkNotNull(from.getFirstHeaderOrNull(CloudFilesHeaders.CDN_STREAMING_URI), CloudFilesHeaders.CDN_STREAMING_URI); - String cdnIosUri = checkNotNull(from.getFirstHeaderOrNull(CloudFilesHeaders.CDN_IOS_URI), CloudFilesHeaders.CDN_IOS_URI); - - List<String> parts = newArrayList(Splitter.on('/').split(request.getEndpoint().getPath())); - checkArgument(!parts.isEmpty(), "incorrect path: " + request.getEndpoint().getPath()); - - return new ContainerCDNMetadata( - Iterables.getLast(parts), - Boolean.parseBoolean(cdnEnabled), - Boolean.parseBoolean(cdnLogRetention), - Long.parseLong(cdnTTL), - URI.create(cdnUri), - URI.create(cdnSslUri), - URI.create(cdnStreamingUri), - URI.create(cdnIosUri)); - } - - @Override - public ParseContainerCDNMetadataFromHeaders setContext(HttpRequest request) { - this.request = request; - return this; - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/options/ListCdnContainerOptions.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/options/ListCdnContainerOptions.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/options/ListCdnContainerOptions.java deleted file mode 100644 index b850e6e..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/options/ListCdnContainerOptions.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles.options; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import org.jclouds.http.options.BaseHttpRequestOptions; - - -/** - * Contains options supported in the REST API for the GET CDN containers operation. - */ -public class ListCdnContainerOptions extends BaseHttpRequestOptions { - public static final ListCdnContainerOptions NONE = new ListCdnContainerOptions(); - - public ListCdnContainerOptions enabledOnly() { - queryParameters.put("enabled_only", "true"); - return this; - } - - /** - * Indicates where to begin listing the identity's containers. The list will only include - * containers whose names occur lexicographically after the marker. This is convenient for - * pagination: To get the next page of results use the last container name of the current - * page as the marker. - */ - public ListCdnContainerOptions afterMarker(String marker) { - queryParameters.put("marker", checkNotNull(marker, "marker")); - return this; - } - - - /** - * The maximum number of containers that will be included in the response body. - * The server might return fewer than this many containers, but will not return more. - */ - public ListCdnContainerOptions maxResults(int limit) { - checkState(limit >= 0, "limit must be >= 0"); - checkState(limit <= 10000, "limit must be <= 10000"); - queryParameters.put("limit", Integer.toString(limit)); - return this; - } - - public static class Builder { - - public static ListCdnContainerOptions enabledOnly() { - ListCdnContainerOptions options = new ListCdnContainerOptions(); - return options.enabledOnly(); - } - - /** - * @see ListCdnContainerOptions#afterMarker(String) - */ - public static ListCdnContainerOptions afterMarker(String marker) { - ListCdnContainerOptions options = new ListCdnContainerOptions(); - return options.afterMarker(marker); - } - - /** - * @see ListCdnContainerOptions#limit(int) - */ - public static ListCdnContainerOptions maxResults(int limit) { - ListCdnContainerOptions options = new ListCdnContainerOptions(); - return options.maxResults(limit); - } - - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/package-info.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/package-info.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/package-info.java deleted file mode 100644 index 2368d83..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This package contains an Rackspace Cloud Files client implemented by {@link org.jclouds.http.HttpCommandExecutorService} commands. - * - * @see <a href="http://www.rackspacecloud.com/cf-devguide-20090311.pdf" /> - */ -package org.jclouds.cloudfiles; http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/CloudFilesHeaders.java ---------------------------------------------------------------------- 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 deleted file mode 100644 index 1a60490..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/CloudFilesHeaders.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles.reference; - -import org.jclouds.openstack.swift.reference.SwiftHeaders; - - -/** - * Additional headers specified by Rackspace Cloud Files REST API. - * - * @see <a href="http://www.rackspacecloud.com/cf-devguide-20090311.pdf" /> - */ -public final class CloudFilesHeaders extends SwiftHeaders { - - public static final String CDN_ENABLED = "X-CDN-Enabled"; - public static final String CDN_LOG_RETENTION = "X-Log-Retention"; - public static final String CDN_TTL = "X-TTL"; - public static final String CDN_URI = "X-CDN-URI"; - public static final String CDN_SSL_URI = "X-Cdn-Ssl-Uri"; - public static final String CDN_STREAMING_URI = "X-Cdn-Streaming-Uri"; - public static final String CDN_IOS_URI = "X-Cdn-Ios-Uri"; - - public static final String CDN_CONTAINER_PURGE_OBJECT_EMAIL = "X-Purge-Email"; - public static final String CDN_WEBSITE_INDEX = "X-Container-Meta-Web-Index"; - public static final String CDN_WEBSITE_ERROR = "X-Container-Meta-Web-Error"; - - private CloudFilesHeaders() { - throw new AssertionError("intentionally unimplemented"); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/package-info.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/package-info.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/package-info.java deleted file mode 100644 index ff442b8..0000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This package contains properties and reference data used in Rackspace Cloud Files. - */ -package org.jclouds.cloudfiles.reference; http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java deleted file mode 100644 index 8553dad..0000000 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles; - -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "CloudFilesApiMetadataTest") -public class CloudFilesApiMetadataTest extends BaseBlobStoreApiMetadataTest { - - public CloudFilesApiMetadataTest() { - super(new CloudFilesApiMetadata()); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/87b88530/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientExpectTest.java ---------------------------------------------------------------------- diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientExpectTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientExpectTest.java deleted file mode 100644 index 24e5e53..0000000 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientExpectTest.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudfiles; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.net.URI; - -import org.jclouds.blobstore.ContainerNotFoundException; -import org.jclouds.cloudfiles.domain.ContainerCDNMetadata; -import org.jclouds.cloudfiles.internal.BaseCloudFilesRestClientExpectTest; -import org.jclouds.cloudfiles.reference.CloudFilesHeaders; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "CloudFilesClientExpectTest") -public class CloudFilesClientExpectTest extends BaseCloudFilesRestClientExpectTest { - - @Test - public void testDeleteContainerReturnsTrueOn200And404() { - HttpRequest deleteContainer = HttpRequest - .builder() - .method("DELETE") - .endpoint( - "https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container") - .addHeader("X-Auth-Token", authToken).build(); - - HttpResponse containerDeleted = HttpResponse.builder().statusCode(204).message("HTTP/1.1 204 No Content").build(); - - CloudFilesClient clientWhenContainerExists = requestsSendResponses(initialAuth, responseWithAuth, deleteContainer, - containerDeleted); - assert clientWhenContainerExists.deleteContainerIfEmpty("container"); - - HttpResponse containerNotFound = HttpResponse.builder().statusCode(404).message("HTTP/1.1 404 Not Found").build(); - - CloudFilesClient clientWhenContainerDoesntExist = requestsSendResponses(initialAuth, responseWithAuth, deleteContainer, - containerNotFound); - assert clientWhenContainerDoesntExist.deleteContainerIfEmpty("container"); - } - - @Test - public void testGetCDNMetadataWhenResponseIs2xxReturnsContainerCDNMetadata() { - HttpRequest cdnContainerRequest = HttpRequest.builder() - .method("HEAD") - .endpoint("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container") - .addHeader("X-Auth-Token", authToken) - .build(); - - HttpResponse cdnContainerResponse = HttpResponse.builder() - .addHeader(CloudFilesHeaders.CDN_ENABLED, "True") - .addHeader(CloudFilesHeaders.CDN_LOG_RETENTION, "True") - .addHeader(CloudFilesHeaders.CDN_TTL, "259200") - .addHeader(CloudFilesHeaders.CDN_URI, "http://546406d62bf471d7435d-36c33e76d676c80251b3c13ecb603b67.r19.cf1.rackcdn.com") - .addHeader(CloudFilesHeaders.CDN_SSL_URI, "https://e9f6fe92d217dc013369-36c33e76d676c80251b3c13ecb603b67.ssl.cf1.rackcdn.com") - .addHeader(CloudFilesHeaders.CDN_STREAMING_URI, "http://0e79346bc0a2564dcc5e-36c33e76d676c80251b3c13ecb603b67.r19.stream.cf1.rackcdn.com") - .addHeader(CloudFilesHeaders.CDN_IOS_URI, "http://552e06d62bf471d7435d-36c33e76d676c80251b3c13ecb603b67.r11.iosr.cf1.rackcdn.com") - .statusCode(204) - .build(); - - CloudFilesClient cdnContainerClient = requestsSendResponses( - initialAuth, responseWithAuth, cdnContainerRequest, cdnContainerResponse); - - ContainerCDNMetadata containerCDNMetadata = cdnContainerClient.getCDNMetadata("container"); - assertTrue(containerCDNMetadata.isCDNEnabled()); - assertTrue(containerCDNMetadata.isLogRetention()); - assertEquals(containerCDNMetadata.getTTL(), 259200); - assertEquals(containerCDNMetadata.getCDNUri().toString(), "http://546406d62bf471d7435d-36c33e76d676c80251b3c13ecb603b67.r19.cf1.rackcdn.com"); - assertEquals(containerCDNMetadata.getCDNSslUri().toString(), "https://e9f6fe92d217dc013369-36c33e76d676c80251b3c13ecb603b67.ssl.cf1.rackcdn.com"); - assertEquals(containerCDNMetadata.getCDNStreamingUri().toString(), "http://0e79346bc0a2564dcc5e-36c33e76d676c80251b3c13ecb603b67.r19.stream.cf1.rackcdn.com"); - assertEquals(containerCDNMetadata.getCDNIosUri().toString(), "http://552e06d62bf471d7435d-36c33e76d676c80251b3c13ecb603b67.r11.iosr.cf1.rackcdn.com"); - } - - @Test - public void testGetCDNMetadataWhenResponseIs404ReturnsNull() { - HttpRequest cdnContainerRequest = HttpRequest.builder() - .method("HEAD") - .endpoint("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container") - .addHeader("X-Auth-Token", authToken) - .build(); - - HttpResponse cdnContainerResponse = HttpResponse.builder() - .statusCode(404) - .build(); - - CloudFilesClient cdnContainerClient = requestsSendResponses( - initialAuth, responseWithAuth, cdnContainerRequest, cdnContainerResponse); - - assertNull(cdnContainerClient.getCDNMetadata("container")); - } - - @Test - public void testUpdateCDNMetadataWhenResponseIs2xxReturnsURI() { - HttpRequest cdnContainerRequest = HttpRequest.builder() - .method("POST") - .endpoint("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container") - .addHeader(CloudFilesHeaders.CDN_TTL, "259200") - .addHeader(CloudFilesHeaders.CDN_LOG_RETENTION, "true") - .addHeader("X-Auth-Token", authToken) - .build(); - - HttpResponse cdnContainerResponse = HttpResponse.builder() - .addHeader(CloudFilesHeaders.CDN_ENABLED, "True") - .addHeader(CloudFilesHeaders.CDN_LOG_RETENTION, "True") - .addHeader(CloudFilesHeaders.CDN_TTL, "259200") - .addHeader(CloudFilesHeaders.CDN_URI, "http://546406d62bf471d7435d-36c33e76d676c80251b3c13ecb603b67.r19.cf1.rackcdn.com") - .addHeader(CloudFilesHeaders.CDN_SSL_URI, "https://e9f6fe92d217dc013369-36c33e76d676c80251b3c13ecb603b67.ssl.cf1.rackcdn.com") - .addHeader(CloudFilesHeaders.CDN_STREAMING_URI, "http://0e79346bc0a2564dcc5e-36c33e76d676c80251b3c13ecb603b67.r19.stream.cf1.rackcdn.com") - .addHeader(CloudFilesHeaders.CDN_IOS_URI, "http://552e06d62bf471d7435d-36c33e76d676c80251b3c13ecb603b67.r11.iosr.cf1.rackcdn.com") - .statusCode(204) - .build(); - - CloudFilesClient cdnContainerClient = requestsSendResponses( - initialAuth, responseWithAuth, cdnContainerRequest, cdnContainerResponse); - - URI cdnURI = cdnContainerClient.updateCDN("container", 259200, true); - assertEquals(cdnURI.toString(), "http://546406d62bf471d7435d-36c33e76d676c80251b3c13ecb603b67.r19.cf1.rackcdn.com"); - } - - @Test(expectedExceptions = ContainerNotFoundException.class) - public void testUpdateCDNMetadataWhenResponseIs404ThrowsException() { - HttpRequest cdnContainerRequest = HttpRequest.builder() - .method("POST") - .endpoint("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container") - .addHeader(CloudFilesHeaders.CDN_TTL, "259200") - .addHeader(CloudFilesHeaders.CDN_LOG_RETENTION, "true") - .addHeader("X-Auth-Token", authToken) - .build(); - - HttpResponse cdnContainerResponse = HttpResponse.builder() - .statusCode(404) - .build(); - - CloudFilesClient cdnContainerClient = requestsSendResponses( - initialAuth, responseWithAuth, cdnContainerRequest, cdnContainerResponse); - - cdnContainerClient.updateCDN("container", 259200, true); - } - - @Test - public void testPurgeCDNObjectWhenResponseIs2xxReturnsTrue() { - HttpRequest cdnContainerRequest = HttpRequest.builder() - .method("DELETE") - .endpoint("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container/foo.txt") - .addHeader("X-Auth-Token", authToken) - .build(); - - HttpResponse cdnContainerResponse = HttpResponse.builder() - .statusCode(204) - .build(); - - CloudFilesClient cdnContainerClient = requestsSendResponses( - initialAuth, responseWithAuth, cdnContainerRequest, cdnContainerResponse); - - assertTrue(cdnContainerClient.purgeCDNObject("container", "foo.txt")); - } - - @Test - public void testSetCDNStaticWebsiteIndexWhenResponseIs2xxReturnsTrue() { - HttpRequest cdnContainerRequest = HttpRequest.builder() - .method("POST") - .endpoint("https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container") - .addHeader(CloudFilesHeaders.CDN_WEBSITE_INDEX, "index.html") - .addHeader("X-Auth-Token", authToken) - .build(); - - HttpResponse cdnContainerResponse = HttpResponse.builder() - .statusCode(204) - .build(); - - CloudFilesClient cdnContainerClient = requestsSendResponses( - initialAuth, responseWithAuth, cdnContainerRequest, cdnContainerResponse); - - assertTrue(cdnContainerClient.setCDNStaticWebsiteIndex("container", "index.html")); - } - - @Test(expectedExceptions = ContainerNotFoundException.class) - public void testSetCDNStaticWebsiteIndexWhenResponseIs404ThrowsException() { - HttpRequest cdnContainerRequest = HttpRequest.builder() - .method("POST") - .endpoint("https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container") - .addHeader(CloudFilesHeaders.CDN_WEBSITE_INDEX, "index.html") - .addHeader("X-Auth-Token", authToken) - .build(); - - HttpResponse cdnContainerResponse = HttpResponse.builder() - .statusCode(404) - .build(); - - CloudFilesClient cdnContainerClient = requestsSendResponses( - initialAuth, responseWithAuth, cdnContainerRequest, cdnContainerResponse); - - cdnContainerClient.setCDNStaticWebsiteIndex("container", "index.html"); - } - - @Test - public void testSetCDNStaticWebsiteErrorWhenResponseIs2xxReturnsTrue() { - HttpRequest cdnContainerRequest = HttpRequest.builder() - .method("POST") - .endpoint("https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container") - .addHeader(CloudFilesHeaders.CDN_WEBSITE_ERROR, "error.html") - .addHeader("X-Auth-Token", authToken) - .build(); - - HttpResponse cdnContainerResponse = HttpResponse.builder() - .statusCode(204) - .build(); - - CloudFilesClient cdnContainerClient = requestsSendResponses( - initialAuth, responseWithAuth, cdnContainerRequest, cdnContainerResponse); - - assertTrue(cdnContainerClient.setCDNStaticWebsiteError("container", "error.html")); - } - - @Test(expectedExceptions = ContainerNotFoundException.class) - public void testSetCDNStaticWebsiteErrorWhenResponseIs404ThrowsException() { - HttpRequest cdnContainerRequest = HttpRequest.builder() - .method("POST") - .endpoint("https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container") - .addHeader(CloudFilesHeaders.CDN_WEBSITE_ERROR, "error.html") - .addHeader("X-Auth-Token", authToken) - .build(); - - HttpResponse cdnContainerResponse = HttpResponse.builder() - .statusCode(404) - .build(); - - CloudFilesClient cdnContainerClient = requestsSendResponses( - initialAuth, responseWithAuth, cdnContainerRequest, cdnContainerResponse); - - cdnContainerClient.setCDNStaticWebsiteError("container", "error.html"); - } -}