use of com.adaptris.core.http.client.StatusEvaluator in project interlok by adaptris.
the class BranchingHttpRequestService method doService.
@Override
public void doService(AdaptrisMessage msg) throws ServiceException {
StandardHttpProducer p = buildProducer(msg);
p.setIgnoreServerResponseCode(true);
try {
LifecycleHelper.initAndStart(p, false).request(msg);
Optional.ofNullable(getDefaultServiceId()).ifPresent((s) -> msg.setNextServiceId(s));
int responseCode = ((Integer) msg.getObjectHeaders().get(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE)).intValue();
for (StatusEvaluator rp : getStatusMatches()) {
if (rp.matches(responseCode)) {
msg.setNextServiceId(rp.serviceId());
break;
}
}
} catch (CoreException e) {
throw ExceptionHelper.wrapServiceException(e);
} finally {
LifecycleHelper.stopAndClose(p, false);
}
}
Aggregations