List of usage examples for org.springframework.http.client ClientHttpResponse getStatusCode
HttpStatus getStatusCode() throws IOException;
From source file:org.grails.datastore.mapping.riak.util.Ignore404sErrorHandler.java
@Override public void handleError(ClientHttpResponse response) throws IOException { // Ignore 404s entirely if (response.getStatusCode() != HttpStatus.NOT_FOUND) { super.handleError(response); }/*w ww . j a v a 2s . c o m*/ }
From source file:fr.itldev.koya.services.impl.util.AlfrescoRestErrorHandler.java
@Override public boolean hasError(ClientHttpResponse clienthttpresponse) throws IOException { if (clienthttpresponse.getStatusCode() != HttpStatus.OK) { logger.warn(/* w w w.ja v a 2 s . c o m*/ "Status code: " + clienthttpresponse.getStatusCode() + " - " + clienthttpresponse.getBody()); return true; } return false; }
From source file:org.craftercms.commons.rest.HttpMessageConvertingResponseErrorHandler.java
@Override public boolean hasError(ClientHttpResponse response) throws IOException { return hasError(response.getStatusCode()); }
From source file:nl.gridshore.nosapi.impl.NosApiResponseErrorHandler.java
@Override public boolean hasError(ClientHttpResponse response) throws IOException { HttpStatus statusCode = response.getStatusCode(); return (statusCode.series() == HttpStatus.Series.CLIENT_ERROR || statusCode.series() == HttpStatus.Series.SERVER_ERROR); }
From source file:de.zib.gndms.gndmc.utils.DefaultResponseExtractor.java
@Override public void extractData(final String url, final ClientHttpResponse response) throws IOException { statusCode = response.getStatusCode().value(); headers = response.getHeaders();//from w w w . jav a2s . c om body = response.getBody(); this.url = url; }
From source file:org.zalando.riptide.OAuth2CompatibilityResponseErrorHandlerTest.java
private Matcher<ClientHttpResponse> statusCode(final HttpStatus status) { return hasFeature("statusCode", new Function<ClientHttpResponse, HttpStatus>() { @Override//from w w w . ja v a 2s . co m public HttpStatus apply(final ClientHttpResponse response) { try { return response.getStatusCode(); } catch (final Exception e) { throw new RuntimeException(e); } } }, is(status)); }
From source file:org.craftercms.commons.rest.HttpMessageConvertingResponseErrorHandler.java
@Override public void handleError(ClientHttpResponse response) throws IOException { HttpStatus status = response.getStatusCode(); HttpMessageConverterExtractor<?> responseExtractor = new HttpMessageConverterExtractor<>(responseType, messageConverters);/* w w w .ja v a2s . co m*/ Object errorDetails; try { errorDetails = responseExtractor.extractData(response); } catch (RestClientException e) { // No message converter to extract the response, so make the error details // the response body as string throw new RestServiceException(status, getResponseBodyAsString(response)); } throw new RestServiceException(status, errorDetails); }
From source file:org.zalando.riptide.RouterTest.java
@Test public void shouldCatchIOExceptionFromResponse() throws IOException { exception.expect(RestClientException.class); exception.expectCause(instanceOf(IOException.class)); final ClientHttpResponse response = mock(ClientHttpResponse.class); when(response.getStatusCode()).thenThrow(new IOException()); unit.route(response, emptyList(), status(), singletonList(anyStatus().capture())); }
From source file:com.appglu.impl.AppGluResponseErrorHandler.java
public void handleError(ClientHttpResponse response) throws IOException { HttpStatus statusCode = response.getStatusCode(); Error error = this.readErrorFromResponse(response); if (statusCode == HttpStatus.NOT_FOUND) { throw new AppGluHttpNotFoundException(error); }//from w w w . j a v a2s .com if (error.getCode() == ErrorCode.APP_USER_UNAUTHORIZED) { throw new AppGluHttpUserUnauthorizedException(error); } if (error.getCode() == ErrorCode.APP_USER_USERNAME_ALREADY_USED) { throw new AppGluHttpInvalidUserSignupException(statusCode.value(), error); } if (error.getCode() == ErrorCode.INCOMPATIBLE_CLIENT_VERSION) { throw new AppGluHttpIncompatibleClientVersionException(error); } switch (statusCode.series()) { case CLIENT_ERROR: throw new AppGluHttpClientException(statusCode.value(), error); case SERVER_ERROR: throw new AppGluHttpServerException(statusCode.value(), error); default: throw new AppGluHttpStatusCodeException(statusCode.value(), error); } }
From source file:com.epam.ta.reportportal.commons.exception.forwarding.ResponseForwardingException.java
public ResponseForwardingException(ClientHttpResponse response) throws IOException { this.headers = response.getHeaders(); this.status = response.getStatusCode(); this.body = ByteStreams.toByteArray(response.getBody()); }