Search in sources :

Example 51 with CommandChecker

use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.

the class GetDeploymentResourceCmd method execute.

public InputStream execute(CommandContext commandContext) {
    ensureNotNull("deploymentId", deploymentId);
    ensureNotNull("resourceName", resourceName);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkReadDeployment(deploymentId);
    }
    ResourceEntity resource = commandContext.getResourceManager().findResourceByDeploymentIdAndResourceName(deploymentId, resourceName);
    ensureNotNull(DeploymentResourceNotFoundException.class, "no resource found with name '" + resourceName + "' in deployment '" + deploymentId + "'", "resource", resource);
    return new ByteArrayInputStream(resource.getBytes());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ResourceEntity(org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 52 with CommandChecker

use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.

the class DeleteHistoricCaseInstanceCmd method execute.

public Object execute(CommandContext commandContext) {
    ensureNotNull("caseInstanceId", caseInstanceId);
    // Check if case instance is still running
    HistoricCaseInstance instance = commandContext.getHistoricCaseInstanceManager().findHistoricCaseInstance(caseInstanceId);
    ensureNotNull("No historic case instance found with id: " + caseInstanceId, "instance", instance);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkDeleteHistoricCaseInstance(instance);
    }
    ensureNotNull("Case instance is still running, cannot delete historic case instance: " + caseInstanceId, "instance.getCloseTime()", instance.getCloseTime());
    commandContext.getHistoricCaseInstanceManager().deleteHistoricCaseInstancesByIds(Arrays.asList(caseInstanceId));
    return null;
}
Also used : HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 53 with CommandChecker

use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.

the class DeleteHistoricProcessInstancesCmd method execute.

@Override
public Void execute(CommandContext commandContext) {
    ensureNotEmpty(BadUserRequestException.class, "processInstanceIds", processInstanceIds);
    ensureNotContainsNull(BadUserRequestException.class, "processInstanceId is null", "processInstanceIds", processInstanceIds);
    // Check if process instance is still running
    List<HistoricProcessInstance> instances = commandContext.runWithoutAuthorization(new Callable<List<HistoricProcessInstance>>() {

        @Override
        public List<HistoricProcessInstance> call() throws Exception {
            return new HistoricProcessInstanceQueryImpl().processInstanceIds(new HashSet<String>(processInstanceIds)).list();
        }
    });
    if (processInstanceIds.size() == 1) {
        ensureNotEmpty(BadUserRequestException.class, "No historic process instance found with id: " + processInstanceIds.get(0), "historicProcessInstanceIds", instances);
    } else {
        ensureNotEmpty(BadUserRequestException.class, "No historic process instances found", "historicProcessInstanceIds", instances);
    }
    // check if all historicProcessInstances were found
    List<String> existingIds = new ArrayList<String>();
    for (HistoricProcessInstance historicProcessInstance : instances) {
        existingIds.add(historicProcessInstance.getId());
        for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
            checker.checkDeleteHistoricProcessInstance(historicProcessInstance);
        }
        ensureNotNull(BadUserRequestException.class, "Process instance is still running, cannot delete historic process instance: " + historicProcessInstance, "instance.getEndTime()", historicProcessInstance.getEndTime());
    }
    ArrayList<String> nonExistingIds = new ArrayList<String>(processInstanceIds);
    nonExistingIds.removeAll(existingIds);
    ensureNumberOfElements(BadUserRequestException.class, "No historic process instances found with ids " + nonExistingIds, "nonExistingIds", nonExistingIds, 0);
    commandContext.getHistoricProcessInstanceManager().deleteHistoricProcessInstanceByIds(processInstanceIds);
    return null;
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) HistoricProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl) ArrayList(java.util.ArrayList) List(java.util.List)

Example 54 with CommandChecker

use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.

the class EvaluateDecisionTableCmd method execute.

@Override
public DmnDecisionTableResult execute(CommandContext commandContext) {
    ensureOnlyOneNotNull("either decision definition id or key must be set", decisionDefinitionId, decisionDefinitionKey);
    DecisionDefinition decisionDefinition = getDecisionDefinition(commandContext);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkEvaluateDecision(decisionDefinition);
    }
    return doEvaluateDecision(decisionDefinition, variables);
}
Also used : CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Example 55 with CommandChecker

use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.

the class GetDeploymentDecisionRequirementsDefinitionCmd method execute.

public DecisionRequirementsDefinition execute(CommandContext commandContext) {
    ensureNotNull("decisionRequirementsDefinitionId", decisionRequirementsDefinitionId);
    DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache();
    DecisionRequirementsDefinitionEntity decisionRequirementsDefinition = deploymentCache.findDeployedDecisionRequirementsDefinitionById(decisionRequirementsDefinitionId);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkReadDecisionRequirementsDefinition(decisionRequirementsDefinition);
    }
    return decisionRequirementsDefinition;
}
Also used : DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker) DecisionRequirementsDefinitionEntity(org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionRequirementsDefinitionEntity)

Aggregations

CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)59 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)14 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)10 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)8 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)7 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)6 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)6 InputStream (java.io.InputStream)5 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)4 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)3 DecisionDefinitionEntity (org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionEntity)3 TaskFormHandler (org.camunda.bpm.engine.impl.form.handler.TaskFormHandler)3 ExternalTaskEntity (org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity)3 JobDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity)3 JobDefinitionManager (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager)3 PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)3 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)3 TaskManager (org.camunda.bpm.engine.impl.persistence.entity.TaskManager)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2