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

COVERAGE SUMMARY FOR SOURCE FILE [AtmosBlobRequestSigner.java]

nameclass, %method, %block, %line, %
AtmosBlobRequestSigner.java100% (1/1)83%  (5/6)85%  (135/158)92%  (12/13)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AtmosBlobRequestSigner100% (1/1)83%  (5/6)85%  (135/158)92%  (12/13)
signGetBlob (String, String, GetOptions): HttpRequest 0%   (0/1)0%   (0/23)0%   (0/1)
AtmosBlobRequestSigner (RestAnnotationProcessor, BlobToObject, BlobToHttpGetO... 100% (1/1)100% (66/66)100% (8/8)
getPath (String, String): String 100% (1/1)100% (17/17)100% (1/1)
signGetBlob (String, String): HttpRequest 100% (1/1)100% (16/16)100% (1/1)
signPutBlob (String, Blob): HttpRequest 100% (1/1)100% (20/20)100% (1/1)
signRemoveBlob (String, String): HttpRequest 100% (1/1)100% (16/16)100% (1/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.atmos.blobstore;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static org.jclouds.blobstore.util.BlobStoreUtils.cleanRequest;
23 
24import java.lang.reflect.Method;
25 
26import javax.inject.Inject;
27import javax.inject.Singleton;
28 
29import org.jclouds.atmos.AtmosAsyncClient;
30import org.jclouds.atmos.blobstore.functions.BlobToObject;
31import org.jclouds.atmos.domain.AtmosObject;
32import org.jclouds.atmos.options.PutOptions;
33import org.jclouds.blobstore.BlobRequestSigner;
34import org.jclouds.blobstore.domain.Blob;
35import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
36import org.jclouds.http.HttpRequest;
37import org.jclouds.http.options.GetOptions;
38import org.jclouds.rest.internal.RestAnnotationProcessor;
39 
40/**
41 * 
42 * @author Adrian Cole
43 */
44@Singleton
45public class AtmosBlobRequestSigner implements BlobRequestSigner {
46   private final RestAnnotationProcessor<AtmosAsyncClient> processor;
47   private final BlobToObject blobToObject;
48   private final BlobToHttpGetOptions blob2ObjectGetOptions;
49 
50   private final Method getMethod;
51   private final Method deleteMethod;
52   private final Method createMethod;
53 
54   @Inject
55   public AtmosBlobRequestSigner(RestAnnotationProcessor<AtmosAsyncClient> processor, BlobToObject blobToObject,
56            BlobToHttpGetOptions blob2ObjectGetOptions) throws SecurityException, NoSuchMethodException {
57      this.processor = checkNotNull(processor, "processor");
58      this.blobToObject = checkNotNull(blobToObject, "blobToObject");
59      this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
60      this.getMethod = AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class);
61      this.deleteMethod = AtmosAsyncClient.class.getMethod("deletePath", String.class);
62      this.createMethod = AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class, PutOptions[].class);
63   }
64 
65   @Override
66   public HttpRequest signGetBlob(String container, String name) {
67      return cleanRequest(processor.createRequest(getMethod, getPath(container, name)));
68   }
69 
70   @Override
71   public HttpRequest signPutBlob(String container, Blob blob) {
72      return cleanRequest(processor.createRequest(createMethod, container, blobToObject.apply(blob)));
73   }
74 
75   @Override
76   public HttpRequest signRemoveBlob(String container, String name) {
77      return cleanRequest(processor.createRequest(deleteMethod, getPath(container, name)));
78   }
79 
80   private String getPath(String container, String name) {
81      return checkNotNull(container, "container") + "/" + checkNotNull(name, "name");
82   }
83 
84   @Override
85   public HttpRequest signGetBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
86      return cleanRequest(processor.createRequest(getMethod, getPath(container, name), blob2ObjectGetOptions
87               .apply(options)));
88   }
89 
90}

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