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

COVERAGE SUMMARY FOR SOURCE FILE [S3Utils.java]

nameclass, %method, %block, %line, %
S3Utils.java0%   (0/1)0%   (0/4)0%   (0/50)0%   (0/9)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class S3Utils0%   (0/1)0%   (0/4)0%   (0/50)0%   (0/9)
<static initializer> 0%   (0/1)0%   (0/4)0%   (0/1)
S3Utils (): void 0%   (0/1)0%   (0/3)0%   (0/1)
deleteAndVerifyContainerGone (S3Client, String): boolean 0%   (0/1)0%   (0/8)0%   (0/2)
validateBucketName (String): String 0%   (0/1)0%   (0/35)0%   (0/5)

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.util;
20 
21import static com.google.common.base.Preconditions.checkArgument;
22import static com.google.common.base.Preconditions.checkNotNull;
23 
24import java.util.regex.Pattern;
25 
26import org.jclouds.s3.S3Client;
27import org.jclouds.util.Patterns;
28 
29/**
30 * Encryption, Hashing, and IO Utilities needed to sign and verify S3 requests and responses.
31 * 
32 * @author Adrian Cole
33 */
34public class S3Utils {
35 
36   public static final Pattern BUCKET_NAME_PATTERN = Pattern.compile("^[a-z0-9][-_.a-z0-9]+");
37 
38   // TODO add validatorparam so that this is actually used
39   public static String validateBucketName(String bucketName) {
40      checkNotNull(bucketName, "bucketName");
41      checkArgument(
42               BUCKET_NAME_PATTERN.matcher(bucketName).matches(),
43               "bucketName name must start with a number or letter and  can only contain lowercase letters, numbers, periods (.), underscores (_), and dashes (-)");
44      checkArgument(bucketName.length() > 2 && bucketName.length() < 256,
45               "bucketName name must be between 3 and 255 characters long");
46      checkArgument(!Patterns.IP_PATTERN.matcher(bucketName).matches(),
47               "bucketName name cannot be ip address style");
48      return bucketName;
49   }
50 
51   /**
52    * This implementation invokes {@link S3Client#deleteBucketIfEmpty} followed by
53    * {@link S3Client#bucketExists} until it is true.
54    */
55   public static boolean deleteAndVerifyContainerGone(S3Client sync, String container) {
56      sync.deleteBucketIfEmpty(container);
57      return sync.bucketExists(container);
58   }
59}

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