Mercurial > public > JIRA
view ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireDocumentIssueValidator.java @ 0:92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
for JIRA 3.12.
author | smith |
---|---|
date | Tue, 20 May 2008 17:11:35 -0400 |
parents | |
children |
line wrap: on
line source
/* * RequireDocumentIssueValidator.java * * Created on May 14, 2007, 1:04 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package org.nwoca.ssdt.jira; import com.atlassian.jira.ComponentManager; import com.atlassian.jira.ManagerFactory; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.MutableIssue; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.link.IssueLink; import com.atlassian.jira.issue.link.IssueLinkManager; import com.atlassian.jira.workflow.WorkflowActionsBean; import com.opensymphony.module.propertyset.PropertySet; import com.opensymphony.workflow.InvalidInputException; import com.opensymphony.workflow.Validator; import com.opensymphony.workflow.WorkflowException; import java.util.Collection; import java.util.List; import java.util.Map; /** * Validator requires to an issue type of "Document" or a sub-task of type "Document". * * These are custom issue types used by the SSDT. * * @author SMITH */ public class RequireDocumentIssueValidator implements Validator { /** * Creates a new instance of RequireDocumentIssueValidator */ public RequireDocumentIssueValidator() { } public void validate(Map transientVars, Map args, PropertySet ps) throws InvalidInputException, WorkflowException { Issue issue = (Issue) transientVars.get("issue"); CustomField docRequiredField = ManagerFactory.getCustomFieldManager() .getCustomFieldObjectByName("Documentation Required"); if (docRequiredField == null) { return; } String docRequired = (String)issue.getCustomFieldValue(docRequiredField); if (docRequired == null || docRequired.startsWith("No")) { return; } if (docRequired.startsWith("Yes")) { Collection subtasks = issue.getSubTaskObjects(); for (Object o : subtasks) { MutableIssue subt = (MutableIssue)o; if (subt.getIssueTypeObject().getName().equals("Document Subtask")) { return; } } IssueLinkManager lm = ComponentManager.getInstance().getIssueLinkManager(); List links = lm.getOutwardLinks(issue.getId()); for (Object o : links) { IssueLink link = (IssueLink)o; if (link.getIssueLinkType().getName().equals("Documention") ) { return; } } throw new InvalidInputException("Issue requiring documentation must have " + "at least one 'Document' Subtask or a 'Documention' link." ); } return; } }