Examples of CDNContainer


Examples of ch.iterate.openstack.swift.model.CDNContainer

     * @throws GenericException Unexpected response
     * @throws ch.iterate.openstack.swift.exception.NotFoundException
     *                          The Container has never been CDN enabled
     */
    public boolean isCDNEnabled(Region region, String container) throws IOException {
        final CDNContainer info = this.getCDNContainerInfo(region, container);
        return info.isEnabled();
    }
View Full Code Here

Examples of ch.iterate.openstack.swift.model.CDNContainer

     * @throws GenericException Unexpected response
     * @throws ch.iterate.openstack.swift.exception.NotFoundException
     *                          The Container has never been CDN enabled
     */
    public boolean isCDNEnabled(Region region, String container) throws IOException {
        final CDNContainer info = this.getCDNContainerInfo(region, container);
        return info.isEnabled();
    }
View Full Code Here

Examples of ch.iterate.openstack.swift.model.CDNContainer

    }

    public CDNContainer handleResponse(final HttpResponse response) throws ClientProtocolException, IOException {
        if(response.getStatusLine().getStatusCode() == HttpStatus.SC_NO_CONTENT ||
                response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            CDNContainer result = new CDNContainer(region, container);
            result.setCdnURL(this.getCdnUrl(response));
            result.setSslURL(this.getCdnSslUrl(response));
            result.setStreamingURL(this.getCdnStreamingUrl(response));
            result.setiOSStreamingURL(this.getCdnIosStreamingUrl(response));
            for(Header header : response.getAllHeaders()) {
                String name = header.getName().toLowerCase();
                if(Constants.X_CDN_ENABLED.equalsIgnoreCase(name)) {
                    result.setEnabled(Boolean.valueOf(header.getValue()));
                }
                else if(Constants.X_CDN_RETAIN_LOGS.equalsIgnoreCase(name)) {
                    result.setRetainLogs(Boolean.valueOf(header.getValue()));
                }
                else if(Constants.X_CDN_TTL.equalsIgnoreCase(name)) {
                    result.setTtl(Integer.parseInt(header.getValue()));
                }
                else if(Constants.X_CDN_REFERRER_ACL.equalsIgnoreCase(name)) {
                    result.setReferrerACL(header.getValue());
                }
                else if(Constants.X_CDN_USER_AGENT_ACL.equalsIgnoreCase(name)) {
                    result.setUserAgentACL(header.getValue());
                }
            }
            return result;
        }
        else if(response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
View Full Code Here

Examples of ch.iterate.openstack.swift.model.CDNContainer

                for(int i = 0; i < containerNodes.getLength(); ++i) {
                    Node containerNode = containerNodes.item(i);
                    if(!"container".equals(containerNode.getNodeName())) {
                        continue;
                    }
                    CDNContainer container = new CDNContainer(region);
                    NodeList objectData = containerNode.getChildNodes();
                    for(int j = 0; j < objectData.getLength(); ++j) {
                        Node data = objectData.item(j);
                        if("name".equals(data.getNodeName())) {
                            container.setName(data.getTextContent());
                        }
                        else if("cdn_url".equals(data.getNodeName())) {
                            container.setCdnURL(data.getTextContent());
                        }
                        else if("cdn_ssl_url".equals(data.getNodeName())) {
                            container.setSslURL(data.getTextContent());
                        }
                        else if("cdn_streaming_url".equals(data.getNodeName())) {
                            container.setStreamingURL(data.getTextContent());
                        }
                        else if("cdn_ios_url".equals(data.getNodeName())) {
                            container.setiOSStreamingURL(data.getTextContent());
                        }
                        else if("cdn_enabled".equals(data.getNodeName())) {
                            container.setEnabled(Boolean.parseBoolean(data.getTextContent()));
                        }
                        else if("log_retention".equals(data.getNodeName())) {
                            container.setRetainLogs(Boolean.parseBoolean(data.getTextContent()));
                        }
                        else if("ttl".equals(data.getNodeName())) {
                            container.setTtl(Integer.parseInt(data.getTextContent()));
                        }
                        else if("referrer_acl".equals(data.getNodeName())) {
                            container.setReferrerACL(data.getTextContent());
                        }
                        else if("useragent_acl".equals(data.getNodeName())) {
                            container.setUserAgentACL(data.getTextContent());
                        }
                        else {
                            logger.warn(String.format("Unexpected node name %s", data.getNodeName()));
                        }
                    }
                    if(container.getName() != null) {
                        list.add(container);
                    }
                }
                return list;
            }
View Full Code Here

Examples of ch.iterate.openstack.swift.model.CDNContainer

                for(int i = 0; i < containerNodes.getLength(); ++i) {
                    Node containerNode = containerNodes.item(i);
                    if(!"container".equals(containerNode.getNodeName())) {
                        continue;
                    }
                    CDNContainer container = new CDNContainer(region);
                    NodeList objectData = containerNode.getChildNodes();
                    for(int j = 0; j < objectData.getLength(); ++j) {
                        Node data = objectData.item(j);
                        if("name".equals(data.getNodeName())) {
                            container.setName(data.getTextContent());
                        }
                        else if("cdn_url".equals(data.getNodeName())) {
                            container.setCdnURL(data.getTextContent());
                        }
                        else if("cdn_ssl_url".equals(data.getNodeName())) {
                            container.setSslURL(data.getTextContent());
                        }
                        else if("cdn_streaming_url".equals(data.getNodeName())) {
                            container.setStreamingURL(data.getTextContent());
                        }
                        else if("cdn_ios_url".equals(data.getNodeName())) {
                            container.setiOSStreamingURL(data.getTextContent());
                        }
                        else if("cdn_enabled".equals(data.getNodeName())) {
                            container.setEnabled(Boolean.parseBoolean(data.getTextContent()));
                        }
                        else if("log_retention".equals(data.getNodeName())) {
                            container.setRetainLogs(Boolean.parseBoolean(data.getTextContent()));
                        }
                        else if("ttl".equals(data.getNodeName())) {
                            container.setTtl(Integer.parseInt(data.getTextContent()));
                        }
                        else if("referrer_acl".equals(data.getNodeName())) {
                            container.setReferrerACL(data.getTextContent());
                        }
                        else if("useragent_acl".equals(data.getNodeName())) {
                            container.setUserAgentACL(data.getTextContent());
                        }
                        else {
                            logger.warn(String.format("Unexpected node name %s", data.getNodeName()));
                        }
                    }
                    if(container.getName() != null) {
                        list.add(container);
                    }
                }
                return list;
            }
View Full Code Here

Examples of ch.iterate.openstack.swift.model.CDNContainer

        this.container = container;
    }

    public CDNContainer handleResponse(final HttpResponse response) throws ClientProtocolException, IOException {
        if(response.getStatusLine().getStatusCode() == HttpStatus.SC_NO_CONTENT) {
            CDNContainer result = new CDNContainer(region, container);
            result.setCdnURL(this.getCdnUrl(response));
            result.setSslURL(this.getCdnSslUrl(response));
            result.setStreamingURL(this.getCdnStreamingUrl(response));
            result.setiOSStreamingURL(this.getCdnIosStreamingUrl(response));
            for(Header header : response.getAllHeaders()) {
                String name = header.getName().toLowerCase();
                if(Constants.X_CDN_ENABLED.equalsIgnoreCase(name)) {
                    result.setEnabled(Boolean.valueOf(header.getValue()));
                }
                else if(Constants.X_CDN_RETAIN_LOGS.equalsIgnoreCase(name)) {
                    result.setRetainLogs(Boolean.valueOf(header.getValue()));
                }
                else if(Constants.X_CDN_TTL.equalsIgnoreCase(name)) {
                    result.setTtl(Integer.parseInt(header.getValue()));
                }
                else if(Constants.X_CDN_REFERRER_ACL.equalsIgnoreCase(name)) {
                    result.setReferrerACL(header.getValue());
                }
                else if(Constants.X_CDN_USER_AGENT_ACL.equalsIgnoreCase(name)) {
                    result.setUserAgentACL(header.getValue());
                }
            }
            return result;
        }
        else if(response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
View Full Code Here

Examples of org.jclouds.hpcloud.objectstorage.domain.CDNContainer

      @Override
      public URI load(String container) {
         Optional<CDNContainerApi> cdnExtension = client.getCDNExtension();
         checkArgument(cdnExtension.isPresent(), "CDN is required, but the extension is not available!");
         try {
            CDNContainer md = cdnExtension.get().get(container);
            return md != null ? md.getCDNUri() : null;
         } catch (HttpResponseException e) {
            // TODO: this is due to beta status
            logger.trace("couldn't get cdn metadata for %s: %s", container, e.getMessage());
            return null;
         } catch (NoSuchElementException e) {
View Full Code Here

Examples of org.jclouds.hpcloud.objectstorage.domain.CDNContainer

            getApi().getCDNExtension().get().disable(containerNameWithCDN);
            getApi().getCDNExtension().get().disable(containerNameWithoutCDN);
         } catch (Exception e) {
            e.printStackTrace();
         }
         CDNContainer cdnMetadata = null;

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

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

         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getCDNUri(), cdnUri);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithoutCDN);
         assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
                  + " should not have metadata";

         assert getApi().getCDNExtension().get().get("DoesNotExist") == null;

         // List CDN metadata for containers, and ensure all CDN info is
         // available for enabled
         // container
         FluentIterable<CDNContainer> cdnMetadataList = getApi().getCDNExtension().get().list();
         assertTrue(cdnMetadataList.size() >= 1);

         final long initialTTL = cdnMetadata.getTTL();
         assertTrue(cdnMetadataList.contains(CDNContainer.builder().name(containerNameWithCDN)
               .CDNEnabled(true).ttl(initialTTL).CDNUri(cdnUri).build()));

         /*
          * Test listing with options FIXFIX cdnMetadataList =
          * getApi().list(ListCDNContainerOptions.Builder.enabledOnly());
          * assertTrue(Iterables.all(cdnMetadataList, new Predicate<CDNContainer>() { public
          * boolean apply(CDNContainer cdnMetadata) { return cdnMetadata.isCDNEnabled(); }
          * }));
          */

         cdnMetadataList = getApi().getCDNExtension().get().list(
                  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
         long ttl = 4000;
         getApi().getCDNExtension().get().enable(containerNameWithCDN, ttl);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());
  
         assertEquals(cdnMetadata.getTTL(), ttl);

         // Check POST by updating TTL settings
         ttl = minimumTTL;
         getApi().getCDNExtension().get().update(containerNameWithCDN, minimumTTL);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), minimumTTL);

         // Confirm that minimum allowed value for TTL is 3600, lower values are
         // ignored.
         getApi().getCDNExtension().get().update(containerNameWithCDN, 3599L);
         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertEquals(cdnMetadata.getTTL(), 3599L);

         // Disable CDN with POST
         assertTrue(getApi().getCDNExtension().get().disable(containerNameWithCDN));

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertEquals(cdnMetadata.isCDNEnabled(), false);
      } catch (Exception e) {
         e.printStackTrace();
      } finally {
         recycleContainer(containerNameWithCDN);
         recycleContainer(containerNameWithoutCDN);
View Full Code Here

Examples of org.jclouds.hpcloud.objectstorage.domain.CDNContainer

            getApi().getCDNExtension().get().disable(containerNameWithCDN);
            getApi().getCDNExtension().get().disable(containerNameWithoutCDN);
         } catch (Exception e) {
            e.printStackTrace();
         }
         CDNContainer cdnMetadata = null;

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

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

         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getCDNUri(), cdnUri);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithoutCDN);
         assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
                  + " should not have metadata";

         assert getApi().getCDNExtension().get().get("DoesNotExist") == null;

         // List CDN metadata for containers, and ensure all CDN info is
         // available for enabled
         // container
         FluentIterable<CDNContainer> cdnMetadataList = getApi().getCDNExtension().get().list();
         assertTrue(cdnMetadataList.size() >= 1);

         final long initialTTL = cdnMetadata.getTTL();
         assertTrue(cdnMetadataList.contains(CDNContainer.builder().name(containerNameWithCDN)
               .CDNEnabled(true).ttl(initialTTL).CDNUri(cdnUri).build()));

         /*
          * Test listing with options FIXFIX cdnMetadataList =
          * getApi().list(ListCDNContainerOptions.Builder.enabledOnly());
          * assertTrue(Iterables.all(cdnMetadataList, new Predicate<CDNContainer>() { public
          * boolean apply(CDNContainer cdnMetadata) { return cdnMetadata.isCDNEnabled(); }
          * }));
          */

         cdnMetadataList = getApi().getCDNExtension().get().list(
                  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
         long ttl = 4000;
         getApi().getCDNExtension().get().enable(containerNameWithCDN, ttl);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());
  
         assertEquals(cdnMetadata.getTTL(), ttl);

         // Check POST by updating TTL settings
         ttl = minimumTTL;
         getApi().getCDNExtension().get().update(containerNameWithCDN, minimumTTL);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), minimumTTL);

         // Confirm that minimum allowed value for TTL is 3600, lower values are
         // ignored.
         getApi().getCDNExtension().get().update(containerNameWithCDN, 3599L);
         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertEquals(cdnMetadata.getTTL(), 3599L);

         // Disable CDN with POST
         assertTrue(getApi().getCDNExtension().get().disable(containerNameWithCDN));

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertEquals(cdnMetadata.isCDNEnabled(), false);
      } catch (Exception e) {
         e.printStackTrace();
      } finally {
         recycleContainer(containerNameWithCDN);
         recycleContainer(containerNameWithoutCDN);
View Full Code Here

Examples of org.jclouds.hpcloud.objectstorage.domain.CDNContainer

      @Override
      public URI load(String container) {
         Optional<CDNContainerApi> cdnExtension = client.getCDNExtension();
         checkArgument(cdnExtension.isPresent(), "CDN is required, but the extension is not available!");
         try {
            CDNContainer md = cdnExtension.get().get(container);
            return md != null ? md.getCDNUri() : null;
         } catch (HttpResponseException e) {
            // TODO: this is due to beta status
            logger.trace("couldn't get cdn metadata for %s: %s", container, e.getMessage());
            return null;
         } catch (NoSuchElementException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.