Beispiel #1
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);
            }
        }
Beispiel #2
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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Deletes the timer start events for the given process definition.
        /// </summary>
        /// <param name="processDefinition"> the process definition </param>
        protected internal virtual void deleteTimerStartEventsForProcessDefinition(ProcessDefinition processDefinition)
        {
            IList <JobEntity> timerStartJobs = JobManager.findJobsByConfiguration(TimerStartEventJobHandler.TYPE, processDefinition.Key, processDefinition.TenantId);

            ProcessDefinitionEntity latestVersion = ProcessDefinitionManager.findLatestProcessDefinitionByKeyAndTenantId(processDefinition.Key, processDefinition.TenantId);

            // delete timer start event jobs only if this is the latest version of the process definition.
            if (latestVersion != null && latestVersion.Id.Equals(processDefinition.Id))
            {
                foreach (Job job in timerStartJobs)
                {
                    ((JobEntity)job).delete();
                }
            }
        }
Beispiel #6
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);
        }
Beispiel #7
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);
        }
Beispiel #8
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public void deleteDeployment(String deploymentId, final boolean cascade, final boolean skipCustomListeners, boolean skipIoMappings)
        public virtual void deleteDeployment(string deploymentId, bool cascade, bool skipCustomListeners, bool skipIoMappings)
        {
            IList <ProcessDefinition> processDefinitions = ProcessDefinitionManager.findProcessDefinitionsByDeploymentId(deploymentId);

            if (cascade)
            {
                // *NOTE*:
                // The process instances of ALL process definitions must be
                // deleted, before every process definition can be deleted!
                //
                // On deletion of all process instances, the task listeners will
                // be deleted as well. Deletion of tasks and listeners needs
                // the redeployment of deployments, which can cause to problems if
                // is done sequential with deletion of process definition.
                //
                // For example:
                // Deployment contains two process definiton. First process definition
                // and instances will be removed, also cleared from the cache.
                // Second process definition will be removed and his instances.
                // Deletion of instances will cause redeployment this deploys again
                // first into the cache. Only the second will be removed from cache and
                // first remains in the cache after the deletion process.
                //
                // Thats why we have to clear up all instances at first, after that
                // we can cleanly remove the process definitions.
                foreach (ProcessDefinition processDefinition in processDefinitions)
                {
                    string processDefinitionId = processDefinition.Id;
                    ProcessInstanceManager.deleteProcessInstancesByProcessDefinition(processDefinitionId, "deleted deployment", true, skipCustomListeners, skipIoMappings);
                }
                // delete historic job logs (for example for timer start event jobs)
                HistoricJobLogManager.deleteHistoricJobLogsByDeploymentId(deploymentId);
            }


            foreach (ProcessDefinition processDefinition in processDefinitions)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String processDefinitionId = processDefinition.getId();
                string processDefinitionId = processDefinition.Id;
                // Process definition cascade true deletes the history and
                // process instances if instances flag is set as well to true.
                // Problem as described above, redeployes the deployment.
                // Represents no problem if only one process definition is deleted
                // in a transaction! We have to set the instances flag to false.
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.interceptor.CommandContext commandContext = org.camunda.bpm.engine.impl.context.Context.getCommandContext();
                CommandContext commandContext = Context.CommandContext;
                commandContext.runWithoutAuthorization(new CallableAnonymousInnerClass(this, cascade, skipCustomListeners, processDefinitionId, commandContext));
            }

            deleteCaseDeployment(deploymentId, cascade);

            deleteDecisionDeployment(deploymentId, cascade);
            deleteDecisionRequirementDeployment(deploymentId);

            ResourceManager.deleteResourcesByDeploymentId(deploymentId);

            deleteAuthorizations(Resources.DEPLOYMENT, deploymentId);
            DbEntityManager.delete(typeof(DeploymentEntity), "deleteDeployment", deploymentId);
        }