use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class ExecutionCachedEntityStateTest method testExecutionIncidentParallel.
@Deployment
public void testExecutionIncidentParallel() {
runtimeService.startProcessInstanceByKey("testProcess");
ExecutionEntity processInstance = (ExecutionEntity) runtimeService.createProcessInstanceQuery().singleResult();
assertEquals(0, processInstance.getCachedEntityStateRaw());
final ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().activityId("task").singleResult();
assertEquals(0, execution.getCachedEntityStateRaw());
processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
IncidentContext incidentContext = new IncidentContext();
incidentContext.setExecutionId(execution.getId());
IncidentEntity.createAndInsertIncident("foo", incidentContext, null);
return null;
}
});
ExecutionEntity execution2 = (ExecutionEntity) runtimeService.createExecutionQuery().activityId("task").singleResult();
assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.INCIDENT_STATE_BIT), execution2.getCachedEntityStateRaw());
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class CaseDefinitionEntity method loadCaseDefinition.
/**
* Returns the cached version if exists; does not update the entity from the database in that case
*/
protected CaseDefinitionEntity loadCaseDefinition(String caseDefinitionId) {
ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
DeploymentCache deploymentCache = configuration.getDeploymentCache();
CaseDefinitionEntity caseDefinition = deploymentCache.findCaseDefinitionFromCache(caseDefinitionId);
if (caseDefinition == null) {
CommandContext commandContext = Context.getCommandContext();
CaseDefinitionManager caseDefinitionManager = commandContext.getCaseDefinitionManager();
caseDefinition = caseDefinitionManager.findCaseDefinitionById(caseDefinitionId);
if (caseDefinition != null) {
caseDefinition = deploymentCache.resolveCaseDefinition(caseDefinition);
}
}
return caseDefinition;
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class CaseExecutionManager method deleteCaseInstance.
public void deleteCaseInstance(String caseInstanceId, String deleteReason, boolean cascade) {
CaseExecutionEntity execution = findCaseExecutionById(caseInstanceId);
if (execution == null) {
throw new BadUserRequestException("No case instance found for id '" + caseInstanceId + "'");
}
CommandContext commandContext = Context.getCommandContext();
commandContext.getTaskManager().deleteTasksByCaseInstanceId(caseInstanceId, deleteReason, cascade);
execution.deleteCascade();
if (cascade) {
Context.getCommandContext().getHistoricCaseInstanceManager().deleteHistoricCaseInstancesByIds(Arrays.asList(caseInstanceId));
}
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class FailedJobListener method fireHistoricJobFailedEvt.
protected void fireHistoricJobFailedEvt(JobEntity job) {
CommandContext commandContext = Context.getCommandContext();
// the given job failed and a rollback happened,
// that's why we have to increment the job
// sequence counter once again
job.incrementSequenceCounter();
commandContext.getHistoricJobLogManager().fireJobFailedEvent(job, exception);
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class StatisticsManager method checkReadProcessDefinition.
protected void checkReadProcessDefinition(ActivityStatisticsQueryImpl query) {
CommandContext commandContext = getCommandContext();
if (isAuthorizationEnabled() && getCurrentAuthentication() != null && commandContext.isAuthorizationCheckEnabled()) {
String processDefinitionId = query.getProcessDefinitionId();
ProcessDefinitionEntity definition = getProcessDefinitionManager().findLatestProcessDefinitionById(processDefinitionId);
ensureNotNull("no deployed process definition found with id '" + processDefinitionId + "'", "processDefinition", definition);
getAuthorizationManager().checkAuthorization(READ, PROCESS_DEFINITION, definition.getKey());
}
}
Aggregations