1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.jclouds.azureblob.domain.internal;
20
21 import java.io.Serializable;
22 import java.net.URI;
23 import java.util.Date;
24 import java.util.Map;
25
26 import org.jclouds.azureblob.domain.BlobProperties;
27 import org.jclouds.azureblob.domain.BlobType;
28 import org.jclouds.azureblob.domain.LeaseStatus;
29 import org.jclouds.azureblob.domain.MutableBlobProperties;
30 import org.jclouds.http.HttpUtils;
31 import org.jclouds.io.MutableContentMetadata;
32 import org.jclouds.io.payloads.BaseMutableContentMetadata;
33
34 import com.google.common.collect.Maps;
35
36
37
38
39
40
41 public class MutableBlobPropertiesImpl implements Serializable, MutableBlobProperties {
42
43
44 private static final long serialVersionUID = -4648755473986695062L;
45
46 private BlobType type = BlobType.BLOCK_BLOB;
47 private LeaseStatus leaseStatus = LeaseStatus.UNLOCKED;
48
49 private String name;
50 private String container;
51 private URI url;
52 private Date lastModified;
53 private String eTag;
54 private MutableContentMetadata contentMetadata;
55 private Map<String, String> metadata = Maps.newHashMap();
56
57 public MutableBlobPropertiesImpl() {
58 super();
59 this.contentMetadata = new BaseMutableContentMetadata();
60 }
61
62 public MutableBlobPropertiesImpl(BlobProperties from) {
63 this.contentMetadata = new BaseMutableContentMetadata();
64 this.name = from.getName();
65 this.container = from.getContainer();
66 this.url = from.getUrl();
67 this.lastModified = from.getLastModified();
68 this.eTag = from.getETag();
69 this.metadata.putAll(from.getMetadata());
70 HttpUtils.copy(from.getContentMetadata(), this.contentMetadata);
71 }
72
73
74
75
76 @Override
77 public BlobType getType() {
78 return type;
79 }
80
81
82
83
84 public void setType(BlobType type) {
85 this.type = type;
86 }
87
88
89
90
91 public String getName() {
92 return name;
93 }
94
95
96
97
98 public Date getLastModified() {
99 return lastModified;
100 }
101
102
103
104
105 public String getETag() {
106 return eTag;
107 }
108
109
110
111
112 public int compareTo(BlobProperties o) {
113 return (this == o) ? 0 : getName().compareTo(o.getName());
114 }
115
116
117
118
119 public Map<String, String> getMetadata() {
120 return metadata;
121 }
122
123
124
125
126 @Override
127 public LeaseStatus getLeaseStatus() {
128 return leaseStatus;
129 }
130
131
132
133
134 public void setETag(String eTag) {
135 this.eTag = eTag;
136 }
137
138
139
140
141 public void setName(String name) {
142 this.name = name;
143 }
144
145
146
147
148 public void setLastModified(Date lastModified) {
149 this.lastModified = lastModified;
150 }
151
152
153
154
155 public void setMetadata(Map<String, String> metadata) {
156 this.metadata = metadata;
157 }
158
159 public void setUrl(URI url) {
160 this.url = url;
161 }
162
163 public URI getUrl() {
164 return url;
165 }
166
167 @Override
168 public int hashCode() {
169 final int prime = 31;
170 int result = 1;
171 result = prime * result + ((url == null) ? 0 : url.hashCode());
172 return result;
173 }
174
175 @Override
176 public boolean equals(Object obj) {
177 if (this == obj)
178 return true;
179 if (obj == null)
180 return false;
181 if (getClass() != obj.getClass())
182 return false;
183 MutableBlobPropertiesImpl other = (MutableBlobPropertiesImpl) obj;
184 if (url == null) {
185 if (other.url != null)
186 return false;
187 } else if (!url.equals(other.url))
188 return false;
189 return true;
190 }
191
192 @Override
193 public String toString() {
194 return String
195 .format(
196 "[name=%s, container=%s, url=%s, contentMetadata=%s, eTag=%s, lastModified=%s, leaseStatus=%s, metadata=%s, type=%s]",
197 name, container, url, contentMetadata, eTag, lastModified, leaseStatus, metadata, type);
198 }
199
200
201
202
203 @Override
204 public MutableContentMetadata getContentMetadata() {
205 return contentMetadata;
206 }
207
208
209
210
211 @Override
212 public void setContentMetadata(MutableContentMetadata contentMetadata) {
213 this.contentMetadata = contentMetadata;
214 }
215
216
217
218
219 @Override
220 public String getContainer() {
221 return container;
222 }
223
224
225
226
227 @Override
228 public void setContainer(String container) {
229 this.container = container;
230 }
231
232 }