Пример #1
0
        public virtual T execute(CommandContext commandContext)
        {
            T result = command.execute(commandContext);

            controllableThread.returnControlToTestThreadAndWait();
            return(result);
        }
Пример #2
0
        public virtual Void execute(CommandContext commandContext)
        {
            ensureNotNull(typeof(NotValidException), "jobDefinitionId", jobDefinitionId);

            JobDefinitionEntity jobDefinition = commandContext.JobDefinitionManager.findById(jobDefinitionId);

            ensureNotNull(typeof(NotFoundException), "Job definition with id '" + jobDefinitionId + "' does not exist", "jobDefinition", jobDefinition);

            checkUpdateProcess(commandContext, jobDefinition);

            long?currentPriority = jobDefinition.OverridingJobPriority;

            jobDefinition.JobPriority = priority;

            UserOperationLogContext opLogContext = new UserOperationLogContext();

            createJobDefinitionOperationLogEntry(opLogContext, currentPriority, jobDefinition);

            if (cascade && priority != null)
            {
                commandContext.JobManager.updateJobPriorityByDefinitionId(jobDefinitionId, priority.Value);
                createCascadeJobsOperationLogEntry(opLogContext, jobDefinition);
            }

            commandContext.OperationLogManager.logUserOperations(opLogContext);

            return(null);
        }
Пример #3
0
 protected internal virtual void logJobSuccess(CommandContext commandContext)
 {
     if (commandContext.ProcessEngineConfiguration.MetricsEnabled)
     {
         commandContext.ProcessEngineConfiguration.MetricsRegistry.markOccurrence(Metrics.JOB_SUCCESSFUL);
     }
 }
Пример #4
0
            public Void execute(CommandContext commandContext)
            {
                // assume
                assertThat(commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), historicByteArrayId[0]), nullValue());

                return(null);
            }
Пример #5
0
	  public virtual Void execute(CommandContext commandContext)
	  {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.runtime.Incident incident = commandContext.getIncidentManager().findIncidentById(incidentId);
		Incident incident = commandContext.IncidentManager.findIncidentById(incidentId);

		EnsureUtil.ensureNotNull(typeof(NotFoundException), "Cannot find an incident with id '" + incidentId + "'", "incident", incident);

		if (incident.IncidentType.Equals("failedJob") || incident.IncidentType.Equals("failedExternalTask"))
		{
		  throw new BadUserRequestException("Cannot resolve an incident of type " + incident.IncidentType);
		}

		EnsureUtil.ensureNotNull(typeof(BadUserRequestException), "", "executionId", incident.ExecutionId);
		ExecutionEntity execution = commandContext.ExecutionManager.findExecutionById(incident.ExecutionId);

		EnsureUtil.ensureNotNull(typeof(BadUserRequestException), "Cannot find an execution for an incident with id '" + incidentId + "'", "execution", execution);

		foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
		{
		  checker.checkUpdateProcessInstance(execution);
		}

		commandContext.OperationLogManager.logProcessInstanceOperation(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_RESOLVE, execution.ProcessInstanceId, execution.ProcessDefinitionId, null, Collections.singletonList(new PropertyChange("incidentId", null, incidentId)));

		execution.resolveIncident(incidentId);
		return null;
	  }
Пример #6
0
 protected internal override void checkParameters(CommandContext commandContext)
 {
     if (string.ReferenceEquals(jobId, null) && string.ReferenceEquals(jobDefinitionId, null) && string.ReferenceEquals(processInstanceId, null) && string.ReferenceEquals(processDefinitionId, null) && string.ReferenceEquals(processDefinitionKey, null))
     {
         throw new ProcessEngineException("Job id, job definition id, process instance id, process definition id nor process definition key cannot be null");
     }
 }
Пример #7
0
 protected internal virtual void logExclusiveJobAdded(CommandContext commandContext)
 {
     if (commandContext.ProcessEngineConfiguration.MetricsEnabled)
     {
         commandContext.ProcessEngineConfiguration.MetricsRegistry.markOccurrence(Metrics.JOB_LOCKED_EXCLUSIVE);
     }
 }
Пример #8
0
            public Void execute(CommandContext commandContext)
            {
                // camunda-admin should access data from all tenants
                assertThat(commandContext.TenantManager.TenantCheckEnabled, @is(false));

                return(null);
            }
Пример #9
0
        protected internal override void updateSuspensionState(CommandContext commandContext, SuspensionState suspensionState)
        {
            JobManager jobManager = commandContext.JobManager;

            if (!string.ReferenceEquals(jobId, null))
            {
                jobManager.updateJobSuspensionStateById(jobId, suspensionState);
            }
            else if (!string.ReferenceEquals(jobDefinitionId, null))
            {
                jobManager.updateJobSuspensionStateByJobDefinitionId(jobDefinitionId, suspensionState);
            }
            else if (!string.ReferenceEquals(processInstanceId, null))
            {
                jobManager.updateJobSuspensionStateByProcessInstanceId(processInstanceId, suspensionState);
            }
            else if (!string.ReferenceEquals(processDefinitionId, null))
            {
                jobManager.updateJobSuspensionStateByProcessDefinitionId(processDefinitionId, suspensionState);
            }
            else if (!string.ReferenceEquals(processDefinitionKey, null))
            {
                if (!processDefinitionTenantIdSet)
                {
                    jobManager.updateJobSuspensionStateByProcessDefinitionKey(processDefinitionKey, suspensionState);
                }
                else
                {
                    jobManager.updateJobSuspensionStateByProcessDefinitionKeyAndTenantId(processDefinitionKey, processDefinitionTenantId, suspensionState);
                }
            }
        }
Пример #10
0
        public virtual object execute(CommandContext commandContext)
        {
            AuthorizationManager authorizationManager = commandContext.AuthorizationManager;

            authorizationManager.checkCamundaAdmin();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.persistence.entity.PropertyManager propertyManager = commandContext.getPropertyManager();
            PropertyManager propertyManager = commandContext.PropertyManager;

            PropertyEntity property  = propertyManager.findPropertyById(name);
            string         operation = null;

            if (property != null)
            {
                // update
                property.Value = value;
                operation      = org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_UPDATE;
            }
            else
            {
                // create
                property = new PropertyEntity(name, value);
                propertyManager.insert(property);
                operation = org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_CREATE;
            }

            commandContext.OperationLogManager.logPropertyOperation(operation, Collections.singletonList(new PropertyChange("name", null, name)));

            return(null);
        }
Пример #11
0
 public void execute(CommandContext commandContext)
 {
     if (outerInstance.TransactionActive)
     {
         outerInstance.entityManager.Transaction.rollback();
     }
 }
Пример #12
0
 protected internal virtual void checkAccess(CommandContext commandContext, BatchEntity batch)
 {
     foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
     {
         checkAccess(checker, batch);
     }
 }
Пример #13
0
        public virtual Authorization execute(CommandContext commandContext)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.persistence.entity.AuthorizationManager authorizationManager = commandContext.getAuthorizationManager();
            AuthorizationManager authorizationManager = commandContext.AuthorizationManager;

            authorizationManager.validateResourceCompatibility(authorization);

            string operationType = null;
            AuthorizationEntity previousValues = null;

            if (string.ReferenceEquals(authorization.Id, null))
            {
                authorizationManager.insert(authorization);
                operationType = org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_CREATE;
            }
            else
            {
                previousValues = commandContext.DbEntityManager.selectById(typeof(AuthorizationEntity), authorization.Id);
                authorizationManager.update(authorization);
                operationType = org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_UPDATE;
            }
            commandContext.OperationLogManager.logAuthorizationOperation(operationType, authorization, previousValues);

            return(authorization);
        }
Пример #14
0
 protected internal virtual void checkCreateTask(CommandContext commandContext)
 {
     foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
     {
         checker.checkCreateTask();
     }
 }
Пример #15
0
            public Void execute(CommandContext commandContext)
            {
                DbSqlSession sqlSession = commandContext.getSession(typeof(DbSqlSession));

                assertTrue(sqlSession.isTablePresent("SOME_TABLE"));
                return(null);
            }
Пример #16
0
        protected internal override void checkAuthorization(CommandContext commandContext)
        {
            foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
            {
                if (!string.ReferenceEquals(processDefinitionId, null))
                {
                    checker.checkUpdateProcessDefinitionSuspensionStateById(processDefinitionId);

                    if (includeSubResources)
                    {
                        checker.checkUpdateProcessInstanceSuspensionStateByProcessDefinitionId(processDefinitionId);
                    }
                }
                else
                {
                    if (!string.ReferenceEquals(processDefinitionKey, null))
                    {
                        checker.checkUpdateProcessDefinitionSuspensionStateByKey(processDefinitionKey);

                        if (includeSubResources)
                        {
                            checker.checkUpdateProcessInstanceSuspensionStateByProcessDefinitionKey(processDefinitionKey);
                        }
                    }
                }
            }
        }
Пример #17
0
 protected internal virtual void checkAuthorizations(CommandContext commandContext, Permission permission)
 {
     foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
     {
         checker.checkCreateBatch(permission);
     }
 }
Пример #18
0
            public ProcessApplicationReference execute(CommandContext commandContext)
            {
                ProcessDefinitionEntity definition = commandContext.ProcessDefinitionManager.findLatestProcessDefinitionByKey(PROCESS_ID);
                string deploymentId = definition.DeploymentId;
                ProcessApplicationManager processApplicationManager = outerInstance.processEngineConfiguration.ProcessApplicationManager;

                return(processApplicationManager.getProcessApplicationForDeployment(deploymentId));
            }
Пример #19
0
        protected internal virtual void triggerExecution(CommandContext commandContext, CorrelationHandlerResult correlationResult)
        {
            string executionId = correlationResult.ExecutionEntity.Id;

            MessageEventReceivedCmd command = new MessageEventReceivedCmd(messageName, executionId, builder.PayloadProcessInstanceVariables, builder.PayloadProcessInstanceVariablesLocal, builder.ExclusiveCorrelation);

            command.execute(commandContext);
        }
Пример #20
0
 protected internal override void checkParameters(CommandContext commandContext)
 {
     // Validation of input parameters
     if (string.ReferenceEquals(processDefinitionId, null) && string.ReferenceEquals(processDefinitionKey, null))
     {
         throw new ProcessEngineException("Process definition id / key cannot be null");
     }
 }
Пример #21
0
            public Void execute(CommandContext commandContext)
            {
                // cannot enable tenant check for command when it is disabled for process engine
                commandContext.enableTenantCheck();
                assertThat(commandContext.TenantManager.TenantCheckEnabled, @is(false));

                return(null);
            }
Пример #22
0
            public Void execute(CommandContext commandContext)
            {
                // assert that it is enabled again for further commands
                assertThat(commandContext.TenantCheckEnabled, @is(true));
                assertThat(commandContext.TenantManager.TenantCheckEnabled, @is(true));

                return(null);
            }
Пример #23
0
            public Void execute(CommandContext commandContext)
            {
                HistoricVariableInstanceEntity historicVariableInstanceEntity = (HistoricVariableInstanceEntity)outerInstance.historyService.createHistoricVariableInstanceQuery().singleResult();

                commandContext.DbEntityManager.delete(historicVariableInstanceEntity);

                return(null);
            }
Пример #24
0
        protected internal override void checkAuthorization(CommandContext commandContext)
        {
            TaskEntity taskEntity = commandContext.TaskManager.findTaskById(taskId);

            foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
            {
                checker.checkReadTask(taskEntity);
            }
        }
Пример #25
0
            public Void execute(CommandContext commandContext)
            {
                // disable tenant check for the current command
                commandContext.disableTenantCheck();
                assertThat(commandContext.TenantCheckEnabled, @is(false));
                assertThat(commandContext.TenantManager.TenantCheckEnabled, @is(false));

                return(null);
            }
Пример #26
0
        public virtual Task execute(CommandContext commandContext)
        {
            checkCreateTask(commandContext);

            TaskEntity task = TaskEntity.create();

            task.Id = taskId;
            return(task);
        }
Пример #27
0
                public Void execute(CommandContext context)
                {
                    IdentityInfoManager identityInfoManager = Context.CommandContext.getSession(typeof(IdentityInfoManager));

                    UserEntity userEntity = (UserEntity)identityService.createUserQuery().userId(USER_ID).singleResult();

                    identityInfoManager.updateUserLock(userEntity, 10, TIMESTAMP);
                    return(null);
                }
Пример #28
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void handleInvocationInContext(final DelegateInvocation invocation) throws Exception
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        protected internal virtual void handleInvocationInContext(DelegateInvocation invocation)
        {
            CommandContext        commandContext = Context.CommandContext;
            bool                  wasAuthorizationCheckEnabled = commandContext.AuthorizationCheckEnabled;
            bool                  wasUserOperationLogEnabled   = commandContext.UserOperationLogEnabled;
            BaseDelegateExecution contextExecution             = invocation.ContextExecution;

            ProcessEngineConfigurationImpl configuration = Context.ProcessEngineConfiguration;

            bool popExecutionContext = false;

            try
            {
                if (!configuration.AuthorizationEnabledForCustomCode)
                {
                    // 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
                {
                    if (wasUserOperationLogEnabled)
                    {
                        commandContext.enableUserOperationLog();
                    }
                }
            }
            finally
            {
                if (wasAuthorizationCheckEnabled)
                {
                    commandContext.enableAuthorizationCheck();
                }
            }
        }
Пример #29
0
            public override Void execute(CommandContext commandContext)
            {
                outerInstance.historyService.createHistoricVariableInstanceQuery().singleResult().Id;   // cache

                monitor.sync();

                commandContext.ProcessEngineConfiguration.RuntimeService.setVariable(processInstanceId, outerInstance.VARIABLE_NAME, outerInstance.ANOTHER_VARIABLE_VALUE);

                return(null);
            }
Пример #30
0
        public object execute(CommandContext commandContext)
        {
            string databaseSchemaUpdate = Context.ProcessEngineConfiguration.DatabaseSchemaUpdate;

            if (ProcessEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP.Equals(databaseSchemaUpdate))
            {
                commandContext.getSession(typeof(PersistenceSession)).dbSchemaDrop();
            }
            return(null);
        }