public JiraWorkflow getWorkflow(String name) { try { WorkflowDescriptor workflowDescriptor = getConfiguration().getWorkflow(name); //TODO: We should check here if the returned workflowDescriptor is non null. if (JiraWorkflow.DEFAULT_WORKFLOW_NAME.equals(name)) { return new DefaultJiraWorkflow(workflowDescriptor, this, context); } else { return new ConfigurableJiraWorkflow(name, workflowDescriptor, this); } } catch (FactoryException e) { log.debug("Could not get workflow called: " + name + ": " + e, e); return null; } }
public JiraWorkflow getWorkflowClone(String name) { try { WorkflowDescriptor workflowDescriptor = getConfiguration().getWorkflow(name); if (JiraWorkflow.DEFAULT_WORKFLOW_NAME.equals(name)) { return new DefaultJiraWorkflow(workflowDescriptor, this, context); } WorkflowDescriptor mutableDescriptor = cloneDescriptor(workflowDescriptor); return new ConfigurableJiraWorkflow(name, mutableDescriptor, this); } catch (FactoryException e) { log.error("Could not get workflow called: " + name + ": " + e, e); return null; } }
final ConfigurableJiraWorkflow newWorkflow = new ConfigurableJiraWorkflow(name, workflowDescriptor, workflowManager); newWorkflow.setDescription(description); workflowManager.createWorkflow(getLoggedInUser(), newWorkflow);
public JiraWorkflow copyWorkflow(ApplicationUser user, String clonedWorkflowName, String clonedWorkflowDescription, JiraWorkflow workflowToClone) { final WorkflowDescriptor workflowDescriptor; try { workflowDescriptor = cloneDescriptor(workflowToClone.getDescriptor()); } catch (FactoryException e) { throw new WorkflowException("Unexpected exception copying a workflowDescriptor for workflow '" + clonedWorkflowName + "'!", e); } ConfigurableJiraWorkflow newWorkflow = new ConfigurableJiraWorkflow(clonedWorkflowName, workflowDescriptor, this); // Set description if we have one, otherwise set it to an empty string if (StringUtils.isNotEmpty(clonedWorkflowDescription)) { newWorkflow.setDescription(clonedWorkflowDescription); } else { newWorkflow.setDescription(""); } createActualWorkflow(user, newWorkflow); eventPublisher.publish(new WorkflowCopiedEvent(workflowToClone, newWorkflow)); return newWorkflow; }
@RequiresXsrfCheck public String doAddWorkflow() throws Exception { if (!WorkflowUtil.isAcceptableName(newWorkflowName,"newWorkflowName",this)) { return INPUT; } else if (workflowManager.workflowExists(newWorkflowName)) { addError("newWorkflowName", getText("admin.errors.a.workflow.with.this.name.already.exists")); } if (invalidInput()) { return INPUT; } ConfigurableJiraWorkflow newWorkflow = new ConfigurableJiraWorkflow(newWorkflowName, workflowManager); newWorkflow.setDescription(description); workflowManager.createWorkflow(getLoggedInUser(), newWorkflow); UrlBuilder builder = new UrlBuilder("EditWorkflowDispatcher.jspa") .addParameter("wfName", newWorkflow.getName()) .addParameter("atl_token", getXsrfToken()); return returnCompleteWithInlineRedirect(builder.asUrlString()); }