Package org.jclouds.http

Examples of org.jclouds.http.HttpResponseException


   public void handleError(HttpCommand command, HttpResponse response) {
      // it is important to always read fully and close streams
      byte[] data = closeClientButKeepContentStream(response);
      String message = data != null ? new String(data) : null;

      Exception exception = message != null ? new HttpResponseException(command, response, message)
               : new HttpResponseException(command, response);
      message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
               response.getStatusLine());
      switch (response.getStatusCode()) {
         case 400:
            if (message.contains("quota exceeded"))
View Full Code Here


   public void handleError(HttpCommand command, HttpResponse response) {
      // it is important to always read fully and close streams
      byte[] data = closeClientButKeepContentStream(response);
      String message = data != null ? new String(data) : null;

      Exception exception = message != null ? new HttpResponseException(command, response, message)
              : new HttpResponseException(command, response);
      message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
              response.getStatusLine());
      switch (response.getStatusCode()) {
         case 400:
            break;
View Full Code Here

   public void handleError(HttpCommand command, HttpResponse response) {
      // it is important to always read fully and close streams
      byte[] data = closeClientButKeepContentStream(response);
      String message = data != null ? new String(data) : null;

      Exception exception = message != null ? new HttpResponseException(command, response, message)
               : new HttpResponseException(command, response);
      message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
               response.getStatusLine());
      switch (response.getStatusCode()) {
         case 401:
            exception = new AuthorizationException(exception.getMessage(), exception);
View Full Code Here

   public void handleError(HttpCommand command, HttpResponse response) {
      // it is important to always read fully and close streams
      byte[] data = closeClientButKeepContentStream(response);
      String message = data != null ? new String(data) : null;

      Exception exception = message != null ? new HttpResponseException(command, response, message)
            : new HttpResponseException(command, response);
      message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
            response.getStatusLine());
      switch (response.getStatusCode()) {
         case 400:
            break;
View Full Code Here

   public void handleError(HttpCommand command, HttpResponse response) {
      // it is important to always read fully and close streams
      byte[] data = closeClientButKeepContentStream(response);
      String message = data != null ? new String(data) : null;

      Exception exception = message != null ? new HttpResponseException(command, response, message)
               : new HttpResponseException(command, response);
      message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
               response.getStatusLine());
      switch (response.getStatusCode()) {
         case 401:
            exception = new AuthorizationException(exception.getMessage(), exception);
View Full Code Here

   }

   @Override
   public Map<String, Supplier<Set<String>>> get() {
      Builder<String, Set<String>> map = ImmutableMap.builder();
      HttpResponseException exception = null;
      // TODO: this should be parallel
      for (String region : regions.get()) {
         try {
            ImmutableSet<String> zones = ImmutableSet.copyOf(Iterables.transform(client
                     .describeAvailabilityZonesInRegion(region), new Function<AvailabilityZoneInfo, String>() {
View Full Code Here

      EC2Client client = control.createMock(EC2Client.class);
      AvailabilityZoneAndRegionClient regionClient = control.createMock(AvailabilityZoneAndRegionClient.class);
      AvailabilityZoneInfo info1 = control.createMock(AvailabilityZoneInfo.class);
      AvailabilityZoneInfo info2 = control.createMock(AvailabilityZoneInfo.class);
      HttpCommand command = control.createMock(HttpCommand.class);
      HttpResponseException exception = new HttpResponseException("Error: Unable to tunnel through proxy: ...",
               command, null);

      expect(client.getAvailabilityZoneAndRegionServices()).andStubReturn(regionClient);
      expect(regionClient.describeAvailabilityZonesInRegion("accessibleRegion1")).andReturn(
               ImmutableSet.of(info1));
View Full Code Here

   public void testDescribeAvailabilityZonesInRegion_RethrowIfNoneFound() {
      IMocksControl control = createControl();
      EC2Client client = control.createMock(EC2Client.class);
      AvailabilityZoneAndRegionClient regionClient = control.createMock(AvailabilityZoneAndRegionClient.class);
      HttpCommand command = control.createMock(HttpCommand.class);
      HttpResponseException exception = new HttpResponseException("Error: Unable to tunnel through proxy: ...",
               command, null);

      expect(client.getAvailabilityZoneAndRegionServices()).andStubReturn(regionClient);
      expect(regionClient.describeAvailabilityZonesInRegion("inaccessibleRegion")).andThrow(exception);
View Full Code Here

      while (!created) {
         privateDirectory = containerPrefix + new SecureRandom().nextInt();
         try {
            created = getApi().createDirectory(privateDirectory) != null;
         } catch (UndeclaredThrowableException e) {
            HttpResponseException htpe = (HttpResponseException) e.getCause().getCause();
            if (htpe.getResponse().getStatusCode() == 409)
               continue;
            throw e;
         }
      }
      BoundedSet<? extends DirectoryEntry> response = getApi().listDirectories();
View Full Code Here

            cookieHeader = Iterables.find(from.getHeaders().get(HttpHeaders.SET_COOKIE), Predicates.contains(pattern));
            Matcher matcher = pattern.matcher(cookieHeader);
            matcher.find();
            return matcher.group(2);
         } catch (NoSuchElementException e) {
            throw new HttpResponseException(String.format("Header %s or %s must be present", "x-vcloud-authorization",
                     HttpHeaders.SET_COOKIE), null, from);
         }
      }
   }
View Full Code Here

TOP

Related Classes of org.jclouds.http.HttpResponseException

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.