Package org.jclouds.cloudfiles.domain

Examples of org.jclouds.cloudfiles.domain.ContainerCDNMetadata


            getApi().disableCDN(containerNameWithCDN);
            getApi().disableCDN(containerNameWithoutCDN);
         } catch (Exception e) {

         }
         ContainerCDNMetadata cdnMetadata = null;

         // Enable CDN with PUT for one container
         final URI cdnUri = getApi().enableCDN(containerNameWithCDN);
         assertNotNull(cdnUri);

         // Confirm CDN is enabled via HEAD request and has default TTL
         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());
         assertEquals(cdnMetadata.getCDNUri(), cdnUri);
        
         // Test static website metadata
         getApi().setCDNStaticWebsiteIndex(containerNameWithCDN, "index.html");
         getApi().setCDNStaticWebsiteError(containerNameWithCDN, "error.html");
        
         ContainerMetadata containerMetadata = getApi().getContainerMetadata(containerNameWithCDN);
        
         assertEquals(containerMetadata.getMetadata().get("web-index"), "index.html");
         assertEquals(containerMetadata.getMetadata().get("web-error"), "error.html");
        
         cdnMetadata = getApi().getCDNMetadata(containerNameWithoutCDN);
         assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
                  + " should not have metadata";

         assert getApi().getCDNMetadata("DoesNotExist") == null;
        
         // List CDN metadata for containers, and ensure all CDN info is
         // available for enabled
         // container
         Set<ContainerCDNMetadata> cdnMetadataList = getApi().listCDNContainers();
         assertTrue(cdnMetadataList.size() >= 1);

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         final boolean cdnEnabled = cdnMetadata.isCDNEnabled();
         final boolean logRetention = cdnMetadata.isLogRetention();
         final long initialTTL = cdnMetadata.getTTL();
         final URI cdnSslUri = cdnMetadata.getCDNSslUri();
         final URI cdnStreamingUri = cdnMetadata.getCDNStreamingUri();
         assertTrue(cdnMetadataList.contains(new ContainerCDNMetadata(
            containerNameWithCDN, cdnEnabled, logRetention, initialTTL, cdnUri, cdnSslUri, cdnStreamingUri)));

        
        
         // Test listing with options
         cdnMetadataList = getApi().listCDNContainers(ListCdnContainerOptions.Builder.enabledOnly());
         assertTrue(Iterables.all(cdnMetadataList, new Predicate<ContainerCDNMetadata>() {
            public boolean apply(ContainerCDNMetadata cdnMetadata) {
               return cdnMetadata.isCDNEnabled();
            }
         }));

         cdnMetadataList = getApi().listCDNContainers(
                  ListCdnContainerOptions.Builder.afterMarker(
                           containerNameWithCDN.substring(0, containerNameWithCDN.length() - 1)).maxResults(1));
         assertEquals(cdnMetadataList.size(), 1);

         // Enable CDN with PUT for the same container, this time with a custom TTL and Log Retention
         long ttl = 4000;
         getApi().enableCDN(containerNameWithCDN, ttl, true);

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), ttl);

         // Check POST by updating TTL settings
         ttl = minimumTTL;
         getApi().updateCDN(containerNameWithCDN, minimumTTL, false);

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), minimumTTL);

         // Confirm that minimum allowed value for TTL is 3600, lower values are
         // ignored.
         getApi().updateCDN(containerNameWithCDN, 3599L, false);
         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         assertEquals(cdnMetadata.getTTL(), 3599L);
        
         // Test purging an object from a CDN container
         SwiftObject swiftObject = newSwiftObject("hello", "hello.txt");
         getApi().putObject(containerNameWithCDN, swiftObject);
        
         assertTrue(getApi().purgeCDNObject(containerNameWithCDN, swiftObject.getInfo().getName()));

         // Disable CDN with POST
         assertTrue(getApi().disableCDN(containerNameWithCDN));

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         assertEquals(cdnMetadata.isCDNEnabled(), false);
      } finally {
         recycleContainer(containerNameWithCDN);
         recycleContainer(containerNameWithoutCDN);
      }
   }
View Full Code Here


   @Test
   public void testApplyInputStream() {

      InputStream is = getClass().getResourceAsStream("/test_list_cdn.json");
      Set<ContainerCDNMetadata> expects = ImmutableSortedSet.of(
         new ContainerCDNMetadata(
            "adriancole-blobstore.testCDNOperationsContainerWithCDN",
            false,
            false,
            3600,
            URI.create("http://c0354712.cdn.cloudfiles.rackspacecloud.com"),
            URI.create("https://c0354712.cdn.ssl.cloudfiles.rackspacecloud.com"),
            URI.create("http://c0354712.cdn.stream.cloudfiles.rackspacecloud.com"),
            URI.create("http://c0354712.cdn.iosr.cloudfiles.rackspacecloud.com")),
         new ContainerCDNMetadata(
            "adriancole-blobstore5",
            true,
            false,
            28800,
            URI.create("http://c0404671.cdn.cloudfiles.rackspacecloud.com"),
            URI.create("https://c0404671.cdn.ssl.cloudfiles.rackspacecloud.com"),
            URI.create("http://c0404671.cdn.stream.cloudfiles.rackspacecloud.com"),
            URI.create("http://c0404671.cdn.iosr.cloudfiles.rackspacecloud.com")),
         new ContainerCDNMetadata(
            "adriancole-cfcdnint.testCDNOperationsContainerWithCDN",
            false,
            false,
            3600,
            URI.create("http://c0320431.cdn.cloudfiles.rackspacecloud.com"),
View Full Code Here

            getApi().disableCDN(containerNameWithCDN);
            getApi().disableCDN(containerNameWithoutCDN);
         } catch (Exception e) {

         }
         ContainerCDNMetadata cdnMetadata = null;

         // Enable CDN with PUT for one container
         final URI cdnUri = getApi().enableCDN(containerNameWithCDN);
         assertNotNull(cdnUri);

         // Confirm CDN is enabled via HEAD request and has default TTL
         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());
         assertEquals(cdnMetadata.getCDNUri(), cdnUri);
        
         // Test static website metadata
         getApi().setCDNStaticWebsiteIndex(containerNameWithCDN, "index.html");
         getApi().setCDNStaticWebsiteError(containerNameWithCDN, "error.html");
        
         ContainerMetadata containerMetadata = getApi().getContainerMetadata(containerNameWithCDN);
        
         assertEquals(containerMetadata.getMetadata().get("web-index"), "index.html");
         assertEquals(containerMetadata.getMetadata().get("web-error"), "error.html");
        
         cdnMetadata = getApi().getCDNMetadata(containerNameWithoutCDN);
         assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
                  + " should not have metadata";

         assert getApi().getCDNMetadata("DoesNotExist") == null;
        
         // List CDN metadata for containers, and ensure all CDN info is
         // available for enabled
         // container
         Set<ContainerCDNMetadata> cdnMetadataList = getApi().listCDNContainers();
         assertTrue(cdnMetadataList.size() >= 1);

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         final boolean cdnEnabled = cdnMetadata.isCDNEnabled();
         final boolean logRetention = cdnMetadata.isLogRetention();
         final long initialTTL = cdnMetadata.getTTL();
         final URI cdnSslUri = cdnMetadata.getCDNSslUri();
         final URI cdnStreamingUri = cdnMetadata.getCDNStreamingUri();
         final URI cdnIosUri = cdnMetadata.getCDNIosUri();
         assertTrue(cdnMetadataList.contains(new ContainerCDNMetadata(
            containerNameWithCDN, cdnEnabled, logRetention, initialTTL, cdnUri, cdnSslUri, cdnStreamingUri, cdnIosUri)));

         // Test listing with options
         cdnMetadataList = getApi().listCDNContainers(ListCdnContainerOptions.Builder.enabledOnly());
         assertTrue(Iterables.all(cdnMetadataList, new Predicate<ContainerCDNMetadata>() {
            public boolean apply(ContainerCDNMetadata cdnMetadata) {
               return cdnMetadata.isCDNEnabled();
            }
         }));

         cdnMetadataList = getApi().listCDNContainers(
                  ListCdnContainerOptions.Builder.afterMarker(
                           containerNameWithCDN.substring(0, containerNameWithCDN.length() - 1)).maxResults(1));
         assertEquals(cdnMetadataList.size(), 1);

         // Enable CDN with PUT for the same container, this time with a custom TTL and Log Retention
         long ttl = 4000;
         getApi().enableCDN(containerNameWithCDN, ttl, true);

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), ttl);

         // Check POST by updating TTL settings
         ttl = minimumTTL;
         getApi().updateCDN(containerNameWithCDN, minimumTTL, false);

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), minimumTTL);

         // Confirm that minimum allowed value for TTL is 3600, lower values are
         // ignored.
         getApi().updateCDN(containerNameWithCDN, 3599L, false);
         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         assertEquals(cdnMetadata.getTTL(), 3599L);
        
         // Test purging an object from a CDN container
         SwiftObject swiftObject = newSwiftObject("hello", "hello.txt");
         getApi().putObject(containerNameWithCDN, swiftObject);
        
         assertTrue(getApi().purgeCDNObject(containerNameWithCDN, swiftObject.getInfo().getName()));

         // Disable CDN with POST
         assertTrue(getApi().disableCDN(containerNameWithCDN));

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         assertEquals(cdnMetadata.isCDNEnabled(), false);
      } finally {
         recycleContainer(containerNameWithCDN);
         recycleContainer(containerNameWithoutCDN);
      }
   }
View Full Code Here

      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),
View Full Code Here

            .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");
   }
View Full Code Here

            getApi().disableCDN(containerNameWithCDN);
            getApi().disableCDN(containerNameWithoutCDN);
         } catch (Exception e) {

         }
         ContainerCDNMetadata cdnMetadata = null;

         // Enable CDN with PUT for one container
         final URI cdnUri = getApi().enableCDN(containerNameWithCDN);
         assertNotNull(cdnUri);

         // Confirm CDN is enabled via HEAD request and has default TTL
         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());
         assertEquals(cdnMetadata.getCDNUri(), cdnUri);
        
         // Test static website metadata
         getApi().setCDNStaticWebsiteIndex(containerNameWithCDN, "index.html");
         getApi().setCDNStaticWebsiteError(containerNameWithCDN, "error.html");
        
         ContainerMetadata containerMetadata = getApi().getContainerMetadata(containerNameWithCDN);
        
         assertEquals(containerMetadata.getMetadata().get("web-index"), "index.html");
         assertEquals(containerMetadata.getMetadata().get("web-error"), "error.html");
        
         cdnMetadata = getApi().getCDNMetadata(containerNameWithoutCDN);
         assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
                  + " should not have metadata";

         assert getApi().getCDNMetadata("DoesNotExist") == null;
        
         // List CDN metadata for containers, and ensure all CDN info is
         // available for enabled
         // container
         Set<ContainerCDNMetadata> cdnMetadataList = getApi().listCDNContainers();
         assertTrue(cdnMetadataList.size() >= 1);

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         final boolean cdnEnabled = cdnMetadata.isCDNEnabled();
         final boolean logRetention = cdnMetadata.isLogRetention();
         final long initialTTL = cdnMetadata.getTTL();
         final URI cdnSslUri = cdnMetadata.getCDNSslUri();
         final URI cdnStreamingUri = cdnMetadata.getCDNStreamingUri();
         assertTrue(cdnMetadataList.contains(new ContainerCDNMetadata(
            containerNameWithCDN, cdnEnabled, logRetention, initialTTL, cdnUri, cdnSslUri, cdnStreamingUri)));

        
        
         // Test listing with options
         cdnMetadataList = getApi().listCDNContainers(ListCdnContainerOptions.Builder.enabledOnly());
         assertTrue(Iterables.all(cdnMetadataList, new Predicate<ContainerCDNMetadata>() {
            public boolean apply(ContainerCDNMetadata cdnMetadata) {
               return cdnMetadata.isCDNEnabled();
            }
         }));

         cdnMetadataList = getApi().listCDNContainers(
                  ListCdnContainerOptions.Builder.afterMarker(
                           containerNameWithCDN.substring(0, containerNameWithCDN.length() - 1)).maxResults(1));
         assertEquals(cdnMetadataList.size(), 1);

         // Enable CDN with PUT for the same container, this time with a custom TTL and Log Retention
         long ttl = 4000;
         getApi().enableCDN(containerNameWithCDN, ttl, true);

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), ttl);

         // Check POST by updating TTL settings
         ttl = minimumTTL;
         getApi().updateCDN(containerNameWithCDN, minimumTTL, false);

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), minimumTTL);

         // Confirm that minimum allowed value for TTL is 3600, lower values are
         // ignored.
         getApi().updateCDN(containerNameWithCDN, 3599L, false);
         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         assertEquals(cdnMetadata.getTTL(), 3599L);
        
         // Test purging an object from a CDN container
         SwiftObject swiftObject = newSwiftObject("hello", "hello.txt");
         getApi().putObject(containerNameWithCDN, swiftObject);
        
         assertTrue(getApi().purgeCDNObject(containerNameWithCDN, swiftObject.getInfo().getName()));

         // Disable CDN with POST
         assertTrue(getApi().disableCDN(containerNameWithCDN));

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         assertEquals(cdnMetadata.isCDNEnabled(), false);
      } finally {
         recycleContainer(containerNameWithCDN);
         recycleContainer(containerNameWithoutCDN);
      }
   }
View Full Code Here

   @Test
   public void testApplyInputStream() {

      InputStream is = getClass().getResourceAsStream("/test_list_cdn.json");
      Set<ContainerCDNMetadata> expects = ImmutableSortedSet.of(
         new ContainerCDNMetadata(
            "adriancole-blobstore.testCDNOperationsContainerWithCDN",
            false,
            false,
            3600,
            URI.create("http://c0354712.cdn.cloudfiles.rackspacecloud.com"),
            URI.create("https://c0354712.cdn.ssl.cloudfiles.rackspacecloud.com"),
            URI.create("http://c0354712.cdn.stream.cloudfiles.rackspacecloud.com")),
         new ContainerCDNMetadata(
            "adriancole-blobstore5",
            true,
            false,
            28800,
            URI.create("http://c0404671.cdn.cloudfiles.rackspacecloud.com"),
            URI.create("https://c0404671.cdn.ssl.cloudfiles.rackspacecloud.com"),
            URI.create("http://c0404671.cdn.stream.cloudfiles.rackspacecloud.com")),
         new ContainerCDNMetadata(
            "adriancole-cfcdnint.testCDNOperationsContainerWithCDN",
            false,
            false,
            3600,
            URI.create("http://c0320431.cdn.cloudfiles.rackspacecloud.com"),
View Full Code Here

      if (cdnUri == null) {
         // CDN is not, and has never, been enabled for this container.
         return null;
      }
      else {
         return new ContainerCDNMetadata(
            request.getEndpoint().getPath(),
            Boolean.parseBoolean(cdnEnabled),
            Boolean.parseBoolean(cdnLogRetention),
            Long.parseLong(cdnTTL),
            URI.create(cdnUri),
View Full Code Here

   @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()";
View Full Code Here

            .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");
   }
View Full Code Here

TOP

Related Classes of org.jclouds.cloudfiles.domain.ContainerCDNMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.