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

COVERAGE SUMMARY FOR SOURCE FILE [PutBucketOptions.java]

nameclass, %method, %block, %line, %
PutBucketOptions.java100% (2/2)86%  (6/7)95%  (74/78)98%  (16.6/17)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PutBucketOptions$Builder100% (1/1)50%  (1/2)73%  (8/11)67%  (2/3)
PutBucketOptions$Builder (): void 0%   (0/1)0%   (0/3)0%   (0/1)
withBucketAcl (CannedAccessPolicy): PutBucketOptions 100% (1/1)100% (8/8)100% (2/2)
     
class PutBucketOptions100% (1/1)100% (5/5)99%  (66/67)100% (14.9/15)
buildRequestHeaders (): Multimap 100% (1/1)97%  (36/37)99%  (4.9/5)
PutBucketOptions (): void 100% (1/1)100% (6/6)100% (3/3)
getAcl (): CannedAccessPolicy 100% (1/1)100% (3/3)100% (1/1)
setHeaderTag (String): void 100% (1/1)100% (4/4)100% (2/2)
withBucketAcl (CannedAccessPolicy): PutBucketOptions 100% (1/1)100% (17/17)100% (4/4)

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.s3.options;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static com.google.common.base.Preconditions.checkState;
23import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
24 
25import java.util.Map.Entry;
26 
27import javax.inject.Inject;
28import javax.inject.Named;
29 
30import org.jclouds.s3.domain.CannedAccessPolicy;
31import org.jclouds.s3.reference.S3Headers;
32import org.jclouds.http.options.BaseHttpRequestOptions;
33 
34import com.google.common.collect.LinkedHashMultimap;
35import com.google.common.collect.Multimap;
36 
37/**
38 * Contains options supported in the REST API for the PUT bucket operation. <h2>
39 * Usage</h2> The recommended way to instantiate a PutBucketOptions object is to statically import
40 * PutBucketOptions.Builder.* and invoke a static creation method followed by an instance mutator
41 * (if needed):
42 * <p/>
43 * <code>
44 * import static org.jclouds.s3.commands.options.PutBucketOptions.Builder.*
45 * import static org.jclouds.s3.domain.S3Bucket.Metadata.LocationConstraint.*;
46 * import org.jclouds.s3.S3Client;
47 * <p/>
48 * S3Client connection = // get connection
49 * Future<Boolean> createdInEu = connection.putBucketIfNotExists("bucketName",createIn(EU));
50 * <code>
51 * 
52 * @author Adrian Cole
53 * @see <a
54 *      href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html?RESTBucketPUT.html?"
55 *      />
56 */
57public class PutBucketOptions extends BaseHttpRequestOptions {
58   private CannedAccessPolicy acl = CannedAccessPolicy.PRIVATE;
59 
60   private String headerTag;
61 
62   @Inject
63   public void setHeaderTag(@Named(PROPERTY_HEADER_TAG) String headerTag) {
64      this.headerTag = headerTag;
65   }
66 
67   @Override
68   public Multimap<String, String> buildRequestHeaders() {
69      checkState(headerTag != null, "headerTag should have been injected!");
70      Multimap<String, String> returnVal = LinkedHashMultimap.create();
71      for (Entry<String, String> entry : headers.entries()) {
72         returnVal.put(entry.getKey().replace("aws", headerTag), entry.getValue());
73      }
74      return returnVal;
75   }
76 
77   /**
78    * Override the default ACL (private) with the specified one.
79    * 
80    * @see CannedAccessPolicy
81    */
82   public PutBucketOptions withBucketAcl(CannedAccessPolicy acl) {
83      this.acl = checkNotNull(acl, "acl");
84      if (!acl.equals(CannedAccessPolicy.PRIVATE))
85         this.replaceHeader(S3Headers.CANNED_ACL, acl.toString());
86      return this;
87   }
88 
89   /**
90    * @see PutBucketOptions#withBucketAcl
91    */
92   public CannedAccessPolicy getAcl() {
93      return acl;
94   }
95 
96   public static class Builder {
97      /**
98       * @see PutBucketOptions#withBucketAcl
99       */
100      public static PutBucketOptions withBucketAcl(CannedAccessPolicy acl) {
101         PutBucketOptions options = new PutBucketOptions();
102         return options.withBucketAcl(acl);
103      }
104   }
105}

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