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);
}
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;
}
}
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;
}
Aggregations