EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.azureblob.blobstore]

COVERAGE SUMMARY FOR SOURCE FILE [AzureBlobStore.java]

nameclass, %method, %block, %line, %
AzureBlobStore.java50%  (1/2)6%   (1/17)26%  (55/209)31%  (10/32)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AzureBlobStore$10%   (0/1)0%   (0/2)0%   (0/17)0%   (0/2)
AzureBlobStore$1 (AzureBlobStore): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (BoundedSet): PageSet 0%   (0/1)0%   (0/11)0%   (0/1)
     
class AzureBlobStore100% (1/1)7%   (1/15)29%  (55/192)32%  (10/31)
access$000 (AzureBlobStore): ContainerToResourceMetadata 0%   (0/1)0%   (0/3)0%   (0/1)
blobExists (String, String): boolean 0%   (0/1)0%   (0/6)0%   (0/1)
blobMetadata (String, String): BlobMetadata 0%   (0/1)0%   (0/9)0%   (0/1)
containerExists (String): boolean 0%   (0/1)0%   (0/5)0%   (0/1)
createContainerInLocation (Location, String): boolean 0%   (0/1)0%   (0/7)0%   (0/1)
createContainerInLocation (Location, String, CreateContainerOptions): boolean 0%   (0/1)0%   (0/22)0%   (0/4)
deleteAndVerifyContainerGone (String): boolean 0%   (0/1)0%   (0/5)0%   (0/1)
deleteContainer (String): void 0%   (0/1)0%   (0/5)0%   (0/2)
getBlob (String, String, GetOptions): Blob 0%   (0/1)0%   (0/20)0%   (0/2)
list (): PageSet 0%   (0/1)0%   (0/15)0%   (0/1)
list (String, ListContainerOptions): PageSet 0%   (0/1)0%   (0/20)0%   (0/2)
putBlob (String, Blob): String 0%   (0/1)0%   (0/9)0%   (0/1)
putBlob (String, Blob, PutOptions): String 0%   (0/1)0%   (0/5)0%   (0/1)
removeBlob (String, String): void 0%   (0/1)0%   (0/6)0%   (0/2)
AzureBlobStore (BlobStoreContext, BlobUtils, Supplier, Supplier, AzureBlobCli... 100% (1/1)100% (55/55)100% (10/10)

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 */
19package org.jclouds.azureblob.blobstore;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static org.jclouds.azure.storage.options.ListOptions.Builder.includeMetadata;
23 
24import java.util.Set;
25 
26import javax.inject.Inject;
27import javax.inject.Singleton;
28 
29import org.jclouds.azure.storage.domain.BoundedSet;
30import org.jclouds.azureblob.AzureBlobClient;
31import org.jclouds.azureblob.blobstore.functions.AzureBlobToBlob;
32import org.jclouds.azureblob.blobstore.functions.BlobPropertiesToBlobMetadata;
33import org.jclouds.azureblob.blobstore.functions.BlobToAzureBlob;
34import org.jclouds.azureblob.blobstore.functions.ContainerToResourceMetadata;
35import org.jclouds.azureblob.blobstore.functions.ListBlobsResponseToResourceList;
36import org.jclouds.azureblob.blobstore.functions.ListOptionsToListBlobsOptions;
37import org.jclouds.azureblob.domain.ContainerProperties;
38import org.jclouds.azureblob.domain.PublicAccess;
39import org.jclouds.azureblob.options.ListBlobsOptions;
40import org.jclouds.blobstore.BlobStoreContext;
41import org.jclouds.blobstore.domain.Blob;
42import org.jclouds.blobstore.domain.BlobMetadata;
43import org.jclouds.blobstore.domain.PageSet;
44import org.jclouds.blobstore.domain.StorageMetadata;
45import org.jclouds.blobstore.domain.internal.PageSetImpl;
46import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
47import org.jclouds.blobstore.internal.BaseBlobStore;
48import org.jclouds.blobstore.options.CreateContainerOptions;
49import org.jclouds.blobstore.options.ListContainerOptions;
50import org.jclouds.blobstore.options.PutOptions;
51import org.jclouds.blobstore.util.BlobUtils;
52import org.jclouds.collect.Memoized;
53import org.jclouds.domain.Location;
54import org.jclouds.http.options.GetOptions;
55 
56import com.google.common.base.Function;
57import com.google.common.base.Supplier;
58import com.google.common.collect.Iterables;
59 
60/**
61 * @author Adrian Cole
62 */
63@Singleton
64public class AzureBlobStore extends BaseBlobStore {
65   private final AzureBlobClient sync;
66   private final ContainerToResourceMetadata container2ResourceMd;
67   private final ListOptionsToListBlobsOptions blobStore2AzureContainerListOptions;
68   private final ListBlobsResponseToResourceList azure2BlobStoreResourceList;
69   private final AzureBlobToBlob azureBlob2Blob;
70   private final BlobToAzureBlob blob2AzureBlob;
71   private final BlobPropertiesToBlobMetadata blob2BlobMd;
72   private final BlobToHttpGetOptions blob2ObjectGetOptions;
73 
74   @Inject
75   AzureBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
76            @Memoized Supplier<Set<? extends Location>> locations, AzureBlobClient sync,
77            ContainerToResourceMetadata container2ResourceMd,
78            ListOptionsToListBlobsOptions blobStore2AzureContainerListOptions,
79            ListBlobsResponseToResourceList azure2BlobStoreResourceList, AzureBlobToBlob azureBlob2Blob,
80            BlobToAzureBlob blob2AzureBlob, BlobPropertiesToBlobMetadata blob2BlobMd,
81            BlobToHttpGetOptions blob2ObjectGetOptions) {
82      super(context, blobUtils, defaultLocation, locations);
83      this.sync = checkNotNull(sync, "sync");
84      this.container2ResourceMd = checkNotNull(container2ResourceMd, "container2ResourceMd");
85      this.blobStore2AzureContainerListOptions = checkNotNull(blobStore2AzureContainerListOptions,
86               "blobStore2AzureContainerListOptions");
87      this.azure2BlobStoreResourceList = checkNotNull(azure2BlobStoreResourceList, "azure2BlobStoreResourceList");
88      this.azureBlob2Blob = checkNotNull(azureBlob2Blob, "azureBlob2Blob");
89      this.blob2AzureBlob = checkNotNull(blob2AzureBlob, "blob2AzureBlob");
90      this.blob2BlobMd = checkNotNull(blob2BlobMd, "blob2BlobMd");
91      this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
92   }
93 
94   /**
95    * This implementation invokes {@link AzureBlobClient#listContainers}
96    */
97   @Override
98   public PageSet<? extends StorageMetadata> list() {
99      return new Function<BoundedSet<ContainerProperties>, org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata>>() {
100         public org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata> apply(
101                  BoundedSet<ContainerProperties> from) {
102            return new PageSetImpl<StorageMetadata>(Iterables.transform(from, container2ResourceMd), from
103                     .getNextMarker());
104         }
105         // TODO this may be a list that isn't complete due to 1000 container limit
106      }.apply(sync.listContainers(includeMetadata()));
107   }
108 
109   /**
110    * This implementation invokes {@link AzureBlobClient#bucketExists}
111    * 
112    * @param container
113    *           container name
114    */
115   @Override
116   public boolean containerExists(String container) {
117      return sync.containerExists(container);
118   }
119 
120   /**
121    * This implementation invokes {@link AzureBlobClient#putBucketInRegion}
122    * 
123    * @param location
124    *           currently ignored
125    * @param container
126    *           container name
127    */
128   @Override
129   public boolean createContainerInLocation(Location location, String container) {
130      return sync.createContainer(container);
131   }
132 
133   /**
134    * This implementation invokes {@link AzureBlobClient#listBlobs}
135    * 
136    * @param container
137    *           container name
138    */
139   @Override
140   public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) {
141      ListBlobsOptions azureOptions = blobStore2AzureContainerListOptions.apply(options);
142      return azure2BlobStoreResourceList.apply(sync.listBlobs(container, azureOptions.includeMetadata()));
143   }
144 
145   /**
146    * This implementation invokes {@link AzureBlobClient#deleteContainer}
147    * 
148    * @param container
149    *           container name
150    */
151   @Override
152   public void deleteContainer(final String container) {
153      sync.deleteContainer(container);
154   }
155 
156   /**
157    * This implementation invokes {@link AzureBlobClient#blobExists}
158    * 
159    * @param container
160    *           container name
161    * @param key
162    *           blob key
163    */
164   @Override
165   public boolean blobExists(String container, String key) {
166      return sync.blobExists(container, key);
167   }
168 
169   /**
170    * This implementation invokes {@link AzureBlobClient#getBlob}
171    * 
172    * @param container
173    *           container name
174    * @param key
175    *           blob key
176    */
177   @Override
178   public Blob getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions options) {
179      GetOptions azureOptions = blob2ObjectGetOptions.apply(options);
180      return azureBlob2Blob.apply(sync.getBlob(container, key, azureOptions));
181 
182   }
183 
184   /**
185    * This implementation invokes {@link AzureBlobClient#putObject}
186    * 
187    * @param container
188    *           container name
189    * @param blob
190    *           object
191    */
192   @Override
193   public String putBlob(String container, Blob blob) {
194      return sync.putBlob(container, blob2AzureBlob.apply(blob));
195   }
196 
197   /**
198    * This implementation invokes {@link AzureBlobClient#putObject}
199    * 
200    * @param container
201    *           container name
202    * @param blob
203    *           object
204    */
205   @Override
206   public String putBlob(String container, Blob blob, PutOptions options) {
207      // TODO implement options
208      return putBlob(container, blob);
209   }
210 
211   /**
212    * This implementation invokes {@link AzureBlobClient#deleteObject}
213    * 
214    * @param container
215    *           container name
216    * @param key
217    *           blob key
218    */
219   @Override
220   public void removeBlob(String container, String key) {
221      sync.deleteBlob(container, key);
222   }
223 
224   /**
225    * This implementation invokes {@link AzureBlobClient#getBlobProperties}
226    * 
227    * @param container
228    *           container name
229    * @param key
230    *           blob key
231    */
232   @Override
233   public BlobMetadata blobMetadata(String container, String key) {
234      return blob2BlobMd.apply(sync.getBlobProperties(container, key));
235   }
236 
237   @Override
238   protected boolean deleteAndVerifyContainerGone(String container) {
239      throw new UnsupportedOperationException("please use deleteContainer");
240   }
241 
242   @Override
243   public boolean createContainerInLocation(Location location, String container, CreateContainerOptions options) {
244      org.jclouds.azureblob.options.CreateContainerOptions createContainerOptions = new org.jclouds.azureblob.options.CreateContainerOptions();
245      if (options.isPublicRead())
246         createContainerOptions.withPublicAccess(PublicAccess.CONTAINER);
247      return sync.createContainer(container, createContainerOptions);
248   }
249}

[all classes][org.jclouds.azureblob.blobstore]
EMMA 2.0.5312 (C) Vladimir Roubtsov