Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-20548

Finding users using userpicker.action on systems with spaces in the user name causes unwieldy results

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Low Low
    • None
    • 3.2.1
    • None
    • confluence 3.2.1_01 enterprise

      To Reproduce

      1. set up a system with several thousand common names where the user names are all first-name-space-last-name like "jeff kirby". For example in our system we have dozens of users whose last or first name contains 'paul' and dozens of users whose last name contains 'ngu'.
      2. From a page that you have full permissions on, go to Tools | Restrictions
      3. Click the Person... search button to open users/userpicker.action
      4. In user details, type 'paul ngu' and click search

      Expected Result

      The user paul ngu is at the top of the list or is the only result.

      Actual Result

      paul ngu doesn't appear on the list.
      See

      This also affects the Administration Manage Users feature.
      A work around is to search by email address in the Advanced link in the userpicker but the average user, even the above average user, isn't going to do this.

          Form Name

            [CONFSERVER-20548] Finding users using userpicker.action on systems with spaces in the user name causes unwieldy results

            Hi jkirby

            Thanks for taking the time to raise this issue. As you are probably aware this has been on our backlog now for quite some time we very little progress being made in that time. Rather than leaving this issue on the backlog I'm going to close this out as won't fix, I believe this better reflects the status of this issue.

            If the problem is raised again in the future we'll readdress it.

            Regards
            Steve Haffenden
            Confluence Bugmaster
            Atlassian

            Steve Haffenden (Inactive) added a comment - Hi jkirby Thanks for taking the time to raise this issue. As you are probably aware this has been on our backlog now for quite some time we very little progress being made in that time. Rather than leaving this issue on the backlog I'm going to close this out as won't fix, I believe this better reflects the status of this issue. If the problem is raised again in the future we'll readdress it. Regards Steve Haffenden Confluence Bugmaster Atlassian

            I forgot to include: AJAX LUTs should be used within the email wizard when selecting recipients.

            Sean Diggins added a comment - I forgot to include: AJAX LUTs should be used within the email wizard when selecting recipients.

            For enterprise, the current wizard for mailing a page is hopeless. Our users simply refuse to jump through the hoops.
            Aside from the obvious missing functionality (Confluence should be able to tap into distrubution lists on the enterprise email server), the wizard has an unhelpful structure which makes it too difficult for unsophisticated users. It drives me nuts, and I know what I'm doing!
            Please improve the wizard for emailing pages.

            Sean Diggins added a comment - For enterprise, the current wizard for mailing a page is hopeless. Our users simply refuse to jump through the hoops. Aside from the obvious missing functionality (Confluence should be able to tap into distrubution lists on the enterprise email server), the wizard has an unhelpful structure which makes it too difficult for unsophisticated users. It drives me nuts, and I know what I'm doing! Please improve the wizard for emailing pages.

            Still have same bug in 3.3 as well..

            William Lee added a comment - Still have same bug in 3.3 as well..

            Hey guys,

            Is there any update?
            Even " " is not working to find the right user.

            This is the only thing preventing us from upgrading Confluence to this version (3.2.1)

            The user search was working as expected in 2.9 but it became totally different from this version 3.2.
            Can we have same user search stuff in this version?

            Thanks

            William Lee added a comment - Hey guys, Is there any update? Even " " is not working to find the right user. This is the only thing preventing us from upgrading Confluence to this version (3.2.1) The user search was working as expected in 2.9 but it became totally different from this version 3.2. Can we have same user search stuff in this version? Thanks

            Hi Sherif,

            Is there any ETA to resolve this issue?
            And any possibility to apply the solution to 3.2 with another fix pack or something?
            As you know, we cannot upgrade Confluence to 3.3

            Thanks
            William Lee

            William Lee added a comment - Hi Sherif, Is there any ETA to resolve this issue? And any possibility to apply the solution to 3.2 with another fix pack or something? As you know, we cannot upgrade Confluence to 3.3 Thanks William Lee

            I changed our SearchUsersAction.doUserSearch() to be like this and we're happier

                public String doUserSearch()
                {
                    Query finalQuery;
                    List result = null;
                    try
                    {
                        if (!StringUtils.isEmpty(searchTerm) && !advanced && isSupportsSimpleSearch())
                        {
                           List<TermQuery> termQueries = new ArrayList<TermQuery>();
                           termQueries.add(searchEntitiesManager.getTermQuery(searchTerm, UserNameTermQuery.class));
                           finalQuery = searchEntitiesManager.createUserQuery(termQueries, SearchEntitiesManager.MATCH_ANY);
                           List possible = searchEntitiesManager.findUsersAsList(finalQuery);
                           if(possible.size() == 1) {
                              result = possible;
                           }
                           else {
                              termQueries = convertToTermQueries(searchTerm, UserNameTermQuery.class);
            
                              termQueries.addAll(convertToTermQueries(searchTerm, FullNameTermQuery.class));
            
                              if (isEmailVisible())
                              {
                                  termQueries.addAll(convertToTermQueries(searchTerm, EmailTermQuery.class));
                              }
            
                              finalQuery = searchEntitiesManager.createUserQuery(termQueries, SearchEntitiesManager.MATCH_ANY);
                           }
                        }
                        else
                        {
                           List<Query> andQueries = new ArrayList<Query>();
            
                           if (StringUtils.isNotEmpty(usernameTerm))
                           {
                               List<TermQuery> usernameQueries = convertToTermQueries(usernameTerm, UserNameTermQuery.class);
                               andQueries.add(searchEntitiesManager.createUserQuery(usernameQueries, SearchEntitiesManager.MATCH_ANY));
                           }
                           if (StringUtils.isNotEmpty(fullnameTerm))
                           {
                               List<TermQuery> fullnameQueries = convertToTermQueries(fullnameTerm, FullNameTermQuery.class);
                               andQueries.add(searchEntitiesManager.createUserQuery(fullnameQueries, SearchEntitiesManager.MATCH_ANY));
                           }
                           if (StringUtils.isNotEmpty(emailTerm) && isEmailVisible())
                           {
                               List<TermQuery> emailQueries = convertToTermQueries(emailTerm, EmailTermQuery.class);
                               andQueries.add(searchEntitiesManager.createUserQuery(emailQueries, SearchEntitiesManager.MATCH_ANY));
                           }
            
                           finalQuery = searchEntitiesManager.createUserQuery(andQueries, SearchEntitiesManager.MATCH_ALL);
                        }
                        if(result == null) {
                           result = searchEntitiesManager.findUsersAsList(finalQuery);
                        }
                    }
                    catch (EntityException e)
                    {
                        addActionError(GeneralUtil.htmlEncode(e.getMessage()));
                        //todo CONF-16769: add a message
                        log.error(e.toString(), e);
                        return Action.ERROR;
                    }
                    resultsPerPageOptions = buildResultsPerPageOptions(result.size());
                    Collections.sort(result, new Comparator() {
                         public int compare(final Object o1, final Object o2) {
                             // CONF-18030 - NPE was thrown if 'givenname' entry did not exist in LDAP repository for a given user.
                             String fullName1 = ((User) o1).getFullName();
                             String fullName2 = ((User) o2).getFullName();
            
                             if(StringUtils.isBlank(fullName1) && StringUtils.isNotBlank(fullName2)) {
                                 return 1;
                             }
                             else if(StringUtils.isBlank(fullName2) && StringUtils.isNotBlank(fullName1)) {
                                 return -1;
                             }
                             else if(StringUtils.isBlank(fullName1) && StringUtils.isBlank(fullName2)) {
                                 return 0;
                             }
                             else {
                                 return fullName1.compareTo(fullName2);
                             }
                         }
                    });
                    paginationSupport.setItems(result);
            
                    return SUCCESS;
            

            Jeff Kirby added a comment - I changed our SearchUsersAction.doUserSearch() to be like this and we're happier public String doUserSearch() { Query finalQuery; List result = null ; try { if (!StringUtils.isEmpty(searchTerm) && !advanced && isSupportsSimpleSearch()) { List<TermQuery> termQueries = new ArrayList<TermQuery>(); termQueries.add(searchEntitiesManager.getTermQuery(searchTerm, UserNameTermQuery.class)); finalQuery = searchEntitiesManager.createUserQuery(termQueries, SearchEntitiesManager.MATCH_ANY); List possible = searchEntitiesManager.findUsersAsList(finalQuery); if (possible.size() == 1) { result = possible; } else { termQueries = convertToTermQueries(searchTerm, UserNameTermQuery.class); termQueries.addAll(convertToTermQueries(searchTerm, FullNameTermQuery.class)); if (isEmailVisible()) { termQueries.addAll(convertToTermQueries(searchTerm, EmailTermQuery.class)); } finalQuery = searchEntitiesManager.createUserQuery(termQueries, SearchEntitiesManager.MATCH_ANY); } } else { List<Query> andQueries = new ArrayList<Query>(); if (StringUtils.isNotEmpty(usernameTerm)) { List<TermQuery> usernameQueries = convertToTermQueries(usernameTerm, UserNameTermQuery.class); andQueries.add(searchEntitiesManager.createUserQuery(usernameQueries, SearchEntitiesManager.MATCH_ANY)); } if (StringUtils.isNotEmpty(fullnameTerm)) { List<TermQuery> fullnameQueries = convertToTermQueries(fullnameTerm, FullNameTermQuery.class); andQueries.add(searchEntitiesManager.createUserQuery(fullnameQueries, SearchEntitiesManager.MATCH_ANY)); } if (StringUtils.isNotEmpty(emailTerm) && isEmailVisible()) { List<TermQuery> emailQueries = convertToTermQueries(emailTerm, EmailTermQuery.class); andQueries.add(searchEntitiesManager.createUserQuery(emailQueries, SearchEntitiesManager.MATCH_ANY)); } finalQuery = searchEntitiesManager.createUserQuery(andQueries, SearchEntitiesManager.MATCH_ALL); } if (result == null ) { result = searchEntitiesManager.findUsersAsList(finalQuery); } } catch (EntityException e) { addActionError(GeneralUtil.htmlEncode(e.getMessage())); //todo CONF-16769: add a message log.error(e.toString(), e); return Action.ERROR; } resultsPerPageOptions = buildResultsPerPageOptions(result.size()); Collections.sort(result, new Comparator() { public int compare( final Object o1, final Object o2) { // CONF-18030 - NPE was thrown if 'givenname' entry did not exist in LDAP repository for a given user. String fullName1 = ((User) o1).getFullName(); String fullName2 = ((User) o2).getFullName(); if (StringUtils.isBlank(fullName1) && StringUtils.isNotBlank(fullName2)) { return 1; } else if (StringUtils.isBlank(fullName2) && StringUtils.isNotBlank(fullName1)) { return -1; } else if (StringUtils.isBlank(fullName1) && StringUtils.isBlank(fullName2)) { return 0; } else { return fullName1.compareTo(fullName2); } } }); paginationSupport.setItems(result); return SUCCESS;

              shaffenden Steve Haffenden (Inactive)
              adc6ee404f6d Jeff Kirby
              Affected customers:
              1 This affects my team
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: