use of jakarta.ws.rs.client.ResponseProcessingException in project resteasy by resteasy.
the class SigningTest method testBadSignatureProxy.
@Test
public void testBadSignatureProxy() throws Exception {
// ResteasyClientImpl client = new ResteasyClientImpl();
ResteasyWebTarget target = client.target(generateBaseUrl());
target.property(KeyRepository.class.getName(), repository);
SigningProxy proxy = target.proxy(SigningProxy.class);
try {
String output = proxy.bad();
throw new Exception("UNREACHABLE");
} catch (ResponseProcessingException e) {
LOG.error(e.getMessage(), e);
// Assert.assertTrue(e.getCause() instanceof UnauthorizedSignatureException);
}
}
use of jakarta.ws.rs.client.ResponseProcessingException in project resteasy by resteasy.
the class ClientInvocation method filterResponse.
protected ClientResponse filterResponse(ClientRequestContextImpl requestContext, ClientResponse response) {
response.setProperties(configuration.getMutableProperties());
ClientResponseFilter[] responseFilters = getResponseFilters();
if (responseFilters != null && responseFilters.length > 0) {
ClientResponseContextImpl responseContext = new ClientResponseContextImpl(response);
for (ClientResponseFilter filter : responseFilters) {
try {
filter.filter(requestContext, responseContext);
} catch (ResponseProcessingException e) {
throw e;
} catch (Throwable e) {
throw new ResponseProcessingException(response, e);
}
}
}
return response;
}
use of jakarta.ws.rs.client.ResponseProcessingException in project corese by Wimmics.
the class LogManager method process.
void process(EngineException e) {
ContextLog log = getLog();
String sub = DatatypeMap.createBlank().getLabel();
log.set(sub, "a", REPORT);
if (e.getURL() != null) {
log.set(sub, URL, e.getURL().getServer());
if (e.getURL().hasParameter()) {
log.set(sub, URL_PARAM, e.getURL().getURL());
}
}
if (e.getCause() instanceof ResponseProcessingException) {
if (e.getObject() != null && e.getObject() instanceof Response) {
Response resp = (Response) e.getObject();
log.set(sub, INFO, resp.getStatusInfo().toString());
log.set(sub, STATUS, resp.getStatus());
String serv = getServer(resp);
if (serv != null) {
log.set(sub, SERVER, serv);
}
if (resp.getHeaderString("Date") != null) {
log.set(sub, DATE, resp.getHeaderString("Date"));
}
trace(e.getURL(), resp);
}
}
log.set(sub, MESSAGE, e.getMessage());
if (e.getAST() != null) {
log.set(sub, QUERY, DatatypeMap.genericPointer(e.getAST().toString()));
}
}
use of jakarta.ws.rs.client.ResponseProcessingException in project corese by Wimmics.
the class Service method getResponse.
Response getResponse(String url, String mime) {
logger.info("Service: " + url + " " + mime);
clientBuilder.connectTimeout(timeout, TimeUnit.MILLISECONDS);
Client client = clientBuilder.build();
WebTarget target = client.target(url);
Builder build = target.request(mime);
// Builder build = target.request();
Response resp = build.get();
if (resp.getMediaType() != null) {
recordFormat(resp.getMediaType().toString());
}
getCreateReport().setResponse(resp);
if (resp.getStatus() == Response.Status.SEE_OTHER.getStatusCode() || resp.getStatus() == Response.Status.MOVED_PERMANENTLY.getStatusCode()) {
String myUrl = resp.getLocation().toString();
logger.warn(String.format("Service redirection: %s to: %s", url, myUrl));
if (myUrl.equals(url)) {
throw new jakarta.ws.rs.RedirectionException(resp);
}
return getResponse(myUrl, mime);
}
if (resp.getStatus() >= Response.Status.BAD_REQUEST.getStatusCode()) {
String res = resp.readEntity(String.class);
ResponseProcessingException ex = new ResponseProcessingException(resp, res);
if (isLog() && getLog() != null) {
// use case: @federate call not within ProviderService
// log here
getLog().addException(new EngineException(ex, ex.getMessage()).setURL(getURL()).setObject(ex.getResponse()));
}
logger.error("Response status: " + resp.getStatus());
logger.info("message: " + res);
throw ex;
}
return resp;
}
use of jakarta.ws.rs.client.ResponseProcessingException in project corese by Wimmics.
the class QueryProcess method service.
/**
* Annotated query with a service send query to server
*
* @federate <http://dbpedia.org/sparql>
* select where {}
* Mapping m may contain Binding which may contain Log
* use case: xt:sparql("@federate <uri> select where")
*/
Mappings service(Query q, Mapping m) throws EngineException {
Service serv = new Service(q.getService());
serv.setBind(getCreateBinding(m));
serv.setLog(true);
try {
return serv.query(q, m);
} catch (LoadException | ResponseProcessingException ex) {
throw new EngineException(ex);
}
}
Aggregations