use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class AbstractCorrelateMessageCmd method checkAuthorization.
protected void checkAuthorization(CorrelationHandlerResult correlation) {
CommandContext commandContext = Context.getCommandContext();
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
if (MessageCorrelationResultType.Execution.equals(correlation.getResultType())) {
ExecutionEntity execution = correlation.getExecutionEntity();
checker.checkUpdateProcessInstanceById(execution.getProcessInstanceId());
} else {
ProcessDefinitionEntity definition = correlation.getProcessDefinitionEntity();
checker.checkCreateProcessInstance(definition);
}
}
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class DeployCmd method getDeployedProcesses.
protected List<? extends ProcessDefinition> getDeployedProcesses(DeploymentEntity deployment) {
List<? extends ProcessDefinition> deployedProcessDefinitions = deployment.getDeployedProcessDefinitions();
if (deployedProcessDefinitions == null) {
// existing deployment
CommandContext commandContext = Context.getCommandContext();
ProcessDefinitionManager manager = commandContext.getProcessDefinitionManager();
deployedProcessDefinitions = manager.findProcessDefinitionsByDeploymentId(deployment.getId());
}
return deployedProcessDefinitions;
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class MigrationBatchJobHandler method postProcessJob.
@Override
protected void postProcessJob(MigrationBatchConfiguration configuration, JobEntity job) {
CommandContext commandContext = Context.getCommandContext();
String sourceProcessDefinitionId = configuration.getMigrationPlan().getSourceProcessDefinitionId();
ProcessDefinitionEntity processDefinition = getProcessDefinition(commandContext, sourceProcessDefinitionId);
job.setDeploymentId(processDefinition.getDeploymentId());
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class EntityManagerSessionImpl method getEntityManager.
public EntityManager getEntityManager() {
if (entityManager == null) {
entityManager = getEntityManagerFactory().createEntityManager();
if (handleTransactions) {
// Add transaction listeners, if transactions should be handled
TransactionListener jpaTransactionCommitListener = new TransactionListener() {
public void execute(CommandContext commandContext) {
if (isTransactionActive()) {
entityManager.getTransaction().commit();
}
}
};
TransactionListener jpaTransactionRollbackListener = new TransactionListener() {
public void execute(CommandContext commandContext) {
if (isTransactionActive()) {
entityManager.getTransaction().rollback();
}
}
};
TransactionContext transactionContext = Context.getCommandContext().getTransactionContext();
transactionContext.addTransactionListener(TransactionState.COMMITTED, jpaTransactionCommitListener);
transactionContext.addTransactionListener(TransactionState.ROLLED_BACK, jpaTransactionRollbackListener);
// Also, start a transaction, if one isn't started already
if (!isTransactionActive()) {
entityManager.getTransaction().begin();
}
}
}
return entityManager;
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class ManagementServiceTest method testSetJobRetriesByDefinitionUnlocksInconsistentJobs.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/ManagementServiceTest.testGetJobExceptionStacktrace.bpmn20.xml" })
public void testSetJobRetriesByDefinitionUnlocksInconsistentJobs() {
// given a job definition
final JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();
// and an inconsistent job that is never again picked up by a job executor
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Void>() {
@Override
public Void execute(CommandContext commandContext) {
JobManager jobManager = commandContext.getJobManager();
MessageEntity job = new MessageEntity();
job.setJobDefinitionId(jobDefinition.getId());
job.setJobHandlerType("any");
job.setLockOwner("owner");
job.setLockExpirationTime(ClockUtil.getCurrentTime());
job.setRetries(0);
jobManager.send(job);
return null;
}
});
// when the job retries are reset
managementService.setJobRetriesByJobDefinitionId(jobDefinition.getId(), 3);
// then the job can be picked up again
JobEntity job = (JobEntity) managementService.createJobQuery().singleResult();
assertNotNull(job);
assertNull(job.getLockOwner());
assertNull(job.getLockExpirationTime());
assertEquals(3, job.getRetries());
deleteJobAndIncidents(job);
}
Aggregations