mirror of https://github.com/apache/jclouds.git
CDN support changes: fixed parsing issues, initial change for externalizing CDN URL
This commit is contained in:
parent
da4ce8689e
commit
3984d1057d
|
@ -100,5 +100,10 @@
|
|||
<artifactId>filesystem</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds.provider</groupId>
|
||||
<artifactId>hpcloud-object-storage</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
README HP
|
|
@ -77,7 +77,6 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient
|
|||
@Endpoint(CDNManagement.class)
|
||||
ListenableFuture<? extends Set<ContainerCDNMetadata>> listCDNContainers(ListCDNContainerOptions... options);
|
||||
|
||||
// TODO: Container name is not included in CDN HEAD response headers, so we cannot populate it here.
|
||||
/**
|
||||
* @see HPCloudObjectStorageClient#getCDNMetadata(String)
|
||||
*/
|
||||
|
@ -122,7 +121,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient
|
|||
/**
|
||||
* @see HPCloudObjectStorageClient#disableCDN(String)
|
||||
*/
|
||||
@POST
|
||||
@PUT
|
||||
@Path("/{container}")
|
||||
@Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "False")
|
||||
@Endpoint(CDNManagement.class)
|
||||
|
|
|
@ -21,14 +21,15 @@ package org.jclouds.hpcloud.object.storage;
|
|||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
|
||||
import static org.jclouds.hpcloud.object.storage.reference.HPCloudObjectStorageConstants.PROPERTY_CDN_ENDPOINT;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.openstack.OpenStackAuthAsyncClient;
|
||||
import org.jclouds.openstack.swift.SwiftPropertiesBuilder;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jeremy Daggtt
|
||||
* @author Jeremy Daggett
|
||||
*/
|
||||
public class HPCloudObjectStoragePropertiesBuilder extends SwiftPropertiesBuilder {
|
||||
|
||||
|
@ -40,8 +41,10 @@ public class HPCloudObjectStoragePropertiesBuilder extends SwiftPropertiesBuilde
|
|||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_ISO3166_CODES, "US-NV");
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://region-a.geo-1.objects.hpcloudsvc.com/auth/v1.0/");
|
||||
properties.setProperty(PROPERTY_API_VERSION, "1.1");
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://region-a.geo-1.objects.hpcloudsvc.com/auth/");
|
||||
properties.setProperty(PROPERTY_API_VERSION, OpenStackAuthAsyncClient.VERSION);
|
||||
properties.setProperty(PROPERTY_CDN_ENDPOINT, "");
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.hpcloud.object.storage.config;
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.hpcloud.object.storage.CDNManagement;
|
||||
|
@ -33,6 +34,8 @@ import org.jclouds.openstack.swift.CommonSwiftClient;
|
|||
import org.jclouds.openstack.swift.config.BaseSwiftRestClientModule;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
|
@ -63,12 +66,14 @@ public class HPCloudObjectStorageRestClientModule extends BaseSwiftRestClientMod
|
|||
@Singleton
|
||||
@CDNManagement
|
||||
protected URI provideCDNUrl(AuthenticationResponse response) {
|
||||
/* FIXFIX - We need to have an external config for the CDN URI
|
||||
@Named("jclouds.hpcloud-object-storage.cdn.endpoint")
|
||||
@VisibleForTesting
|
||||
String cdnEndpoint = "https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/";
|
||||
|
||||
if (response.getServices().get(AuthHeaders.CDN_MANAGEMENT_URL) == null) {
|
||||
return URI.create("https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/");
|
||||
return URI.create(cdnEndpoint);
|
||||
}
|
||||
*/
|
||||
|
||||
return response.getServices().get(AuthHeaders.CDN_MANAGEMENT_URL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ package org.jclouds.hpcloud.object.storage.domain;
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author James Murty
|
||||
|
@ -30,6 +32,7 @@ public class ContainerCDNMetadata implements Comparable<ContainerCDNMetadata> {
|
|||
private String name;
|
||||
private boolean cdn_enabled;
|
||||
private long ttl;
|
||||
@SerializedName("x-cdn-uri")
|
||||
private URI cdn_uri;
|
||||
private String referrer_acl;
|
||||
private String useragent_acl;
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.hpcloud.object.storage.reference;
|
||||
|
||||
|
||||
/**
|
||||
* Configuration properties and constants used by HP Cloud Object Storage.
|
||||
*
|
||||
* @author Jeremy Daggett
|
||||
*/
|
||||
public interface HPCloudObjectStorageConstants {
|
||||
|
||||
/**
|
||||
* The CDN Endpoint property
|
||||
*/
|
||||
public static final String PROPERTY_CDN_ENDPOINT = "jclouds.hpcloud-object-storage.cdn.endpoint";
|
||||
|
||||
}
|
|
@ -30,11 +30,11 @@ import org.jclouds.openstack.swift.reference.SwiftHeaders;
|
|||
*/
|
||||
public interface HPCloudObjectStorageHeaders extends SwiftHeaders {
|
||||
|
||||
public static final String CDN_ENABLED = "X-CDN-Enabled";
|
||||
public static final String CDN_ENABLED = "X-Cdn-Enabled";
|
||||
public static final String CDN_LOG_RETENTION = "X-Log-Retention";
|
||||
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_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_READ = "X-Container-Read";
|
||||
|
|
|
@ -48,8 +48,17 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
|
|||
|
||||
@Override
|
||||
protected void testGetObjectContentType(SwiftObject getBlob) {
|
||||
//lovely new bug.. should be text/plain
|
||||
assertEquals(getBlob.getInfo().getContentType(), "application/x-www-form-urlencoded");
|
||||
assertEquals(getBlob.getInfo().getContentType(), "application/unknown");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListCDNContainers() {
|
||||
try {
|
||||
Set<ContainerCDNMetadata> cdnMetadataList = getApi().listCDNContainers();
|
||||
System.err.println(cdnMetadataList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -64,7 +73,7 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
|
|||
getApi().disableCDN(containerNameWithCDN);
|
||||
getApi().disableCDN(containerNameWithoutCDN);
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
ContainerCDNMetadata cdnMetadata = null;
|
||||
|
||||
|
@ -139,6 +148,8 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
|
|||
|
||||
cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
|
||||
assertEquals(cdnMetadata.isCDNEnabled(), false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
recycleContainer(containerNameWithCDN);
|
||||
recycleContainer(containerNameWithoutCDN);
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.hpcloud.object.storage;
|
||||
|
||||
import org.jclouds.providers.BaseProviderMetadataTest;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* The HPCloudObjectStorageProviderTest tests the {@link org.jclouds.hpcloud.object.storage.HPCloudObjectStorageProviderMetadata} class.
|
||||
*
|
||||
* @author Jeremy Daggett
|
||||
*/
|
||||
@Test(groups = "unit", testName = "HPCloudObjectStorageProviderTest")
|
||||
public class HPCloudObjectStorageProviderTest extends BaseProviderMetadataTest {
|
||||
|
||||
public HPCloudObjectStorageProviderTest() {
|
||||
super(new HPCloudObjectStorageProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue