You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2003/05/29 22:22:47 UTC

cvs commit: jakarta-james/src/java/org/apache/james/userrepository AbstractJdbcUsersRepository.java

noel        2003/05/29 13:22:47

  Modified:    src/java/org/apache/james/userrepository Tag: branch_2_1_fcs
                        AbstractJdbcUsersRepository.java
  Log:
  Improve performance of listUserNames()
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.14.4.3  +26 -3     jakarta-james/src/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java
  
  Index: AbstractJdbcUsersRepository.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java,v
  retrieving revision 1.14.4.2
  retrieving revision 1.14.4.3
  diff -u -r1.14.4.2 -r1.14.4.3
  --- AbstractJdbcUsersRepository.java	8 Mar 2003 21:54:10 -0000	1.14.4.2
  +++ AbstractJdbcUsersRepository.java	29 May 2003 20:22:46 -0000	1.14.4.3
  @@ -204,7 +204,7 @@
               destUrl += "/";
           }
           // Split on "/", starting after "db://"
  -        List urlParams = new LinkedList();
  +        List urlParams = new ArrayList();
           int start = 5;
           int end = destUrl.indexOf('/', start);
           while ( end > -1 ) {
  @@ -385,6 +385,21 @@
           }
       }
   
  +    /**
  +     * Produces the complete list of User names, with correct case.
  +     * @return a <code>List</code> of <code>String</code>s representing
  +     *         user names.
  +     */
  +    protected List listUserNames() {
  +        Collection users = getAllUsers();
  +        List userNames = new ArrayList(users.size());
  +        for (Iterator it = users.iterator(); it.hasNext(); ) {
  +            userNames.add(((User)it.next()).getUserName());
  +        }
  +        users.clear();
  +        return userNames;
  +    }
  +
       //
       // Superclass methods - overridden from AbstractUsersRepository
       //
  @@ -393,7 +408,15 @@
        * @return an <code>Iterator</code> of <code>JamesUser</code>s.
        */
       protected Iterator listAllUsers() {
  -        List userList = new LinkedList(); // Build the users into this list.
  +        return getAllUsers().iterator();
  +    }
  +
  +    /**
  +     * Returns a list populated with all of the Users in the repository.
  +     * @return a <code>Collection</code> of <code>JamesUser</code>s.
  +     */
  +    private Collection getAllUsers() {
  +        List userList = new ArrayList(); // Build the users into this list.
   
           Connection conn = openConnection();
           PreparedStatement getUsersStatement = null;
  @@ -420,7 +443,7 @@
               theJDBCUtil.closeJDBCConnection(conn);
           }
   
  -        return userList.iterator();
  +        return userList;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org