Search in sources :

Example 1 with StatusEvaluator

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);
    }
}
Also used : StatusEvaluator(com.adaptris.core.http.client.StatusEvaluator) CoreException(com.adaptris.core.CoreException) InputFieldHint(com.adaptris.annotation.InputFieldHint)

Aggregations

InputFieldHint (com.adaptris.annotation.InputFieldHint)1 CoreException (com.adaptris.core.CoreException)1 StatusEvaluator (com.adaptris.core.http.client.StatusEvaluator)1