use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class MultiTenancyProcessDefinitionSuspensionStateTest method tearDown.
@After
public void tearDown() throws Exception {
CommandExecutor commandExecutor = engineRule.getProcessEngineConfiguration().getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Object>() {
public Object execute(CommandContext commandContext) {
commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByHandlerType(TimerActivateProcessDefinitionHandler.TYPE);
commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByHandlerType(TimerSuspendProcessDefinitionHandler.TYPE);
return null;
}
});
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class BpmnDeploymentTest method testDiagramCreationDisabled.
public void testDiagramCreationDisabled() {
repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/bpmn/parse/BpmnParseTest.testParseDiagramInterchangeElements.bpmn20.xml").deploy();
// Graphical information is not yet exposed publicly, so we need to do some plumbing
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
@Override
public ProcessDefinitionEntity execute(CommandContext commandContext) {
return Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedLatestProcessDefinitionByKey("myProcess");
}
});
assertNotNull(processDefinitionEntity);
assertEquals(7, processDefinitionEntity.getActivities().size());
// Check that no diagram has been created
List<String> resourceNames = repositoryService.getDeploymentResourceNames(processDefinitionEntity.getDeploymentId());
assertEquals(1, resourceNames.size());
repositoryService.deleteDeployment(repositoryService.createDeploymentQuery().singleResult().getId(), true);
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class TaskListenerTest method testDeleteListenerByCaseInstanceDeletion.
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/tasklistener/TaskListenerTest.testDeleteListenerByCaseInstanceDeletion.cmmn" })
public void testDeleteListenerByCaseInstanceDeletion() {
TaskDeleteListener.clear();
// given
final String caseInstanceId = caseService.withCaseDefinitionByKey("case").create().getId();
String humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
// when
processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {
@Override
public Void execute(CommandContext commandContext) {
commandContext.getCaseExecutionManager().deleteCaseInstance(caseInstanceId, null);
return null;
}
});
// then
assertEquals(1, TaskDeleteListener.eventCounter);
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class JtaTransactionContext method addTransactionListener.
public void addTransactionListener(TransactionState transactionState, final TransactionListener transactionListener) {
Transaction transaction = getTransaction();
CommandContext commandContext = Context.getCommandContext();
try {
transaction.registerSynchronization(new TransactionStateSynchronization(transactionState, transactionListener, commandContext));
} catch (Exception e) {
throw LOG.exceptionWhileInteractingWithTransaction("registering synchronization", e);
}
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class DefaultDelegateInterceptor method handleInvocationInContext.
protected void handleInvocationInContext(final DelegateInvocation invocation) throws Exception {
CommandContext commandContext = Context.getCommandContext();
boolean oldValue = commandContext.isAuthorizationCheckEnabled();
BaseDelegateExecution contextExecution = invocation.getContextExecution();
ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
boolean popExecutionContext = false;
try {
if (!configuration.isAuthorizationEnabledForCustomCode()) {
// the custom code should be executed without authorization
commandContext.disableAuthorizationCheck();
}
try {
commandContext.disableUserOperationLog();
try {
if (contextExecution != null && !isCurrentContextExecution(contextExecution)) {
popExecutionContext = setExecutionContext(contextExecution);
}
invocation.proceed();
} finally {
if (popExecutionContext) {
Context.removeExecutionContext();
}
}
} finally {
commandContext.enableUserOperationLog();
}
} finally {
if (oldValue) {
commandContext.enableAuthorizationCheck();
}
}
}
Aggregations