HiRISE

HiRISE.HiWish
Class User

java.lang.Object
  extended by org.apache.struts.action.ActionForm
      extended by HiRISE.HiWish.User
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ChangePasswordForm, EditSelfForm, LoginForm, RegisterForm, ResetPasswordForm

public class User
extends org.apache.struts.action.ActionForm
implements Serializable

This class captures form submissions for users. It represents data potentially going into the database. Subclasses should override the validate method their specific purposes.

See Also:
Serialized Form

Nested Class Summary
protected static class User.ConfirmationType
          Type of confirmation
 
Field Summary
protected  String additionalNames
          Other names, middle, patronymic, etc.
protected  String affiliation
          Institutional affiliations
protected  String confirmationToken
          The token value
protected  User.ConfirmationType confirmationType
          The type of confirmation needed
protected  String country
          Country of residence?
protected  boolean educator
          True if an educator
protected  String emailAddress
          Email address.
protected  String familyName
          Family name
protected  String givenName
          Given name (typically first)
protected  String gradeLevel
          Current grade level.
protected  String gradeLevelOther
          Other grade level, if not a value in GRADES
static String[] GRADES
          Possible values of gradeLevel.
static String[] HIGHEST_GRADES
          Possible values of highestGradeCompleted
protected  String highestGradeCompleted
          Highest grade completed.
static String LOGIN_COOKIE_KEY
          Key used for the 'remember me' cookie
static byte MAXLEN_ADDITIONAL_NAMES
          Maximum number of characters in additional names
static byte MAXLEN_AFFILIATION
          Maximum number of characters allowed in the affiliation field
static byte MAXLEN_COUNTRY
          Maximum number of characters in country
static byte MAXLEN_EMAIL_ADDRESS
          Maximum number of characters in email address
static byte MAXLEN_FAMILY_NAME
          Maximum number of characters in family name
static byte MAXLEN_GIVEN_NAME
          Maximum number of characters in given name
static byte MAXLEN_GRADE_LEVEL_OTHER
          Maximum number of characters allowed in the grade level 'other' field
static byte MAXLEN_NAME_SUFFIX
          Maximum number of characters in the name suffix
static short MAXLEN_NOTE
          Maximum number of characters allowed in the note field
static byte MAXLEN_OCCUPATION
          Maximum number of characters in occupation
static byte MAXLEN_POSTAL_CODE
          Maximum number of characters in postal code
static byte MAXLEN_USERNAME
          Maximum number of characters in username
static byte MINLEN_PASSWORD
          Minimum number of characters in password (undigested)
static byte MINLEN_USERNAME
          Minimum number of characters in username
protected  String nameSuffix
          Suffix / title
protected  String note
          Additional notes (provided by the user?)
protected  boolean notifyOnGeometry
          True if notify on geometry completion is requested (team members only
protected  boolean notifyOnRelease
          True if notify on release is requested
protected  boolean notifyOnUpdate
          True if notify on update is requested
protected  String occupation
          Current occupation
protected  String password
          Undigested password.
protected  String postalCode
          Postal (zip) code
protected  boolean privileged
          True if the user is special
protected  String publicKey
          Public key, probably unused (what kind is it?)
static Pattern REGEX_USERNAME
          Allowed values of username.
protected  boolean student
          True if a student
protected  String username
          The username.
protected  String verifyEmail
          For cases where user must provide the email twice
protected  String verifyPassword
          For cases where user must provide the password twice
 
Fields inherited from class org.apache.struts.action.ActionForm
multipartRequestHandler, servlet
 
Constructor Summary
User()
          Empty constructor for the JavaBeans
User(long id, String username)
          Create a user form for a particular known user.
User(long id, String username, String... groups)
          Create a user form for a particular known user.
 
Method Summary
 void addSTL(int themeID)
          Set science theme ownership (or co-ownership)
 String getAdditionalNames()
          Get the value for additional names
 String getAffiliation()
          Get the affiliation
 String getConfirmationToken()
          Get the confirmation token value
 User.ConfirmationType getConfirmationType()
          Get the confirmation type
 String getCountry()
          Get the country name
 String getEmailAddress()
          Get the email address value
 String getFamilyName()
          Get the family name value
 String getGivenName()
          Get the given name value
 String getGradeLevel()
          Get the value for grade level
 String getGradeLevelOther()
          Get the 'other' grade level
 String[] getGrades()
          Get the values in the Grades array
 String[] getGroups()
          Get the groups for this user
 String getHighestGradeCompleted()
          Get the value for highest grade completed
 String[] getHighestGrades()
          Get the values in the Highest Grades array
 long getID()
          Get the database ID for this user.
 String getNameSuffix()
          Get the name suffix value
 String getNote()
          Get the note
 boolean getNotifyOnGeometry()
          True if the user has requested notification on geometry completion
 boolean getNotifyOnRelease()
          True if user has requested notification on release
 boolean getNotifyOnUpdate()
          True if the user has requested notification on update
 String getOccupation()
          Get the occupation
 String getPassword()
          Get the value for password
 String getPostalCode()
          Get the postal code
 String getPublicKey()
          Get the value for public key
 String getUsername()
          Get the user's username
 String getVerifyEmail()
          Get the 2nd email which was input.
 String getVerifyPassword()
          Get the 2nd password which was input.
 boolean hasRole(String group)
          Returns true if the user is a member of the given group.
 boolean hasRoles()
          Returns true if the user is any groups
 boolean isEducator()
          Get the value for educator
 boolean isEmail()
          Return true if the input looks like an email address.
 boolean isPrivileged()
          True if the user is special
 boolean isStudent()
          Get the value for student
 boolean leadsTheme(int themeID)
          Check to see if the user is a lead (or co-lead) of a science theme
 void reset(org.apache.struts.action.ActionMapping map, javax.servlet.http.HttpServletRequest req)
          Reset the boolean fields, so that unchecked checkboxes are detected.
 void setAdditionalNames(String additionalNames)
          Set additional names
 void setAffiliation(String affiliation)
          Set the affiliation
 void setConfirmationToken(String token)
          Set the token value for confirmation
 void setConfirmationType(String type)
          Set the confirmation type
 void setConfirmationType(User.ConfirmationType type)
          Set the confirmation type
 void setCountry(String country)
          Set the country
 void setEducator(boolean educator)
          Set the educator value
 void setEmailAddress(String emailAddress)
          Set the email address
 void setFamilyName(String familyName)
          Set the family name
 void setGivenName(String givenName)
          Set the given name
 void setGradeLevel(String gradeLevel)
          Set the grade level
 void setGradeLevelOther(String gradeLevelOther)
          Set the 'other' grade level
 void setGroups(String... groups)
          Set the groups to be used for this user (will not be saved to DB)
 void setHighestGradeCompleted(String highestGradeCompleted)
          Set the highest grade completed
 void setNameSuffix(String nameSuffix)
          Set the name suffix
 void setNote(String note)
          Set the note for this user
 void setNotifyOnGeometry(boolean notifyOnGeometry)
          Pass true if the user requests notification on geometry
 void setNotifyOnRelease(boolean notifyOnRelease)
          Pass true if the user requests notification on release
 void setNotifyOnUpdate(boolean notifyOnUpdate)
          Pass true if the user requests notification on update
 void setOccupation(String occupation)
          Set the occupation
 void setPassword(String password)
          Set the password
 void setPostalCode(String postalCode)
          Set the postal code
 void setPublicKey(String publicKey)
          Set the public key
 void setStudent(boolean student)
          Set the student value
 void setUsername(String username)
          Set the username to be used for this user (will not be saved to DB)
 void setVerifyEmail(String verifyEmail)
          Set the value from the 2nd email element.
 void setVerifyPassword(String verifyPassword)
          Set the value from the 2nd password element.
 String toString()
           
 org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping map, javax.servlet.http.HttpServletRequest req)
          Note this does not validate everything.
 
Methods inherited from class org.apache.struts.action.ActionForm
getMultipartRequestHandler, getServlet, getServletWrapper, reset, setMultipartRequestHandler, setServlet, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOGIN_COOKIE_KEY

public static final String LOGIN_COOKIE_KEY
Key used for the 'remember me' cookie

See Also:
Constant Field Values

username

protected String username
The username. Once the account is created, they cannot edit this.


givenName

protected String givenName
Given name (typically first)


familyName

protected String familyName
Family name


additionalNames

protected String additionalNames
Other names, middle, patronymic, etc.


nameSuffix

protected String nameSuffix
Suffix / title


emailAddress

protected String emailAddress
Email address. They are allowed to change this.


postalCode

protected String postalCode
Postal (zip) code


country

protected String country
Country of residence?


occupation

protected String occupation
Current occupation


password

protected String password
Undigested password.


highestGradeCompleted

protected String highestGradeCompleted
Highest grade completed. Values defined in HIGHEST_GRADES


affiliation

protected String affiliation
Institutional affiliations


educator

protected boolean educator
True if an educator


student

protected boolean student
True if a student


gradeLevel

protected String gradeLevel
Current grade level. Values defined in GRADES.


gradeLevelOther

protected String gradeLevelOther
Other grade level, if not a value in GRADES


publicKey

protected String publicKey
Public key, probably unused (what kind is it?)


note

protected String note
Additional notes (provided by the user?)


verifyEmail

protected String verifyEmail
For cases where user must provide the email twice


verifyPassword

protected String verifyPassword
For cases where user must provide the password twice


confirmationToken

protected String confirmationToken
The token value


confirmationType

protected User.ConfirmationType confirmationType
The type of confirmation needed


privileged

protected boolean privileged
True if the user is special


notifyOnRelease

protected boolean notifyOnRelease
True if notify on release is requested


notifyOnUpdate

protected boolean notifyOnUpdate
True if notify on update is requested


notifyOnGeometry

protected boolean notifyOnGeometry
True if notify on geometry completion is requested (team members only


HIGHEST_GRADES

public static final String[] HIGHEST_GRADES
Possible values of highestGradeCompleted


GRADES

public static final String[] GRADES
Possible values of gradeLevel.


MINLEN_USERNAME

public static final byte MINLEN_USERNAME
Minimum number of characters in username

See Also:
Constant Field Values

MINLEN_PASSWORD

public static final byte MINLEN_PASSWORD
Minimum number of characters in password (undigested)

See Also:
Constant Field Values

MAXLEN_USERNAME

public static final byte MAXLEN_USERNAME
Maximum number of characters in username

See Also:
Constant Field Values

MAXLEN_GIVEN_NAME

public static final byte MAXLEN_GIVEN_NAME
Maximum number of characters in given name

See Also:
Constant Field Values

MAXLEN_FAMILY_NAME

public static final byte MAXLEN_FAMILY_NAME
Maximum number of characters in family name

See Also:
Constant Field Values

MAXLEN_ADDITIONAL_NAMES

public static final byte MAXLEN_ADDITIONAL_NAMES
Maximum number of characters in additional names

See Also:
Constant Field Values

MAXLEN_NAME_SUFFIX

public static final byte MAXLEN_NAME_SUFFIX
Maximum number of characters in the name suffix

See Also:
Constant Field Values

MAXLEN_EMAIL_ADDRESS

public static final byte MAXLEN_EMAIL_ADDRESS
Maximum number of characters in email address

See Also:
Constant Field Values

MAXLEN_POSTAL_CODE

public static final byte MAXLEN_POSTAL_CODE
Maximum number of characters in postal code

See Also:
Constant Field Values

MAXLEN_COUNTRY

public static final byte MAXLEN_COUNTRY
Maximum number of characters in country

See Also:
Constant Field Values

MAXLEN_OCCUPATION

public static final byte MAXLEN_OCCUPATION
Maximum number of characters in occupation

See Also:
Constant Field Values

MAXLEN_AFFILIATION

public static final byte MAXLEN_AFFILIATION
Maximum number of characters allowed in the affiliation field

See Also:
Constant Field Values

MAXLEN_GRADE_LEVEL_OTHER

public static final byte MAXLEN_GRADE_LEVEL_OTHER
Maximum number of characters allowed in the grade level 'other' field

See Also:
Constant Field Values

MAXLEN_NOTE

public static final short MAXLEN_NOTE
Maximum number of characters allowed in the note field

See Also:
Constant Field Values

REGEX_USERNAME

public static final Pattern REGEX_USERNAME
Allowed values of username.

Constructor Detail

User

public User()
Empty constructor for the JavaBeans


User

public User(long id,
            String username)
Create a user form for a particular known user.

Parameters:
id - DB key
username - Value of username

User

public User(long id,
            String username,
            String... groups)
Create a user form for a particular known user.

Parameters:
id - People table ID key
username - People table username
groups - People table groups (1 or more)
Method Detail

isEmail

public boolean isEmail()
Return true if the input looks like an email address.

Returns:
True if username is actually an email address

getID

public long getID()
Get the database ID for this user.

Returns:
database key

setGroups

public void setGroups(String... groups)
Set the groups to be used for this user (will not be saved to DB)

Parameters:
groups - One or more groups

getGroups

public String[] getGroups()
Get the groups for this user

Returns:
groups array

addSTL

public void addSTL(int themeID)
Set science theme ownership (or co-ownership)

Parameters:
themeID - corresponds to Science_Themes table ID

leadsTheme

public boolean leadsTheme(int themeID)
Check to see if the user is a lead (or co-lead) of a science theme

Parameters:
themeID - corresponds to Science_Themes table ID
Returns:
true if user is an STL for the theme

getGrades

public String[] getGrades()
Get the values in the Grades array

Returns:
grades

getHighestGrades

public String[] getHighestGrades()
Get the values in the Highest Grades array

Returns:
highest grades

getUsername

public String getUsername()
Get the user's username

Returns:
username

setUsername

public void setUsername(String username)
Set the username to be used for this user (will not be saved to DB)

Parameters:
username - Username text

getVerifyEmail

public String getVerifyEmail()
Get the 2nd email which was input.

Returns:
The String from the verifyEmail field

setVerifyEmail

public void setVerifyEmail(String verifyEmail)
Set the value from the 2nd email element.

Parameters:
verifyEmail - Email address input

getVerifyPassword

public String getVerifyPassword()
Get the 2nd password which was input.

Returns:
The String from the verifyPassword field

setVerifyPassword

public void setVerifyPassword(String verifyPassword)
Set the value from the 2nd password element.

Parameters:
verifyPassword - Password input

getGivenName

public String getGivenName()
Get the given name value

Returns:
given name

setGivenName

public void setGivenName(String givenName)
Set the given name

Parameters:
givenName - value for given name

getFamilyName

public String getFamilyName()
Get the family name value

Returns:
family name

setFamilyName

public void setFamilyName(String familyName)
Set the family name

Parameters:
familyName - value for family name

getAdditionalNames

public String getAdditionalNames()
Get the value for additional names

Returns:
additional names

setAdditionalNames

public void setAdditionalNames(String additionalNames)
Set additional names

Parameters:
additionalNames - values

getNameSuffix

public String getNameSuffix()
Get the name suffix value

Returns:
name suffix

setNameSuffix

public void setNameSuffix(String nameSuffix)
Set the name suffix

Parameters:
nameSuffix - value for name suffix

getEmailAddress

public String getEmailAddress()
Get the email address value

Returns:
email address

setEmailAddress

public void setEmailAddress(String emailAddress)
Set the email address

Parameters:
emailAddress - value for email address

getPostalCode

public String getPostalCode()
Get the postal code

Returns:
value for postal code

setPostalCode

public void setPostalCode(String postalCode)
Set the postal code

Parameters:
postalCode - value for postal code

getCountry

public String getCountry()
Get the country name

Returns:
value for country

setCountry

public void setCountry(String country)
Set the country

Parameters:
country - value for country name

getOccupation

public String getOccupation()
Get the occupation

Returns:
value for occupation

setOccupation

public void setOccupation(String occupation)
Set the occupation

Parameters:
occupation - value for occupation name

getPassword

public String getPassword()
Get the value for password

Returns:
text input as password

setPassword

public void setPassword(String password)
Set the password

Parameters:
password - unhashed password text

getHighestGradeCompleted

public String getHighestGradeCompleted()
Get the value for highest grade completed

Returns:
highest grade completed value

setHighestGradeCompleted

public void setHighestGradeCompleted(String highestGradeCompleted)
Set the highest grade completed

Parameters:
highestGradeCompleted - value for highest grade completed

getAffiliation

public String getAffiliation()
Get the affiliation

Returns:
value for affiliation

setAffiliation

public void setAffiliation(String affiliation)
Set the affiliation

Parameters:
affiliation - value for affiliation

isEducator

public boolean isEducator()
Get the value for educator

Returns:
true if educator

setEducator

public void setEducator(boolean educator)
Set the educator value

Parameters:
educator - true for educators

isStudent

public boolean isStudent()
Get the value for student

Returns:
true if student

setStudent

public void setStudent(boolean student)
Set the student value

Parameters:
student - true for students

getGradeLevel

public String getGradeLevel()
Get the value for grade level

Returns:
grade level

setGradeLevel

public void setGradeLevel(String gradeLevel)
Set the grade level

Parameters:
gradeLevel - value for grade level

getGradeLevelOther

public String getGradeLevelOther()
Get the 'other' grade level

Returns:
value for other grade level

setGradeLevelOther

public void setGradeLevelOther(String gradeLevelOther)
Set the 'other' grade level

Parameters:
gradeLevelOther - value for other grade level

getPublicKey

public String getPublicKey()
Get the value for public key

Returns:
public key

setPublicKey

public void setPublicKey(String publicKey)
Set the public key

Parameters:
publicKey - value for public key

isPrivileged

public boolean isPrivileged()
True if the user is special

Returns:
true if special

getNote

public String getNote()
Get the note

Returns:
note

setNote

public void setNote(String note)
Set the note for this user

Parameters:
note - text

getConfirmationToken

public String getConfirmationToken()
Get the confirmation token value

Returns:
token

setConfirmationToken

public void setConfirmationToken(String token)
Set the token value for confirmation

Parameters:
token - value

getConfirmationType

public User.ConfirmationType getConfirmationType()
Get the confirmation type

Returns:
confirmation type

setConfirmationType

public void setConfirmationType(String type)
Set the confirmation type

Parameters:
type - null or a valid confirmation type string

setConfirmationType

public void setConfirmationType(User.ConfirmationType type)
Set the confirmation type

Parameters:
type - null or a valid confirmation type

getNotifyOnRelease

public boolean getNotifyOnRelease()
True if user has requested notification on release

Returns:
notify on release

getNotifyOnUpdate

public boolean getNotifyOnUpdate()
True if the user has requested notification on update

Returns:
notify on update

getNotifyOnGeometry

public boolean getNotifyOnGeometry()
True if the user has requested notification on geometry completion

Returns:
notify on geometry

setNotifyOnRelease

public void setNotifyOnRelease(boolean notifyOnRelease)
Pass true if the user requests notification on release

Parameters:
notifyOnRelease - input from user

setNotifyOnUpdate

public void setNotifyOnUpdate(boolean notifyOnUpdate)
Pass true if the user requests notification on update

Parameters:
notifyOnUpdate - input from user

setNotifyOnGeometry

public void setNotifyOnGeometry(boolean notifyOnGeometry)
Pass true if the user requests notification on geometry

Parameters:
notifyOnGeometry - input from user

hasRole

public boolean hasRole(String group)
Returns true if the user is a member of the given group.

Parameters:
group - Name of group
Returns:
True if user in group

hasRoles

public boolean hasRoles()
Returns true if the user is any groups

Returns:
True if the user is in at least one group

toString

public String toString()
Overrides:
toString in class Object

validate

public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping map,
                                                      javax.servlet.http.HttpServletRequest req)
Note this does not validate everything. Subclasses should override and provide validation for the specific fields that they need.

Overrides:
validate in class org.apache.struts.action.ActionForm
Parameters:
map - Struts mapping
req - Incoming request
Returns:
Any validation errors

reset

public void reset(org.apache.struts.action.ActionMapping map,
                  javax.servlet.http.HttpServletRequest req)
Reset the boolean fields, so that unchecked checkboxes are detected.

Overrides:
reset in class org.apache.struts.action.ActionForm
Parameters:
map - Struts action mapping
req - Incoming request

HiRISE

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