EMMA Coverage Report (generated Wed Aug 10 12:30:04 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 *
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.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