Пример #1
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();
                }
            }
        }