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

COVERAGE SUMMARY FOR SOURCE FILE [ParseAzureBlobErrorFromXmlContent.java]

nameclass, %method, %block, %line, %
ParseAzureBlobErrorFromXmlContent.java100% (1/1)100% (2/2)90%  (71/79)93%  (14/15)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ParseAzureBlobErrorFromXmlContent100% (1/1)100% (2/2)90%  (71/79)93%  (14/15)
refineException (HttpCommand, HttpResponse, Exception, AzureStorageError, Str... 100% (1/1)89%  (67/75)92%  (12/13)
ParseAzureBlobErrorFromXmlContent (AzureStorageUtils): void 100% (1/1)100% (4/4)100% (2/2)

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.azureblob.handlers;
20 
21import java.util.List;
22 
23import javax.inject.Inject;
24import javax.inject.Singleton;
25 
26import org.jclouds.azure.storage.domain.AzureStorageError;
27import org.jclouds.azure.storage.handlers.ParseAzureStorageErrorFromXmlContent;
28import org.jclouds.azure.storage.util.AzureStorageUtils;
29import org.jclouds.blobstore.ContainerNotFoundException;
30import org.jclouds.blobstore.KeyNotFoundException;
31import org.jclouds.http.HttpCommand;
32import org.jclouds.http.HttpResponse;
33import org.jclouds.rest.ResourceNotFoundException;
34 
35import com.google.common.base.Joiner;
36import com.google.common.base.Splitter;
37import com.google.common.collect.Lists;
38 
39/**
40 * @author Adrian Cole
41 * 
42 */
43@Singleton
44public class ParseAzureBlobErrorFromXmlContent extends ParseAzureStorageErrorFromXmlContent {
45 
46   @Inject
47   ParseAzureBlobErrorFromXmlContent(AzureStorageUtils utils) {
48      super(utils);
49   }
50 
51   protected Exception refineException(HttpCommand command, HttpResponse response, Exception exception,
52            AzureStorageError error, String message) {
53      switch (response.getStatusCode()) {
54         case 404:
55            if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
56               exception = new ResourceNotFoundException(message, exception);
57               List<String> parts = Lists.newArrayList(Splitter.on('/').split(
58                        command.getCurrentRequest().getEndpoint().getPath()));
59               parts.remove("");
60               if (parts.size() > 0) {
61                  String container = parts.remove(0);
62                  String query = command.getCurrentRequest().getEndpoint().getQuery();
63                  if (query != null && query.indexOf("container") != -1) {
64                     exception = new ContainerNotFoundException(container, message);
65                  } else {
66                     exception = new KeyNotFoundException(container, Joiner.on('/').join(parts), message);
67                  }
68               }
69            }
70            return exception;
71         default:
72            return super.refineException(command, response, exception, error, message);
73      }
74   }
75}

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