use of org.jboss.resteasy.client.core.BaseClientResponse in project quickstarts by jboss-switchyard.
the class MyClientErrorInterceptor method handle.
public void handle(ClientResponse response) throws RuntimeException {
try {
BaseClientResponse r = (BaseClientResponse) response;
InputStream stream = r.getStreamFactory().getInputStream();
if (stream != null) {
stream.reset();
}
if ((response.getResponseStatus() != null) && (response.getResponseStatus().getStatusCode() == 404) && !(r.getException() instanceof ItemNotFoundException)) {
throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new ApiError("Error at " + response.getHeaders().get("full-path"))).build());
}
} catch (IOException e) {
//...
}
}
use of org.jboss.resteasy.client.core.BaseClientResponse in project quickstarts by jboss-switchyard.
the class MyClientExecutionInterceptor method execute.
public ClientResponse execute(ClientExecutionContext ctx) throws Exception {
ClientRequest request = ctx.getRequest();
ClientResponse response = null;
response = ctx.proceed();
if ((response.getResponseStatus() != null) && (response.getResponseStatus().getStatusCode() == 404)) {
BaseClientResponse r = (BaseClientResponse) response;
MultivaluedMap<String, String> headers = r.getHeaders();
headers.add("full-path", request.getUri());
r.setHeaders(headers);
}
return response;
}
Aggregations