Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: joist/java/org/joist/database UserManager.java

Project highlights: Architectural Overview

joist
Discussion topic

Back to topic list

CVS update: joist/java/org/joist/database UserManager.java

Author anoncvs
Full name anonymous CVS access
Date 2000-12-04 22:34:07 PST
Message User: jrobbins
  Date: 00/12/04 22:34:07

  Modified: java/org/joist/database Tag: TIGRIS_0_8_4 UserManager.java
  Log:
  merged in changes from HEAD
  
  Revision Changes Path
  No revision
  
  
  No revision
  
  
  1.51.2.1 +66 -53 joist/java/org/joist​/database/UserManage​r.java
  
  Index: UserManager.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/database/UserM​anager.java,v
  retrieving revision 1.51
  retrieving revision 1.51.2.1
  diff -u -r1.51 -r1.51.2.1
  --- UserManager.java 2000/11/21 22:47:47 1.51
  +++ UserManager.java 2000/12/05 06:34:07 1.51.2.1
  @@ -14,7 +14,7 @@
    *
    * 3. The end-user documentation included with the redistribution, if
    * any, must include the following acknowlegement: "This product includes
  - * software developed by CollabNet (http://www.CollabNet/)."
  + * software developed by CollabNet (http://www.collab.net/)."
    * Alternately, this acknowlegement may appear in the software itself, if
    * and wherever such third-party acknowlegements normally appear.
    *
  @@ -62,7 +62,7 @@
     * @author David C. Pellegrini <A HREF="mailto:davidp@​dataweb-systems.com"​>davidp@dataweb-s​ystems.com</A>​
     * @author Leonard Richardson <A HREF="mailto:leonard​r@collab.net">leo​nardr at collab dot net<​/A>
     * @author <A HREF="mailto:dlr@col​lab.net">Daniel Rall</A>
  - * @version $Revision: 1.51 $
  + * @version $Revision: 1.51.2.1 $
     *
     * Copyright (c) 1999 dataweb systems, inc.
     * Copyright (c) 1999, 2000 CollabNet, Inc.
  @@ -74,12 +74,13 @@
       protected static boolean debug = true;
   
       public static final String TABLE_NAME = "User";
  + public static final String DOMAIN_ID = "domainID"; // [Helm]
       public static final String USER_ID = "userID";
       public static final String LOGIN_ID = "loginID";
       public static final String EMAIL = "email";
  - public static final String NAME = "name";
  + public static final String NAME = "name";
       public static final String PASSWORD = "password";
  - public static final String TYPE = "type";
  + public static final String TYPE = "type"; // [Helm]
   
       /**
        * The max in the range of user database keys reserved for system use.
  @@ -87,11 +88,11 @@
       protected static int systemUserIDCeiling = 99;
   
       /**
  - * Create an instance with a data manager.
  - * @param dataMgr A variable of type DataManager
  + * Create an instance with a data manager.
  + *
  + * @param dataMgr The associated data manager.
        */
  - public
  - UserManager(DataManager dataMgr)
  + public UserManager(DataManager dataMgr)
       {
       super(dataMgr);
       }
  @@ -99,8 +100,8 @@
       /**
        * The max in the range of user database keys reserved for system use.
        *
  - * @return The max in the range of user database keys reserved for system
  - * use.
  + * @return The max in the range of user database keys reserved for system
  + * use.
        */
       public static int getSystemUserIDCeiling ()
       {
  @@ -189,7 +190,8 @@
           }
           else
           {
  - throw new JoistDatabaseException("No such user: " + userID);
  + throw new JoistDatabaseException("No such user: " + USER_ID + '=' +
  + userID);
           }
       }
   
  @@ -218,7 +220,8 @@
           }
           else
           {
  - throw new JoistDatabaseException("No such user " + name);
  + throw new JoistDatabaseException("No such user: " + NAME + '=' +
  + name);
           }
       }
   
  @@ -244,7 +247,8 @@
           }
           else
           {
  - throw new JoistDatabaseException("No such user " + loginID);
  + throw new JoistDatabaseException("No such user: " + LOGIN_ID +
  + '=' + loginID);
           }
       }
   
  @@ -269,8 +273,11 @@
           if (user != null && user.containsRecord(0))
           {
               return user.getRecord(0);
  - } else {
  - throw new JoistDatabaseException("No user with email " + email);
  + }
  + else
  + {
  + throw new JoistDatabaseException("No such user: " + EMAIL + '=' +
  + email);
           }
       }
   
  @@ -285,7 +292,7 @@
       }
   
       /**
  - * Retrieves contact information for a user from the database.
  + * Retrieves contact information for a user from the database.
        *
        * @param connection a JDBC database connection
        * @param userID the userID for which to fetch contact info
  @@ -293,8 +300,8 @@
        * @exception SQLException
        * @exception DataSetException
        */
  - public QueryDataSet
  - getContactInfoForUser (Connection connection, String userID)
  + public QueryDataSet getContactInfoForUser (Connection connection,
  + String userID)
       throws SQLException, DataSetException
       {
       QueryDataSet qds = null;
  @@ -339,26 +346,17 @@
       return qds;
       }
   
  -
       /**
  - * Adds a new user registration to the database
  - *
  - * @param connection the JDBC database connection
  - * @param context the WebContext
  - * @param loginID the new user's login name
  - * @param password the new user's password
  - * @return the system-assigned userID for the newly added user.
  - * @exception SQLException
  - * @exception DataSetException
  - * @exception JoistDatabaseException
  + * @see addUser()
        */
  - public Integer
  - addUser (Connection connection, WebContext context, String loginID,
  - String password)
  - throws SQLException, DataSetException, JoistDatabaseException
  + public Integer addUser (Connection connection, WebContext context,
  + String loginID, String password)
  + throws SQLException, DataSetException, InsertFailedException,
  + JoistDatabaseException
       {
  - return addUser(connection, context, context.getForm("name"), loginID,
  + return addUser(connection, context, context.getForm("name"), loginID,
                          password);
  +
       }
   
       /**
  @@ -366,9 +364,11 @@
        */
       public Integer addUser (Connection conn, WebContext context, String name,
                               String loginID, String password)
  - throws SQLException, DataSetException, JoistDatabaseException
  + throws SQLException, DataSetException, InsertFailedException,
  + JoistDatabaseException
       {
  - return addUser(conn, context, name, loginID, password, null);
  + return addUser(conn, context, null, name, loginID, password, null,
  + null);
       }
   
       /**
  @@ -376,20 +376,25 @@
        *
        * @param conn The JDBC database connection to use.
        * @param context The WebContext to pull extra fields from.
  + * @param domainID The domain the user is a part of. [Helm]
        * @param name The new user's real name.
        * @param loginID The new user's login name
        * @param password The new user's password
  - * @param type The type of the new user.
  + * @param email The email of the new user.
  + * @param type The type of the new user. [Helm]
        * @return The system-assigned userID for the newly added user.
        *
  - * @exception SQLException Generic database error.
  - * @exception DataSetException Generic database error.
  - * @exception JoistDatabaseException Possibly a duplicate user.
  + * @exception SQLException Generic database error.
  + * @exception DataSetException Generic database error.
  + * @exception InsertFailedException Duplicate user.
  + * @exception JoistDatabaseException The record was not inserted.
        */
       
  - public Integer addUser (Connection conn, WebContext context, String name,
  - String loginID, String password, String type)
  - throws SQLException, DataSetException, JoistDatabaseException
  + public Integer addUser (Connection conn, WebContext context,
  + String domainID, String name, String loginID,
  + String password, String email, String type)
  + throws SQLException, DataSetException, InsertFailedException,
  + JoistDatabaseException
       {
       Integer userID = null;
   
  @@ -401,8 +406,12 @@
   
               if (type != null)
               {
  - sqlStmt.append(", type");
  + sqlStmt.append(", ").append(TYPE);
               }
  + if (domainID != null)
  + {
  + sqlStmt.append(", ").append(DOMAIN_ID);
  + }
               sqlStmt.append(") values (");
   
           sqlStmt.append(escap​eAndQuoteSQL(loginID​)).append(',');
  @@ -448,7 +457,7 @@
           sqlStmt.append(escap​eAndQuoteSQL(context​.getForm("pager")));​
               sqlStmt.append(',');
   
  - String email = context.getForm("email");
  + if (!haveValue(email)) email = context.getForm("email");
           sqlStmt.append(escap​eAndQuoteSQL(email))​.append(',');
           context.put("email", email);
   
  @@ -459,6 +468,10 @@
               {
                   sqlStmt.append(',').​append(escapeAndQuot​eSQL(type));
               }
  + if (domainID != null)
  + {
  + sqlStmt.append(',').​append(domainID);
  + }
   
               sqlStmt.append(')');
   
  @@ -501,7 +514,7 @@
       /**
        * @see #addUser()
        */
  - public void updateUser(Connection conn, String userID, WebContext context)
  + public void updateUser (Connection conn, String userID, WebContext context)
       throws SQLException, DataSetException, JoistDatabaseException
       {
           updateUser(conn, context, userID, null, null, null, null);
  @@ -527,7 +540,7 @@
       public void updateUser (Connection connection, WebContext context,
                               String userID, String loginID, String email,
                               String realName, String passwd)
  - throws SQLException, DataSetException, JoistDatabaseException
  + throws SQLException, DataSetException, InsertFailedException
       {
       // Encrypt the password if it has changed
       String oldPassword = context.getForm("mackerel");
  @@ -556,15 +569,15 @@
   
       try
       {
  - KeyDef kd = new KeyDef().addAttrib("userID");
  + KeyDef kd = new KeyDef().addAttrib(USER_ID);
           tds = new TableDataSet (connection, TABLE_NAME, kd);
  - tds.where("userID=" + userID);
  + tds.where(USER_ID + '=' + userID);
           tds.fetchRecords();
   
           user = tds.getRecord(0);
   
           if (loginID == null) loginID = context.getForm("loginID");
  - if (loginID != null) user.setValue("loginID", loginID);
  + if (loginID != null) user.setValue(LOGIN_ID, loginID);
   
           if (email == null) email = context.getForm("email");
           if (email != null) user.setValue(EMAIL, email);
  @@ -737,15 +750,15 @@
           String email = null;
           if (user != null)
           {
  - email = user.getValue("email​").asString();
  + email = user.getValue(EMAIL)​.asString();
           }
           return email;
       }
   
       /**
  - * Returns a clause fragment for sorting a user list alphabetically.
  + * Returns a SQL clause fragment for sorting a user list alphabetically.
        *
  - * @return The ORDER BY clause.
  + * @return The <code>order by</code> clause.
        *
        */
       public String alphabeticalOrderBy()

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: joist/java/org/joist/database UserManager.java anoncvs anonymous CVS access 2000-12-04 22:34:07 PST
Messages per page: