Exemplo n.º 1
0
        public virtual void logExternalTaskOperation(string operation, ExternalTaskEntity externalTask, IList <PropertyChange> propertyChanges)
        {
            if (UserOperationLogEnabled)
            {
                UserOperationLogContext             context      = new UserOperationLogContext();
                UserOperationLogContextEntryBuilder entryBuilder = UserOperationLogContextEntryBuilder.entry(operation, EntityTypes.EXTERNAL_TASK).propertyChanges(propertyChanges).category(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR);

                if (externalTask != null)
                {
                    ExecutionEntity         instance   = null;
                    ProcessDefinitionEntity definition = null;
                    if (!string.ReferenceEquals(externalTask.ProcessInstanceId, null))
                    {
                        instance = ProcessInstanceManager.findExecutionById(externalTask.ProcessInstanceId);
                    }
                    else if (!string.ReferenceEquals(externalTask.ProcessDefinitionId, null))
                    {
                        definition = ProcessDefinitionManager.findLatestProcessDefinitionById(externalTask.ProcessDefinitionId);
                    }
                    entryBuilder.processInstanceId(externalTask.ProcessInstanceId).processDefinitionId(externalTask.ProcessDefinitionId).processDefinitionKey(externalTask.ProcessDefinitionKey).inContextOf(externalTask, instance, definition);
                }

                context.addEntry(entryBuilder.create());
                fireUserOperationLog(context);
            }
        }
Exemplo n.º 2
0
        public virtual void logJobDefinitionOperation(string operation, string jobDefinitionId, string processDefinitionId, string processDefinitionKey, PropertyChange propertyChange)
        {
            if (UserOperationLogEnabled)
            {
                UserOperationLogContext             context      = new UserOperationLogContext();
                UserOperationLogContextEntryBuilder entryBuilder = UserOperationLogContextEntryBuilder.entry(operation, EntityTypes.JOB_DEFINITION).jobDefinitionId(jobDefinitionId).processDefinitionId(processDefinitionId).processDefinitionKey(processDefinitionKey).propertyChanges(propertyChange).category(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR);

                if (!string.ReferenceEquals(jobDefinitionId, null))
                {
                    JobDefinitionEntity jobDefinition = JobDefinitionManager.findById(jobDefinitionId);
                    // Backward compatibility
                    if (jobDefinition != null)
                    {
                        entryBuilder.inContextOf(jobDefinition);
                    }
                }
                else if (!string.ReferenceEquals(processDefinitionId, null))
                {
                    ProcessDefinitionEntity definition = ProcessDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);
                    // Backward compatibility
                    if (definition != null)
                    {
                        entryBuilder.inContextOf(definition);
                    }
                }

                context.addEntry(entryBuilder.create());

                fireUserOperationLog(context);
            }
        }
Exemplo n.º 3
0
        public virtual void logProcessInstanceOperation(string operation, string processInstanceId, string processDefinitionId, string processDefinitionKey, IList <PropertyChange> propertyChanges)
        {
            if (UserOperationLogEnabled)
            {
                UserOperationLogContext             context      = new UserOperationLogContext();
                UserOperationLogContextEntryBuilder entryBuilder = UserOperationLogContextEntryBuilder.entry(operation, EntityTypes.PROCESS_INSTANCE).propertyChanges(propertyChanges).processInstanceId(processInstanceId).processDefinitionId(processDefinitionId).processDefinitionKey(processDefinitionKey).category(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR);

                if (!string.ReferenceEquals(processInstanceId, null))
                {
                    ExecutionEntity instance = ProcessInstanceManager.findExecutionById(processInstanceId);

                    if (instance != null)
                    {
                        entryBuilder.inContextOf(instance);
                    }
                }
                else if (!string.ReferenceEquals(processDefinitionId, null))
                {
                    ProcessDefinitionEntity definition = ProcessDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);
                    if (definition != null)
                    {
                        entryBuilder.inContextOf(definition);
                    }
                }

                context.addEntry(entryBuilder.create());
                fireUserOperationLog(context);
            }
        }
Exemplo n.º 4
0
        protected internal virtual void checkReadProcessDefinition(ActivityStatisticsQueryImpl query)
        {
            CommandContext commandContext = CommandContext;

            if (AuthorizationEnabled && CurrentAuthentication != null && commandContext.AuthorizationCheckEnabled)
            {
                string processDefinitionId         = query.ProcessDefinitionId;
                ProcessDefinitionEntity definition = ProcessDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);
                ensureNotNull("no deployed process definition found with id '" + processDefinitionId + "'", "processDefinition", definition);
                AuthorizationManager.checkAuthorization(READ, PROCESS_DEFINITION, definition.Key);
            }
        }
Exemplo n.º 5
0
        protected internal virtual bool ensureHistoryReadOnProcessDefinition(HistoricActivityStatisticsQueryImpl query)
        {
            CommandContext commandContext = CommandContext;

            if (AuthorizationEnabled && CurrentAuthentication != null && commandContext.AuthorizationCheckEnabled)
            {
                string processDefinitionId         = query.ProcessDefinitionId;
                ProcessDefinitionEntity definition = ProcessDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);

                if (definition == null)
                {
                    return(false);
                }

                return(AuthorizationManager.isAuthorized(READ_HISTORY, PROCESS_DEFINITION, definition.Key));
            }

            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Returns the cached version if exists; does not update the entity from the database in that case
        /// </summary>
        protected internal virtual ProcessDefinitionEntity loadProcessDefinition(string processDefinitionId)
        {
            ProcessEngineConfigurationImpl configuration = Context.ProcessEngineConfiguration;
            DeploymentCache deploymentCache = configuration.DeploymentCache;

            ProcessDefinitionEntity processDefinition = deploymentCache.findProcessDefinitionFromCache(processDefinitionId);

            if (processDefinition == null)
            {
                CommandContext           commandContext           = Context.CommandContext;
                ProcessDefinitionManager processDefinitionManager = commandContext.ProcessDefinitionManager;
                processDefinition = processDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);

                if (processDefinition != null)
                {
                    processDefinition = deploymentCache.resolveProcessDefinition(processDefinition);
                }
            }

            return(processDefinition);
        }