EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.blobstore]

COVERAGE SUMMARY FOR SOURCE FILE [TransientBlobRequestSigner.java]

nameclass, %method, %block, %line, %
TransientBlobRequestSigner.java100% (1/1)80%  (4/5)76%  (95/125)83%  (10/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TransientBlobRequestSigner100% (1/1)80%  (4/5)76%  (95/125)83%  (10/12)
signGetBlob (String, String, GetOptions): HttpRequest 0%   (0/1)0%   (0/30)0%   (0/2)
TransientBlobRequestSigner (BasicAuthentication, BlobToHttpGetOptions): void 100% (1/1)100% (15/15)100% (4/4)
signGetBlob (String, String): HttpRequest 100% (1/1)100% (23/23)100% (2/2)
signPutBlob (String, Blob): HttpRequest 100% (1/1)100% (34/34)100% (2/2)
signRemoveBlob (String, String): HttpRequest 100% (1/1)100% (23/23)100% (2/2)

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.blobstore;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.net.URI;
24 
25import javax.inject.Inject;
26import javax.inject.Singleton;
27 
28import org.jclouds.blobstore.domain.Blob;
29import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
30import org.jclouds.blobstore.options.GetOptions;
31import org.jclouds.http.HttpRequest;
32import org.jclouds.http.HttpUtils;
33import org.jclouds.http.filters.BasicAuthentication;
34 
35/**
36 * 
37 * @author Adrian Cole
38 */
39@Singleton
40public class TransientBlobRequestSigner implements BlobRequestSigner {
41 
42   private final BasicAuthentication basicAuth;
43   private final BlobToHttpGetOptions blob2HttpGetOptions;
44 
45   @Inject
46   public TransientBlobRequestSigner(BasicAuthentication basicAuth, BlobToHttpGetOptions blob2HttpGetOptions) {
47      this.basicAuth = checkNotNull(basicAuth, "basicAuth");
48      this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions");
49   }
50 
51   @Override
52   public HttpRequest signGetBlob(String container, String name) {
53      HttpRequest request = new HttpRequest("GET", URI.create(String.format("http://localhost/%s/%s", container, name)));
54      return basicAuth.filter(request);
55   }
56 
57   @Override
58   public HttpRequest signPutBlob(String container, Blob blob) {
59      HttpRequest request = HttpRequest.builder().method("PUT").endpoint(
60               URI.create(String.format("http://localhost/%s/%s", container, blob.getMetadata().getName()))).payload(
61               blob.getPayload()).headers(
62               HttpUtils.getContentHeadersFromMetadata(blob.getMetadata().getContentMetadata())).build();
63      return basicAuth.filter(request);
64   }
65 
66   @Override
67   public HttpRequest signRemoveBlob(String container, String name) {
68      HttpRequest request = new HttpRequest("DELETE", URI.create(String.format("http://localhost/%s/%s", container,
69               name)));
70      return basicAuth.filter(request);
71   }
72 
73   @Override
74   public HttpRequest signGetBlob(String container, String name, GetOptions options) {
75      HttpRequest request = HttpRequest.builder().method("GET").endpoint(
76               URI.create(String.format("http://localhost/%s/%s", container, name))).headers(
77               blob2HttpGetOptions.apply(options).buildRequestHeaders()).build();
78      return basicAuth.filter(request);
79   }
80 
81}

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