Search in sources :

Example 1 with PolicyApplier

use of com.walmartlabs.concord.server.process.pipelines.processors.policy.PolicyApplier in project concord by walmartlabs.

the class PolicyProcessor method process.

@Override
public Payload process(Chain chain, Payload payload) {
    ProcessKey processKey = payload.getProcessKey();
    PolicyEngine policy = payload.getHeader(Payload.POLICY);
    if (policy == null) {
        return chain.process(payload);
    }
    logManager.info(processKey, "Applying policies...");
    try {
        // TODO merge check results
        for (PolicyApplier a : appliers) {
            a.apply(payload, policy);
        }
    } catch (ProcessException e) {
        throw e;
    } catch (Exception e) {
        logManager.error(processKey, "Error while applying policy '{}': {}", policy.policyNames(), e);
        throw new ProcessException(processKey, "Policy '" + policy.policyNames() + "' error", e);
    }
    return chain.process(payload);
}
Also used : PolicyApplier(com.walmartlabs.concord.server.process.pipelines.processors.policy.PolicyApplier) ProcessException(com.walmartlabs.concord.server.process.ProcessException) PolicyEngine(com.walmartlabs.concord.policyengine.PolicyEngine) ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey) ProcessException(com.walmartlabs.concord.server.process.ProcessException)

Aggregations

PolicyEngine (com.walmartlabs.concord.policyengine.PolicyEngine)1 ProcessException (com.walmartlabs.concord.server.process.ProcessException)1 PolicyApplier (com.walmartlabs.concord.server.process.pipelines.processors.policy.PolicyApplier)1 ProcessKey (com.walmartlabs.concord.server.sdk.ProcessKey)1