Search in sources :

Example 16 with JobDefinitionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity 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

JobDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity)16 JobDefinitionManager (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager)5 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)5 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)3 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)3 MigratingJobInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingJobInstance)2 IncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 ParameterValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)1 HistoryLevel (org.camunda.bpm.engine.impl.history.HistoryLevel)1 HistoryEvent (org.camunda.bpm.engine.impl.history.event.HistoryEvent)1 HistoryEventProcessor (org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor)1 HistoryEventProducer (org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1 TimerDeclarationImpl (org.camunda.bpm.engine.impl.jobexecutor.TimerDeclarationImpl)1 MigratingActivityInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance)1 MigratingAsyncJobInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingAsyncJobInstance)1