Example usage for org.springframework.http.client ClientHttpResponse getStatusText

List of usage examples for org.springframework.http.client ClientHttpResponse getStatusText

Introduction

In this page you can find the example usage for org.springframework.http.client ClientHttpResponse getStatusText.

Prototype

String getStatusText() throws IOException;

Source Link

Document

Return the HTTP status text of the response.

Usage

From source file:com.design.perpetual.ecobeethermostat.app.handlers.TemplateErrorHandler.java

@Override
public void handleError(ClientHttpResponse chr) throws IOException {
    log.error("Response error: {} {}", chr.getStatusCode(), chr.getStatusText());
}

From source file:org.kurento.repository.test.util.ContextByTestSpringBootTest.java

protected RestTemplate getRestTemplate() {
    RestTemplate restTemplate = new RestTemplate();
    restTemplate.setErrorHandler(new DefaultResponseErrorHandler() {
        @Override/* ww w .  j av a  2s  .  co m*/
        public void handleError(ClientHttpResponse response) throws IOException {
            log.error(response.getStatusText());
        }
    });
    return restTemplate;
}

From source file:com.sra.biotech.submittool.persistence.client.SubmitResponseErrorHandler.java

@Override
public void handleError(ClientHttpResponse response) throws IOException {
    log.error("Response error: {} {}", response.getStatusCode(), response.getStatusText());
}

From source file:nu.yona.server.rest.RestClientErrorHandler.java

@Override
public void handleError(ClientHttpResponse response) throws IOException {
    logger.error("Response error: {} {}", getStatusCode(response), response.getStatusText());
    Optional<ErrorResponseDto> yonaErrorResponse = getYonaErrorResponse(response);
    yonaErrorResponse.ifPresent(yer -> {
        throw UpstreamException.yonaException(getStatusCode(response), yer.getCode(), yer.getMessage());
    });/*w w w  . j a  va2 s  .  c om*/
    throw UpstreamException.remoteServiceError(getStatusCode(response),
            convertStreamToString(response.getBody()));
}

From source file:org.obiba.onyx.core.service.impl.RestfulParticipantRegistryErrorHandler.java

@Override
public void handleError(ClientHttpResponse response) throws IOException {
    if (response.getStatusCode().equals(HttpStatus.NOT_FOUND)) {
        throw new NoSuchParticipantException(response.getStatusText());
    }//from w ww . j a  va2  s. c  om
    throw new ParticipantRegistryLookupException(response.getStatusText());
}

From source file:cz.cvut.zuul.support.spring.provider.TokenValidationErrorHandler.java

public void handleError(ClientHttpResponse response) throws IOException {
    switch (response.getStatusCode()) {
    case CONFLICT:
        throw new InvalidClientTokenException(response.getStatusText());
    default:/*ww w.java2 s  . com*/
        parentHandler.handleError(response);
    }
}

From source file:org.zalando.riptide.ContentTypeDispatchTest.java

private void fail(final ClientHttpResponse response) throws IOException {
    throw new AssertionError(response.getStatusText());
}

From source file:tools.AssertingRestTemplate.java

public AssertingRestTemplate() {
    setErrorHandler(new DefaultResponseErrorHandler() {
        @Override//from  w ww  .  ja  v a  2s  .  c  o m
        public void handleError(ClientHttpResponse response) throws IOException {
            if (hasError(response)) {
                log.error("Response has status code [" + response.getStatusCode() + "] and text ["
                        + response.getStatusText() + "])");
            }
        }
    });
}

From source file:org.bremersee.common.web.client.ResponseErrorHandlerImpl.java

/**
 * Find a throwable instance by calling the {@link ExceptionRegistry}.
 *
 * @param response the HTTP response as JSON
 * @return the throwable/*from  www  . j a va  2s .  co  m*/
 * @throws IOException if the response cannot be parsed
 */
protected RuntimeException findThrowableByStatusCode(final ClientHttpResponse response) throws IOException {
    return ExceptionRegistry.getExceptionByHttpStatusCode(response.getRawStatusCode(),
            response.getStatusText());
}

From source file:org.fao.geonet.utils.XmlRequest.java

protected final Element executeAndReadResponse(HttpRequestBase httpMethod)
        throws IOException, BadXmlResponseEx {

    final ClientHttpResponse httpResponse = doExecute(httpMethod);

    if (httpResponse.getRawStatusCode() > 399) {
        httpMethod.releaseConnection();/*from  w w  w.  j  a  v  a2s  .  com*/
        throw new BadServerResponseEx(httpResponse.getStatusText() + " -- URI: " + httpMethod.getURI()
                + " -- Response Code: " + httpResponse.getRawStatusCode());
    }

    byte[] data = null;

    try {
        data = IOUtils.toByteArray(httpResponse.getBody());
        return Xml.loadStream(new ByteArrayInputStream(data));
    } catch (JDOMException e) {
        throw new BadXmlResponseEx(
                "Response: '" + new String(data, "UTF8") + "' (from URI " + httpMethod.getURI() + ")");
    } finally {
        httpMethod.releaseConnection();

        sentData = getSentData(httpMethod);
    }
}