Java Code Examples for org.camunda.bpm.engine.impl.interceptor.CommandContext#getOperationLogManager()

The following examples show how to use org.camunda.bpm.engine.impl.interceptor.CommandContext#getOperationLogManager() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractDeleteProcessDefinitionCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void deleteProcessDefinitionCmd(CommandContext commandContext, String processDefinitionId, boolean cascade, boolean skipCustomListeners, boolean skipIoMappings) {
  ensureNotNull("processDefinitionId", processDefinitionId);

  ProcessDefinition processDefinition = commandContext.getProcessDefinitionManager()
    .findLatestProcessDefinitionById(processDefinitionId);
  ensureNotNull(NotFoundException.class, "No process definition found with id '" + processDefinitionId + "'",
    "processDefinition", processDefinition);

  List<CommandChecker> commandCheckers = commandContext.getProcessEngineConfiguration().getCommandCheckers();
  for (CommandChecker checker: commandCheckers) {
    checker.checkDeleteProcessDefinitionById(processDefinitionId);
  }

  UserOperationLogManager userOperationLogManager = commandContext.getOperationLogManager();
  userOperationLogManager.logProcessDefinitionOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE, processDefinitionId,
    processDefinition.getKey(), new PropertyChange("cascade", false, cascade));

  ProcessDefinitionManager definitionManager = commandContext.getProcessDefinitionManager();
  definitionManager.deleteProcessDefinition(processDefinition, processDefinitionId, cascade, cascade, skipCustomListeners, skipIoMappings);
}
 
Example 2
Source File: DeployCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void createUserOperationLog(DeploymentBuilderImpl deploymentBuilder, Deployment deployment, CommandContext commandContext) {
  UserOperationLogManager logManager = commandContext.getOperationLogManager();

  List<PropertyChange> properties = new ArrayList<>();

  PropertyChange filterDuplicate = new PropertyChange("duplicateFilterEnabled", null, deploymentBuilder.isDuplicateFilterEnabled());
  properties.add(filterDuplicate);

  if (deploymentBuilder.isDuplicateFilterEnabled()) {
    PropertyChange deployChangedOnly = new PropertyChange("deployChangedOnly", null, deploymentBuilder.isDeployChangedOnly());
    properties.add(deployChangedOnly);
  }

  logManager.logDeploymentOperation(UserOperationLogEntry.OPERATION_TYPE_CREATE, deployment.getId(), properties);
}
 
Example 3
Source File: DeleteProcessDefinitionsByIdsCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void deleteProcessDefinitions(ProcessDefinitionGroup group) {
  ProcessDefinitionEntity newLatestProcessDefinition = findNewLatestProcessDefinition(group);

  CommandContext commandContext = Context.getCommandContext();
  UserOperationLogManager userOperationLogManager = commandContext.getOperationLogManager();
  ProcessDefinitionManager definitionManager = commandContext.getProcessDefinitionManager();

  List<ProcessDefinitionEntity> processDefinitions = group.processDefinitions;
  for (ProcessDefinitionEntity processDefinition : processDefinitions) {
    String processDefinitionId = processDefinition.getId();

    if (writeUserOperationLog) {
      userOperationLogManager.logProcessDefinitionOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE, processDefinitionId, processDefinition.getKey(),
          new PropertyChange("cascade", false, cascadeToHistory));
    }

    definitionManager.deleteProcessDefinition(processDefinition, processDefinitionId, cascadeToHistory, cascadeToInstances, skipCustomListeners, skipIoMappings);
  }

  if (newLatestProcessDefinition != null) {
    ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
    DeploymentCache deploymentCache = configuration.getDeploymentCache();
    newLatestProcessDefinition = deploymentCache.resolveProcessDefinition(newLatestProcessDefinition);

    List<Deployer> deployers = configuration.getDeployers();
    for (Deployer deployer : deployers) {
      if (deployer instanceof BpmnDeployer) {
        ((BpmnDeployer) deployer).addEventSubscriptions(newLatestProcessDefinition);
      }
    }
  }
}
 
Example 4
Source File: DeleteDeploymentCmd.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public Void execute(final CommandContext commandContext) {
  ensureNotNull("deploymentId", deploymentId);

  for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
    checker.checkDeleteDeployment(deploymentId);
  }

  UserOperationLogManager logManager = commandContext.getOperationLogManager();
  List<PropertyChange> propertyChanges = Arrays.asList(new PropertyChange("cascade", null, cascade));
  logManager.logDeploymentOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE, deploymentId, propertyChanges);

  commandContext
    .getDeploymentManager()
    .deleteDeployment(deploymentId, cascade, skipCustomListeners, skipIoMappings);

  ProcessApplicationReference processApplicationReference = Context
    .getProcessEngineConfiguration()
    .getProcessApplicationManager()
    .getProcessApplicationForDeployment(deploymentId);

  DeleteDeploymentFailListener listener = new DeleteDeploymentFailListener(deploymentId, processApplicationReference,
    Context.getProcessEngineConfiguration().getCommandExecutorTxRequiresNew());

  try {
    commandContext.runWithoutAuthorization(new Callable<Void>() {
      public Void call() throws Exception {
        new UnregisterProcessApplicationCmd(deploymentId, false).execute(commandContext);
        new UnregisterDeploymentCmd(Collections.singleton(deploymentId)).execute(commandContext);
        return null;
      }
    });
  } finally {
    try {
      commandContext.getTransactionContext().addTransactionListener(TransactionState.ROLLED_BACK, listener);
    }
    catch (Exception e) {
      TX_LOG.debugTransactionOperation("Could not register transaction synchronization. Probably the TX has already been rolled back by application code.");
      listener.execute(commandContext);
    }
  }


  return null;
}