@Override public void updateWorkflowScreenIds(ConfigurableJiraWorkflow jiraWorkflow, Map<Long, Long> oldToNewIdMapping) { Collection<ActionDescriptor> allActions = jiraWorkflow.getAllActions(); for (ActionDescriptor action : allActions) { if(FIELDSCREEN_VIEW.equals(action.getView()) && action.getMetaAttributes().containsKey(FIELDSCREEN_ID_NAME)) { String screenId = (String) action.getMetaAttributes().get(FIELDSCREEN_ID_NAME); if(StringUtils.isNumeric(screenId)) { Long oldScreenId = Long.parseLong(screenId); if(oldToNewIdMapping.containsKey(oldScreenId)) { action.getMetaAttributes().put(FIELDSCREEN_ID_NAME,Long.toString(oldToNewIdMapping.get(oldScreenId))); } } } } }
public void resetFieldScreens() { super.reset(); } }
@Override public void doUpgrade(boolean setupMode) throws Exception { DescriptorFactory descriptorFactory = DescriptorFactory.getFactory(); WorkflowManager workflowManager = ComponentAccessor.getComponentOfType(WorkflowManager.class); for (JiraWorkflow workflow : workflowManager.getWorkflows()) { if (workflow instanceof ConfigurableJiraWorkflow) { ConfigurableJiraWorkflow mutableWorkflow = (ConfigurableJiraWorkflow) workflow; try { Element upgradedDescriptor = upgradeDescriptor(mutableWorkflow.getDescriptor().asXML()); WorkflowDescriptor workflowDescriptor = descriptorFactory.createWorkflowDescriptor(upgradedDescriptor); mutableWorkflow.setDescriptor(workflowDescriptor); workflowManager.saveWorkflowWithoutAudit(mutableWorkflow); log.debug("Upgraded workflow '{}'", mutableWorkflow.getName()); } catch (Exception e) { throw new RuntimeException("Failed to upgrade workflow: " + workflow.getName(), e); } } } }
@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()); }
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; }
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; } }
final ConfigurableJiraWorkflow newWorkflow = new ConfigurableJiraWorkflow(name, workflowDescriptor, workflowManager); newWorkflow.setDescription(description); workflowManager.createWorkflow(getLoggedInUser(), newWorkflow);
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; } }
@Override public ExtensionCustomFieldUpdateResult updateWorkflowCustomFieldIds(ConfigurableJiraWorkflow jiraWorkflow, Map<String, String> oldToNewIdMapping) { ExtensionCustomFieldUpdateResultImpl result = new ExtensionCustomFieldUpdateResultImpl(); Collection<ActionDescriptor> allActions = jiraWorkflow.getAllActions(); for (ActionDescriptor action : allActions) { Map<String,Map<String,String>> functions = updatePostFunctionCustomFieldIds(action,oldToNewIdMapping); Map<String,Map<String,String>> validators = updateValidatorCustomFieldIds(action,oldToNewIdMapping); Map<String,Map<String,String>> conditions = updateConditionsCustomFieldIds(action,oldToNewIdMapping); result.addAction(action.getName() + "(" + action.getId() + ")",functions,validators,conditions); } return result; }