| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.cloudfiles.domain; |
| 20 | |
| 21 | import java.net.URI; |
| 22 | |
| 23 | /** |
| 24 | * |
| 25 | * @author James Murty |
| 26 | * |
| 27 | */ |
| 28 | public class ContainerCDNMetadata implements Comparable<ContainerCDNMetadata> { |
| 29 | |
| 30 | private String name; |
| 31 | private boolean cdn_enabled; |
| 32 | private long ttl; |
| 33 | private URI cdn_uri; |
| 34 | private String referrer_acl; |
| 35 | private String useragent_acl; |
| 36 | private boolean log_retention; |
| 37 | |
| 38 | public ContainerCDNMetadata(String name, boolean cdnEnabled, long ttl, URI cdnUri) { |
| 39 | this.name = name; |
| 40 | this.cdn_enabled = cdnEnabled; |
| 41 | this.ttl = ttl; |
| 42 | this.cdn_uri = cdnUri; |
| 43 | } |
| 44 | |
| 45 | public ContainerCDNMetadata() { |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Beware: The container name is not available from HEAD CDN responses and will be null. return |
| 50 | * the name of the container to which these CDN settings apply. |
| 51 | */ |
| 52 | public String getName() { |
| 53 | return name; |
| 54 | } |
| 55 | |
| 56 | public URI getCDNUri() { |
| 57 | return cdn_uri; |
| 58 | } |
| 59 | |
| 60 | public long getTTL() { |
| 61 | return ttl; |
| 62 | } |
| 63 | |
| 64 | public boolean isCDNEnabled() { |
| 65 | return cdn_enabled; |
| 66 | } |
| 67 | |
| 68 | public int compareTo(ContainerCDNMetadata o) { |
| 69 | if (getName() == null) |
| 70 | return -1; |
| 71 | return (this == o) ? 0 : getName().compareTo(o.getName()); |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public int hashCode() { |
| 76 | final int prime = 31; |
| 77 | int result = 1; |
| 78 | result = prime * result + ((cdn_uri == null) ? 0 : cdn_uri.hashCode()); |
| 79 | return result; |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public boolean equals(Object obj) { |
| 84 | if (this == obj) |
| 85 | return true; |
| 86 | if (obj == null) |
| 87 | return false; |
| 88 | if (getClass() != obj.getClass()) |
| 89 | return false; |
| 90 | ContainerCDNMetadata other = (ContainerCDNMetadata) obj; |
| 91 | if (cdn_uri == null) { |
| 92 | if (other.cdn_uri != null) |
| 93 | return false; |
| 94 | } else if (!cdn_uri.equals(other.cdn_uri)) |
| 95 | return false; |
| 96 | return true; |
| 97 | } |
| 98 | |
| 99 | public String getReferrerACL() { |
| 100 | return referrer_acl; |
| 101 | } |
| 102 | |
| 103 | public String getUseragentACL() { |
| 104 | return useragent_acl; |
| 105 | } |
| 106 | |
| 107 | public boolean isLogRetention() { |
| 108 | return log_retention; |
| 109 | } |
| 110 | |
| 111 | @Override |
| 112 | public String toString() { |
| 113 | return String.format( |
| 114 | "[name=%s, cdn_uri=%s, cdn_enabled=%s, log_retention=%s, referrer_acl=%s, ttl=%s, useragent_acl=%s]", |
| 115 | name, cdn_uri, cdn_enabled, log_retention, referrer_acl, ttl, useragent_acl); |
| 116 | } |
| 117 | } |