public class

DefaultWorkflowService

extends Object
implements WorkflowService Startable
java.lang.Object
   ↳ com.atlassian.jira.bc.workflow.DefaultWorkflowService

Class Overview

Default workflow service implementation. Provides some 'nice' error handling and delegates straight through to the underlying WorkflowManager

Summary

Public Constructors
DefaultWorkflowService(WorkflowManager workflowManager, JiraAuthenticationContext jiraAuthenticationContext, PermissionManager permissionManager, WorkflowSchemeManager workflowSchemeManager, ClusterLockService clusterLockService)
Public Methods
JiraWorkflow copyWorkflow(JiraServiceContext jiraServiceContext, String clonedWorkflowName, String clonedWorkflowDescription, JiraWorkflow workflowToClone)
Clones and persists a new workflow with the name given.
JiraWorkflow createDraftWorkflow(JiraServiceContext jiraServiceContext, String parentWorkflowName)
Creates a copy of an active workflow for editing.
boolean deleteDraftWorkflow(JiraServiceContext jiraServiceContext, String parentWorkflowName)
Deletes draft workflows (there should only be one) that are associated with the given parent workflow name.
ServiceOutcome<Void> deleteWorkflow(ApplicationUser deletingUser, String workflowName)
Deletes the workflow which has the passed name.
JiraWorkflow getDraftWorkflow(JiraServiceContext jiraServiceContext, String parentWorkflowName)
Given a parentWorkflowName, this methods will retrieved the relevant draft workflow linked to that parent.
JiraWorkflow getWorkflow(JiraServiceContext jiraServiceContext, String name)
Returns the workflow with the given name.
boolean isStepOnDraftWithNoTransitionsOnParentWorkflow(JiraServiceContext jiraServiceContext, JiraWorkflow workflow, int stepId)
Given a draft workflow and a step Id, this method returns true, if the step does not have any transitions on the original workflow.
void overwriteActiveWorkflow(JiraServiceContext jiraServiceContext, String parentWorkflowName)
This method will overwrite the parentWorkflow with a draft Workflow if it exists.
void start()
This method will be called after the plugin system is fully initialised and all components added to the dependency injection framework.
void updateWorkflow(JiraServiceContext jiraServiceContext, JiraWorkflow workflow)
Updates the workflow descriptor provided in the persistance mechanism implemented.
void updateWorkflowNameAndDescription(JiraServiceContext jiraServiceContext, JiraWorkflow currentWorkflow, String newName, String newDescription)
Used to change the name and description of an existing worfklow with the given name.
void validateAddWorkflowTransitionToDraft(JiraServiceContext jiraServiceContext, JiraWorkflow newJiraWorkflow, int stepId)
Validates if a workflow transition can be added to a draft.
void validateCopyWorkflow(JiraServiceContext jiraServiceContext, String newWorkflowName)
Validates if a workflow can be cloned and saved with the provided name.
void validateOverwriteWorkflow(JiraServiceContext jiraServiceContext, String workflowName)
Validates that the draft workflow with the given name is allowed to be saved into the corresponding active workflow.
void validateUpdateWorkflowNameAndDescription(JiraServiceContext jiraServiceContext, JiraWorkflow currentWorkflow, String newWorkflowName)
Validates that the workflow with currentName can have its name and description changed to newWorkflowName and newDescription.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.bc.workflow.WorkflowService
From interface com.atlassian.jira.extension.Startable

Public Constructors

public DefaultWorkflowService (WorkflowManager workflowManager, JiraAuthenticationContext jiraAuthenticationContext, PermissionManager permissionManager, WorkflowSchemeManager workflowSchemeManager, ClusterLockService clusterLockService)

Public Methods

public JiraWorkflow copyWorkflow (JiraServiceContext jiraServiceContext, String clonedWorkflowName, String clonedWorkflowDescription, JiraWorkflow workflowToClone)

Clones and persists a new workflow with the name given. This will create a complete deep copy of the worfklow provided.

Parameters
jiraServiceContext service context with user and error collection
clonedWorkflowName The name to store the cloned workflow with.
clonedWorkflowDescription The description of the new copy. May be null.
workflowToClone The workflow to clone.
Returns
  • A clone of the workflow provided.

public JiraWorkflow createDraftWorkflow (JiraServiceContext jiraServiceContext, String parentWorkflowName)

Creates a copy of an active workflow for editing. This will not overwrite the current active workflow

Parameters
jiraServiceContext service context with user and error collection
parentWorkflowName The parent workflow name to create an draft copy of.
Returns
  • A copy of the active workflow

public boolean deleteDraftWorkflow (JiraServiceContext jiraServiceContext, String parentWorkflowName)

Deletes draft workflows (there should only be one) that are associated with the given parent workflow name.

Parameters
jiraServiceContext service context with user and error collection
parentWorkflowName The parent workflow name that the draft workflow to be deleted is associated with
Returns
  • true if an draft workflow was deleted, false otherwise

public ServiceOutcome<Void> deleteWorkflow (ApplicationUser deletingUser, String workflowName)

Deletes the workflow which has the passed name.

Parameters
deletingUser user who performs the deletion
workflowName name of the workflow to be deleted
Returns
  • the result of the operation.

public JiraWorkflow getDraftWorkflow (JiraServiceContext jiraServiceContext, String parentWorkflowName)

Given a parentWorkflowName, this methods will retrieved the relevant draft workflow linked to that parent.
If the parentWorkflow doesn't exist, this method returns null and will log an error in the servicecontext errorcollection. If no DraftWorkflow exists, then this method will simply return null.

Parameters
jiraServiceContext service context with user and error collection
parentWorkflowName The parent workflow name to create an draft copy of.
Returns
  • A draft workflow or null if no draft workflow is found

public JiraWorkflow getWorkflow (JiraServiceContext jiraServiceContext, String name)

Returns the workflow with the given name.

Parameters
jiraServiceContext service context with user and error collection
name the name of the workflow
Returns
  • the workflow with the given name.

public boolean isStepOnDraftWithNoTransitionsOnParentWorkflow (JiraServiceContext jiraServiceContext, JiraWorkflow workflow, int stepId)

Given a draft workflow and a step Id, this method returns true, if the step does not have any transitions on the original workflow.

Parameters
jiraServiceContext service context with user and error collection
workflow The draft workflow with the new step
stepId The stepId of the step to check
Returns
  • true if the step does not have any transitions on the original workflow.

public void overwriteActiveWorkflow (JiraServiceContext jiraServiceContext, String parentWorkflowName)

This method will overwrite the parentWorkflow with a draft Workflow if it exists. If it doesn't exist, this method will add an error to the errorcollection in the service context. The method will also check for the existance of the parent, and call validateOverwriteWorkflow(com.atlassian.jira.bc.JiraServiceContext, String) to ensure the active workflow isn't being overwritten with an invalid draft workflow.

Parameters
jiraServiceContext service context with user and error collection
parentWorkflowName The parent workflow name that will be overwritten with its draft workflow

public void start ()

This method will be called after the plugin system is fully initialised and all components added to the dependency injection framework.

public void updateWorkflow (JiraServiceContext jiraServiceContext, JiraWorkflow workflow)

Updates the workflow descriptor provided in the persistance mechanism implemented. This method can be used for draft workflows, as well as for copies of active workflows. This method does not save the changes to the active workflow. Instead, this is meant to be used to make persistent changes to your working edit. Once all changes have been made you can over write the active workflow by calling overwriteActiveWorkflow(com.atlassian.jira.bc.JiraServiceContext, String) }

Parameters
jiraServiceContext service context with user and error collection
workflow contains the descriptor that the workflow will be updated to.

public void updateWorkflowNameAndDescription (JiraServiceContext jiraServiceContext, JiraWorkflow currentWorkflow, String newName, String newDescription)

Used to change the name and description of an existing worfklow with the given name.

Parameters
jiraServiceContext service context with user and error collection
currentWorkflow The current workflow to be updated.
newName The new name to save with the workflow
newDescription The new descriptio to save with the workflow

public void validateAddWorkflowTransitionToDraft (JiraServiceContext jiraServiceContext, JiraWorkflow newJiraWorkflow, int stepId)

Validates if a workflow transition can be added to a draft. If the original workflow for the draft does not have any outgoing transitions, then this method will add an error to the error collection.

Parameters
jiraServiceContext service context with user and error collection
newJiraWorkflow The draft workflow to which the transition is being added
stepId The step to which the transition is being added.

public void validateCopyWorkflow (JiraServiceContext jiraServiceContext, String newWorkflowName)

Validates if a workflow can be cloned and saved with the provided name. This means checking if the name is set, if it contains invalid characters, and if the workflow already exists.

Parameters
jiraServiceContext service context with user and error collection
newWorkflowName The name of the cloned workflow.

public void validateOverwriteWorkflow (JiraServiceContext jiraServiceContext, String workflowName)

Validates that the draft workflow with the given name is allowed to be saved into the corresponding active workflow. Basically you are allowed to add new Steps and change the transitions, but you are not allowed to remove any steps/statuses, or change an existing association between a step ID and an Issue status.

Parameters
jiraServiceContext JiraServiceContext
workflowName Name of the workflow to be validated.

public void validateUpdateWorkflowNameAndDescription (JiraServiceContext jiraServiceContext, JiraWorkflow currentWorkflow, String newWorkflowName)

Validates that the workflow with currentName can have its name and description changed to newWorkflowName and newDescription.

Parameters
jiraServiceContext service context with user and error collection
currentWorkflow The current workflow to be updated.
newWorkflowName The new name to save with the workflow