コード例 #1
0
        protected internal virtual bool matchesSubscription(EventSubscriptionEntity subscription,string type,string eventName)
        {
            EnsureUtil.ensureNotNull("event type",type);
            string subscriptionEventName = subscription.EventName;

            return(type.Equals(subscription.EventType) && ((string.ReferenceEquals(eventName,null) && string.ReferenceEquals(subscriptionEventName,null)) || (!string.ReferenceEquals(eventName,null) && eventName.Equals(subscriptionEventName))));
        }
コード例 #2
0
        public virtual Void execute(CommandContext commandContext)
        {
            ensureNotNull("taskId", taskId);

            TaskManager taskManager = commandContext.TaskManager;

            task = taskManager.findTaskById(taskId);
            EnsureUtil.ensureNotNull("Cannot find task with id " + taskId, "task", task);

            checkAddIdentityLink(task, commandContext);

            if (IdentityLinkType.ASSIGNEE.Equals(type))
            {
                task.Assignee = userId;
            }
            else if (IdentityLinkType.OWNER.Equals(type))
            {
                task.Owner = userId;
            }
            else
            {
                task.addIdentityLink(userId, groupId, type);
            }

            return(null);
        }
コード例 #3
0
        public virtual BatchDto setRetries(SetJobRetriesDto setJobRetriesDto)
        {
            try
            {
                EnsureUtil.ensureNotNull("setJobRetriesDto", setJobRetriesDto);
                EnsureUtil.ensureNotNull("retries", setJobRetriesDto.Retries);
            }
            catch (NullValueException e)
            {
                throw new InvalidRequestException(Status.BAD_REQUEST, e.Message);
            }
            JobQuery jobQuery = null;

            if (setJobRetriesDto.JobQuery != null)
            {
                jobQuery = setJobRetriesDto.JobQuery.toQuery(ProcessEngine);
            }

            try
            {
                Batch batch = ProcessEngine.ManagementService.setJobRetriesAsync(setJobRetriesDto.JobIds, jobQuery, setJobRetriesDto.Retries.Value);
                return(BatchDto.fromBatch(batch));
            }
            catch (BadUserRequestException e)
            {
                throw new InvalidRequestException(Status.BAD_REQUEST, e.Message);
            }
        }
コード例 #4
0
 protected internal virtual void ensureExecutionInitialized()
 {
     if (execution == null)
     {
         execution = Context.CommandContext.ExecutionManager.findExecutionById(executionId);
         EnsureUtil.ensureNotNull("Cannot find execution with id " + executionId + " for external task " + id, "execution", execution);
     }
 }
コード例 #5
0
        // byte array delete ////////////////////////////////////////////////////////

        protected internal virtual void deleteExceptionByteArrayByParameterMap(string key, object value)
        {
            EnsureUtil.ensureNotNull(key, value);
            IDictionary <string, object> parameterMap = new Dictionary <string, object>();

            parameterMap[key] = value;
            DbEntityManager.delete(typeof(ByteArrayEntity), "deleteExceptionByteArraysByIds", parameterMap);
        }
コード例 #6
0
        /// <summary>
        /// Initialize <seealso cref="historyEventHandlers"/> with data transfered from constructor
        /// </summary>
        /// <param name="historyEventHandlers"> </param>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void initializeHistoryEventHandlers(final java.util.List<HistoryEventHandler> historyEventHandlers)
        private void initializeHistoryEventHandlers(IList <HistoryEventHandler> historyEventHandlers)
        {
            EnsureUtil.ensureNotNull("History event handler", historyEventHandlers);
            foreach (HistoryEventHandler historyEventHandler in historyEventHandlers)
            {
                EnsureUtil.ensureNotNull("History event handler", historyEventHandler);
                this.historyEventHandlers.Add(historyEventHandler);
            }
        }
コード例 #7
0
        public virtual Void execute(CommandContext commandContext)
        {
            ProcessDefinitionEntity processDefinition = Context.CommandContext.ProcessDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);

            EnsureUtil.ensureNotNull("Cannot find process definition with id " + processDefinitionId, "processDefinition", processDefinition);

            processDefinition.addIdentityLink(userId, groupId);
            return(null);
        }
コード例 #8
0
        protected internal virtual ProcessDefinitionEntity resolveTargetProcessDefinition(CommandContext commandContext)
        {
            string targetProcessDefinitionId = executionBuilder.MigrationPlan.TargetProcessDefinitionId;

            ProcessDefinitionEntity sourceProcessDefinition = getProcessDefinition(commandContext, targetProcessDefinitionId);

            EnsureUtil.ensureNotNull("sourceProcessDefinition", sourceProcessDefinition);

            return(sourceProcessDefinition);
        }
コード例 #9
0
        public virtual TransitionInstance[] getTransitionInstances(string activityId)
        {
            EnsureUtil.ensureNotNull("activityId", activityId);

            IList <TransitionInstance> instances = new List <TransitionInstance>();

            collectTransitionInstances(activityId, instances);

            return(instances.ToArray());
        }
コード例 #10
0
        protected internal virtual void validateInput()
        {
            EnsureUtil.ensureNotNull("workerId", workerId);
            EnsureUtil.ensureGreaterThanOrEqual("maxResults", maxResults, 0);

            foreach (TopicFetchInstruction instruction in fetchInstructions.Values)
            {
                EnsureUtil.ensureNotNull("topicName", instruction.TopicName);
                EnsureUtil.ensurePositive("lockTime", instruction.LockDuration);
            }
        }
コード例 #11
0
        public virtual Filter execute(CommandContext commandContext)
        {
            EnsureUtil.ensureNotNull("filter", filter);

            string operation = string.ReferenceEquals(filter.Id, null) ? org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_CREATE : org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_UPDATE;

            Filter savedFilter = commandContext.FilterManager.insertOrUpdateFilter(filter);

            commandContext.OperationLogManager.logFilterOperation(operation, filter.Id);

            return(savedFilter);
        }
コード例 #12
0
        protected internal virtual ProcessDefinitionEntity getProcessDefinition(CommandContext commandContext, string id, string type)
        {
            EnsureUtil.ensureNotNull(typeof(BadUserRequestException), type + " process definition id", id);

            try
            {
                return(commandContext.ProcessEngineConfiguration.DeploymentCache.findDeployedProcessDefinitionById(id));
            }
            catch (NullValueException)
            {
                throw LOG.processDefinitionDoesNotExist(id, type);
            }
        }
コード例 #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void execute(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution execution) throws Exception
        public virtual void execute(ActivityExecution execution)
        {
            EnsureUtil.ensureNotNull("Could not find cancel boundary event for cancel end event " + execution.Activity, "cancelBoundaryEvent", cancelBoundaryEvent);

            IList <EventSubscriptionEntity> compensateEventSubscriptions = CompensationUtil.collectCompensateEventSubscriptionsForScope(execution);

            if (compensateEventSubscriptions.Count == 0)
            {
                leave(execution);
            }
            else
            {
                CompensationUtil.throwCompensationEvent(compensateEventSubscriptions, execution, false);
            }
        }
コード例 #14
0
        protected internal virtual TransitionImpl findTransition(ProcessDefinitionImpl processDefinition)
        {
            PvmActivity activity = processDefinition.findActivity(activityId);

            EnsureUtil.ensureNotNull(typeof(NotValidException), describeFailure("Activity '" + activityId + "' does not exist"), "activity", activity);

            if (activity.OutgoingTransitions.Count == 0)
            {
                throw new ProcessEngineException("Cannot start after activity " + activityId + "; activity " + "has no outgoing sequence flow to take");
            }
            else if (activity.OutgoingTransitions.Count > 1)
            {
                throw new ProcessEngineException("Cannot start after activity " + activityId + "; " + "activity has more than one outgoing sequence flow");
            }

            return((TransitionImpl)activity.OutgoingTransitions[0]);
        }
コード例 #15
0
        public virtual Void execute(CommandContext commandContext)
        {
            EnsureUtil.ensureNotNull("externalTaskId", externalTaskId);
            validateInput();

            ExternalTaskEntity externalTask = commandContext.ExternalTaskManager.findExternalTaskById(externalTaskId);

            ensureNotNull(typeof(NotFoundException), "Cannot find external task with id " + externalTaskId, "externalTask", externalTask);

            foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
            {
                checker.checkUpdateProcessInstanceById(externalTask.ProcessInstanceId);
            }

            writeUserOperationLog(commandContext, externalTask, UserOperationLogOperationType, getUserOperationLogPropertyChanges(externalTask));

            execute(externalTask);

            return(null);
        }
コード例 #16
0
        public virtual PasswordPolicyResult checkPasswordAgainstPolicy(PasswordPolicy policy, string password)
        {
            EnsureUtil.ensureNotNull("policy", policy);
            EnsureUtil.ensureNotNull("password", password);

            IList <PasswordPolicyRule> violatedRules  = new List <PasswordPolicyRule>();
            IList <PasswordPolicyRule> fulfilledRules = new List <PasswordPolicyRule>();

            foreach (PasswordPolicyRule rule in policy.Rules)
            {
                if (rule.execute(password))
                {
                    fulfilledRules.Add(rule);
                }
                else
                {
                    violatedRules.Add(rule);
                }
            }
            return(new PasswordPolicyResultImpl(violatedRules, fulfilledRules));
        }
コード例 #17
0
        protected internal virtual void assignExecutionsToActivities(IList <ExecutionEntity> leaves)
        {
            foreach (ExecutionEntity leaf in leaves)
            {
                ScopeImpl activity = leaf.getActivity();

                if (activity != null)
                {
                    if (!string.ReferenceEquals(leaf.ActivityInstanceId, null))
                    {
                        EnsureUtil.ensureNotNull("activity", activity);
                        submitExecution(leaf, activity);
                    }
                    mergeScopeExecutions(leaf);
                }
                else if (leaf.ProcessInstanceExecution)
                {
                    submitExecution(leaf, leaf.getProcessDefinition());
                }
            }
        }
コード例 #18
0
        public virtual Incident execute(CommandContext commandContext)
        {
            EnsureUtil.ensureNotNull(typeof(BadUserRequestException), "Execution id cannot be null", "executionId", executionId);
            EnsureUtil.ensureNotNull(typeof(BadUserRequestException), "incidentType", incidentType);

            ExecutionEntity execution = commandContext.ExecutionManager.findExecutionById(executionId);

            EnsureUtil.ensureNotNull(typeof(BadUserRequestException), "Cannot find an execution with executionId '" + executionId + "'", "execution", execution);
            EnsureUtil.ensureNotNull(typeof(BadUserRequestException), "Execution must be related to an activity", "activity", execution.getActivity());

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

            IList <PropertyChange> propertyChanges = new List <PropertyChange>();

            propertyChanges.Add(new PropertyChange("incidentType", null, incidentType));
            propertyChanges.Add(new PropertyChange("configuration", null, configuration));

            commandContext.OperationLogManager.logProcessInstanceOperation(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_CREATE_INCIDENT, execution.ProcessInstanceId, execution.ProcessDefinitionId, null, propertyChanges);

            return(execution.createIncident(incidentType, configuration, message));
        }
コード例 #19
0
 public virtual object getValue(VariableScope variableScope)
 {
     EnsureUtil.ensureNotNull("variableScope", variableScope);
     return(expression.getValue(variableScope));
 }
コード例 #20
0
 protected internal override void validateInput()
 {
     base.validateInput();
     EnsureUtil.ensureNotNull("errorCode", errorCode);
 }
コード例 #21
0
 public EventSubscriptionJobDeclaration(EventSubscriptionDeclaration eventSubscriptionDeclaration) : base(ProcessEventJobHandler.TYPE)
 {
     EnsureUtil.ensureNotNull("eventSubscriptionDeclaration", eventSubscriptionDeclaration);
     this.eventSubscriptionDeclaration = eventSubscriptionDeclaration;
 }
コード例 #22
0
        /// <summary>
        /// Adds the <seealso cref="HistoryEventHandler"/> to the list of
        /// <seealso cref="HistoryEventHandler"/> that consume the event.
        /// </summary>
        /// <param name="historyEventHandler">
        ///          the <seealso cref="HistoryEventHandler"/> that consume the event. </param>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public void add(final HistoryEventHandler historyEventHandler)
        public virtual void add(HistoryEventHandler historyEventHandler)
        {
            EnsureUtil.ensureNotNull("History event handler", historyEventHandler);
            historyEventHandlers.Add(historyEventHandler);
        }
コード例 #23
0
 protected internal virtual void ensurePropertySaved(string name, object property)
 {
     EnsureUtil.ensureNotNull(typeof(BadUserRequestException), "The snapshot has not saved the " + name + " of the process instance", name, property);
 }
コード例 #24
0
 protected internal override void checkQueryOk()
 {
     base.checkQueryOk();
     EnsureUtil.ensureNotNull("decisionRequirementsDefinitionId", decisionRequirementsDefinitionId);
 }
コード例 #25
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public Void execute(final org.camunda.bpm.engine.impl.interceptor.CommandContext commandContext)
        public override Void execute(CommandContext commandContext)
        {
            ExecutionEntity processInstance = commandContext.ExecutionManager.findExecutionById(processInstanceId);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl processDefinition = processInstance.getProcessDefinition();
            ProcessDefinitionImpl processDefinition = processInstance.getProcessDefinition();

            CoreModelElement elementToInstantiate = getTargetElement(processDefinition);

            EnsureUtil.ensureNotNull(typeof(NotValidException), describeFailure("Element '" + TargetElementId + "' does not exist in process '" + processDefinition.Id + "'"), "element", elementToInstantiate);

            // rebuild the mapping because the execution tree changes with every iteration
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.ActivityExecutionTreeMapping mapping = new org.camunda.bpm.engine.impl.ActivityExecutionTreeMapping(commandContext, processInstanceId);
            ActivityExecutionTreeMapping mapping = new ActivityExecutionTreeMapping(commandContext, processInstanceId);

            // before instantiating an activity, two things have to be determined:
            //
            // activityStack:
            // For the activity to instantiate, we build a stack of parent flow scopes
            // for which no executions exist yet and that have to be instantiated
            //
            // scopeExecution:
            // This is typically the execution under which a new sub tree has to be created.
            // if an explicit ancestor activity instance is set:
            //   - this is the scope execution for that ancestor activity instance
            //   - throws exception if that scope execution is not in the parent hierarchy
            //     of the activity to be started
            // if no explicit ancestor activity instance is set:
            //   - this is the execution of the first parent/ancestor flow scope that has an execution
            //   - throws an exception if there is more than one such execution

            ScopeImpl targetFlowScope = getTargetFlowScope(processDefinition);

            // prepare to walk up the flow scope hierarchy and collect the flow scope activities
            ActivityStackCollector stackCollector = new ActivityStackCollector();
            FlowScopeWalker        walker         = new FlowScopeWalker(targetFlowScope);

            walker.addPreVisitor(stackCollector);

            ExecutionEntity scopeExecution = null;

            // if no explicit ancestor activity instance is set
            if (string.ReferenceEquals(ancestorActivityInstanceId, null))
            {
                // walk until a scope is reached for which executions exist
                walker.walkWhile(new WalkConditionAnonymousInnerClass(this, processDefinition, mapping));

                ISet <ExecutionEntity> flowScopeExecutions = mapping.getExecutions(walker.CurrentElement);

                if (flowScopeExecutions.Count > 1)
                {
                    throw new ProcessEngineException("Ancestor activity execution is ambiguous for activity " + targetFlowScope);
                }

                scopeExecution = flowScopeExecutions.GetEnumerator().next();
            }
            else
            {
                ActivityInstance tree = commandContext.runWithoutAuthorization(new CallableAnonymousInnerClass(this, commandContext));

                ActivityInstance ancestorInstance = findActivityInstance(tree, ancestorActivityInstanceId);
                EnsureUtil.ensureNotNull(typeof(NotValidException), describeFailure("Ancestor activity instance '" + ancestorActivityInstanceId + "' does not exist"), "ancestorInstance", ancestorInstance);

                // determine ancestor activity scope execution and activity
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity ancestorScopeExecution = getScopeExecutionForActivityInstance(processInstance, mapping, ancestorInstance);
                ExecutionEntity ancestorScopeExecution = getScopeExecutionForActivityInstance(processInstance, mapping, ancestorInstance);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.pvm.PvmScope ancestorScope = getScopeForActivityInstance(processDefinition, ancestorInstance);
                PvmScope ancestorScope = getScopeForActivityInstance(processDefinition, ancestorInstance);

                // walk until the scope of the ancestor scope execution is reached
                walker.walkWhile(new WalkConditionAnonymousInnerClass2(this, processDefinition, mapping, ancestorScopeExecution, ancestorScope));

                ISet <ExecutionEntity> flowScopeExecutions = mapping.getExecutions(walker.CurrentElement);

                if (!flowScopeExecutions.Contains(ancestorScopeExecution))
                {
                    throw new NotValidException(describeFailure("Scope execution for '" + ancestorActivityInstanceId + "' cannot be found in parent hierarchy of flow element '" + elementToInstantiate.Id + "'"));
                }

                scopeExecution = ancestorScopeExecution;
            }

            IList <PvmActivity> activitiesToInstantiate = stackCollector.ActivityStack;

            activitiesToInstantiate.Reverse();

            // We have to make a distinction between
            // - "regular" activities for which the activity stack can be instantiated and started
            //   right away
            // - interrupting or cancelling activities for which we have to ensure that
            //   the interruption and cancellation takes place before we instantiate the activity stack
            ActivityImpl topMostActivity = null;
            ScopeImpl    flowScope       = null;

            if (activitiesToInstantiate.Count > 0)
            {
                topMostActivity = (ActivityImpl)activitiesToInstantiate[0];
                flowScope       = topMostActivity.FlowScope;
            }
            else if (elementToInstantiate.GetType().IsAssignableFrom(typeof(ActivityImpl)))
            {
                topMostActivity = (ActivityImpl)elementToInstantiate;
                flowScope       = topMostActivity.FlowScope;
            }
            else if (elementToInstantiate.GetType().IsAssignableFrom(typeof(TransitionImpl)))
            {
                TransitionImpl transitionToInstantiate = (TransitionImpl)elementToInstantiate;
                flowScope = transitionToInstantiate.Source.FlowScope;
            }

            if (!supportsConcurrentChildInstantiation(flowScope))
            {
                throw new ProcessEngineException("Concurrent instantiation not possible for " + "activities in scope " + flowScope.Id);
            }

            ActivityStartBehavior startBehavior = ActivityStartBehavior.CONCURRENT_IN_FLOW_SCOPE;

            if (topMostActivity != null)
            {
                startBehavior = topMostActivity.ActivityStartBehavior;

                if (activitiesToInstantiate.Count > 0)
                {
                    // this is in BPMN relevant if there is an interrupting event sub process.
                    // we have to distinguish between instantiation of the start event and any other activity.
                    // instantiation of the start event means interrupting behavior; instantiation
                    // of any other task means no interruption.
                    PvmActivity initialActivity       = topMostActivity.Properties.get(BpmnProperties.INITIAL_ACTIVITY);
                    PvmActivity secondTopMostActivity = null;
                    if (activitiesToInstantiate.Count > 1)
                    {
                        secondTopMostActivity = activitiesToInstantiate[1];
                    }
                    else if (elementToInstantiate.GetType().IsAssignableFrom(typeof(ActivityImpl)))
                    {
                        secondTopMostActivity = (PvmActivity)elementToInstantiate;
                    }

                    if (initialActivity != secondTopMostActivity)
                    {
                        startBehavior = ActivityStartBehavior.CONCURRENT_IN_FLOW_SCOPE;
                    }
                }
            }

            switch (startBehavior)
            {
            case ActivityStartBehavior.CANCEL_EVENT_SCOPE:
            {
                ScopeImpl       scopeToCancel     = topMostActivity.EventScope;
                ExecutionEntity executionToCancel = getSingleExecutionForScope(mapping, scopeToCancel);
                if (executionToCancel != null)
                {
                    executionToCancel.deleteCascade("Cancelling activity " + topMostActivity + " executed.", skipCustomListeners, skipIoMappings);
                    instantiate(executionToCancel.Parent, activitiesToInstantiate, elementToInstantiate);
                }
                else
                {
                    ExecutionEntity flowScopeExecution = getSingleExecutionForScope(mapping, topMostActivity.FlowScope);
                    instantiateConcurrent(flowScopeExecution, activitiesToInstantiate, elementToInstantiate);
                }
                break;
            }

            case ActivityStartBehavior.INTERRUPT_EVENT_SCOPE:
            {
                ScopeImpl       scopeToCancel     = topMostActivity.EventScope;
                ExecutionEntity executionToCancel = getSingleExecutionForScope(mapping, scopeToCancel);
                executionToCancel.interrupt("Interrupting activity " + topMostActivity + " executed.", skipCustomListeners, skipIoMappings);
                executionToCancel.setActivity(null);
                executionToCancel.leaveActivityInstance();
                instantiate(executionToCancel, activitiesToInstantiate, elementToInstantiate);
                break;
            }

            case ActivityStartBehavior.INTERRUPT_FLOW_SCOPE:
            {
                ScopeImpl       scopeToCancel     = topMostActivity.FlowScope;
                ExecutionEntity executionToCancel = getSingleExecutionForScope(mapping, scopeToCancel);
                executionToCancel.interrupt("Interrupting activity " + topMostActivity + " executed.", skipCustomListeners, skipIoMappings);
                executionToCancel.setActivity(null);
                executionToCancel.leaveActivityInstance();
                instantiate(executionToCancel, activitiesToInstantiate, elementToInstantiate);
                break;
            }

            default:
            {
                // if all child executions have been cancelled
                // or this execution has ended executing its scope, it can be reused
                if (!scopeExecution.hasChildren() && (scopeExecution.getActivity() == null || scopeExecution.Ended))
                {
                    // reuse the scope execution
                    instantiate(scopeExecution, activitiesToInstantiate, elementToInstantiate);
                }
                else
                {
                    // if the activity is not cancelling/interrupting, it can simply be instantiated as
                    // a concurrent child of the scopeExecution
                    instantiateConcurrent(scopeExecution, activitiesToInstantiate, elementToInstantiate);
                }
                break;
            }
            }

            return(null);
        }
コード例 #26
0
 public FileValueBuilderImpl(string filename)
 {
     EnsureUtil.ensureNotNull("filename", filename);
     fileValue = new FileValueImpl(PrimitiveValueType.FILE, filename);
 }