EMMA Coverage Report (generated Mon Oct 17 05:41:20 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/16)0%   (0/199)0%   (0/33)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SwiftBlobStore0%   (0/1)0%   (0/14)0%   (0/183)0%   (0/32)
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)
createContainerInLocation (Location, String, CreateContainerOptions): boolean 0%   (0/1)0%   (0/13)0%   (0/3)
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)
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)
     
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 * 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.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.CreateContainerOptions;
39import org.jclouds.blobstore.options.ListContainerOptions;
40import org.jclouds.blobstore.options.PutOptions;
41import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
42import org.jclouds.blobstore.util.BlobUtils;
43import org.jclouds.collect.Memoized;
44import org.jclouds.domain.Location;
45import org.jclouds.http.options.GetOptions;
46import org.jclouds.openstack.swift.CommonSwiftClient;
47import org.jclouds.openstack.swift.blobstore.functions.BlobStoreListContainerOptionsToListContainerOptions;
48import org.jclouds.openstack.swift.blobstore.functions.BlobToObject;
49import org.jclouds.openstack.swift.blobstore.functions.ContainerToResourceList;
50import org.jclouds.openstack.swift.blobstore.functions.ContainerToResourceMetadata;
51import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlob;
52import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata;
53import org.jclouds.openstack.swift.domain.ContainerMetadata;
54 
55import com.google.common.base.Function;
56import com.google.common.base.Supplier;
57import com.google.common.collect.Iterables;
58 
59/**
60 * 
61 * @author Adrian Cole
62 */
63@Singleton
64public class SwiftBlobStore extends BaseBlobStore {
65   private final CommonSwiftClient sync;
66   private final ContainerToResourceMetadata container2ResourceMd;
67   private final BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions;
68   private final ContainerToResourceList container2ResourceList;
69   private final ObjectToBlob object2Blob;
70   private final BlobToObject blob2Object;
71   private final ObjectToBlobMetadata object2BlobMd;
72   private final BlobToHttpGetOptions blob2ObjectGetOptions;
73   private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
74 
75   @Inject
76   protected SwiftBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
77            @Memoized Supplier<Set<? extends Location>> locations, CommonSwiftClient sync,
78            ContainerToResourceMetadata container2ResourceMd,
79            BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions,
80            ContainerToResourceList container2ResourceList, ObjectToBlob object2Blob, BlobToObject blob2Object,
81            ObjectToBlobMetadata object2BlobMd, BlobToHttpGetOptions blob2ObjectGetOptions,
82            Provider<FetchBlobMetadata> fetchBlobMetadataProvider) {
83      super(context, blobUtils, defaultLocation, locations);
84      this.sync = sync;
85      this.container2ResourceMd = container2ResourceMd;
86      this.container2ContainerListOptions = container2ContainerListOptions;
87      this.container2ResourceList = container2ResourceList;
88      this.object2Blob = object2Blob;
89      this.blob2Object = blob2Object;
90      this.object2BlobMd = object2BlobMd;
91      this.blob2ObjectGetOptions = blob2ObjectGetOptions;
92      this.fetchBlobMetadataProvider = checkNotNull(fetchBlobMetadataProvider, "fetchBlobMetadataProvider");
93   }
94 
95   /**
96    * This implementation invokes {@link CommonSwiftClient#listContainers}
97    */
98   @Override
99   public PageSet<? extends StorageMetadata> list() {
100      return new Function<Set<ContainerMetadata>, org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata>>() {
101         public org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata> apply(Set<ContainerMetadata> from) {
102            return new PageSetImpl<StorageMetadata>(Iterables.transform(from, container2ResourceMd), null);
103         }
104      }.apply(sync.listContainers());
105   }
106 
107   /**
108    * This implementation invokes {@link CommonSwiftClient#containerExists}
109    * 
110    * @param container
111    *           container name
112    */
113   @Override
114   public boolean containerExists(String container) {
115      return sync.containerExists(container);
116   }
117 
118   /**
119    * This implementation invokes {@link CommonSwiftClient#putBucketInRegion}
120    * 
121    * @param location
122    *           currently ignored
123    * @param container
124    *           container name
125    */
126   @Override
127   public boolean createContainerInLocation(Location location, String container) {
128      return sync.createContainer(container);
129   }
130 
131   /**
132    * This implementation invokes {@link CommonSwiftClient#listObjects}
133    * 
134    * @param container
135    *           container name
136    */
137   @Override
138   public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) {
139      org.jclouds.openstack.swift.options.ListContainerOptions httpOptions = container2ContainerListOptions
140               .apply(options);
141      PageSet<? extends StorageMetadata> list = container2ResourceList.apply(sync.listObjects(container, httpOptions));
142      return options.isDetailed() ? fetchBlobMetadataProvider.get().setContainerName(container).apply(list) : list;
143   }
144 
145   /**
146    * This implementation invokes {@link CommonSwiftClient#blobExists}
147    * 
148    * @param container
149    *           container name
150    * @param key
151    *           file name
152    */
153   @Override
154   public boolean blobExists(String container, String key) {
155      return sync.objectExists(container, key);
156   }
157 
158   /**
159    * This implementation invokes {@link CommonSwiftClient#getObjectInfo}
160    * 
161    * @param container
162    *           container name
163    * @param key
164    *           file name
165    */
166   @Override
167   public BlobMetadata blobMetadata(String container, String key) {
168      return object2BlobMd.apply(sync.getObjectInfo(container, key));
169   }
170 
171   /**
172    * This implementation invokes {@link CommonSwiftClient#getObject}
173    * 
174    * @param container
175    *           container name
176    * @param key
177    *           file name
178    */
179   @Override
180   public Blob getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions optionsList) {
181      GetOptions httpOptions = blob2ObjectGetOptions.apply(optionsList);
182      return object2Blob.apply(sync.getObject(container, key, httpOptions));
183   }
184 
185   /**
186    * This implementation invokes {@link CommonSwiftClient#putObject}
187    * 
188    * @param container
189    *           container name
190    * @param blob
191    *           object
192    */
193   @Override
194   public String putBlob(String container, Blob blob) {
195      createParentIfNeededAsync(context.getAsyncBlobStore(), container, blob);
196      return sync.putObject(container, blob2Object.apply(blob));
197   }
198 
199   /**
200    * This implementation invokes {@link CommonSwiftClient#putObject}
201    * 
202    * @param container
203    *           container name
204    * @param blob
205    *           object
206    */
207   @Override
208   public String putBlob(String container, Blob blob, PutOptions options) {
209      // TODO implement options
210      return putBlob(container, blob);
211   }
212 
213   /**
214    * This implementation invokes {@link CommonSwiftClient#removeObject}
215    * 
216    * @param container
217    *           container name
218    * @param key
219    *           file name
220    */
221   @Override
222   public void removeBlob(String container, String key) {
223      sync.removeObject(container, key);
224   }
225 
226   @Override
227   protected boolean deleteAndVerifyContainerGone(String container) {
228      sync.deleteContainerIfEmpty(container);
229      return !sync.containerExists(container);
230   }
231 
232   @Override
233   public boolean createContainerInLocation(Location location, String container, CreateContainerOptions options) {
234      if (options.isPublicRead())
235         throw new UnsupportedOperationException("publicRead");
236      return createContainerInLocation(location, container);
237   }
238}

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