/** * This is used for unit testing so we can return our own 'mock store' instead of the static * StoreFactory.getPersistence(ctx); * <p/> * Also used in the migrateIssueToWorkflow method. */ public WorkflowStore getStore() throws StoreException { return getConfiguration().getWorkflowStore(); }
@Override public Configuration get() { try { final Configuration configuration = new DefaultConfiguration(); configuration.load(ClassLoaderUtils.getResource("osworkflow.xml", getClass())); // This is here because there is a concurrency bug in osworkflow such that the configuration // does not safely initialize its GenericDelegator. If we do not "prime" the reference to the // delegator then you can run into issues where you get a null pointer when concurrently trying // to create issues. DO NOT REMOVE THIS BLOCK OF CODE!! try { configuration.getWorkflowStore(); return configuration; } catch (StoreException e) { throw new DataAccessException(e); } } catch (FactoryException e) { log.error("Error loading OSWorkflow Configuration: " + e, e); throw new InfrastructureException("Error loading osworkflow.xml file: " + e, e); } } }
public boolean isSystemWorkflow(JiraWorkflow workflow) { return !getConfiguration().isModifiable(workflow.getName()); }
/** * initializes the workflow and a default config * * @return the unique workflow id */ private long createWorkflow() throws InvalidRoleException, InvalidInputException, WorkflowException { this.osWorkflowInstance = new BasicWorkflow(this.caller); DefaultConfiguration config = new DefaultConfiguration(); this.osWorkflowInstance.setConfiguration(config); long wfId = this.osWorkflowInstance.initialize(this.osWorkflowName, this.action, this.map); return wfId; }
getConfiguration().removeWorkflow(currentWorkflowName); getConfiguration().saveWorkflow(newName, workflow.getDescriptor(), true);
public void saveWorkflowWithoutAudit(JiraWorkflow workflow) throws WorkflowException { if (workflow.isDraftWorkflow()) { // Save the passed workflow over the existing draft draftWorkflowStore.updateDraftWorkflowWithoutAudit(workflow.getName(), workflow); } try { getConfiguration().saveWorkflow(workflow.getName(), workflow.getDescriptor(), true); workflow.reset(); } catch (FactoryException e) { throw new WorkflowException(e); } }
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; } }
@Override public boolean contains(String name) { // This is more efficient than the parent method as it does not create workflow objects // but simply looks at workflow names if (name == null) { throw new IllegalArgumentException("Name must not be null."); } // Cannot get access to a Map that stores the workflows - so need to loop over the // name array. try { for (int i = 0; i < getConfiguration().getWorkflowNames().length; i++) { String workflowName = getConfiguration().getWorkflowNames()[i]; if (name.equals(workflowName)) { return true; } } } catch (FactoryException e) { throw new WorkflowException(e); } return false; }
public void deleteWorkflow(JiraWorkflow workflow) throws WorkflowException { if (!Iterables.isEmpty(getWorkflowSchemeManager().getSchemesForWorkflowIncludingDrafts(workflow))) { throw new WorkflowException("The workflow is assigned to workflow schemes"); } try { //we need to delete the draft first since it needs a reference to the parent deleteDraftWorkflow(workflow.getName()); //TODO: Should we move this to the store? getConfiguration().removeWorkflow(workflow.getName()); eventPublisher.publish(new WorkflowDeletedEvent(workflow)); } catch (FactoryException e) { throw new WorkflowException("Error deleting workflow: " + e, e); } }
saved = getConfiguration().saveWorkflow(workflowName, draftWorkflow.getDescriptor(), true); eventPublisher.publish(new DraftWorkflowPublishedEvent(draftWorkflow, originalWorkflow));
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; } }
/** * Retrieve all of the workflows in the system * * @return A collection of JiraWorkflow objects. */ public Collection<JiraWorkflow> getWorkflows() { List<JiraWorkflow> workflows = Lists.newArrayList(); try { String[] workflowNames = getConfiguration().getWorkflowNames(); workflows = Lists.newArrayListWithCapacity(workflowNames.length); for (String workflowName : workflowNames) { workflows.add(getWorkflow(workflowName)); } } catch (FactoryException e) { log.error("Could not get workflow names: " + e, e); } Collections.sort(workflows); return workflows; }