Package org.jclouds.rest

Examples of org.jclouds.rest.ResourceNotFoundException


   protected Exception refineException(HttpCommand command, HttpResponse response, Exception exception,
            AzureStorageError error, String message) {
      switch (response.getStatusCode()) {
         case 404:
            if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
               exception = new ResourceNotFoundException(message, exception);
               List<String> parts = Lists.newArrayList(Splitter.on('/').split(
                        command.getCurrentRequest().getEndpoint().getPath()));
               parts.remove("");
               if (parts.size() > 0) {
                  String container = parts.remove(0);
View Full Code Here


            CacheBuilder.newBuilder().<String, Set<IPForwardingRule>> build(
                  new CacheLoader<String, Set<IPForwardingRule>>() {

                     @Override
                     public Set<IPForwardingRule> load(String arg0) throws Exception {
                        throw new ResourceNotFoundException("no ip forwarding rule for: " + arg0);
                     }

                  }), namingConvention);

      // notice if we've already parsed this properly here, we can rely on it.
View Full Code Here

            case 403:
               exception = new AuthorizationException(message, exception);
               break;
            case 404:
               if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
                  exception = new ResourceNotFoundException(message, exception);
               }
               break;
            case 500:
               if (message != null ) {
                  if (message.indexOf("Unable to determine package for") != -1) {
                     exception = new ResourceNotFoundException(message, exception);
                  } else if (message.indexOf("currently an active transaction") != -1) {
                     exception = new IllegalStateException(message, exception);
                  } else if (message.indexOf("SoftLayer_Exception_Order_Item_Duplicate") != -1) {
                     exception = new SoftLayerOrderItemDuplicateException(command, response, message);
                  }
View Full Code Here

      case ErrorCodes.UNKNOWN:
         if (!exception.getError().getDescription().isPresent())
            return exception;
         if (exception.getError().getDescription().get().indexOf("Cannot find") == -1)
            return exception;
         return new ResourceNotFoundException(message, exception);
      case ErrorCodes.ZONE_NOT_FOUND:
      case ErrorCodes.RESOURCE_RECORD_NOT_FOUND:
      case ErrorCodes.ACCOUNT_NOT_FOUND:
      case ErrorCodes.POOL_NOT_FOUND:
      case ErrorCodes.DIRECTIONALPOOL_NOT_FOUND:
      case ErrorCodes.DIRECTIONALPOOL_RECORD_NOT_FOUND:
      case ErrorCodes.POOL_RECORD_NOT_FOUND:
      case ErrorCodes.GROUP_NOT_FOUND:
         return new ResourceNotFoundException(message, exception);
      case ErrorCodes.ZONE_ALREADY_EXISTS:
      case ErrorCodes.RESOURCE_RECORD_ALREADY_EXISTS:
      case ErrorCodes.POOL_ALREADY_EXISTS:
      case ErrorCodes.POOL_RECORD_ALREADY_EXISTS:
         return new ResourceAlreadyExistsException(message, exception);
View Full Code Here

         if (errors != null)
            exception = new GoGridResponseException(command, response, errors);
         switch (response.getStatusCode()) {
            case 400:
               if (Iterables.get(errors, 0).getMessage().indexOf("No object found") != -1) {
                  exception = new ResourceNotFoundException(Iterables.get(errors, 0).getMessage(), exception);
                  break;
               }
               break;
            case 403:
               exception = new AuthorizationException(exception.getMessage(), exception);
View Full Code Here

      propagateIfPossible(new RuntimeException(e), ImmutableSet.<TypeToken<? extends Throwable>> of());
   }

   @Test(expectedExceptions = ResourceNotFoundException.class)
   public void testPropagateStandardExceptionResourceNotFoundException() throws Throwable {
      Exception e = new ResourceNotFoundException();
      propagateIfPossible(new RuntimeException(e), ImmutableSet.<TypeToken<? extends Throwable>> of());
   }
View Full Code Here

            ImmutableSet.<TypeToken<? extends Throwable>> of());
   }

   @Test(expectedExceptions = ResourceNotFoundException.class)
   public void testPropagateStandardExceptionResourceNotFoundExceptionNestedInHttpResponseException() throws Throwable {
      Exception e = new ResourceNotFoundException();
      propagateIfPossible(new HttpResponseException("goo", createNiceMock(HttpCommand.class), null, e),
            ImmutableSet.<TypeToken<? extends Throwable>> of());
   }
View Full Code Here

         case 403:
            exception = new AuthorizationException(message, exception);
            break;
         case 404:
            if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
               exception = new ResourceNotFoundException(message, exception);
            }
            break;
      }
      command.setException(exception);
   }
View Full Code Here

            case 401:
            case 403:
               if (error != null
                        && ((error.getMinorErrorCode() != null && error.getMinorErrorCode() == MinorCode.ACCESS_TO_RESOURCE_IS_FORBIDDEN)
                        || (error.getMessage() != null && error.getMessage().indexOf("No access to entity") != -1)))
                  exception = new ResourceNotFoundException(message, exception);
               else
                  exception = new AuthorizationException(exception.getMessage(), exception);
               break;
            case 404:
               if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
                  String path = command.getCurrentRequest().getEndpoint().getPath();
                  Matcher matcher = RESOURCE_PATTERN.matcher(path);
                  if (matcher.find()) {
                     message = String.format("%s %s not found", matcher.group(1), matcher.group(2));
                  } else {
                     message = path;
                  }
                  exception = new ResourceNotFoundException(message);
               }
               break;
         }
      } finally {
         releasePayload(response);
View Full Code Here

   @Override
   protected Exception refineException(HttpCommand command, HttpResponse response, Exception exception, AWSError error,
         String message) {
      String errorCode = (error != null && error.getCode() != null) ? error.getCode() : null;
      if (resourceNotFoundCodes.contains(errorCode))
         exception = new ResourceNotFoundException(message, exception);
      else if (illegalStateCodes.contains(errorCode))
         exception = new IllegalStateException(message, exception);
      else if (illegalArgumentCodes.contains(errorCode))
         exception = new IllegalArgumentException(message, exception);
      else
View Full Code Here

TOP

Related Classes of org.jclouds.rest.ResourceNotFoundException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.