com.atlassian.jira.bc.workflow
Class DefaultWorkflowService

java.lang.Object
  extended by com.atlassian.jira.bc.workflow.DefaultWorkflowService
All Implemented Interfaces:
WorkflowService

public class DefaultWorkflowService
extends java.lang.Object
implements WorkflowService

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


Constructor Summary
DefaultWorkflowService(WorkflowManager workflowManager, JiraAuthenticationContext jiraAuthenticationContext, PermissionManager permissionManager)
           
 
Method Summary
 JiraWorkflow copyWorkflow(JiraServiceContext jiraServiceContext, java.lang.String clonedWorkflowName, java.lang.String clonedWorkflowDescription, JiraWorkflow workflowToClone)
          Clones and persists a new workflow with the name given.
 JiraWorkflow createDraftWorkflow(JiraServiceContext jiraServiceContext, java.lang.String parentWorkflowName)
          Creates a copy of an active workflow for editing.
 boolean deleteDraftWorkflow(JiraServiceContext jiraServiceContext, java.lang.String parentWorkflowName)
          Deletes draft workflows (there should only be one) that are associated with the given parent workflow name.
 JiraWorkflow getDraftWorkflow(JiraServiceContext jiraServiceContext, java.lang.String parentWorkflowName)
          Given a parentWorkflowName, this methods will retrieved the relevant draft workflow linked to that parent.
 JiraWorkflow getWorkflow(JiraServiceContext jiraServiceContext, java.lang.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, java.lang.String parentWorkflowName)
          This method will overwrite the parentWorkflow with a JiraDraftWorkflow if it exists.
 void updateWorkflow(JiraServiceContext jiraServiceContext, JiraWorkflow workflow)
          Updates the workflow descriptor provided in the persistance mechanism implemented.
 void updateWorkflowNameAndDescription(JiraServiceContext jiraServiceContext, JiraWorkflow currentWorkflow, java.lang.String newName, java.lang.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, java.lang.String newWorkflowName)
          Validates if a workflow can be cloned and saved with the provided name.
 void validateOverwriteWorkflow(JiraServiceContext jiraServiceContext, java.lang.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, java.lang.String newWorkflowName)
          Validates that the workflow with currentName can have its name and description changed to newWorkflowName and newDescription.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultWorkflowService

public DefaultWorkflowService(WorkflowManager workflowManager,
                              JiraAuthenticationContext jiraAuthenticationContext,
                              PermissionManager permissionManager)
Method Detail

getDraftWorkflow

public JiraWorkflow getDraftWorkflow(JiraServiceContext jiraServiceContext,
                                     java.lang.String parentWorkflowName)
Description copied from interface: WorkflowService
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.

Specified by:
getDraftWorkflow in interface WorkflowService
Parameters:
jiraServiceContext - service context with user and error collection
parentWorkflowName - The parent workflow name to create an draft copy of.
Returns:
A JiraDraftWorkflow or null if no draft workflow is found

createDraftWorkflow

public JiraWorkflow createDraftWorkflow(JiraServiceContext jiraServiceContext,
                                        java.lang.String parentWorkflowName)
Description copied from interface: WorkflowService
Creates a copy of an active workflow for editing. This will not overwrite the current active workflow

Specified by:
createDraftWorkflow in interface WorkflowService
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 in the form of a JiraDraftWorkflow

deleteDraftWorkflow

public boolean deleteDraftWorkflow(JiraServiceContext jiraServiceContext,
                                   java.lang.String parentWorkflowName)
Description copied from interface: WorkflowService
Deletes draft workflows (there should only be one) that are associated with the given parent workflow name.

Specified by:
deleteDraftWorkflow in interface WorkflowService
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

overwriteActiveWorkflow

public void overwriteActiveWorkflow(JiraServiceContext jiraServiceContext,
                                    java.lang.String parentWorkflowName)
Description copied from interface: WorkflowService
This method will overwrite the parentWorkflow with a JiraDraftWorkflow 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 WorkflowService.validateOverwriteWorkflow(com.atlassian.jira.bc.JiraServiceContext, String) to ensure the active workflow isn't being overwritten with an invalid draft workflow.

Specified by:
overwriteActiveWorkflow in interface WorkflowService
Parameters:
jiraServiceContext - service context with user and error collection
parentWorkflowName - The parent workflow name that will be overwritten with its draft workflow

validateOverwriteWorkflow

public void validateOverwriteWorkflow(JiraServiceContext jiraServiceContext,
                                      java.lang.String workflowName)
Description copied from interface: WorkflowService
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.

Specified by:
validateOverwriteWorkflow in interface WorkflowService
Parameters:
jiraServiceContext - JiraServiceContext
workflowName - Name of the workflow to be validated.

updateWorkflow

public void updateWorkflow(JiraServiceContext jiraServiceContext,
                           JiraWorkflow workflow)
Description copied from interface: WorkflowService
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 WorkflowService.overwriteActiveWorkflow(com.atlassian.jira.bc.JiraServiceContext, String) }

Specified by:
updateWorkflow in interface WorkflowService
Parameters:
jiraServiceContext - service context with user and error collection
workflow - contains the descriptor that the workflow will be updated to.

validateUpdateWorkflowNameAndDescription

public void validateUpdateWorkflowNameAndDescription(JiraServiceContext jiraServiceContext,
                                                     JiraWorkflow currentWorkflow,
                                                     java.lang.String newWorkflowName)
Description copied from interface: WorkflowService
Validates that the workflow with currentName can have its name and description changed to newWorkflowName and newDescription.

Specified by:
validateUpdateWorkflowNameAndDescription in interface WorkflowService
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

updateWorkflowNameAndDescription

public void updateWorkflowNameAndDescription(JiraServiceContext jiraServiceContext,
                                             JiraWorkflow currentWorkflow,
                                             java.lang.String newName,
                                             java.lang.String newDescription)
Description copied from interface: WorkflowService
Used to change the name and description of an existing worfklow with the given name.

Specified by:
updateWorkflowNameAndDescription in interface WorkflowService
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

getWorkflow

public JiraWorkflow getWorkflow(JiraServiceContext jiraServiceContext,
                                java.lang.String name)
Description copied from interface: WorkflowService
Returns the workflow with the given name.

Specified by:
getWorkflow in interface WorkflowService
Parameters:
jiraServiceContext - service context with user and error collection
name - the name of the workflow
Returns:
the workflow with the given name.

validateCopyWorkflow

public void validateCopyWorkflow(JiraServiceContext jiraServiceContext,
                                 java.lang.String newWorkflowName)
Description copied from interface: WorkflowService
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.

Specified by:
validateCopyWorkflow in interface WorkflowService
Parameters:
jiraServiceContext - service context with user and error collection
newWorkflowName - The name of the cloned workflow.

copyWorkflow

public JiraWorkflow copyWorkflow(JiraServiceContext jiraServiceContext,
                                 java.lang.String clonedWorkflowName,
                                 java.lang.String clonedWorkflowDescription,
                                 JiraWorkflow workflowToClone)
Description copied from interface: WorkflowService
Clones and persists a new workflow with the name given. This will create a complete deep copy of the worfklow provided.

Specified by:
copyWorkflow in interface WorkflowService
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.

isStepOnDraftWithNoTransitionsOnParentWorkflow

public boolean isStepOnDraftWithNoTransitionsOnParentWorkflow(JiraServiceContext jiraServiceContext,
                                                              JiraWorkflow workflow,
                                                              int stepId)
Description copied from interface: WorkflowService
Given a draft workflow and a step Id, this method returns true, if the step does not have any transitions on the original workflow.

Specified by:
isStepOnDraftWithNoTransitionsOnParentWorkflow in interface WorkflowService
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.

validateAddWorkflowTransitionToDraft

public void validateAddWorkflowTransitionToDraft(JiraServiceContext jiraServiceContext,
                                                 JiraWorkflow newJiraWorkflow,
                                                 int stepId)
Description copied from interface: WorkflowService
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.

Specified by:
validateAddWorkflowTransitionToDraft in interface WorkflowService
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.


Copyright © 2002-2011 Atlassian. All Rights Reserved.