public class DefaultWorkflowService extends Object implements WorkflowService, Startable
WorkflowManager
WorkflowService.WorkflowPermission
Constructor and Description |
---|
DefaultWorkflowService(WorkflowManager workflowManager,
JiraAuthenticationContext jiraAuthenticationContext,
PermissionManager permissionManager,
WorkflowSchemeManager workflowSchemeManager,
com.atlassian.beehive.ClusterLockService clusterLockService,
GlobalPermissionManager globalPermissionManager,
com.atlassian.event.api.EventPublisher eventPublisher,
WorkflowStatusesValidator workflowStatusesValidator,
ProjectWorkflowSchemeHelper projectWorkflowSchemeHelper,
ProjectPermissionHelper projectPermissionHelper) |
Modifier and Type | Method and Description |
---|---|
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.
|
WorkflowService.WorkflowPermission |
getWorkflowPermission(ApplicationUser user,
JiraWorkflow workflow)
* User has to satisfy any condition of the following:
- have ADMINISTER permission
- have
ProjectPermissions.ADMINISTER_PROJECTS in every project that uses passed workflow and workflow is not shared with other projects and workflow is used in at least 1 project. |
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.
|
boolean |
isWorkflowEditable(ApplicationUser applicationUser,
JiraWorkflow workflow)
Checks if user can edit 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.
|
public DefaultWorkflowService(WorkflowManager workflowManager, JiraAuthenticationContext jiraAuthenticationContext, PermissionManager permissionManager, WorkflowSchemeManager workflowSchemeManager, com.atlassian.beehive.ClusterLockService clusterLockService, GlobalPermissionManager globalPermissionManager, com.atlassian.event.api.EventPublisher eventPublisher, WorkflowStatusesValidator workflowStatusesValidator, ProjectWorkflowSchemeHelper projectWorkflowSchemeHelper, ProjectPermissionHelper projectPermissionHelper)
public void start()
Startable
public JiraWorkflow getDraftWorkflow(JiraServiceContext jiraServiceContext, String parentWorkflowName)
WorkflowService
getDraftWorkflow
in interface WorkflowService
jiraServiceContext
- service context with user and error collectionparentWorkflowName
- The parent workflow name to create an draft copy of.public JiraWorkflow createDraftWorkflow(JiraServiceContext jiraServiceContext, String parentWorkflowName)
WorkflowService
createDraftWorkflow
in interface WorkflowService
jiraServiceContext
- service context with user and error collectionparentWorkflowName
- The parent workflow name to create an draft copy of.public boolean deleteDraftWorkflow(JiraServiceContext jiraServiceContext, String parentWorkflowName)
WorkflowService
deleteDraftWorkflow
in interface WorkflowService
jiraServiceContext
- service context with user and error collectionparentWorkflowName
- The parent workflow name that the draft workflow to be deleted is associated withpublic ServiceOutcome<Void> deleteWorkflow(ApplicationUser deletingUser, String workflowName)
WorkflowService
deleteWorkflow
in interface WorkflowService
deletingUser
- user who performs the deletionworkflowName
- name of the workflow to be deletedpublic void overwriteActiveWorkflow(JiraServiceContext jiraServiceContext, String parentWorkflowName)
WorkflowService
WorkflowService.validateOverwriteWorkflow(com.atlassian.jira.bc.JiraServiceContext, String)
to ensure the active
workflow isn't being overwritten with an invalid draft workflow.overwriteActiveWorkflow
in interface WorkflowService
jiraServiceContext
- service context with user and error collectionparentWorkflowName
- The parent workflow name that will be overwritten with its draft workflowpublic void validateOverwriteWorkflow(JiraServiceContext jiraServiceContext, String workflowName)
WorkflowService
validateOverwriteWorkflow
in interface WorkflowService
jiraServiceContext
- JiraServiceContextworkflowName
- Name of the workflow to be validated.public void updateWorkflow(JiraServiceContext jiraServiceContext, JiraWorkflow workflow)
WorkflowService
WorkflowService.overwriteActiveWorkflow(com.atlassian.jira.bc.JiraServiceContext, String)
}
updateWorkflow
in interface WorkflowService
jiraServiceContext
- service context with user and error collectionworkflow
- contains the descriptor that the workflow will be updated to.public void validateUpdateWorkflowNameAndDescription(JiraServiceContext jiraServiceContext, JiraWorkflow currentWorkflow, String newWorkflowName)
WorkflowService
validateUpdateWorkflowNameAndDescription
in interface WorkflowService
jiraServiceContext
- service context with user and error collectioncurrentWorkflow
- The current workflow to be updated.newWorkflowName
- The new name to save with the workflowpublic void updateWorkflowNameAndDescription(JiraServiceContext jiraServiceContext, JiraWorkflow currentWorkflow, String newName, String newDescription)
WorkflowService
updateWorkflowNameAndDescription
in interface WorkflowService
jiraServiceContext
- service context with user and error collectioncurrentWorkflow
- The current workflow to be updated.newName
- The new name to save with the workflownewDescription
- The new descriptio to save with the workflowpublic JiraWorkflow getWorkflow(JiraServiceContext jiraServiceContext, String name)
WorkflowService
getWorkflow
in interface WorkflowService
jiraServiceContext
- service context with user and error collectionname
- the name of the workflowpublic void validateCopyWorkflow(JiraServiceContext jiraServiceContext, String newWorkflowName)
WorkflowService
validateCopyWorkflow
in interface WorkflowService
jiraServiceContext
- service context with user and error collectionnewWorkflowName
- The name of the cloned workflow.public JiraWorkflow copyWorkflow(JiraServiceContext jiraServiceContext, String clonedWorkflowName, String clonedWorkflowDescription, JiraWorkflow workflowToClone)
WorkflowService
copyWorkflow
in interface WorkflowService
jiraServiceContext
- service context with user and error collectionclonedWorkflowName
- The name to store the cloned workflow with.clonedWorkflowDescription
- The description of the new copy. May be null.workflowToClone
- The workflow to clone.public boolean isStepOnDraftWithNoTransitionsOnParentWorkflow(JiraServiceContext jiraServiceContext, JiraWorkflow workflow, int stepId)
WorkflowService
isStepOnDraftWithNoTransitionsOnParentWorkflow
in interface WorkflowService
jiraServiceContext
- service context with user and error collectionworkflow
- The draft workflow with the new stepstepId
- The stepId of the step to checkpublic void validateAddWorkflowTransitionToDraft(JiraServiceContext jiraServiceContext, JiraWorkflow newJiraWorkflow, int stepId)
WorkflowService
validateAddWorkflowTransitionToDraft
in interface WorkflowService
jiraServiceContext
- service context with user and error collectionnewJiraWorkflow
- The draft workflow to which the transition is being addedstepId
- The step to which the transition is being added.public WorkflowService.WorkflowPermission getWorkflowPermission(ApplicationUser user, JiraWorkflow workflow)
ProjectPermissions.ADMINISTER_PROJECTS
in every project that uses passed workflow and workflow is not shared with other projects and workflow is used in at least 1 project.getWorkflowPermission
in interface WorkflowService
user
- The user to check permission forworkflow
- The workflow to which permission is checkedpublic boolean isWorkflowEditable(ApplicationUser applicationUser, JiraWorkflow workflow)
WorkflowService
isWorkflowEditable
in interface WorkflowService
applicationUser
- The user to check permission forworkflow
- The workflow to which permission is checkedCopyright © 2002-2018 Atlassian. All Rights Reserved.