EMMA Coverage Report (generated Tue Jun 21 05:51:52 EDT 2011)
[all classes][org.jclouds.openstack.swift.blobstore]

COVERAGE SUMMARY FOR SOURCE FILE [SwiftBlobStore.java]

nameclass, %method, %block, %line, %
SwiftBlobStore.java0%   (0/2)0%   (0/14)0%   (0/181)0%   (0/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SwiftBlobStore0%   (0/1)0%   (0/12)0%   (0/165)0%   (0/28)
SwiftBlobStore (BlobStoreContext, BlobUtils, Supplier, Supplier, CommonSwiftC... 0%   (0/1)0%   (0/37)0%   (0/11)
access$000 (SwiftBlobStore): 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/5)0%   (0/1)
deleteAndVerifyContainerGone (String): boolean 0%   (0/1)0%   (0/14)0%   (0/2)
getBlob (String, String, GetOptions): Blob 0%   (0/1)0%   (0/20)0%   (0/2)
list (): PageSet 0%   (0/1)0%   (0/11)0%   (0/1)
list (String, ListContainerOptions): PageSet 0%   (0/1)0%   (0/33)0%   (0/3)
putBlob (String, Blob): String 0%   (0/1)0%   (0/16)0%   (0/2)
removeBlob (String, String): void 0%   (0/1)0%   (0/6)0%   (0/2)
     
class SwiftBlobStore$10%   (0/1)0%   (0/2)0%   (0/16)0%   (0/2)
SwiftBlobStore$1 (SwiftBlobStore): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (Set): PageSet 0%   (0/1)0%   (0/10)0%   (0/1)

1/**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * 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, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
18 */
19package org.jclouds.openstack.swift.blobstore;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static org.jclouds.blobstore.util.BlobStoreUtils.createParentIfNeededAsync;
23 
24import java.util.Set;
25 
26import javax.inject.Inject;
27import javax.inject.Provider;
28import javax.inject.Singleton;
29 
30import org.jclouds.blobstore.BlobStoreContext;
31import org.jclouds.blobstore.domain.Blob;
32import org.jclouds.blobstore.domain.BlobMetadata;
33import org.jclouds.blobstore.domain.PageSet;
34import org.jclouds.blobstore.domain.StorageMetadata;
35import org.jclouds.blobstore.domain.internal.PageSetImpl;
36import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
37import org.jclouds.blobstore.internal.BaseBlobStore;
38import org.jclouds.blobstore.options.ListContainerOptions;
39import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
40import org.jclouds.blobstore.util.BlobUtils;
41import org.jclouds.collect.Memoized;
42import org.jclouds.domain.Location;
43import org.jclouds.http.options.GetOptions;
44import org.jclouds.openstack.swift.CommonSwiftClient;
45import org.jclouds.openstack.swift.blobstore.functions.BlobStoreListContainerOptionsToListContainerOptions;
46import org.jclouds.openstack.swift.blobstore.functions.BlobToObject;
47import org.jclouds.openstack.swift.blobstore.functions.ContainerToResourceList;
48import org.jclouds.openstack.swift.blobstore.functions.ContainerToResourceMetadata;
49import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlob;
50import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata;
51import org.jclouds.openstack.swift.domain.ContainerMetadata;
52 
53import com.google.common.base.Function;
54import com.google.common.base.Supplier;
55import com.google.common.collect.Iterables;
56 
57/**
58 * 
59 * @author Adrian Cole
60 */
61@Singleton
62public class SwiftBlobStore extends BaseBlobStore {
63   private final CommonSwiftClient sync;
64   private final ContainerToResourceMetadata container2ResourceMd;
65   private final BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions;
66   private final ContainerToResourceList container2ResourceList;
67   private final ObjectToBlob object2Blob;
68   private final BlobToObject blob2Object;
69   private final ObjectToBlobMetadata object2BlobMd;
70   private final BlobToHttpGetOptions blob2ObjectGetOptions;
71   private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
72 
73   @Inject
74   SwiftBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
75            @Memoized Supplier<Set<? extends Location>> locations, CommonSwiftClient sync,
76            ContainerToResourceMetadata container2ResourceMd,
77            BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions,
78            ContainerToResourceList container2ResourceList, ObjectToBlob object2Blob, BlobToObject blob2Object,
79            ObjectToBlobMetadata object2BlobMd, BlobToHttpGetOptions blob2ObjectGetOptions,
80            Provider<FetchBlobMetadata> fetchBlobMetadataProvider) {
81      super(context, blobUtils, defaultLocation, locations);
82      this.sync = sync;
83      this.container2ResourceMd = container2ResourceMd;
84      this.container2ContainerListOptions = container2ContainerListOptions;
85      this.container2ResourceList = container2ResourceList;
86      this.object2Blob = object2Blob;
87      this.blob2Object = blob2Object;
88      this.object2BlobMd = object2BlobMd;
89      this.blob2ObjectGetOptions = blob2ObjectGetOptions;
90      this.fetchBlobMetadataProvider = checkNotNull(fetchBlobMetadataProvider, "fetchBlobMetadataProvider");
91   }
92 
93   /**
94    * This implementation invokes {@link CommonSwiftClient#listContainers}
95    */
96   @Override
97   public PageSet<? extends StorageMetadata> list() {
98      return new Function<Set<ContainerMetadata>, org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata>>() {
99         public org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata> apply(Set<ContainerMetadata> from) {
100            return new PageSetImpl<StorageMetadata>(Iterables.transform(from, container2ResourceMd), null);
101         }
102      }.apply(sync.listContainers());
103   }
104 
105   /**
106    * This implementation invokes {@link CommonSwiftClient#containerExists}
107    * 
108    * @param container
109    *           container name
110    */
111   @Override
112   public boolean containerExists(String container) {
113      return sync.containerExists(container);
114   }
115 
116   /**
117    * This implementation invokes {@link CommonSwiftClient#putBucketInRegion}
118    * 
119    * @param location
120    *           currently ignored
121    * @param container
122    *           container name
123    */
124   @Override
125   public boolean createContainerInLocation(Location location, String container) {
126      return sync.createContainer(container);
127   }
128 
129   /**
130    * This implementation invokes {@link CommonSwiftClient#listObjects}
131    * 
132    * @param container
133    *           container name
134    */
135   @Override
136   public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) {
137      org.jclouds.openstack.swift.options.ListContainerOptions httpOptions = container2ContainerListOptions
138               .apply(options);
139      PageSet<? extends StorageMetadata> list = container2ResourceList.apply(sync.listObjects(container, httpOptions));
140      return options.isDetailed() ? fetchBlobMetadataProvider.get().setContainerName(container).apply(list) : list;
141   }
142 
143   /**
144    * This implementation invokes {@link CommonSwiftClient#blobExists}
145    * 
146    * @param container
147    *           container name
148    * @param key
149    *           file name
150    */
151   @Override
152   public boolean blobExists(String container, String key) {
153      return sync.objectExists(container, key);
154   }
155 
156   /**
157    * This implementation invokes {@link CommonSwiftClient#getObjectInfo}
158    * 
159    * @param container
160    *           container name
161    * @param key
162    *           file name
163    */
164   @Override
165   public BlobMetadata blobMetadata(String container, String key) {
166      return object2BlobMd.apply(sync.getObjectInfo(container, key));
167   }
168 
169   /**
170    * This implementation invokes {@link CommonSwiftClient#getObject}
171    * 
172    * @param container
173    *           container name
174    * @param key
175    *           file name
176    */
177   @Override
178   public Blob getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions optionsList) {
179      GetOptions httpOptions = blob2ObjectGetOptions.apply(optionsList);
180      return object2Blob.apply(sync.getObject(container, key, httpOptions));
181   }
182 
183   /**
184    * This implementation invokes {@link CommonSwiftClient#putObject}
185    * 
186    * @param container
187    *           container name
188    * @param blob
189    *           object
190    */
191   @Override
192   public String putBlob(String container, Blob blob) {
193      createParentIfNeededAsync(context.getAsyncBlobStore(), container, blob);
194      return sync.putObject(container, blob2Object.apply(blob));
195   }
196 
197   /**
198    * This implementation invokes {@link CommonSwiftClient#removeObject}
199    * 
200    * @param container
201    *           container name
202    * @param key
203    *           file name
204    */
205   @Override
206   public void removeBlob(String container, String key) {
207      sync.removeObject(container, key);
208   }
209 
210   @Override
211   protected boolean deleteAndVerifyContainerGone(String container) {
212      sync.deleteContainerIfEmpty(container);
213      return !sync.containerExists(container);
214   }
215}

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