Package org.jclouds.rest

Examples of org.jclouds.rest.AuthorizationException


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


      int statusCode = in.getResponse().getStatusCode();
      String errorCode = in.getError().getCode();
      String message = in.getError().getMessage();

      if (statusCode == 403 || "RequestExpired".equals(errorCode))
         return new AuthorizationException(message, in);
      if (statusCode == 400) {
         if (ImmutableSet.of("InvalidAction", "AccessDenied").contains(errorCode))
            return new UnsupportedOperationException(message, in);
         else if ("Throttling".equals(errorCode))
            return new InsufficientResourcesException(message, in);
View Full Code Here

                     || (errorCode != null && (error.getCode().endsWith(".Duplicate") || error.getCode().endsWith(
                              ".InUse")))
                     || (message != null && (message.indexOf("already exists") != -1 || message.indexOf("is in use") != -1)))
               exception = new IllegalStateException(message, exception);
            else if (errorCode != null && errorCode.indexOf("AuthFailure") != -1)
               exception = new AuthorizationException(message, exception);
            else if (message != null
                     && (message.indexOf("Invalid id") != -1 || message.indexOf("Failed to bind") != -1))
               exception = new IllegalArgumentException(message, exception);
            break;
         case 401:
         case 403:
            exception = new AuthorizationException(message, exception);
            break;
         case 404:
            if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
               exception = new ResourceNotFoundException(message, exception);
            }
View Full Code Here

            else if (message.indexOf("already exists") != -1)
               exception = new IllegalStateException(message, exception);
            break;
         case 401:
         case 403:
            exception = new AuthorizationException(message, exception);
            break;
         case 404:
            if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
               exception = new ResourceNotFoundException(message, exception);
            }
View Full Code Here

      assert ssh.shouldRetry(new IOException("channel %s is not open", new NullPointerException(null)));
   }

   public void testOnlyRetryAuthWhenSet() throws UnknownHostException {
      JschSshClient ssh1 = createClient();
      assert !ssh1.shouldRetry(new AuthorizationException("problem", null));
      ssh1.retryAuth = true;
      assert ssh1.shouldRetry(new AuthorizationException("problem", null));
   }
View Full Code Here

   public void testOnlyRetryAuthWhenSetViaProperties() throws UnknownHostException {
      Properties props = new Properties();
      props.setProperty("jclouds.ssh.retry-auth", "true");
      JschSshClient ssh1 = createClient(props);
      assert ssh1.shouldRetry(new AuthorizationException("problem", null));
   }
View Full Code Here

            throw propagate(e.getCause());
         } catch (RuntimeException e) {
            return instanceOfTypeOrPropagate(genericReturnType, e);
         }
      } catch (ProvisionException e) {
         AuthorizationException aex = getFirstThrowableOfType(e, AuthorizationException.class);
         if (aex != null)
            throw aex;
         throw e;
      }
   }
View Full Code Here

         message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
               response.getStatusLine());
         switch (response.getStatusCode()) {
         case 401:
         case 403:
            exception = new AuthorizationException(message, exception);
            break;
         case 400:
            if (message.indexOf("not find") != -1) {
               exception = new ResourceNotFoundException(message, exception);
            }
View Full Code Here

      }
      return null;
   }

   public static <T> T propagateAuthorizationOrOriginalException(Exception e) {
      AuthorizationException aex = getFirstThrowableOfType(e, AuthorizationException.class);
      if (aex != null)
         throw aex;
      propagate(e);
      assert false : "exception should have propagated " + e;
      return null;
View Full Code Here

      try {
         transformParallel(ImmutableSet.of("hello", "goodbye"), new Function<String, ListenableFuture<? extends String>>() {
            public ListenableFuture<String> apply(String input) {
               counter.incrementAndGet();
               return immediateFailedFuture(new AuthorizationException());
            }
         }, sameThreadExecutor(), null, Logger.NULL, "");
         fail("Expected AuthorizationException");
      } catch (AuthorizationException e) {
         assertEquals(counter.get(), 2);
View Full Code Here

TOP

Related Classes of org.jclouds.rest.AuthorizationException

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.