Search in sources :

Example 1 with CorrelationHandler

use of org.camunda.bpm.engine.impl.runtime.CorrelationHandler in project camunda-bpm-platform by camunda.

the class CorrelateMessageCmd method execute.

public MessageCorrelationResult execute(final CommandContext commandContext) {
    ensureAtLeastOneNotNull("At least one of the following correlation criteria has to be present: " + "messageName, businessKey, correlationKeys, processInstanceId", messageName, builder.getBusinessKey(), builder.getCorrelationProcessInstanceVariables(), builder.getProcessInstanceId());
    final CorrelationHandler correlationHandler = Context.getProcessEngineConfiguration().getCorrelationHandler();
    final CorrelationSet correlationSet = new CorrelationSet(builder);
    CorrelationHandlerResult correlationResult = commandContext.runWithoutAuthorization(new Callable<CorrelationHandlerResult>() {

        public CorrelationHandlerResult call() throws Exception {
            return correlationHandler.correlateMessage(commandContext, messageName, correlationSet);
        }
    });
    if (correlationResult == null) {
        throw new MismatchingMessageCorrelationException(messageName, "No process definition or execution matches the parameters");
    }
    // check authorization
    checkAuthorization(correlationResult);
    return createMessageCorrelationResult(commandContext, correlationResult);
}
Also used : CorrelationHandler(org.camunda.bpm.engine.impl.runtime.CorrelationHandler) CorrelationSet(org.camunda.bpm.engine.impl.runtime.CorrelationSet) CorrelationHandlerResult(org.camunda.bpm.engine.impl.runtime.CorrelationHandlerResult) MismatchingMessageCorrelationException(org.camunda.bpm.engine.MismatchingMessageCorrelationException) MismatchingMessageCorrelationException(org.camunda.bpm.engine.MismatchingMessageCorrelationException)

Example 2 with CorrelationHandler

use of org.camunda.bpm.engine.impl.runtime.CorrelationHandler in project camunda-bpm-platform by camunda.

the class CorrelateStartMessageCmd method execute.

public ProcessInstance execute(final CommandContext commandContext) {
    ensureNotNull("messageName", messageName);
    final CorrelationHandler correlationHandler = Context.getProcessEngineConfiguration().getCorrelationHandler();
    final CorrelationSet correlationSet = new CorrelationSet(builder);
    List<CorrelationHandlerResult> correlationResults = commandContext.runWithoutAuthorization(new Callable<List<CorrelationHandlerResult>>() {

        public List<CorrelationHandlerResult> call() throws Exception {
            return correlationHandler.correlateStartMessages(commandContext, messageName, correlationSet);
        }
    });
    if (correlationResults.isEmpty()) {
        throw new MismatchingMessageCorrelationException(messageName, "No process definition matches the parameters");
    } else if (correlationResults.size() > 1) {
        throw LOG.exceptionCorrelateMessageToSingleProcessDefinition(messageName, correlationResults.size(), correlationSet);
    } else {
        CorrelationHandlerResult correlationResult = correlationResults.get(0);
        checkAuthorization(correlationResult);
        ProcessInstance processInstance = instantiateProcess(commandContext, correlationResult);
        return processInstance;
    }
}
Also used : CorrelationHandler(org.camunda.bpm.engine.impl.runtime.CorrelationHandler) CorrelationSet(org.camunda.bpm.engine.impl.runtime.CorrelationSet) CorrelationHandlerResult(org.camunda.bpm.engine.impl.runtime.CorrelationHandlerResult) List(java.util.List) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) MismatchingMessageCorrelationException(org.camunda.bpm.engine.MismatchingMessageCorrelationException) MismatchingMessageCorrelationException(org.camunda.bpm.engine.MismatchingMessageCorrelationException)

Example 3 with CorrelationHandler

use of org.camunda.bpm.engine.impl.runtime.CorrelationHandler in project camunda-bpm-platform by camunda.

the class CorrelateAllMessageCmd method execute.

public List<MessageCorrelationResult> execute(final CommandContext commandContext) {
    ensureAtLeastOneNotNull("At least one of the following correlation criteria has to be present: " + "messageName, businessKey, correlationKeys, processInstanceId", messageName, builder.getBusinessKey(), builder.getCorrelationProcessInstanceVariables(), builder.getProcessInstanceId());
    final CorrelationHandler correlationHandler = Context.getProcessEngineConfiguration().getCorrelationHandler();
    final CorrelationSet correlationSet = new CorrelationSet(builder);
    List<CorrelationHandlerResult> correlationResults = commandContext.runWithoutAuthorization(new Callable<List<CorrelationHandlerResult>>() {

        public List<CorrelationHandlerResult> call() throws Exception {
            return correlationHandler.correlateMessages(commandContext, messageName, correlationSet);
        }
    });
    // check authorization
    for (CorrelationHandlerResult correlationResult : correlationResults) {
        checkAuthorization(correlationResult);
    }
    List<MessageCorrelationResult> results = new ArrayList<MessageCorrelationResult>();
    for (CorrelationHandlerResult correlationResult : correlationResults) {
        results.add(createMessageCorrelationResult(commandContext, correlationResult));
    }
    return results;
}
Also used : CorrelationHandler(org.camunda.bpm.engine.impl.runtime.CorrelationHandler) CorrelationSet(org.camunda.bpm.engine.impl.runtime.CorrelationSet) ArrayList(java.util.ArrayList) CorrelationHandlerResult(org.camunda.bpm.engine.impl.runtime.CorrelationHandlerResult) List(java.util.List) ArrayList(java.util.ArrayList) MessageCorrelationResult(org.camunda.bpm.engine.runtime.MessageCorrelationResult)

Aggregations

CorrelationHandler (org.camunda.bpm.engine.impl.runtime.CorrelationHandler)3 CorrelationHandlerResult (org.camunda.bpm.engine.impl.runtime.CorrelationHandlerResult)3 CorrelationSet (org.camunda.bpm.engine.impl.runtime.CorrelationSet)3 List (java.util.List)2 MismatchingMessageCorrelationException (org.camunda.bpm.engine.MismatchingMessageCorrelationException)2 ArrayList (java.util.ArrayList)1 MessageCorrelationResult (org.camunda.bpm.engine.runtime.MessageCorrelationResult)1 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1