org.jclouds.http.HttpCommand Java Examples

The following examples show how to use org.jclouds.http.HttpCommand. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JenkinsErrorHandler.java    From jenkins-rest with Apache License 2.0 6 votes vote down vote up
private String parseMessage(final HttpCommand command, final HttpResponse response) {
    if (response.getPayload() != null) {
        try {
            return Strings2.toStringAndClose(response.getPayload().openStream());
        } catch (IOException e) {
            throw Throwables.propagate(e);
        }
    } else {
        final String errorMessage = response.getFirstHeaderOrNull("X-Error");
        return new StringBuffer(command.getCurrentRequest().getRequestLine())
                .append(" -> ")
                .append(response.getStatusLine())
                .append(" -> ")
                .append(errorMessage != null ? errorMessage : "")
                .toString();
    }
}
 
Example #2
Source File: BitbucketErrorHandler.java    From bitbucket-rest with Apache License 2.0 5 votes vote down vote up
private String parseMessage(final HttpCommand command, final HttpResponse response) {
    if (response.getPayload() != null) {
        try {
            return Strings2.toStringAndClose(response.getPayload().openStream());
        } catch (IOException e) {
            throw Throwables.propagate(e);
        }
    } else {
        return new StringBuffer(command.getCurrentRequest().getRequestLine())
                .append(" -> ")
                .append(response.getStatusLine())
                .toString();
    }
}
 
Example #3
Source File: AWSEC2TemplateBuilderLiveTest.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
private static void assertOnlyOneRegionQueriedForAvailabilityZone(List<HttpCommand> commandsInvoked)
      throws NoSuchMethodException {
   assert commandsInvoked.size() == 2 : commandsInvoked;
   assertInvokedCommand(getInvokerOfRequestAtIndex(commandsInvoked, 0), Invokable.from(
         AvailabilityZoneAndRegionApi.class.getMethod("describeRegions", DescribeRegionsOptions[].class)));
   assertInvokedCommand(getInvokerOfRequestAtIndex(commandsInvoked, 1), Invokable.from(
         AvailabilityZoneAndRegionApi.class.getMethod("describeAvailabilityZonesInRegion", String.class,
               DescribeAvailabilityZonesOptions[].class)));
}