edu.mssm.crover.scentral
Class UserRecordImpl

java.lang.Object
  |
  +--edu.mssm.crover.scentral.UserRecordImpl
All Implemented Interfaces:
java.io.Serializable, UserRecord

public class UserRecordImpl
extends java.lang.Object
implements UserRecord, java.io.Serializable

Stores the information about a registered user.

See Also:
Serialized Form

Field Summary
protected static boolean address1_required
           
protected static boolean address2_required
           
protected static boolean affiliation_required
           
protected static boolean city_required
           
protected static boolean company_required
           
protected static boolean country_required
           
protected static boolean department_required
           
protected static boolean email_required
           
protected static boolean faxNumber_required
           
protected static boolean firstName_required
           
protected static boolean lastName_required
           
protected static boolean middleName_required
           
static java.lang.String NO_PROBLEM_REPORT
           
protected static boolean password_required
           
protected static boolean phoneNumber_required
           
protected static boolean state_required
           
protected static boolean title_required
           
protected static boolean userID_required
           
protected static boolean zip_required
           
 
Fields inherited from interface edu.mssm.crover.scentral.UserRecord
ADDRESS_LINE1_PARAM, ADDRESS_LINE2_PARAM, CITY_PARAM, COMPANY_NAME_PARAM, COUNTRY_PARAM, DEPARTMENT_PARAM, EMAIL_PARAM, FAX_PARAM, FIRST_NAME_PARAM, KIND_PARAM, LAST_NAME_PARAM, MIDDLE_NAME_PARAM, PASSWORD_CHECK_PARAM, PASSWORD_PARAM, PHONE_PARAM, STATE_PARAM, USERID_PARAM, ZIP_PARAM
 
Constructor Summary
  UserRecordImpl(java.sql.Connection conn, java.lang.String recordID)
          Constructor for UserRecord that takes a connection and constructs the UserRecord by querying the database tables.
  UserRecordImpl(java.sql.Connection conn, java.lang.String userID, java.lang.String password)
          Constructor for UserRecord that takes a connection and constructs the UserRecord by querying the database tables.
  UserRecordImpl(javax.servlet.http.HttpServletRequest request)
          Deprecated. Use parseParameters(javax.servlet.http.HttpServletRequest) instead.
protected UserRecordImpl(java.lang.String userID)
           
 
Method Summary
 void generatePassword()
          Generates a password for this account and send it to the user by email.
 java.lang.String getAddress1()
          Gets the first line of the mail address for the person represented by this record.
 java.lang.String getAddress2()
          Gets the second line of the mail address for the person represented by this record.
 java.lang.String getAffiliation()
          Gets the affiliation of the person represented by this record.
 java.lang.String getCity()
          Gets the city of the mail address for the person represented by this record.
 java.lang.String getCompany()
          Gets the company for which the person represented by this record works.
 java.lang.String getCountry()
          Gets the country of the mail address for the person represented by this record.
 java.lang.String getDepartment()
          Gets the department in which the person represented by this record works.
 java.lang.String getDiagnostic()
          Returns the reason(s) why the record was found invalid.
 java.lang.String getEmail()
          Returns the email declared by this user.
 java.lang.String getFaxNumber()
          Gets the fax number for the person represented by this record.
 java.lang.String getFirstName()
          Gets the first name of the person represented by this record.
static UserRecord getGuestRecord()
          Returns a dummy record for the guest account.
 java.util.Date getLastLogin()
          Get the last login time.
 java.lang.String getLastName()
          Gets the last name of the person represented by this record.
 java.lang.String getMiddleName()
          Gets the middle name of the person represented by this record.
 java.lang.String getPhoneNumber()
          Gets the phone number for the person represented by this record.
 java.lang.String getRecordID()
          Returns this recordID.
 java.lang.String getState()
          Gets the state of the mail address for the person represented by this record.
 java.lang.String getTitle()
          Gets the title of the person represented by this record.
 java.lang.String getUserID()
          Gets the user id for this record.
 java.lang.String getZip()
          Gets the zip or postal code of the mail address for the person represented by this record.
 boolean hasBeenUsed()
          Has this registered user entered the service once ?
 boolean isEmailTrusted()
          Can this email be trusted ? An email is declared trusted after A user registered successfully the user received the (login, passwd) via email the user logged in successfully at least once with (login, passwd).
 boolean isValid(boolean needsPassword)
          Returns wether this user record is valid.
 void parseParameters(javax.servlet.http.HttpServletRequest request)
          Updates the record with the information stored in the request parameters.
 void putToDatabase(java.sql.Connection con)
          Saves itself to database using JDBC.
 void sendPassword(SimpleMailer mailer)
          Sends an email to the user that show his/her password in the body of the message.
 void setAddress1(java.lang.String x)
          Stores the of the first line of the mail address for the person represented by this record.
 void setAddress2(java.lang.String x)
          Stores the of the second line of the mail address for the person represented by this record.
 void setAffiliation(java.lang.String affiliation)
          Stores the affiliation of the person represented by this record.
 void setCity(java.lang.String x)
          Stores the city of the mail address for the person represented by this record.
 void setCompany(java.lang.String x)
          Stores the company for which the person represented by this record works.
 void setCountry(java.lang.String x)
          Stores the country of the mail address for the person represented by this record.
 void setDepartment(java.lang.String x)
          Stores the department in which the person represented by this record works.
 void setDirectory(UserDirectory dir)
          Keep in touch with the UserDirectory to request that it save our state when important changes occured.
 void setEmail(java.lang.String email)
          Sets the email field for this user.
 void setFaxNumber(java.lang.String x)
          Stores the fax number for the person represented by this record.
 void setFirstName(java.lang.String name)
          Stores the first name of the person represented by this record.
 void setLastName(java.lang.String name)
          Stores the last name of the person represented by this record.
 void setMiddleName(java.lang.String name)
          Stores the middle name of the person represented by this record.
 void setPassword(java.lang.String passwd)
          Sets the password for this user record.
 void setPhoneNumber(java.lang.String x)
          Stores the for the person represented by this record.
 void setState(java.lang.String x)
          Stores the zip or postal code of the mail address for the person represented by this record.
 void setTitle(java.lang.String title)
          Stores the title of the person represented by this record.
 void setUserID(java.lang.String uid)
          Sets the user id for this record.
 void setZip(java.lang.String x)
          Stores the zip or postal code of the mail address for the person represented by this record.
 java.lang.String toString()
           
 boolean tryPassword(java.lang.String password)
          Try wether this password is correct for this user.
 void userLogsIn()
          Keeps track of the logins for this user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

userID_required

protected static boolean userID_required

firstName_required

protected static boolean firstName_required

middleName_required

protected static boolean middleName_required

lastName_required

protected static boolean lastName_required

title_required

protected static boolean title_required

email_required

protected static boolean email_required

password_required

protected static boolean password_required

affiliation_required

protected static boolean affiliation_required

company_required

protected static boolean company_required

department_required

protected static boolean department_required

address1_required

protected static boolean address1_required

address2_required

protected static boolean address2_required

zip_required

protected static boolean zip_required

country_required

protected static boolean country_required

state_required

protected static boolean state_required

phoneNumber_required

protected static boolean phoneNumber_required

faxNumber_required

protected static boolean faxNumber_required

city_required

protected static boolean city_required

NO_PROBLEM_REPORT

public static java.lang.String NO_PROBLEM_REPORT
Constructor Detail

UserRecordImpl

public UserRecordImpl(java.sql.Connection conn,
                      java.lang.String userID,
                      java.lang.String password)
               throws java.sql.SQLException
Constructor for UserRecord that takes a connection and constructs the UserRecord by querying the database tables. JDBC implementation.


UserRecordImpl

public UserRecordImpl(java.sql.Connection conn,
                      java.lang.String recordID)
               throws java.sql.SQLException
Constructor for UserRecord that takes a connection and constructs the UserRecord by querying the database tables. JDBC implementation.


UserRecordImpl

public UserRecordImpl(javax.servlet.http.HttpServletRequest request)
Deprecated. Use parseParameters(javax.servlet.http.HttpServletRequest) instead.

Constructs a user record from a request parameters.


UserRecordImpl

protected UserRecordImpl(java.lang.String userID)
Method Detail

putToDatabase

public void putToDatabase(java.sql.Connection con)
                   throws java.sql.SQLException
Saves itself to database using JDBC.

Specified by:
putToDatabase in interface UserRecord
java.sql.SQLException

getRecordID

public java.lang.String getRecordID()
Returns this recordID. The record identifier is built so that it is nearly impossible to build one by chance that allows to obtain a valid user record from the user directory. Once the recordID has been obtained, it can be used at a latter time to get a record from the UserDirectory. For the guest account, the recordID is well known: it is "guest".

Specified by:
getRecordID in interface UserRecord
See Also:
UserDirectory

isValid

public final boolean isValid(boolean needsPassword)
Returns wether this user record is valid.

Specified by:
isValid in interface UserRecord
Parameters:
needsPassword - True requires the password to be valid, False ignores the password.

isEmailTrusted

public boolean isEmailTrusted()
Can this email be trusted ? An email is declared trusted after
  • A user registered successfully
  • the user received the (login, passwd) via email
  • the user logged in successfully at least once with (login, passwd).

    Specified by:
    isEmailTrusted in interface UserRecord

  • hasBeenUsed

    public boolean hasBeenUsed()
    Has this registered user entered the service once ?

    Specified by:
    hasBeenUsed in interface UserRecord
    Returns:
    True when the user received the password by email and loggued in at least once to our service. False otherwise.

    userLogsIn

    public void userLogsIn()
    Keeps track of the logins for this user. This method must be called by SessionLogin each time a new login is granted to this user.

    Specified by:
    userLogsIn in interface UserRecord

    getLastLogin

    public java.util.Date getLastLogin()
    Get the last login time.

    Specified by:
    getLastLogin in interface UserRecord

    parseParameters

    public void parseParameters(javax.servlet.http.HttpServletRequest request)
                         throws PasswordDoesNotMatch
    Updates the record with the information stored in the request parameters.

    Specified by:
    parseParameters in interface UserRecord
    PasswordDoesNotMatch
    See Also:
    For the first supported parameter (the list follows).

    getDiagnostic

    public java.lang.String getDiagnostic()
    Description copied from interface: UserRecord
    Returns the reason(s) why the record was found invalid.

    Specified by:
    getDiagnostic in interface UserRecord
    Returns:
    always returns a user oriented String.

    getGuestRecord

    public static UserRecord getGuestRecord()
    Returns a dummy record for the guest account.


    tryPassword

    public boolean tryPassword(java.lang.String password)
    Try wether this password is correct for this user.

    Specified by:
    tryPassword in interface UserRecord
    Returns:
    True if the password is correct, False otherwise.

    generatePassword

    public void generatePassword()
    Generates a password for this account and send it to the user by email. After a UserRecord has been constructed, a password needs to be set and sent to the user via email so that the email is checked. This method generates a random password and sends the email that communicate it to the user declared email account.

    Specified by:
    generatePassword in interface UserRecord

    sendPassword

    public void sendPassword(SimpleMailer mailer)
    Sends an email to the user that show his/her password in the body of the message.

    Specified by:
    sendPassword in interface UserRecord

    toString

    public java.lang.String toString()
    Overrides:
    toString in class java.lang.Object

    setEmail

    public void setEmail(java.lang.String email)
    Sets the email field for this user. When the new email and the previous one are identical, nothing is done and the state of the UserRecord is unchanged (the email is still trusted). The new email is not trusted immediately. We need to regenerate a random password and send it to the user.

    Specified by:
    setEmail in interface UserRecord
    Parameters:
    email - the new email or null, in which case nothing is done.

    getEmail

    public java.lang.String getEmail()
    Returns the email declared by this user. This email may or may not have been validated.

    Specified by:
    getEmail in interface UserRecord
    See Also:
    isEmailTrusted.

    getUserID

    public java.lang.String getUserID()
    Gets the user id for this record.

    Specified by:
    getUserID in interface UserRecord

    setUserID

    public void setUserID(java.lang.String uid)
    Sets the user id for this record.

    Specified by:
    setUserID in interface UserRecord

    getFirstName

    public java.lang.String getFirstName()
    Gets the first name of the person represented by this record.

    Specified by:
    getFirstName in interface UserRecord

    setFirstName

    public void setFirstName(java.lang.String name)
    Stores the first name of the person represented by this record.

    Specified by:
    setFirstName in interface UserRecord

    getMiddleName

    public java.lang.String getMiddleName()
    Gets the middle name of the person represented by this record.

    Specified by:
    getMiddleName in interface UserRecord

    setMiddleName

    public void setMiddleName(java.lang.String name)
    Stores the middle name of the person represented by this record.

    Specified by:
    setMiddleName in interface UserRecord

    getLastName

    public java.lang.String getLastName()
    Gets the last name of the person represented by this record.

    Specified by:
    getLastName in interface UserRecord

    setLastName

    public void setLastName(java.lang.String name)
    Stores the last name of the person represented by this record.

    Specified by:
    setLastName in interface UserRecord

    getTitle

    public java.lang.String getTitle()
    Gets the title of the person represented by this record.

    Specified by:
    getTitle in interface UserRecord

    setTitle

    public void setTitle(java.lang.String title)
    Stores the title of the person represented by this record.

    Specified by:
    setTitle in interface UserRecord

    getAffiliation

    public java.lang.String getAffiliation()
    Gets the affiliation of the person represented by this record.

    Specified by:
    getAffiliation in interface UserRecord

    setAffiliation

    public void setAffiliation(java.lang.String affiliation)
    Stores the affiliation of the person represented by this record.

    Specified by:
    setAffiliation in interface UserRecord

    setPassword

    public void setPassword(java.lang.String passwd)
    Description copied from interface: UserRecord
    Sets the password for this user record.

    Specified by:
    setPassword in interface UserRecord

    getCompany

    public java.lang.String getCompany()
    Description copied from interface: UserRecord
    Gets the company for which the person represented by this record works.

    Specified by:
    getCompany in interface UserRecord

    setCompany

    public void setCompany(java.lang.String x)
    Description copied from interface: UserRecord
    Stores the company for which the person represented by this record works.

    Specified by:
    setCompany in interface UserRecord

    getDepartment

    public java.lang.String getDepartment()
    Description copied from interface: UserRecord
    Gets the department in which the person represented by this record works.

    Specified by:
    getDepartment in interface UserRecord

    setDepartment

    public void setDepartment(java.lang.String x)
    Description copied from interface: UserRecord
    Stores the department in which the person represented by this record works.

    Specified by:
    setDepartment in interface UserRecord

    getAddress1

    public java.lang.String getAddress1()
    Description copied from interface: UserRecord
    Gets the first line of the mail address for the person represented by this record.

    Specified by:
    getAddress1 in interface UserRecord

    setAddress1

    public void setAddress1(java.lang.String x)
    Description copied from interface: UserRecord
    Stores the of the first line of the mail address for the person represented by this record.

    Specified by:
    setAddress1 in interface UserRecord

    getAddress2

    public java.lang.String getAddress2()
    Description copied from interface: UserRecord
    Gets the second line of the mail address for the person represented by this record.

    Specified by:
    getAddress2 in interface UserRecord

    setAddress2

    public void setAddress2(java.lang.String x)
    Description copied from interface: UserRecord
    Stores the of the second line of the mail address for the person represented by this record.

    Specified by:
    setAddress2 in interface UserRecord

    getZip

    public java.lang.String getZip()
    Description copied from interface: UserRecord
    Gets the zip or postal code of the mail address for the person represented by this record.

    Specified by:
    getZip in interface UserRecord

    setZip

    public void setZip(java.lang.String x)
    Description copied from interface: UserRecord
    Stores the zip or postal code of the mail address for the person represented by this record.

    Specified by:
    setZip in interface UserRecord

    getCity

    public java.lang.String getCity()
    Description copied from interface: UserRecord
    Gets the city of the mail address for the person represented by this record.

    Specified by:
    getCity in interface UserRecord

    setCity

    public void setCity(java.lang.String x)
    Description copied from interface: UserRecord
    Stores the city of the mail address for the person represented by this record.

    Specified by:
    setCity in interface UserRecord

    getCountry

    public java.lang.String getCountry()
    Description copied from interface: UserRecord
    Gets the country of the mail address for the person represented by this record.

    Specified by:
    getCountry in interface UserRecord

    setCountry

    public void setCountry(java.lang.String x)
    Description copied from interface: UserRecord
    Stores the country of the mail address for the person represented by this record.

    Specified by:
    setCountry in interface UserRecord

    getState

    public java.lang.String getState()
    Description copied from interface: UserRecord
    Gets the state of the mail address for the person represented by this record.

    Specified by:
    getState in interface UserRecord

    setState

    public void setState(java.lang.String x)
    Description copied from interface: UserRecord
    Stores the zip or postal code of the mail address for the person represented by this record.

    Specified by:
    setState in interface UserRecord

    getPhoneNumber

    public java.lang.String getPhoneNumber()
    Description copied from interface: UserRecord
    Gets the phone number for the person represented by this record.

    Specified by:
    getPhoneNumber in interface UserRecord

    setPhoneNumber

    public void setPhoneNumber(java.lang.String x)
    Description copied from interface: UserRecord
    Stores the for the person represented by this record.

    Specified by:
    setPhoneNumber in interface UserRecord

    getFaxNumber

    public java.lang.String getFaxNumber()
    Description copied from interface: UserRecord
    Gets the fax number for the person represented by this record.

    Specified by:
    getFaxNumber in interface UserRecord

    setFaxNumber

    public void setFaxNumber(java.lang.String x)
    Description copied from interface: UserRecord
    Stores the fax number for the person represented by this record.

    Specified by:
    setFaxNumber in interface UserRecord

    setDirectory

    public void setDirectory(UserDirectory dir)
    Keep in touch with the UserDirectory to request that it save our state when important changes occured.

    Specified by:
    setDirectory in interface UserRecord


    Copyright @ 2003 Mount Sinai School of Medicine. All Rights Reserved.