use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionManager in project camunda-bpm-platform by camunda.
the class MessageEventReceivedCmd method execute.
@Override
public Void execute(CommandContext commandContext) {
ensureNotNull("executionId", executionId);
EventSubscriptionManager eventSubscriptionManager = commandContext.getEventSubscriptionManager();
List<EventSubscriptionEntity> eventSubscriptions = null;
if (messageName != null) {
eventSubscriptions = eventSubscriptionManager.findEventSubscriptionsByNameAndExecution(EventType.MESSAGE.name(), messageName, executionId, exclusive);
} else {
eventSubscriptions = eventSubscriptionManager.findEventSubscriptionsByExecutionAndType(executionId, EventType.MESSAGE.name(), exclusive);
}
ensureNotEmpty("Execution with id '" + executionId + "' does not have a subscription to a message event with name '" + messageName + "'", "eventSubscriptions", eventSubscriptions);
ensureNumberOfElements("More than one matching message subscription found for execution " + executionId, "eventSubscriptions", eventSubscriptions, 1);
// there can be only one:
EventSubscriptionEntity eventSubscriptionEntity = eventSubscriptions.get(0);
// check authorization
String processInstanceId = eventSubscriptionEntity.getProcessInstanceId();
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkUpdateProcessInstanceById(processInstanceId);
}
eventSubscriptionEntity.eventReceived(processVariables, false);
return null;
}
use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionManager in project camunda-bpm-platform by camunda.
the class BpmnDeployer method removeObsoleteEventSubscriptions.
protected void removeObsoleteEventSubscriptions(ProcessDefinitionEntity processDefinition, ProcessDefinitionEntity latestProcessDefinition) {
// remove all subscriptions for the previous version
if (latestProcessDefinition != null) {
EventSubscriptionManager eventSubscriptionManager = getEventSubscriptionManager();
List<EventSubscriptionEntity> subscriptionsToDelete = new ArrayList<EventSubscriptionEntity>();
List<EventSubscriptionEntity> messageEventSubscriptions = eventSubscriptionManager.findEventSubscriptionsByConfiguration(EventType.MESSAGE.name(), latestProcessDefinition.getId());
subscriptionsToDelete.addAll(messageEventSubscriptions);
List<EventSubscriptionEntity> signalEventSubscriptions = eventSubscriptionManager.findEventSubscriptionsByConfiguration(EventType.SIGNAL.name(), latestProcessDefinition.getId());
subscriptionsToDelete.addAll(signalEventSubscriptions);
List<EventSubscriptionEntity> conditionalEventSubscriptions = eventSubscriptionManager.findEventSubscriptionsByConfiguration(EventType.CONDITONAL.name(), latestProcessDefinition.getId());
subscriptionsToDelete.addAll(conditionalEventSubscriptions);
for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsToDelete) {
eventSubscriptionEntity.delete();
}
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionManager in project camunda-bpm-platform by camunda.
the class SignalEventReceivedCmd method sendSignalToExecution.
protected void sendSignalToExecution(CommandContext commandContext, String signalName, String executionId) {
ExecutionManager executionManager = commandContext.getExecutionManager();
ExecutionEntity execution = executionManager.findExecutionById(executionId);
ensureNotNull("Cannot find execution with id '" + executionId + "'", "execution", execution);
EventSubscriptionManager eventSubscriptionManager = commandContext.getEventSubscriptionManager();
List<EventSubscriptionEntity> signalEvents = eventSubscriptionManager.findSignalEventSubscriptionsByNameAndExecution(signalName, executionId);
ensureNotEmpty("Execution '" + executionId + "' has not subscribed to a signal event with name '" + signalName + "'.", signalEvents);
checkAuthorizationOfCatchSignals(commandContext, signalEvents);
notifyExecutions(signalEvents);
}
Aggregations