Example #1
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)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.pvm.PvmActivity currentActivity = execution.getActivity();
            PvmActivity currentActivity = execution.Activity;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final EscalationEventDefinitionFinder escalationEventDefinitionFinder = new EscalationEventDefinitionFinder(escalation.getEscalationCode(), currentActivity);
            EscalationEventDefinitionFinder   escalationEventDefinitionFinder   = new EscalationEventDefinitionFinder(this, escalation.EscalationCode, currentActivity);
            ActivityExecutionMappingCollector activityExecutionMappingCollector = new ActivityExecutionMappingCollector(execution);

            ActivityExecutionHierarchyWalker walker = new ActivityExecutionHierarchyWalker(execution);

            walker.addScopePreVisitor(escalationEventDefinitionFinder);
            walker.addExecutionPreVisitor(activityExecutionMappingCollector);
            walker.addExecutionPreVisitor(new OutputVariablesPropagator());

            walker.walkUntil(new WalkConditionAnonymousInnerClass(this, escalationEventDefinitionFinder));

            EscalationEventDefinition escalationEventDefinition = escalationEventDefinitionFinder.EscalationEventDefinition;

            if (escalationEventDefinition != null)
            {
                executeEscalationHandler(escalationEventDefinition, activityExecutionMappingCollector);
            }

            if (escalationEventDefinition == null || !escalationEventDefinition.CancelActivity)
            {
                leaveExecution(execution, currentActivity, escalationEventDefinition);
            }
        }
        public virtual void execute(IActivityExecution execution)
        {
            var currentActivity = execution.Activity;

            var escalationEventDefinitionFinder = new EscalationEventDefinitionFinder(this, Escalation.EscalationCode,
                                                                                      currentActivity);
            var activityExecutionMappingCollector = new ActivityExecutionMappingCollector(execution);

            var walker = new ActivityExecutionHierarchyWalker(execution);

            walker.AddScopePreVisitor(escalationEventDefinitionFinder);
            walker.AddExecutionPreVisitor(activityExecutionMappingCollector);
            walker.AddExecutionPreVisitor(new OutputVariablesPropagator());

            walker.WalkUntil((element) => escalationEventDefinitionFinder.EscalationEventDefinition != null || element == null);

            var escalationEventDefinition = escalationEventDefinitionFinder.EscalationEventDefinition;

            if (escalationEventDefinition != null)
            {
                executeEscalationHandler(escalationEventDefinition, activityExecutionMappingCollector);
            }

            if ((escalationEventDefinition == null) || !escalationEventDefinition.CancelActivity)
            {
                LeaveExecution(execution, currentActivity, escalationEventDefinition);
            }
        }
        protected internal virtual void PropagateError(string errorCode, string errorMessage, System.Exception origException,
                                                       IActivityExecution execution)
        {
            var walker = new ActivityExecutionHierarchyWalker(execution);

            var errorDeclarationFinder = new ErrorDeclarationForProcessInstanceFinder(this, origException, errorCode,
                                                                                      execution.Activity);
            var activityExecutionMappingCollector = new ActivityExecutionMappingCollector(execution);

            walker.AddScopePreVisitor(errorDeclarationFinder);
            walker.AddExecutionPreVisitor(activityExecutionMappingCollector);
            // map variables to super executions in the hierarchy of called process instances
            walker.AddExecutionPreVisitor(new OutputVariablesPropagator());

            try
            {
                walker.WalkUntil((element) => errorDeclarationFinder.ErrorEventDefinition != null || element == null);
            }
            catch (System.Exception e)
            {
                //separate the exception handling to support a fail-safe error propagation
                throw new ErrorPropagationException(this, e);
            }

            var errorHandlingActivity = errorDeclarationFinder.ErrorHandlerActivity;

            // process the error
            if (errorHandlingActivity == null)
            {
                if (origException == null)
                {
                    Log.MissingBoundaryCatchEvent(execution.Activity.Id, errorCode);
                    execution.End(true);
                }
                else
                {
                    // throw original exception
                    throw origException;
                }
            }
            else
            {
                var errorDefinition        = errorDeclarationFinder.ErrorEventDefinition;
                var errorHandlingExecution =
                    activityExecutionMappingCollector.GetExecutionForScope(errorHandlingActivity.EventScope);

                if (!ReferenceEquals(errorDefinition.ErrorCodeVariable, null))
                {
                    errorHandlingExecution.SetVariable(errorDefinition.ErrorCodeVariable, errorCode);
                }
                if (!ReferenceEquals(errorDefinition.ErrorMessageVariable, null))
                {
                    errorHandlingExecution.SetVariable(errorDefinition.ErrorMessageVariable, errorMessage);
                }
                errorHandlingExecution.ExecuteActivity(errorHandlingActivity);
            }
        }
Example #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void propagateError(String errorCode, String errorMessage, Exception origException, org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution execution) throws Exception
        public static void propagateError(string errorCode, string errorMessage, Exception origException, ActivityExecution execution)
        {
            ActivityExecutionHierarchyWalker walker = new ActivityExecutionHierarchyWalker(execution);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final ErrorDeclarationForProcessInstanceFinder errorDeclarationFinder = new ErrorDeclarationForProcessInstanceFinder(origException, errorCode, execution.getActivity());
            ErrorDeclarationForProcessInstanceFinder errorDeclarationFinder            = new ErrorDeclarationForProcessInstanceFinder(origException, errorCode, execution.Activity);
            ActivityExecutionMappingCollector        activityExecutionMappingCollector = new ActivityExecutionMappingCollector(execution);

            walker.addScopePreVisitor(errorDeclarationFinder);
            walker.addExecutionPreVisitor(activityExecutionMappingCollector);
            // map variables to super executions in the hierarchy of called process instances
            walker.addExecutionPreVisitor(new OutputVariablesPropagator());

            try
            {
                walker.walkUntil(new WalkConditionAnonymousInnerClass(errorDeclarationFinder));
            }
            catch (Exception e)
            {
                LOG.errorPropagationException(execution.ActivityInstanceId, e);

                // separate the exception handling to support a fail-safe error propagation
                throw new ErrorPropagationException(e.InnerException);
            }

            PvmActivity errorHandlingActivity = errorDeclarationFinder.ErrorHandlerActivity;

            // process the error
            if (errorHandlingActivity == null)
            {
                if (origException == null)
                {
                    if (Context.CommandContext.ProcessEngineConfiguration.EnableExceptionsAfterUnhandledBpmnError)
                    {
                        throw LOG.missingBoundaryCatchEventError(execution.Activity.Id, errorCode);
                    }
                    else
                    {
                        LOG.missingBoundaryCatchEvent(execution.Activity.Id, errorCode);
                        execution.end(true);
                    }
                }
                else
                {
                    // throw original exception
                    throw origException;
                }
            }
            else
            {
                ErrorEventDefinition errorDefinition        = errorDeclarationFinder.ErrorEventDefinition;
                PvmExecutionImpl     errorHandlingExecution = activityExecutionMappingCollector.getExecutionForScope(errorHandlingActivity.EventScope);

                if (!string.ReferenceEquals(errorDefinition.ErrorCodeVariable, null))
                {
                    errorHandlingExecution.setVariable(errorDefinition.ErrorCodeVariable, errorCode);
                }
                if (!string.ReferenceEquals(errorDefinition.ErrorMessageVariable, null))
                {
                    errorHandlingExecution.setVariable(errorDefinition.ErrorMessageVariable, errorMessage);
                }
                errorHandlingExecution.executeActivity(errorHandlingActivity);
            }
        }