Search in sources :

Example 1 with PolicyChain

use of org.mule.runtime.core.api.policy.PolicyChain in project mule by mulesoft.

the class OperationPolicyProcessor method executePolicyChain.

private Mono<PrivilegedEvent> executePolicyChain(PrivilegedEvent operationEvent, PolicyStateId policyStateId, PrivilegedEvent policyEvent) {
    PolicyChain policyChain = policy.getPolicyChain();
    policyChain.onChainError(t -> manageError(policyStateId, operationEvent, (MessagingException) t));
    return just(policyEvent).doOnNext(event -> logPolicy(event.getContext().getCorrelationId(), policyStateId.getPolicyId(), getMessageAttributesAsString(event), "Before operation")).cast(CoreEvent.class).transform(policyChain).cast(PrivilegedEvent.class).doOnNext(policyChainResult -> policyStateHandler.updateState(policyStateId, policyChainResult)).map(policyChainResult -> policyEventConverter.createEvent(policyChainResult, operationEvent)).doOnNext(event -> logPolicy(event.getContext().getCorrelationId(), policyStateId.getPolicyId(), getMessageAttributesAsString(event), "After operation"));
}
Also used : PolicyStateId(org.mule.runtime.core.api.policy.PolicyStateId) PolicyStateHandler(org.mule.runtime.core.api.policy.PolicyStateHandler) PrivilegedEvent(org.mule.runtime.core.privileged.event.PrivilegedEvent) Logger(org.slf4j.Logger) MessageProcessors.processToApply(org.mule.runtime.core.privileged.processor.MessageProcessors.processToApply) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Publisher(org.reactivestreams.Publisher) Mono(reactor.core.publisher.Mono) Message.of(org.mule.runtime.api.message.Message.of) Processor(org.mule.runtime.core.api.processor.Processor) PolicyChain(org.mule.runtime.core.api.policy.PolicyChain) MuleException(org.mule.runtime.api.exception.MuleException) Policy(org.mule.runtime.core.api.policy.Policy) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Mono.from(reactor.core.publisher.Mono.from) Mono.just(reactor.core.publisher.Mono.just) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) Optional(java.util.Optional) PolicyChain(org.mule.runtime.core.api.policy.PolicyChain) PrivilegedEvent(org.mule.runtime.core.privileged.event.PrivilegedEvent) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) CoreEvent(org.mule.runtime.core.api.event.CoreEvent)

Aggregations

Optional (java.util.Optional)1 MuleException (org.mule.runtime.api.exception.MuleException)1 Message.of (org.mule.runtime.api.message.Message.of)1 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)1 Policy (org.mule.runtime.core.api.policy.Policy)1 PolicyChain (org.mule.runtime.core.api.policy.PolicyChain)1 PolicyStateHandler (org.mule.runtime.core.api.policy.PolicyStateHandler)1 PolicyStateId (org.mule.runtime.core.api.policy.PolicyStateId)1 Processor (org.mule.runtime.core.api.processor.Processor)1 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)1 PrivilegedEvent (org.mule.runtime.core.privileged.event.PrivilegedEvent)1 MessageProcessors.processToApply (org.mule.runtime.core.privileged.processor.MessageProcessors.processToApply)1 Publisher (org.reactivestreams.Publisher)1 Logger (org.slf4j.Logger)1 LoggerFactory.getLogger (org.slf4j.LoggerFactory.getLogger)1 Mono (reactor.core.publisher.Mono)1 Mono.from (reactor.core.publisher.Mono.from)1 Mono.just (reactor.core.publisher.Mono.just)1