Examples of AWSError


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

      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

      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

   }

   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

   @Override
   public void handleError(HttpCommand command, HttpResponse response) {
      Exception exception = new HttpResponseException(command, response);
      try {
         if (response.getPayload() != null) {
            AWSError error = factory.create(handlers.get())
                                    .parse(new String(closeClientButKeepContentStream(response)));
            exception = refineException(new AWSResponseException(command, response, error));
         }
      } finally {
         releasePayload(response);
View Full Code Here

Examples of org.jclouds.aws.domain.AWSError

      switch (response.getStatusCode()) {
      case 503// Service Unavailable
         // Content can be null in the case of HEAD requests
         if (response.getPayload() != null) {
            closeClientButKeepContentStream(response);
            AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response);
            if (error != null) {
               return shouldRetryRequestOnError(command, response, error);
            }
         }
         break;
View Full Code Here

Examples of org.jclouds.aws.domain.AWSError

   public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) {
      if (response.getStatusCode() == 400 || response.getStatusCode() == 403 || response.getStatusCode() == 409) {
         // Content can be null in the case of HEAD requests
         if (response.getPayload() != null) {
            closeClientButKeepContentStream(response);
            AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response);
            if (error != null) {
               return shouldRetryRequestOnError(command, response, error);
            }
         }
      }
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

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
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.