From e1ab1950567a7d80762f1b3ce7019dfde7f4db42 Mon Sep 17 00:00:00 2001 From: Jeremy Daggett Date: Fri, 9 Nov 2012 14:24:55 -0800 Subject: [PATCH 1/2] Added CDNSslUri to CDNContainer class, updated json and unit tests --- .../objectstorage/domain/CDNContainer.java | 64 ++++++++++++------- .../parse/CDNContainersTest.java | 18 ++++-- .../src/test/resources/test_list_cdn.json | 6 +- 3 files changed, 55 insertions(+), 33 deletions(-) diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/domain/CDNContainer.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/domain/CDNContainer.java index 832b276e31..6a77108ad0 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/domain/CDNContainer.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/domain/CDNContainer.java @@ -40,12 +40,13 @@ public class CDNContainer implements Comparable { public static class Builder { protected String name; - protected boolean cdnEnabled; + protected boolean cdn_enabled; + protected boolean log_retention; protected long ttl; - protected URI CDNUri; - protected String referrerAcl; - protected String useragentAcl; - protected boolean logRetention; + protected URI cdn_uri; + protected URI cdn_ssl_uri; + protected String referrer_acl; + protected String useragent_acl; /** * @see CDNContainer#getName() @@ -58,8 +59,8 @@ public class CDNContainer implements Comparable { /** * @see CDNContainer#isCDNEnabled() */ - public Builder CDNEnabled(boolean cdnEnabled) { - this.cdnEnabled = cdnEnabled; + public Builder CDNEnabled(boolean cdn_enabled) { + this.cdn_enabled = cdn_enabled; return this; } @@ -74,61 +75,71 @@ public class CDNContainer implements Comparable { /** * @see CDNContainer#getCDNUri() */ - public Builder CDNUri(URI CDNUri) { - this.CDNUri = CDNUri; + public Builder CDNUri(URI cdn_uri) { + this.cdn_uri = cdn_uri; return this; } + /** + * @see CDNContainer#getCDNSslUri() + */ + public Builder CDNSslUri(URI cdn_ssl_uri) { + this.cdn_ssl_uri = cdn_ssl_uri; + return this; + } + /** * @see CDNContainer#getReferrerAcl() */ - public Builder referrerAcl(String referrerAcl) { - this.referrerAcl = referrerAcl; + public Builder referrerAcl(String referrer_acl) { + this.referrer_acl = referrer_acl; return this; } /** * @see CDNContainer#getUseragentAcl() */ - public Builder useragent_acl(String useragentAcl) { - this.useragentAcl = useragentAcl; + public Builder useragentAcl(String useragent_acl) { + this.useragent_acl = useragent_acl; return this; } /** * @see CDNContainer#isLogRetention() */ - public Builder logRetention(boolean logRetention) { - this.logRetention = logRetention; + public Builder logRetention(boolean log_retention) { + this.log_retention = log_retention; return this; } public CDNContainer build() { - return new CDNContainer(name, cdnEnabled, ttl, CDNUri, referrerAcl, useragentAcl, logRetention); + return new CDNContainer(name, cdn_enabled, ttl, cdn_uri, cdn_ssl_uri, referrer_acl, useragent_acl, log_retention); } public Builder fromCDNContainer(CDNContainer in) { - return this.name(in.getName()).CDNEnabled(in.isCDNEnabled()).ttl(in.getTTL()).CDNUri(in.getCDNUri()) - .referrerAcl(in.getReferrerAcl()).useragent_acl(in.getUseragentAcl()) - .logRetention(in.isLogRetention()); + return this.name(in.getName()).CDNEnabled(in.isCDNEnabled()).ttl(in.getTTL()) + .CDNUri(in.getCDNUri()).CDNSslUri(in.getCDNSslUri()).referrerAcl(in.getReferrerAcl()) + .useragentAcl(in.getUseragentAcl()).logRetention(in.isLogRetention()); } } private final String name; private final boolean cdnEnabled; + private final boolean logRetention; private final long ttl; private final URI CDNUri; + private final URI CDNSslUri; private final String referrerAcl; private final String useragentAcl; - private final boolean logRetention; - @ConstructorProperties({ "name", "cdn_enabled", "ttl", "cdn_uri", "referrer_acl", "useragent_acl", "log_retention" }) + @ConstructorProperties({ "name", "cdn_enabled", "ttl", "cdn_uri", "cdn_ssl_uri", "referrer_acl", "useragent_acl", "log_retention" }) protected CDNContainer(@Nullable String name, boolean cdnEnabled, long ttl, @Nullable URI CDNUri, - @Nullable String referrerAcl, @Nullable String useragentAcl, boolean logRetention) { + @Nullable URI CDNSslUri, @Nullable String referrerAcl, @Nullable String useragentAcl, boolean logRetention) { this.name = Strings.emptyToNull(name); this.cdnEnabled = cdnEnabled; this.ttl = ttl; this.CDNUri = CDNUri; + this.CDNSslUri = CDNSslUri; this.referrerAcl = Strings.emptyToNull(referrerAcl); this.useragentAcl = Strings.emptyToNull(useragentAcl); this.logRetention = logRetention; @@ -157,6 +168,11 @@ public class CDNContainer implements Comparable { return this.CDNUri; } + @Nullable + public URI getCDNSslUri() { + return this.CDNSslUri; + } + @Nullable public String getReferrerAcl() { return this.referrerAcl; @@ -188,8 +204,8 @@ public class CDNContainer implements Comparable { protected ToStringHelper string() { return Objects.toStringHelper(this).omitNullValues().add("name", name).add("cdnEnabled", cdnEnabled) - .add("ttl", ttl).add("CDNUri", CDNUri).add("referrerAcl", referrerAcl).add("useragentAcl", useragentAcl) - .add("logRetention", logRetention); + .add("ttl", ttl).add("CDNUri", CDNUri).add("CDNSslUri", CDNSslUri).add("referrerAcl", referrerAcl) + .add("useragentAcl", useragentAcl).add("logRetention", logRetention); } @Override diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/parse/CDNContainersTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/parse/CDNContainersTest.java index 389b031513..939ae7d8ef 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/parse/CDNContainersTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/parse/CDNContainersTest.java @@ -45,11 +45,17 @@ public class CDNContainersTest extends BaseItemParserTest expected() { return FluentIterable.from(ImmutableSet.of( - CDNContainer.builder().name("hpcloud-blobstore.testCDNOperationsContainerWithCDN").CDNEnabled(false) - .ttl(3600).CDNUri(URI.create("https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/")).build(), - CDNContainer.builder().name("hpcloud-blobstore5").CDNEnabled(true).ttl(28800) - .CDNUri(URI.create("https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/")).build(), - CDNContainer.builder().name("hpcloud-cfcdnint.testCDNOperationsContainerWithCDN").CDNEnabled(false) - .ttl(3600).CDNUri(URI.create("https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/")).build())); + CDNContainer.builder().name("hpcloud-blobstore.testCDNOperationsContainerWithCDN").CDNEnabled(false).ttl(3600) + .CDNUri(URI.create("http://h10cdf69e2913a87afe9ce721ceb35ca5.cdn.hpcloudsvc.com")) + .CDNSslUri(URI.create("https://a248.e.akamai.net/cdn.hpcloudsvc.com/h10cdf69e2913a87afe9ce721ceb35ca5/aw2")) + .build(), + CDNContainer.builder().name("hpcloud-blobstore5").CDNEnabled(true).ttl(28800) + .CDNUri(URI.create("http://h0bc2984e4ad8f8bec0ebf5b147c9fe55.cdn.hpcloudsvc.com")) + .CDNSslUri(URI.create("https://a248.e.akamai.net/cdn.hpcloudsvc.com/h0bc2984e4ad8f8bec0ebf5b147c9fe55/aw2")) + .build(), + CDNContainer.builder().name("hpcloud-cfcdnint.testCDNOperationsContainerWithCDN").CDNEnabled(false).ttl(3600) + .CDNUri(URI.create("http://h82d1ae1ee2ada5151c60e33f097294c2.cdn.hpcloudsvc.com")) + .CDNSslUri(URI.create("https://a248.e.akamai.net/cdn.hpcloudsvc.com/h82d1ae1ee2ada5151c60e33f097294c2/aw2")) + .build())); } } diff --git a/providers/hpcloud-objectstorage/src/test/resources/test_list_cdn.json b/providers/hpcloud-objectstorage/src/test/resources/test_list_cdn.json index 48e3c3759c..7bec3ec704 100644 --- a/providers/hpcloud-objectstorage/src/test/resources/test_list_cdn.json +++ b/providers/hpcloud-objectstorage/src/test/resources/test_list_cdn.json @@ -1,5 +1,5 @@ [ -{"name":"hpcloud-blobstore.testCDNOperationsContainerWithCDN","cdn_enabled":"false","ttl":3600,"cdn_uri":"https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/","referrer_acl":"","useragent_acl":"", "log_retention":"false"}, -{"name":"hpcloud-blobstore5","cdn_enabled":"true","ttl":28800,"cdn_uri":"https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/","referrer_acl":"","useragent_acl":"", "log_retention":"false"}, -{"name":"hpcloud-cfcdnint.testCDNOperationsContainerWithCDN","cdn_enabled":"false","ttl":3600,"cdn_uri":"https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/","referrer_acl":"","useragent_acl":"", "log_retention":"false"} +{"name":"hpcloud-blobstore.testCDNOperationsContainerWithCDN","cdn_enabled":"false","ttl":3600,"cdn_uri":"http://h10cdf69e2913a87afe9ce721ceb35ca5.cdn.hpcloudsvc.com","cdn_ssl_uri":"https://a248.e.akamai.net/cdn.hpcloudsvc.com/h10cdf69e2913a87afe9ce721ceb35ca5/aw2","referrer_acl":"","useragent_acl":"", "log_retention":"false"}, +{"name":"hpcloud-blobstore5","cdn_enabled":"true","ttl":28800,"cdn_uri":"http://h0bc2984e4ad8f8bec0ebf5b147c9fe55.cdn.hpcloudsvc.com","cdn_ssl_uri":"https://a248.e.akamai.net/cdn.hpcloudsvc.com/h0bc2984e4ad8f8bec0ebf5b147c9fe55/aw2","referrer_acl":"","useragent_acl":"", "log_retention":"false"}, +{"name":"hpcloud-cfcdnint.testCDNOperationsContainerWithCDN","cdn_enabled":"false","ttl":3600,"cdn_uri":"http://h82d1ae1ee2ada5151c60e33f097294c2.cdn.hpcloudsvc.com","cdn_ssl_uri":"https://a248.e.akamai.net/cdn.hpcloudsvc.com/h82d1ae1ee2ada5151c60e33f097294c2/aw2","referrer_acl":"","useragent_acl":"", "log_retention":"false"} ] \ No newline at end of file From 2323b51cf0cdfa6a6d393417b8ad3ec149313188 Mon Sep 17 00:00:00 2001 From: Jeremy Daggett Date: Sat, 10 Nov 2012 06:59:23 -0800 Subject: [PATCH 2/2] Converted snake case in parameters --- .../objectstorage/domain/CDNContainer.java | 44 ++++++++++--------- .../src/test/resources/test_list_cdn.json | 6 +-- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/domain/CDNContainer.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/domain/CDNContainer.java index 6a77108ad0..083523b4cc 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/domain/CDNContainer.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/domain/CDNContainer.java @@ -40,13 +40,13 @@ public class CDNContainer implements Comparable { public static class Builder { protected String name; - protected boolean cdn_enabled; - protected boolean log_retention; + protected boolean cdnEnabled; + protected boolean logRetention; protected long ttl; - protected URI cdn_uri; - protected URI cdn_ssl_uri; - protected String referrer_acl; - protected String useragent_acl; + protected URI cdnUri; + protected URI cdnSslUri; + protected String referrerAcl; + protected String useragentAcl; /** * @see CDNContainer#getName() @@ -59,8 +59,8 @@ public class CDNContainer implements Comparable { /** * @see CDNContainer#isCDNEnabled() */ - public Builder CDNEnabled(boolean cdn_enabled) { - this.cdn_enabled = cdn_enabled; + public Builder CDNEnabled(boolean cdnEnabled) { + this.cdnEnabled = cdnEnabled; return this; } @@ -75,45 +75,45 @@ public class CDNContainer implements Comparable { /** * @see CDNContainer#getCDNUri() */ - public Builder CDNUri(URI cdn_uri) { - this.cdn_uri = cdn_uri; + public Builder CDNUri(URI cdnUri) { + this.cdnUri = cdnUri; return this; } /** * @see CDNContainer#getCDNSslUri() */ - public Builder CDNSslUri(URI cdn_ssl_uri) { - this.cdn_ssl_uri = cdn_ssl_uri; + public Builder CDNSslUri(URI cdnSslUri) { + this.cdnSslUri = cdnSslUri; return this; } /** * @see CDNContainer#getReferrerAcl() */ - public Builder referrerAcl(String referrer_acl) { - this.referrer_acl = referrer_acl; + public Builder referrerAcl(String referrerAcl) { + this.referrerAcl = referrerAcl; return this; } /** * @see CDNContainer#getUseragentAcl() */ - public Builder useragentAcl(String useragent_acl) { - this.useragent_acl = useragent_acl; + public Builder useragentAcl(String useragentAcl) { + this.useragentAcl = useragentAcl; return this; } /** * @see CDNContainer#isLogRetention() */ - public Builder logRetention(boolean log_retention) { - this.log_retention = log_retention; + public Builder logRetention(boolean logRetention) { + this.logRetention = logRetention; return this; } public CDNContainer build() { - return new CDNContainer(name, cdn_enabled, ttl, cdn_uri, cdn_ssl_uri, referrer_acl, useragent_acl, log_retention); + return new CDNContainer(name, cdnEnabled, ttl, cdnUri, cdnSslUri, referrerAcl, useragentAcl, logRetention); } public Builder fromCDNContainer(CDNContainer in) { @@ -132,9 +132,11 @@ public class CDNContainer implements Comparable { private final String referrerAcl; private final String useragentAcl; - @ConstructorProperties({ "name", "cdn_enabled", "ttl", "cdn_uri", "cdn_ssl_uri", "referrer_acl", "useragent_acl", "log_retention" }) + @ConstructorProperties({ "name", "cdnEnabled", "ttl", "cdnUri", "cdnSslUri", "referrerAcl", "useragentAcl", + "logRetention" }) protected CDNContainer(@Nullable String name, boolean cdnEnabled, long ttl, @Nullable URI CDNUri, - @Nullable URI CDNSslUri, @Nullable String referrerAcl, @Nullable String useragentAcl, boolean logRetention) { + @Nullable URI CDNSslUri, @Nullable String referrerAcl, @Nullable String useragentAcl, + boolean logRetention) { this.name = Strings.emptyToNull(name); this.cdnEnabled = cdnEnabled; this.ttl = ttl; diff --git a/providers/hpcloud-objectstorage/src/test/resources/test_list_cdn.json b/providers/hpcloud-objectstorage/src/test/resources/test_list_cdn.json index 7bec3ec704..ca09e600f9 100644 --- a/providers/hpcloud-objectstorage/src/test/resources/test_list_cdn.json +++ b/providers/hpcloud-objectstorage/src/test/resources/test_list_cdn.json @@ -1,5 +1,5 @@ [ -{"name":"hpcloud-blobstore.testCDNOperationsContainerWithCDN","cdn_enabled":"false","ttl":3600,"cdn_uri":"http://h10cdf69e2913a87afe9ce721ceb35ca5.cdn.hpcloudsvc.com","cdn_ssl_uri":"https://a248.e.akamai.net/cdn.hpcloudsvc.com/h10cdf69e2913a87afe9ce721ceb35ca5/aw2","referrer_acl":"","useragent_acl":"", "log_retention":"false"}, -{"name":"hpcloud-blobstore5","cdn_enabled":"true","ttl":28800,"cdn_uri":"http://h0bc2984e4ad8f8bec0ebf5b147c9fe55.cdn.hpcloudsvc.com","cdn_ssl_uri":"https://a248.e.akamai.net/cdn.hpcloudsvc.com/h0bc2984e4ad8f8bec0ebf5b147c9fe55/aw2","referrer_acl":"","useragent_acl":"", "log_retention":"false"}, -{"name":"hpcloud-cfcdnint.testCDNOperationsContainerWithCDN","cdn_enabled":"false","ttl":3600,"cdn_uri":"http://h82d1ae1ee2ada5151c60e33f097294c2.cdn.hpcloudsvc.com","cdn_ssl_uri":"https://a248.e.akamai.net/cdn.hpcloudsvc.com/h82d1ae1ee2ada5151c60e33f097294c2/aw2","referrer_acl":"","useragent_acl":"", "log_retention":"false"} +{"name":"hpcloud-blobstore.testCDNOperationsContainerWithCDN","cdnEnabled":"false","ttl":3600,"cdnUri":"http://h10cdf69e2913a87afe9ce721ceb35ca5.cdn.hpcloudsvc.com","cdnSslUri":"https://a248.e.akamai.net/cdn.hpcloudsvc.com/h10cdf69e2913a87afe9ce721ceb35ca5/aw2","referrerAcl":"","useragentAcl":"", "logRetention":"false"}, +{"name":"hpcloud-blobstore5","cdnEnabled":"true","ttl":28800,"cdnUri":"http://h0bc2984e4ad8f8bec0ebf5b147c9fe55.cdn.hpcloudsvc.com","cdnSslUri":"https://a248.e.akamai.net/cdn.hpcloudsvc.com/h0bc2984e4ad8f8bec0ebf5b147c9fe55/aw2","referrerAcl":"","useragentAcl":"", "logRetention":"false"}, +{"name":"hpcloud-cfcdnint.testCDNOperationsContainerWithCDN","cdnEnabled":"false","ttl":3600,"cdnUri":"http://h82d1ae1ee2ada5151c60e33f097294c2.cdn.hpcloudsvc.com","cdnSslUri":"https://a248.e.akamai.net/cdn.hpcloudsvc.com/h82d1ae1ee2ada5151c60e33f097294c2/aw2","referrerAcl":"","useragentAcl":"", "logRetention":"false"} ] \ No newline at end of file