org.starhope.appius.user
Class Person

java.lang.Object
  extended by org.starhope.appius.sql.SQLPeerDatum
      extended by org.starhope.appius.user.Person
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Parent, User

public abstract class Person
extends SQLPeerDatum

This is an abstract superclass for both Parents and Users.

Author:
brpocock, theys
See Also:
Serialized Form

Field Summary
protected  boolean canContact
          If true, we can contact this user.
private  String couponCode
          TODO: document this field (theys, Nov 5, 2009) couponCode (Person)
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  Date mailConfirmed
          The timestamp of the confirmation of the user's (or parent's) eMail.
protected  Date mailConfirmSent
          TODO: document this field (brpocock, Nov 5, 2009) mailConfirmSent (Person)
protected  String password
          The user (or parent)'s unencrypted (plain text) password.
private static long serialVersionUID
          TODO: document this field (theys, Sep 30, 2009) serialVersionUID (long)
 
Constructor Summary
Person()
           
 
Method Summary
 boolean checkPassword(String passwordGuess)
          Returns true if the password is correct.
abstract  void flush()
           
 boolean forgotPassword(String forgottenPasswordQ, String forgottenPasswordA)
          Send the user their forgotten password if they know the answer to their secret question.
protected  void generateNewPassword()
          Generate a new, random password using only ASCII-7 printable characters ($20 to $7e).
abstract  String getApprovalCookie()
          Get a cookie object for sending mail.
abstract  String getConfirmationTemplate()
          WRITEME: document this method (theys, Sep 9, 2009)
 String getCouponCode()
          TODO: document this method (theys, Nov 5, 2009)
 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()
           
 Date getMailConfirmed()
           
 String getPassword()
           
abstract  String getPotentialUserName()
          TODO: document this method (brpocock, Sep 10, 2009)
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 membership subscription
 boolean isCanContact()
          TODO: document this method (brpocock, Oct 13, 2009)
protected  void remindPassword()
          Send a reminder eMail for a forgotten password.
abstract  void rename(String newName)
           Rename the user account, updating all necessary related records.
 void sendConfirmationMail()
          Sends confirmation mail to whomever should receive it
 void sendStaffPasswordReset()
          Sends mail to user or parent when a staff member resets their password.
 void sentConfirmationMail()
          TODO: document this method (brpocock, Sep 25, 2009)
 void setCanContact(boolean canContact1)
           
 void setCouponCode(String newCouponCode)
          TODO: document this method (theys, Nov 5, 2009)
 void setForgotPasswordAnswer(String answer)
          TODO: document this method (brpocock, Sep 25, 2009)
 void setForgotPasswordQuestion(String question)
          TODO: document this method (brpocock, Sep 25, 2009)
 void setGivenName(String givenName1)
           
 void setMail(String mail1)
           
 void setMailConfirmed(Date mailConfirmed1)
           
 void setPassword(String password1)
          Changes the person's password
 void setPasswordAndPasswordRecovery(String question, String answer, String newPassword)
           
 void setPasswordRecovery(String forgottenPasswordQuestion, String forgottenPasswordAnswer)
          Set the password-recovery question and answer pair
 String setRandomPassword()
          TODO: document this method (brpocock, Sep 25, 2009)
 
Methods inherited from class org.starhope.appius.sql.SQLPeerDatum
changed, findInCache, get, getCacheUniqueID, saveInCache, set, set, toJSON
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
TODO: document this field (theys, Sep 30, 2009) serialVersionUID (long)

See Also:
Constant Field Values

canContact

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


couponCode

private transient String couponCode
TODO: document this field (theys, Nov 5, 2009) couponCode (Person)


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 Date mailConfirmed
The timestamp of the confirmation of the user's (or parent's) eMail.


mailConfirmSent

protected Date mailConfirmSent
TODO: document this field (brpocock, Nov 5, 2009) mailConfirmSent (Person)


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 membership subscription

Currently, kids under 17 return their parent.

Parameters:
p - The person, for whom someone else may be responsible for payments
Returns:
the Person object that able to use a credit card.

checkPassword

public boolean checkPassword(String passwordGuess)
Returns true if the password is correct. Returns false if password is not set or the guess was blank.

Parameters:
passwordGuess - The password which is to be checked
Returns:
true, if the password is correct and not null

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.

generateNewPassword

protected void generateNewPassword()
Generate a new, random password using only ASCII-7 printable characters ($20 to $7e). Password's length will range from 10-20 characters in total.


getApprovalCookie

public abstract String getApprovalCookie()
Get a cookie object for sending mail. Cookies are generated differently between User and Parent.

Returns:
an opaque string that identifies the user uniquely
See Also:
Parent, User

getConfirmationTemplate

public abstract String getConfirmationTemplate()
WRITEME: document this method (theys, Sep 9, 2009)

Returns:
the template filename to be used for confirming this account

getCouponCode

public String getCouponCode()
TODO: document this method (theys, Nov 5, 2009)

Returns:
WRITEME

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 Date getMailConfirmed()
Returns:
the mailConfirmed

getPassword

public String getPassword()
Returns:
the password

getPotentialUserName

public abstract String getPotentialUserName()
TODO: document this method (brpocock, Sep 10, 2009)

Returns:
a user name that could be used

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

isCanContact

public boolean isCanContact()
TODO: document this method (brpocock, Oct 13, 2009)

Returns:
WRITEME

remindPassword

protected void remindPassword()
Send a reminder eMail for a forgotten 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

sendConfirmationMail

public void sendConfirmationMail()
Sends confirmation mail to whomever should receive it


sendStaffPasswordReset

public void sendStaffPasswordReset()
Sends mail to user or parent when a staff member resets their password.


sentConfirmationMail

public void sentConfirmationMail()
TODO: document this method (brpocock, Sep 25, 2009)


setCanContact

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

setCouponCode

public void setCouponCode(String newCouponCode)
TODO: document this method (theys, Nov 5, 2009)

Parameters:
newCouponCode - WRITEME

setForgotPasswordAnswer

public void setForgotPasswordAnswer(String answer)
TODO: document this method (brpocock, Sep 25, 2009)

Parameters:
answer - WRITEME

setForgotPasswordQuestion

public void setForgotPasswordQuestion(String question)
TODO: document this method (brpocock, Sep 25, 2009)

Parameters:
question - WRITEME

setGivenName

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

setMail

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

setMailConfirmed

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

setPassword

public void setPassword(String password1)
Changes the person's password

Parameters:
password1 - the password to set

setPasswordAndPasswordRecovery

public void setPasswordAndPasswordRecovery(String question,
                                           String answer,
                                           String newPassword)
                                    throws GameLogicException
Parameters:
question - WRITEME
answer - WRITEME
newPassword - WRITEME
Throws:
GameLogicException - WRITEME

setPasswordRecovery

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

Parameters:
forgottenPasswordQuestion - the question
forgottenPasswordAnswer - the correct answer

setRandomPassword

public String setRandomPassword()
TODO: document this method (brpocock, Sep 25, 2009)

Returns:
WRITEME