Varying assignable users by transition

Warning

The following code modification will only work for versions prior to 3.2.

Using the JIRA Workflow-based permissions plugin, the jira.issue.assignables attribute can only be placed on workflow steps. If you need to have a different set of possible assignees for each transition from a step, this requires code modifications to JIRA. Add the following method to CommentAssignIssue.java:

public class CommentAssignIssue extends AbstractCommentableAssignableIssue
{
...
    public Map getAssignableUsers(GenericValue project, GenericValue issue) throws Exception
    {
        String assignableGroup = WorkflowUtil.getMetaAttributeForAction(issue, getActionDescriptor(), "jira.issue.assignables");
        if (assignableGroup == null)
        {
            return super.getAssignableUsers(project, issue);
        }
        else
        {
            // We have overridden the assignees at the action level, eg. the "Data Changed" action
            // Whatever group jira.issue.assignables specifies, is what is made available.
            List users = GroupUtils.getGroup(assignableGroup).getUsers();
            Map newAssignees = new HashMap(users.size());
            Iterator it = users.iterator();
            while (it.hasNext())
            {
                String username = (String) it.next();
                String fullname = UserUtils.getUser(username).getFullName();
                newAssignees.put(username, fullname);
            }
            return newAssignees;
        }
    }

}
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Nov 30, 2005

    Chris Wood says:

    This also needs the following mod to WorkflowUtil. (or at least this is my best,...

    This also needs the following mod to WorkflowUtil. (or at least this is my best, untested guess of what the mod should be).

    class WorkflowUtil {
       /** Return a workflow meta attribute for the given issue action. */
        public static String getMetaAttributeForAction(GenericValue issue, ActionDescriptor actionDesc, String metaKey)
        {
    
            final String assignableGroups = (String) actionDesc.getMetaAttributes().get(metaKey);
            if (assignableGroups != null && assignableGroups.indexOf("${") != -1)
            {
                GenericValue project = null;
                project = ManagerFactory.getProjectManager().getProject(issue);
                return WorkflowUtil.interpolateProjectKey(project, assignableGroups);
            }
            else
            {
                return assignableGroups;
            }
        }
    }