Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/DerbyWrapper.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/DerbyWrapper.java	(revision 35303)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/DerbyWrapper.java	(revision 35332)
@@ -571,4 +571,8 @@
 	}
 
+  // single arg method for convenience
+  public UserQueryResult findUser(String username) {
+    return findUser(username, null);
+  }
 	public UserQueryResult findUser(String username, String password)
 	{
@@ -619,5 +623,6 @@
 			{
 				ResultSet gs = state.executeQuery("SELECT role FROM " + ROLES + " WHERE username = '" + user.get("username") + "'");
-
+                                conn.commit();
+                                
 				String group = "";
 				while (gs.next())
@@ -650,78 +655,4 @@
 	}
 
-	// findUser(null) will return all users, which is why a UserQueryResult 
-	// (a vector of UserTermInfo) is returned
-	public UserQueryResult findUser(String username)
-	{
-		UserQueryResult userQueryResult = new UserQueryResult();
-
-		String sql_find_user = "SELECT  username, password, accountstatus, comment, email FROM " + USERS;
-		String append_sql = "";
-
-		if (username != null)
-		{
-			append_sql = " WHERE username = '" + username + "'";
-		}
-		if (!append_sql.equals(""))
-		{
-			sql_find_user += append_sql;
-		}
-
-		ArrayList<HashMap<String, String>> users = new ArrayList<HashMap<String, String>>();
-
-		try
-		{
-			Statement state = conn.createStatement();
-			ResultSet rs = state.executeQuery(sql_find_user);
-			conn.commit();
-			while (rs.next())
-			{
-				HashMap<String, String> user = new HashMap<String, String>();
-				user.put("username", rs.getString("username"));
-				user.put("password", rs.getString("password"));
-				user.put("as", rs.getString("accountstatus"));
-				user.put("comment", rs.getString("comment"));
-				user.put("email", rs.getString("email"));
-
-				users.add(user);
-			}
-			state.close();
-
-			state = conn.createStatement();
-			for (HashMap<String, String> user : users)
-			{
-				ResultSet gs = state.executeQuery("SELECT role FROM " + ROLES + " WHERE username = '" + user.get("username") + "'");
-				conn.commit();
-
-				String group = "";
-				while (gs.next())
-				{
-					if (!group.equals(""))
-					{
-						group += ",";
-					}
-					group += gs.getString("role");
-				}
-
-				userQueryResult.addUserTerm(user.get("username"), user.get("password"), group, user.get("as"), user.get("comment"), user.get("email"));
-			}
-			state.close();
-		}
-		catch (Exception ex)
-		{
-			ex.printStackTrace();
-		}
-
-		if (userQueryResult.getSize() > 0)
-		{
-			return userQueryResult;
-		}
-		else
-		{
-			System.out.println("couldn't find the user");
-			return null;
-		}
-	}
-
 	public String modifyUserInfo(String username, String new_password, String expandedGroups, String accountstatus, String comment, String email)
 	{
@@ -737,7 +668,11 @@
 			}
 
-			if (accountstatus != null && comment != null)
-			{
-				sql_modify_user_info += (needComma ? "," : "") + " accountstatus='" + accountstatus + "'" + ", comment='" + comment + "'";
+			if (accountstatus != null) {
+                          sql_modify_user_info += (needComma ? "," : "") + " accountstatus='" + accountstatus + "'";
+                          needComma = true;
+                        }
+                        if (comment != null)
+			{
+                          sql_modify_user_info += (needComma ? "," : "") + "  comment='" + comment + "'";
 				needComma = true;
 			}
@@ -746,22 +681,32 @@
 			{
 				sql_modify_user_info += (needComma ? "," : "") + " email='" + email + "'";
-			}
-
-			sql_modify_user_info += " where username='" + username + "'";
-			Statement state = conn.createStatement();
-			state.execute(sql_modify_user_info);
-
-			String sql_delete_groups = "delete from " + ROLES + " where username='" + username + "'";
-			state.execute(sql_delete_groups);
-
-			String[] groupsArray = expandedGroups.split(",");
-			for (String g : groupsArray)
-			{
-				String sql_insert_group = "insert into " + ROLES + " values ('" + username + "', '" + g + "')";
-				state.execute(sql_insert_group);
-			}
-
-			conn.commit();
-			state.close();
+                                needComma = true;
+			}
+                        Statement state = conn.createStatement(); 
+                        if (needComma) {
+                          // it is possible that we are only modifying groups, so use needComma to
+                          // see if we actually need to run this step
+                          sql_modify_user_info += " where username='" + username + "'";
+                          //System.err.println("about to execute sql: "+sql_modify_user_info);
+                          
+                          state.execute(sql_modify_user_info);
+                        }
+                        if (expandedGroups != null) {
+                          // delete the groups we have currently
+                          
+                          String sql_delete_groups = "delete from " + ROLES + " where username='" + username + "'";
+                          state.execute(sql_delete_groups);
+
+                          // add the new groups
+                          String[] groupsArray = expandedGroups.split(",");
+                          for (String g : groupsArray)
+                          {
+                            String sql_insert_group = "insert into " + ROLES + " values ('" + username + "', '" + g + "')";
+                            state.execute(sql_insert_group);
+                          }
+                          
+                          conn.commit();
+                          state.close();
+                        }
 		}
 		catch (Throwable e)
