EMMA Coverage Report (generated Wed Aug 10 12:30:04 EDT 2011)
[all classes][org.jclouds.s3.blobstore]

COVERAGE SUMMARY FOR SOURCE FILE [S3BlobRequestSigner.java]

nameclass, %method, %block, %line, %
S3BlobRequestSigner.java100% (1/1)80%  (4/5)84%  (128/152)92%  (11/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class S3BlobRequestSigner100% (1/1)80%  (4/5)84%  (128/152)92%  (11/12)
signGetBlob (String, String, GetOptions): HttpRequest 0%   (0/1)0%   (0/24)0%   (0/1)
S3BlobRequestSigner (RestAnnotationProcessor, BlobToObject, BlobToHttpGetOpti... 100% (1/1)100% (74/74)100% (8/8)
signGetBlob (String, String): HttpRequest 100% (1/1)100% (17/17)100% (1/1)
signPutBlob (String, Blob): HttpRequest 100% (1/1)100% (20/20)100% (1/1)
signRemoveBlob (String, String): HttpRequest 100% (1/1)100% (17/17)100% (1/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.s3.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.blobstore.BlobRequestSigner;
30import org.jclouds.blobstore.domain.Blob;
31import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
32import org.jclouds.http.HttpRequest;
33import org.jclouds.http.options.GetOptions;
34import org.jclouds.rest.internal.RestAnnotationProcessor;
35import org.jclouds.s3.S3AsyncClient;
36import org.jclouds.s3.blobstore.functions.BlobToObject;
37import org.jclouds.s3.domain.S3Object;
38import org.jclouds.s3.options.PutObjectOptions;
39 
40/**
41 * 
42 * @author Adrian Cole
43 */
44@Singleton
45public class S3BlobRequestSigner implements BlobRequestSigner {
46   private final RestAnnotationProcessor<S3AsyncClient> processor;
47   private final BlobToObject blobToObject;
48   private final BlobToHttpGetOptions blob2HttpGetOptions;
49 
50   private final Method getMethod;
51   private final Method deleteMethod;
52   private final Method createMethod;
53 
54   @Inject
55   public S3BlobRequestSigner(RestAnnotationProcessor<S3AsyncClient> processor, BlobToObject blobToObject,
56            BlobToHttpGetOptions blob2HttpGetOptions) throws SecurityException, NoSuchMethodException {
57      this.processor = checkNotNull(processor, "processor");
58      this.blobToObject = checkNotNull(blobToObject, "blobToObject");
59      this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions");
60      this.getMethod = S3AsyncClient.class.getMethod("getObject", String.class, String.class, GetOptions[].class);
61      this.deleteMethod = S3AsyncClient.class.getMethod("deleteObject", String.class, String.class);
62      this.createMethod = S3AsyncClient.class.getMethod("putObject", String.class, S3Object.class,
63               PutObjectOptions[].class);
64 
65   }
66 
67   @Override
68   public HttpRequest signGetBlob(String container, String name) {
69      return cleanRequest(processor.createRequest(getMethod, container, name));
70   }
71 
72   @Override
73   public HttpRequest signPutBlob(String container, Blob blob) {
74      return cleanRequest(processor.createRequest(createMethod, container, blobToObject.apply(blob)));
75   }
76 
77   @Override
78   public HttpRequest signRemoveBlob(String container, String name) {
79      return cleanRequest(processor.createRequest(deleteMethod, container, name));
80   }
81 
82   @Override
83   public HttpRequest signGetBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
84      return cleanRequest(processor.createRequest(getMethod, container, name, blob2HttpGetOptions.apply(options)));
85   }
86}

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