Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-13523

Multi user custom field cannot be used with the assignable user permission

    XMLWordPrintable

Details

    Description

      If a multi user custom field is added to JIRA, and the custom field is added to the Assignable User permission, the Assign Issue operation breaks, when trying to gather the list of assignable Users. This is basically because our MultiUserCF is not specific enough and relies to much on the AbstractMultiCFType.

      The MultiUserCFType needs to override the getValueFromIssue(CustomField field, Issue issue) method to return a Set rather than a List.

      Or, we could make the UserCF a little more robust and make the following method able to handle more than just a Set:

       public Set getUsers(PermissionContext ctx, String customFieldId)
          {
              if (ctx.getIssue() == null)
              {
                  throw new IllegalArgumentException("PermissionContext has no issue");
              }
              Issue issue = ctx.getIssue();
              FieldManager fieldManager = ComponentManager.getInstance().getFieldManager();
              CustomField field = fieldManager.getCustomField(customFieldId);
      
              CustomFieldType type = field.getCustomFieldType();
      
              Object obj = type.getValueFromIssue(field, issue);
              Set users = new HashSet(1);
      
              if (obj != null)
              {
                  if (obj instanceof Set)
                  {
                      users = (Set) obj;
                  }
                  else
                  {
                      users.add(obj);
                  }
              }
              return users;
          }
      

      Currently it can't, and the following exception is the result (a little further down the track, after the UserCF has added the wrong thing to the set of users):

      java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.opensymphony.user.User
      	at com.atlassian.core.user.BestNameComparator.compare(BestNameComparator.java:26)
      	at java.util.Arrays.mergeSort(Arrays.java:1270)
      	at java.util.Arrays.sort(Arrays.java:1210)
      	at java.util.Collections.sort(Collections.java:159)
      	at com.atlassian.jira.issue.fields.AssigneeSystemField.makeAssigneeOptionsList(AssigneeSystemField.java:416)
      	at com.atlassian.jira.issue.fields.AssigneeSystemField.getAssigneeOptionsList(AssigneeSystemField.java:348)
      	at com.atlassian.jira.issue.fields.AssigneeSystemField.getEditHtml(AssigneeSystemField.java:87)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:589)
      	at webwork.util.InjectionUtils$DefaultInjectionImpl.invoke(InjectionUtils.java:61)
      	at webwork.util.InjectionUtils.invoke(InjectionUtils.java:52)
      	at webwork.util.ValueStack.findValue(ValueStack.java:426)
      

      Attachments

        Issue Links

          Activity

            People

              dushan@atlassian.com Dushan Hanuska [Atlassian]
              andreask@atlassian.com Andreas Knecht (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 4h
                  4h
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 3.5h Time Not Required
                  3.5h