Search in sources :

Example 6 with JobDefinitionManager

use of org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager in project camunda-bpm-platform by camunda.

the class AbstractSetJobDefinitionStateCmd method checkAuthorization.

@Override
protected void checkAuthorization(CommandContext commandContext) {
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        if (jobDefinitionId != null) {
            JobDefinitionManager jobDefinitionManager = commandContext.getJobDefinitionManager();
            JobDefinitionEntity jobDefinition = jobDefinitionManager.findById(jobDefinitionId);
            if (jobDefinition != null && jobDefinition.getProcessDefinitionKey() != null) {
                String processDefinitionKey = jobDefinition.getProcessDefinitionKey();
                checker.checkUpdateProcessDefinitionByKey(processDefinitionKey);
                if (includeSubResources) {
                    checker.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
                }
            }
        } else if (processDefinitionId != null) {
            checker.checkUpdateProcessDefinitionById(processDefinitionId);
            if (includeSubResources) {
                checker.checkUpdateProcessInstanceByProcessDefinitionId(processDefinitionId);
            }
        } else if (processDefinitionKey != null) {
            checker.checkUpdateProcessDefinitionByKey(processDefinitionKey);
            if (includeSubResources) {
                checker.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
            }
        }
    }
}
Also used : JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) JobDefinitionManager(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 7 with JobDefinitionManager

use of org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager in project camunda-bpm-platform by camunda.

the class AbstractSetJobStateCmd method checkAuthorization.

@Override
protected void checkAuthorization(CommandContext commandContext) {
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        if (jobId != null) {
            JobManager jobManager = commandContext.getJobManager();
            JobEntity job = jobManager.findJobById(jobId);
            if (job != null) {
                String processInstanceId = job.getProcessInstanceId();
                if (processInstanceId != null) {
                    checker.checkUpdateProcessInstanceById(processInstanceId);
                } else {
                    // start timer job is not assigned to a specific process
                    // instance, that's why we have to check whether there
                    // exists a UPDATE_INSTANCES permission on process definition or
                    // a UPDATE permission on any process instance
                    String processDefinitionKey = job.getProcessDefinitionKey();
                    if (processDefinitionKey != null) {
                        checker.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
                    }
                }
            // if (processInstanceId == null && processDefinitionKey == null):
            // job is not assigned to any process instance nor process definition
            // then it is always possible to activate/suspend the corresponding job
            // -> no authorization check necessary
            }
        } else if (jobDefinitionId != null) {
            JobDefinitionManager jobDefinitionManager = commandContext.getJobDefinitionManager();
            JobDefinitionEntity jobDefinition = jobDefinitionManager.findById(jobDefinitionId);
            if (jobDefinition != null) {
                String processDefinitionKey = jobDefinition.getProcessDefinitionKey();
                checker.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
            }
        } else if (processInstanceId != null) {
            checker.checkUpdateProcessInstanceById(processInstanceId);
        } else if (processDefinitionId != null) {
            checker.checkUpdateProcessInstanceByProcessDefinitionId(processDefinitionId);
        } else if (processDefinitionKey != null) {
            checker.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
        }
    }
}
Also used : JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) JobDefinitionManager(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager) JobManager(org.camunda.bpm.engine.impl.persistence.entity.JobManager) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Aggregations

JobDefinitionManager (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager)7 JobDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity)5 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)3 JobManager (org.camunda.bpm.engine.impl.persistence.entity.JobManager)2 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1 HistoricIncidentManager (org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentManager)1 HistoricJobLogManager (org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogManager)1 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)1 PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)1 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)1