Examples of AWSError


Examples of org.jclouds.aws.domain.AWSError

         byte[] data = closeClientButKeepContentStream(response);
         String message = data != null ? new String(data) : null;
         if (message != null) {
            exception = new HttpResponseException(command, response, message);
            if (message.indexOf("ErrorResponse") != -1) {
               AWSError error = factory.create(handlers.get()).parse(message);
               exception = refineException(new AWSResponseException(command, response, error));
            } else if (message.indexOf("InvalidChangeBatch") != -1) {
               ImmutableList<String> errors = factory.create(batchHandlers.get()).parse(message);
               exception = new InvalidChangeBatchException(errors, new HttpResponseException(command, response));
            }
View Full Code Here

Examples of org.jclouds.aws.domain.AWSError

   }

   public void handleError(HttpCommand command, HttpResponse response) {
      Exception exception = new HttpResponseException(command, response);
      try {
         AWSError error = null;
         // it is important to always read fully and close streams
         byte[] data = closeClientButKeepContentStream(response);
         String message = data != null ? new String(data) : null;
         if (response.getPayload() != null) {
            String contentType = response.getPayload().getContentMetadata().getContentType();
            if (contentType != null && (contentType.indexOf("xml") != -1 || contentType.indexOf("unknown") != -1)) {
               error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response);
               if (error != null) {
                  message = error.getMessage();
                  exception = new AWSResponseException(command, response, error);
               } else {
                  exception = new HttpResponseException(command, response, message);
               }
            } else {
View Full Code Here

Examples of org.jclouds.aws.domain.AWSError

   }

   @Test
   public void testErrorFromAmazonIfYouDontRemoveTransferEncodingHeader() throws HttpException {
      ParseSax<AWSError> parser = createParser();
      AWSError error = parser.parse(Strings2.toInputStream(errorFromAmazonIfYouDontRemoveTransferEncodingHeader));
      assertEquals(error.getCode(), "NotImplemented");
      assertEquals(error.getMessage(), "A header you provided implies functionality that is not implemented");
      assertEquals(error.getDetails().get("Header"), "Transfer-Encoding");
      assertEquals(error.getDetails().get("HostId"), "fbskVU51OZJg2yZS/wNIxoE2PmCf0ZqFd0iH6Vrzw0uKG3KmokswBytL/Bfp/GWb");
   }
View Full Code Here

Examples of org.jclouds.aws.domain.AWSError

   }

   @Test
   public void testErrorFromEucalyptusWhenGroupAlreadyExists() throws HttpException {
      ParseSax<AWSError> parser = createParser();
      AWSError error = parser
               .parse(Strings2
                        .toInputStream("<?xml version=\"1.0\"?><Response><Errors><Error><Code>Groups</Code><Message>\nError adding network group: group named jclouds#eucrun#Eucalyptus already exists\nError adding network group: group named jclouds#eucrun#Eucalyptus already exists</Message></Error></Errors><RequestID>e0133975-3bc5-456d-9753-1d61b27e07e9</RequestID></Response>"));
      assertEquals(error.getCode(), "Groups");
      assertEquals(
               error.getMessage(),
               "Error adding network group: group named jclouds#eucrun#Eucalyptus already exists\nError adding network group: group named jclouds#eucrun#Eucalyptus already exists");
   }
View Full Code Here

Examples of org.jclouds.aws.domain.AWSError

      Exception e = getErrorWithCode("blah");
      new FalseIfBucketAlreadyOwnedByYouOrOperationAbortedWhenBucketExists(client).create(e);
   }

   private Exception getErrorWithCode(String code) {
      AWSError error = new AWSError();
      error.setCode(code);
      return new AWSResponseException(null, null, null, error);
   }
View Full Code Here

Examples of org.jclouds.aws.domain.AWSError

   public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) {
      if (response.getFirstHeaderOrNull(HttpHeaders.LOCATION) == null
            && (response.getStatusCode() == 301 || response.getStatusCode() == 307)) {
         command.incrementRedirectCount();
         closeClientButKeepContentStream(response);
         AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response);
         String host = error.getDetails().get("Endpoint");
         if (host != null) {
            if (host.equals(command.getCurrentRequest().getEndpoint().getHost())) {
               // must be an amazon error related to
               // http://developer.amazonwebservices.com/connect/thread.jspa?messageID=72287&#72287
               return backoffHandler.shouldRetryRequest(command, response);
View Full Code Here

Examples of org.jclouds.aws.domain.AWSError

   AWSError error;
   HttpResponse response = HttpResponse.builder().statusCode(400)
         .payload(String.format("<Error><Code>%s</Code></Error>", code)).build();

   public SQSErrorRetryHandlerTest() {
      error = new AWSError();
      error.setCode(code);
   }
View Full Code Here

Examples of org.jclouds.aws.domain.AWSError

      assertNull(utils.parseAWSErrorFromContent(command.getCurrentRequest(), response));
   }

   @Test
   public void testParseAWSErrorFromContentHttpCommandHttpResponseInputStream() {
      AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response(getClass()
            .getResourceAsStream("/error.xml")));
      assertEquals(error.getCode(), "NoSuchKey");
      assertEquals(error.getMessage(), "The resource you requested does not exist");
      assertEquals(error.getRequestToken(), "requesttoken");
      assertEquals(error.getRequestId(), "4442587FB7D0A2F9");
      assertEquals(error.getDetails().get("Resource"), "/mybucket/myfoto.jpg");
   }
View Full Code Here

Examples of org.jclouds.aws.domain.AWSError

      HttpResponse operationAborted = HttpResponse.builder().statusCode(CONFLICT.getStatusCode())
            .payload(Payloads.newStringPayload(String.format("<Error><Code>%s</Code></Error>", code))).build();

      expect(command.getCurrentRequest()).andReturn(putBucket);

      AWSError error = new AWSError();
      error.setCode(code);

      expect(utils.parseAWSErrorFromContent(putBucket, operationAborted)).andReturn(error);

      expect(backoffLimitedRetryHandler.shouldRetryRequest(command, operationAborted)).andReturn(Boolean.TRUE);
View Full Code Here

Examples of org.jclouds.aws.domain.AWSError

         public Integer answer() throws Throwable {
            return counter.get();
         }
      }).anyTimes();

      AWSError error = new AWSError();
      error.setCode(code);

      expect(utils.parseAWSErrorFromContent(putBucket, limitExceeded)).andReturn(error);

      replay(utils, command);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.