use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class ResolveIncidentCmd method execute.
@Override
public Void execute(CommandContext commandContext) {
final Incident incident = commandContext.getIncidentManager().findIncidentById(incidentId);
EnsureUtil.ensureNotNull(NotFoundException.class, "Cannot find an incident with id '" + incidentId + "'", "incident", incident);
if (incident.getIncidentType().equals("failedJob") || incident.getIncidentType().equals("failedExternalTask")) {
throw new BadUserRequestException("Cannot resolve an incident of type " + incident.getIncidentType());
}
EnsureUtil.ensureNotNull(BadUserRequestException.class, "", "executionId", incident.getExecutionId());
ExecutionEntity execution = commandContext.getExecutionManager().findExecutionById(incident.getExecutionId());
EnsureUtil.ensureNotNull(BadUserRequestException.class, "Cannot find an execution for an incident with id '" + incidentId + "'", "execution", execution);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkUpdateProcessInstance(execution);
}
execution.resolveIncident(incidentId);
return null;
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class GetDeploymentProcessDiagramCmd method execute.
public InputStream execute(final CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedProcessDefinitionById(processDefinitionId);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkReadProcessDefinition(processDefinition);
}
final String deploymentId = processDefinition.getDeploymentId();
final String resourceName = processDefinition.getDiagramResourceName();
if (resourceName == null) {
return null;
} else {
InputStream processDiagramStream = commandContext.runWithoutAuthorization(new Callable<InputStream>() {
public InputStream call() throws Exception {
return new GetDeploymentResourceCmd(deploymentId, resourceName).execute(commandContext);
}
});
return processDiagramStream;
}
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class GetRenderedTaskFormCmd method execute.
public Object execute(CommandContext commandContext) {
TaskManager taskManager = commandContext.getTaskManager();
TaskEntity task = taskManager.findTaskById(taskId);
ensureNotNull("Task '" + taskId + "' not found", "task", task);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkReadTask(task);
}
ensureNotNull("Task form definition for '" + taskId + "' not found", "task.getTaskDefinition()", task.getTaskDefinition());
TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
if (taskFormHandler == null) {
return null;
}
FormEngine formEngine = Context.getProcessEngineConfiguration().getFormEngines().get(formEngineName);
ensureNotNull("No formEngine '" + formEngineName + "' defined process engine configuration", "formEngine", formEngine);
TaskFormData taskForm = taskFormHandler.createTaskForm(task);
return formEngine.renderTaskForm(taskForm);
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker 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.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class DeleteDeploymentCmd method execute.
public Void execute(final CommandContext commandContext) {
ensureNotNull("deploymentId", deploymentId);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkDeleteDeployment(deploymentId);
}
UserOperationLogManager logManager = commandContext.getOperationLogManager();
List<PropertyChange> propertyChanges = Arrays.asList(new PropertyChange("cascade", null, cascade));
logManager.logDeploymentOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE, deploymentId, propertyChanges);
commandContext.getDeploymentManager().deleteDeployment(deploymentId, cascade, skipCustomListeners, skipIoMappings);
ProcessApplicationReference processApplicationReference = Context.getProcessEngineConfiguration().getProcessApplicationManager().getProcessApplicationForDeployment(deploymentId);
DeleteDeploymentFailListener listener = new DeleteDeploymentFailListener(deploymentId, processApplicationReference, Context.getProcessEngineConfiguration().getCommandExecutorTxRequiresNew());
try {
commandContext.runWithoutAuthorization(new Callable<Void>() {
public Void call() throws Exception {
new UnregisterProcessApplicationCmd(deploymentId, false).execute(commandContext);
new UnregisterDeploymentCmd(Collections.singleton(deploymentId)).execute(commandContext);
return null;
}
});
} finally {
try {
commandContext.getTransactionContext().addTransactionListener(TransactionState.ROLLED_BACK, listener);
} catch (Exception e) {
TX_LOG.debugTransactionOperation("Could not register transaction synchronization. Probably the TX has already been rolled back by application code.");
listener.execute(commandContext);
}
}
return null;
}
Aggregations