HiRISE

HiRISE.HiCat.Utilities
Class People_Record

java.lang.Object
  extended by HiRISE.HiCat.Utilities.People_Record

public class People_Record
extends Object

A class for searching or updating entries in the People table. The current implementation is limited to operations on group memberships.

To Do:

Version:
1.1
Author:
Rodney Heyd UA/HiRISE

Field Summary
static String DEFAULT_CONFIGURATION_FILE
          The default configuration file.
static String ID
          Class Identification
 
Constructor Summary
People_Record()
          Create a new people object using the DEFAULT_CONFIGURATION_FILE
People_Record(String configuration_file)
          Create a new people object using the given configuration.
 
Method Summary
 void Add_To_Group(String group_name)
          Add the current user to the specified group
 String Get_Family_Name()
          Get the last name of the user.
 String Get_Given_Name()
          Get the given name for this user as retrieved from the database.
 int Get_User_ID()
          Get the User ID of the User
 boolean Get_User(int user_id)
          Retrieve user information from the database for the given user id, calling this method will initialize the object with user information and allow the use of the editing methods.
 boolean Get_User(String username)
          Retrieve user information from the database for the given user id, calling this method will initialize the object with user information and allow the use of the editing methods.
 String Get_Username()
          Get the Username of the user
 Vector<String> Group_Names()
          Get the list of possible group names from the database.
 boolean Is_Initialized()
          Checks to see if this object has been initialized with information about a person registered in the People table.
 boolean Is_Member_Of_Group(String group_name)
          Determine if the user is a member of the specified group
 Vector<String> List_Group_Memberships()
          List the groups the current user is a member of
static void main(String[] arguments)
          Update/Edit People table records.
 void Remove_From_Group(String group_name)
          Remove the user from the specified group
 void Reset_Group_Memberships(Vector<String> group_list)
          Resets the group memberships of the current user
static void Usage()
          Prints the command line usage syntax.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final String ID
Class Identification

See Also:
Constant Field Values

DEFAULT_CONFIGURATION_FILE

public static final String DEFAULT_CONFIGURATION_FILE
The default configuration file. This file will be looked for if no configuration is specified.

See Also:
Constant Field Values
Constructor Detail

People_Record

public People_Record(String configuration_file)
              throws Configuration_Exception,
                     Database_Exception
Create a new people object using the given configuration.

Parameters:
configuration_file - - the configuration to use containing database connection parameters
Throws:
Configuration_Exception - if the configuration file can not be read
Database_Exception - if a database connection can not be established

People_Record

public People_Record()
              throws Configuration_Exception,
                     Database_Exception
Create a new people object using the DEFAULT_CONFIGURATION_FILE

Throws:
Configuration_Exception - if the configuration can not be found
Database_Exception - if a database connection can not be established.
Method Detail

Get_User

public boolean Get_User(int user_id)
                 throws Database_Exception
Retrieve user information from the database for the given user id, calling this method will initialize the object with user information and allow the use of the editing methods.

Parameters:
user_id - - an integer ID of a user in the People table
Returns:
true if information was successfully retrieved from the database for the input user id, false otherwise.
Throws:
Database_Exception - if a problem occurs while retrieving user information from the database.
User_Information_Exception - if no user can be found matching the input user_id

Get_User

public boolean Get_User(String username)
                 throws Database_Exception
Retrieve user information from the database for the given user id, calling this method will initialize the object with user information and allow the use of the editing methods.

Parameters:
username - - The username to search for in the USERNAME column in HiCat.
Returns:
true if information was successfully retrieved from the database for the input username, false otherwise.
Throws:
Database_Exception - if a database error occurs
User_Information_Exception - if the user information can't be found.

Reset_Group_Memberships

public void Reset_Group_Memberships(Vector<String> group_list)
                             throws Database_Exception,
                                    User_Information_Exception
Resets the group memberships of the current user

Parameters:
group_list - A vector of strings containing one or more groups the user should be assigned to.
Throws:
Database_Exception - if a problem occurs while attempting to update the database
User_Information_Exception - if the object has not been initialized with user information from the People table in HiCat.

Add_To_Group

public void Add_To_Group(String group_name)
                  throws Database_Exception,
                         User_Information_Exception
Add the current user to the specified group

Parameters:
group_name - - A string containing the group the user should be added to
Throws:
Database_Exception - if a problem occurs updating the database
User_Information_Exception - if the specified group is not a valid group, or if the class has not been initialized with user information from HiCat.

Remove_From_Group

public void Remove_From_Group(String group_name)
                       throws Database_Exception,
                              User_Information_Exception
Remove the user from the specified group

Parameters:
group_name - - the group the user is to be removed from
Throws:
Database_Exception - if a database error occurs while updating the database.
User_Information_Exception - if the group is unknown, or if the class has not been initialized with user information from HiCat.

Is_Member_Of_Group

public boolean Is_Member_Of_Group(String group_name)
                           throws User_Information_Exception
Determine if the user is a member of the specified group

Parameters:
group_name - - the group to check for membership
Returns:
true if the user is a member of the group, false otherwise
Throws:
User_Information_Exception - if the specified group is not known or if the class has not been initialized with user information from HiCat.

Is_Initialized

public boolean Is_Initialized()
Checks to see if this object has been initialized with information about a person registered in the People table.

Returns:
true if the object has been initialized, false otherwise.

Group_Names

public Vector<String> Group_Names()
                           throws Database_Exception
Get the list of possible group names from the database.

Returns:
A Vector of Strings containing the list of group names
Throws:
Database_Exception - if the group names can not be retrieved

Get_User_ID

public int Get_User_ID()
Get the User ID of the User

Returns:
the integer database ID assigned to the user by the database server. The User_ID will have a value of -1 if the object has not be initialized with user information from the database.

Get_Username

public String Get_Username()
Get the Username of the user

Returns:
A string containing the username, null if no user information has been retrieved from the database.

Get_Given_Name

public String Get_Given_Name()
Get the given name for this user as retrieved from the database.

Returns:
the first name of the user, null if no data has been retrieved from the database.

Get_Family_Name

public String Get_Family_Name()
Get the last name of the user.

Returns:
the last name of the user, null if the information has not be retrieved from the database.

List_Group_Memberships

public Vector<String> List_Group_Memberships()
List the groups the current user is a member of

Returns:
a vector of strings that are the list of group memberships or null if no user information has been retrieved from the database.

main

public static void main(String[] arguments)
Update/Edit People table records.

The command line syntax is described by the Usage method.

Exit Status Values:

0 - Success 1 - Invalid Command Line Syntax 2 - Configuration Error 3 - Database Error 4 - Incomplete/unknown User information

Parameters:
arguments - - array of command line arguments
See Also:
Usage()

Usage

public static void Usage()
Prints the command line usage syntax.

Usage: HiTList <Options>
  Options -
    [-Configuration <filename>]
      (default: HiCat.conf)
    [-Add_To_Group <group_name>]
    [-Group_Memberships]
    [-Help]
    [-ID <integer user id>]
    [-List_Groups]
    [-Remove_From_Group <group_name>]
    [-Username <username>]
    [-Version]
Note: if both an ID and a Username is specified, the ID will be used to
retrieve information from the database.


HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona