use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class ExecuteJobsCmd method execute.
public Void execute(CommandContext commandContext) {
ensureNotNull("jobId", jobId);
final JobEntity job = commandContext.getDbEntityManager().selectById(JobEntity.class, jobId);
final ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
final IdentityService identityService = processEngineConfiguration.getIdentityService();
final JobExecutorContext jobExecutorContext = Context.getJobExecutorContext();
if (job == null) {
if (jobExecutorContext != null) {
// CAM-1842
// Job was acquired but does not exist anymore. This is not a problem.
// It usually means that the job has been deleted after it was acquired which can happen if the
// the activity instance corresponding to the job is cancelled.
LOG.debugAcquiredJobNotFound(jobId);
return null;
} else {
throw LOG.jobNotFoundException(jobId);
}
}
jobFailureCollector.setJob(job);
if (jobExecutorContext == null) {
// if null, then we are not called by the job executor
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkUpdateJob(job);
}
} else {
jobExecutorContext.setCurrentJob(job);
// if the job is called by the job executor then set the tenant id of the job
// as authenticated tenant to enable tenant checks
String tenantId = job.getTenantId();
if (tenantId != null) {
identityService.setAuthentication(null, null, Collections.singletonList(tenantId));
}
}
try {
// register as command context close lister to intercept exceptions on flush
commandContext.registerCommandContextListener(jobFailureCollector);
commandContext.setCurrentJob(job);
job.execute(commandContext);
} finally {
if (jobExecutorContext != null) {
jobExecutorContext.setCurrentJob(null);
identityService.clearAuthentication();
}
}
return null;
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class ExternalTaskCmd method execute.
@Override
public Void execute(CommandContext commandContext) {
EnsureUtil.ensureNotNull("externalTaskId", externalTaskId);
validateInput();
ExternalTaskEntity externalTask = commandContext.getExternalTaskManager().findExternalTaskById(externalTaskId);
ensureNotNull(NotFoundException.class, "Cannot find external task with id " + externalTaskId, "externalTask", externalTask);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkUpdateProcessInstanceById(externalTask.getProcessInstanceId());
}
execute(externalTask);
return null;
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class GetDeployedProcessDefinitionCmd method execute.
@Override
public ProcessDefinitionEntity execute(CommandContext commandContext) {
ensureOnlyOneNotNull("either process definition id or key must be set", processDefinitionId, processDefinitionKey);
ProcessDefinitionEntity processDefinition = find(commandContext);
if (checkReadPermission) {
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkReadProcessDefinition(processDefinition);
}
}
return processDefinition;
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class GetDeploymentBpmnModelInstanceCmd method execute.
public BpmnModelInstance execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
final DeploymentCache deploymentCache = configuration.getDeploymentCache();
ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkReadProcessDefinition(processDefinition);
}
BpmnModelInstance modelInstance = deploymentCache.findBpmnModelInstanceForProcessDefinition(processDefinitionId);
ensureNotNull("no BPMN model instance found for process definition id " + processDefinitionId, "modelInstance", modelInstance);
return modelInstance;
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class GetDeploymentProcessDiagramLayoutCmd method execute.
public DiagramLayout execute(final CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedProcessDefinitionById(processDefinitionId);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkReadProcessDefinition(processDefinition);
}
InputStream processModelStream = commandContext.runWithoutAuthorization(new Callable<InputStream>() {
public InputStream call() throws Exception {
return new GetDeploymentProcessModelCmd(processDefinitionId).execute(commandContext);
}
});
InputStream processDiagramStream = commandContext.runWithoutAuthorization(new Callable<InputStream>() {
public InputStream call() throws Exception {
return new GetDeploymentProcessDiagramCmd(processDefinitionId).execute(commandContext);
}
});
return new ProcessDiagramLayoutFactory().getProcessDiagramLayout(processModelStream, processDiagramStream);
}
Aggregations