org.starhope.appius.user
Class Person

java.lang.Object
  extended by org.starhope.appius.util.ManagedReferenceHolder
      extended by org.starhope.appius.sql.SQLPeerDatum
          extended by org.starhope.appius.user.Person
Direct Known Subclasses:
Parent, User

public abstract class Person
extends SQLPeerDatum

This is an abstract superclass for both Parents and Users.

Author:
brpocock, theys

Field Summary
protected  boolean canContact
          If true, we can contact this user.
protected  String dialect
          The national dialect of the language language which the user speaks.
protected  String forgotPasswordAnswer
          Given answer to forgotten password question.
protected  String forgotPasswordQuestion
          The user's question to answer if they forget their password.
protected  String givenName
          The user's given name.
protected  String language
          The user's preferred human language for communications.
protected  String mail
          The user's eMail address.
protected  Timestamp mailConfirmed
          The timestamp of the confirmation of the user's (or parent's) eMail.
protected  String password
          The user (or parent)'s unencrypted (plain text) password.
 
Constructor Summary
Person()
           
 
Method Summary
 boolean checkPassword(String passwordGuess)
          Check a password provided versus the one stored in the database.
abstract  void flush()
           
 boolean forgotPassword(String forgottenPasswordQ, String forgottenPasswordA)
          Send the user their forgotten password if they know the answer to their secret question.
 String getDialect()
           
abstract  String getDisplayName()
          This method's only use is for more closely aligning User and Parent classes.
 String getForgotPasswordAnswer()
          Get the forgotten password question
 String getForgotPasswordQuestion()
          Get the forgotten password question
 String getGivenName()
           
abstract  HashMap<Timestamp,HashMap<String,String>> getHistory(Date after, int limit)
          Returns the historical contents of this user's record.
 String getLanguage()
           
 String getMail()
           
 Timestamp getMailConfirmed()
           
 String getPassword()
           
abstract  String getResponsibleMail()
          Get the eMail address of a responsible person: either the player, or the parent.
static Person getResponsiblePerson(Person p)
          Get reference to User or Parent for purchasing a transaction.
protected abstract  void remindPassword()
          WRITEME: document this method (brpocock, Aug 12, 2009) method to send e-mail to account owner (parent account or user account) with a reset password.
abstract  void rename(String newName)
           Rename the user account, updating all necessary related records.
 void setCanContact(boolean canContact)
           
 void setGivenName(String givenName)
           
 void setMail(String mail)
           
 void setMailConfirmed(Timestamp mailConfirmed)
           
 void setPassword(String password)
          Changes the personr's password
 void setPasswordRecovery(String forgottenPasswordQuestion, String forgottenPasswordAnswer)
          Set the password-recovery question and answer pair
 
Methods inherited from class org.starhope.appius.sql.SQLPeerDatum
changed, findInCache, get, getCacheUniqueID, prepare, prepare, saveInCache, set, set, toJSON
 
Methods inherited from class org.starhope.appius.util.ManagedReferenceHolder
deref, setRef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

canContact

protected boolean canContact
If true, we can contact this user. Note that we usually mail parents of kids, not the kids themselves.


dialect

protected String dialect
The national dialect of the language language which the user speaks.


forgotPasswordAnswer

protected String forgotPasswordAnswer
Given answer to forgotten password question.


forgotPasswordQuestion

protected String forgotPasswordQuestion
The user's question to answer if they forget their password.


givenName

protected String givenName
The user's given name. Optional. Just for use in membership screens to identify the user (especially to his/her parent)


language

protected String language
The user's preferred human language for communications. Currently must be "en" (English). Use ISO codes.


mail

protected String mail
The user's eMail address. Optional for kids (need their parent's, though); mandatory for teens or adults.


mailConfirmed

protected Timestamp mailConfirmed
The timestamp of the confirmation of the user's (or parent's) eMail.


password

protected String password
The user (or parent)'s unencrypted (plain text) password. Alice and Bill would be so, so sad.

Constructor Detail

Person

public Person()
Method Detail

getResponsiblePerson

public static Person getResponsiblePerson(Person p)
Get reference to User or Parent for purchasing a transaction. Currently, kids under 17 return their parent.

Parameters:
p -
Returns:
the Person object that able to use a credit card.

checkPassword

public boolean checkPassword(String passwordGuess)
Check a password provided versus the one stored in the database.

Parameters:
passwordGuess - The password guess
Returns:
true if password is correct false if password is incorrect

flush

public abstract void flush()
Specified by:
flush in class SQLPeerDatum
See Also:
SQLPeerDatum.flush()

forgotPassword

public boolean forgotPassword(String forgottenPasswordQ,
                              String forgottenPasswordA)
Send the user their forgotten password if they know the answer to their secret question.

Parameters:
forgottenPasswordQ - The question being answered
forgottenPasswordA - The answer provided
Returns:
true if answer is correct and false if it is not also triggers the send password e-mail if correct.

getDialect

public String getDialect()
Returns:
the dialect

getDisplayName

public abstract String getDisplayName()
This method's only use is for more closely aligning User and Parent classes. Since Parent class does not have a user name, it returns null.

Returns:
null

getForgotPasswordAnswer

public String getForgotPasswordAnswer()
Get the forgotten password question

Returns:
the question to ask

getForgotPasswordQuestion

public String getForgotPasswordQuestion()
Get the forgotten password question

Returns:
the question to ask

getGivenName

public String getGivenName()
Returns:
the givenName

getHistory

public abstract HashMap<Timestamp,HashMap<String,String>> getHistory(Date after,
                                                                     int limit)
Returns the historical contents of this user's record.

Parameters:
after - If non-null, specifies the date after which we want to view records. To see all records, back to the creation of the user record, supply a null.
limit - If this is a positive number, it limits the results to this number of records.
Returns:
A map of timestamps to key/value pairs. All values are expressed as strings (even though they may have numeric, enumerative, or date / date-time types in the database), since this is primarily (only?) for human-viewable auditing.

getLanguage

public String getLanguage()
Returns:
the language

getMail

public String getMail()
Returns:
the mail

getMailConfirmed

public Timestamp getMailConfirmed()
Returns:
the mailConfirmed

getPassword

public String getPassword()
Returns:
the password

getResponsibleMail

public abstract String getResponsibleMail()
Get the eMail address of a responsible person: either the player, or the parent. Currently, kids 13-17 return their own mail.

Returns:
the eMail address

remindPassword

protected abstract void remindPassword()
WRITEME: document this method (brpocock, Aug 12, 2009) method to send e-mail to account owner (parent account or user account) with a reset password.


rename

public abstract void rename(String newName)

Rename the user account, updating all necessary related records. Note, in particular, that Smartfox is wholly dependant upon user names, so all records related to Smartfox must be updated!

If the user is currently online, this will fuck up hilariously, I think.

Parameters:
newName - The new user name

setCanContact

public void setCanContact(boolean canContact)
Parameters:
canContact - the canContact to set

setGivenName

public void setGivenName(String givenName)
Parameters:
givenName - the givenName to set

setMail

public void setMail(String mail)
             throws GameLogicException
Parameters:
mail - the mail to set
Throws:
GameLogicException

setMailConfirmed

public void setMailConfirmed(Timestamp mailConfirmed)
Parameters:
mailConfirmed - the mailConfirmed to set

setPassword

public void setPassword(String password)
Changes the personr's password

Parameters:
password - the password to set

setPasswordRecovery

public void setPasswordRecovery(String forgottenPasswordQuestion,
                                String forgottenPasswordAnswer)
Set the password-recovery question and answer pair

Parameters:
forgottenPasswordQuestion - the question
forgottenPasswordAnswer - the correct answer