use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class DeleteJobCmd method execute.
public Object execute(CommandContext commandContext) {
ensureNotNull("jobId", jobId);
JobEntity job = commandContext.getJobManager().findJobById(jobId);
ensureNotNull("No job found with id '" + jobId + "'", "job", job);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkUpdateJob(job);
}
// In that case, we can't allow to delete the job.
if (job.getLockOwner() != null || job.getLockExpirationTime() != null) {
throw new ProcessEngineException("Cannot delete job when the job is being executed. Try again later.");
}
job.delete();
return null;
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class GetHistoricExternalTaskLogErrorDetailsCmd method execute.
public String execute(CommandContext commandContext) {
ensureNotNull("historicExternalTaskLogId", historicExternalTaskLogId);
HistoricExternalTaskLogEntity event = commandContext.getHistoricExternalTaskLogManager().findHistoricExternalTaskLogById(historicExternalTaskLogId);
ensureNotNull("No historic external task log found with id " + historicExternalTaskLogId, "historicExternalTaskLog", event);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkReadHistoricExternalTaskLog(event);
}
return event.getErrorDetails();
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class CreateIncidentCmd method execute.
@Override
public Incident execute(CommandContext commandContext) {
EnsureUtil.ensureNotNull(BadUserRequestException.class, "Execution id cannot be null", "executionId", executionId);
EnsureUtil.ensureNotNull(BadUserRequestException.class, "incidentType", incidentType);
ExecutionEntity execution = commandContext.getExecutionManager().findExecutionById(executionId);
EnsureUtil.ensureNotNull(BadUserRequestException.class, "Cannot find an execution with executionId '" + executionId + "'", "execution", execution);
EnsureUtil.ensureNotNull(BadUserRequestException.class, "Execution must be related to an activity", "activity", execution.getActivity());
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkUpdateProcessInstance(execution);
}
return execution.createIncident(incidentType, configuration, message);
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class AbstractSetJobRetriesCmd method setJobRetriesByJobId.
protected void setJobRetriesByJobId(String jobId, int retries, CommandContext commandContext) {
JobEntity job = commandContext.getJobManager().findJobById(jobId);
if (job != null) {
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkUpdateJob(job);
}
if (job.isInInconsistentLockState()) {
job.resetLock();
}
int oldRetries = job.getRetries();
job.setRetries(retries);
PropertyChange propertyChange = new PropertyChange(RETRIES, oldRetries, job.getRetries());
commandContext.getOperationLogManager().logJobOperation(getLogEntryOperation(), job.getId(), job.getJobDefinitionId(), job.getProcessInstanceId(), job.getProcessDefinitionId(), job.getProcessDefinitionKey(), propertyChange);
} else {
throw new ProcessEngineException("No job found with id '" + jobId + "'.");
}
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class StartProcessInstanceCmd method execute.
public ProcessInstanceWithVariables execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = new GetDeployedProcessDefinitionCmd(instantiationBuilder, false).execute(commandContext);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkCreateProcessInstance(processDefinition);
}
// Start the process instance
ExecutionEntity processInstance = processDefinition.createProcessInstance(instantiationBuilder.getBusinessKey(), instantiationBuilder.getCaseInstanceId());
if (instantiationBuilder.getTenantId() != null) {
processInstance.setTenantId(instantiationBuilder.getTenantId());
}
final ExecutionVariableSnapshotObserver variablesListener = new ExecutionVariableSnapshotObserver(processInstance);
processInstance.start(instantiationBuilder.getVariables());
return new ProcessInstanceWithVariablesImpl(processInstance, variablesListener.getVariables());
}
Aggregations