Examples of AWSError


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

      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

      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

      if (response.getPayload() == null)
         return null;
      if ("text/plain".equals(response.getPayload().getContentMetadata().getContentType()))
         return null;
      try {
         AWSError error = factory.create(errorHandlerProvider.get()).setContext(request).apply(response);
         if (error.getRequestId() == null)
            error.setRequestId(response.getFirstHeaderOrNull(requestId));
         error.setRequestToken(response.getFirstHeaderOrNull(requestToken));
         if ("SignatureDoesNotMatch".equals(error.getCode())) {
            error.setStringSigned(signer.createStringToSign(request));
            error.setSignature(signer.sign(error.getStringSigned()));
         }
         return error;
      } catch (RuntimeException e) {
         logger.warn(e, "error parsing error");
         return null;
View Full Code Here

Examples of org.jclouds.aws.domain.AWSError

      Exception e = getErrorWithCode("blah");
      new FalseIfBucketAlreadyOwnedByYouOrOperationAbortedWhenBucketExists(client).createOrPropagate(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
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.