|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.starhope.appius.mb.MBSession
public class MBSession
This is the session data collected from an arbitrary front-end system (e.g. typical web-browser front-end system) performing some actions involving the user's Membership & Billing records. This is typically associated with a web browser session cookie in a fairly transparent way.
| Field Summary | |
|---|---|
org.starhope.appius.mb.fields.MBField_String |
address1
Street address (first line) |
org.starhope.appius.mb.fields.MBField_String |
address2
Street address (second line) |
private static BeforePageHook |
beforePageHook
hook to run before the engine hits a page |
org.starhope.appius.mb.fields.MBField_String |
buyerFamilyName
Buyer's family name / surname |
org.starhope.appius.mb.fields.MBField_String |
buyerGivenName
Buyer's given name |
org.starhope.appius.mb.fields.MBField_Boolean |
canContact
Permission to contact the user |
org.starhope.appius.mb.fields.MBField_DataRecord<AvatarClass> |
characterClass
WRITEME: Document this brpocock@star-hope.org |
org.starhope.appius.mb.fields.MBField_Child |
child
The child currently selected by a parent |
org.starhope.appius.mb.fields.MBField_String |
city
City/town/village/&c |
org.starhope.appius.mb.fields.MBField_String |
country
country |
MBField_NumericString |
creditCardCode
Credit-Card confirmation code, aka CVC, CCV, and a million other names. |
org.starhope.appius.mb.fields.MBField_Calendar |
creditCardExpiry
expiry date (month and year only are significant) |
MBField_CreditCardNumber |
creditCardNumber
Credit-card number |
org.starhope.appius.mb.fields.MBField_String |
creditCardType
Credit-card type string, “visa” or “mastercard” |
org.starhope.appius.mb.fields.MBField_DateOfBirth |
dateOfBirth
New user registering, date of birth |
org.starhope.appius.mb.fields.MBField_DataRecord<Enrolment> |
enrolmentChosen
Enrolment type chosen |
private EnumMap<org.starhope.appius.mb.fields.MBFieldIdent,EnumSet<MBErrorReason>> |
errors
WRITEME: Document this brpocock@star-hope.org |
private Set<String> |
errorToasts
Error message toasts |
private Map<String,String> |
extraParams
extra params set for local use |
private static EnumMap<org.starhope.appius.mb.fields.MBFieldIdent,Set<String>> |
fieldsMapConfirm
fields that require double-entry confirmation in the UI |
private static EnumMap<org.starhope.appius.mb.fields.MBFieldIdent,Set<String>> |
fieldsMapInput
Mapping input fields to MBFieldIdent tokens |
org.starhope.appius.mb.fields.MBField_String |
forgotPasswordA
Forgotten password recovery question's answer |
org.starhope.appius.mb.fields.MBField_String |
forgotPasswordQ
Forgotten password recovery question |
org.starhope.appius.mb.fields.MBField_String |
givenName
User's self-identified given name (optional) |
(package private) EnumSet<MBGoal> |
goals
Goals that the user is trying to acheive |
private String |
lastPage
previous page viewed |
private String |
latestPage
current page being viewed |
(package private) String |
latestSource
The latest place from which the user accessed this session. |
org.starhope.appius.mb.fields.MBField_String |
loginAuth
Login, being entered for authentication purposes |
org.starhope.appius.mb.fields.MBField_LoginRequest |
loginRequested
Login, being requested for new registration or rename |
org.starhope.appius.mb.fields.MBField_Mail |
mailAuth
Parent logins |
org.starhope.appius.mb.fields.MBField_Mail |
mailProvided
User's mail, maybe for registration, maybe for parent login |
private int |
mySerial
Local session unique serial number for debugging tracing |
private static Set<MBParamTranslator> |
paramTranslators
A collection of hooks to run during parameter processing |
org.starhope.appius.mb.fields.MBField_Password |
passwordAuth
Password, being provided for authentication purposes |
org.starhope.appius.mb.fields.MBField_Password |
passwordRequested
Password, being requested for new registration or password-change |
org.starhope.appius.mb.fields.MBField_Payment |
payment
Payment being constructed |
org.starhope.appius.mb.fields.MBField_String |
phone
phone number |
org.starhope.appius.mb.fields.MBField_String |
postalCode
postal code / ZIP code |
private static Set<PostParentRegistrationHook> |
postParentRegistrationHooks
Hooks to run after successful parent registrations |
private static Set<PostPaymentHook> |
postPaymentHooks
Hooks to run after enrolment payments are received. |
private static Set<PostUserRegistrationHook> |
postUserRegistrationHooks
Hooks to run after successful user registrations |
org.starhope.appius.mb.fields.MBField_String |
prepaidCode
Code from a prepaid card or promotion |
org.starhope.appius.mb.fields.MBField_String |
province
State/province/locality/county/whatever |
org.starhope.appius.mb.fields.MBField_Boolean_True |
rulesAgree
Agree to some rules other than the T&C |
private static AtomicInteger |
serial
For debugging/tracking purposes, assign unique serial numbers to each session originated. |
private static long |
serialVersionUID
Java serialisation unique ID |
private String |
sourceCookie
a cookie identifying the referral source for the user coming in |
org.starhope.appius.mb.fields.MBField_Boolean_True |
termsConditionsAgree
User agreeing to terms and conditions |
private Map<String,String> |
toasts
Toasts |
private static Map<String,EnumSet<org.starhope.appius.mb.fields.MBFieldIdent>> |
urls
A mapping of URL:s to the fields that they are expected to set/provide |
private Parent |
visitorAsParent
the parent who is visiting the site (if one, see visitorRole) |
private User |
visitorAsUser
the user who is visiting the site (if one, see visitorAsUser) |
private VisitorRole |
visitorRole
whether the current visitor to the site is acting for themself, or is a parent |
| Constructor Summary | |
|---|---|
MBSession()
WRITEME: Document this constructor brpocock@star-hope.org |
|
| Method Summary | |
|---|---|
private void |
_fulfillGoals()
See if any goals can be fulfilled. |
void |
acceptInput(javax.servlet.ServletRequest params)
Set any fields who find associated parameters, to their associated values. |
void |
add(org.starhope.appius.mb.fields.MBFieldIdent field,
MBErrorReason reason)
WRITEME: Document this method brpocock@star-hope.org |
boolean |
add(MBGoal goal)
|
void |
addErrorToast(String text)
|
static void |
addParamTranslator(MBParamTranslator translator)
|
static void |
addPostEnrolmentHook(PostPaymentHook hook)
|
static void |
addPostParentRegistrationHook(PostParentRegistrationHook hook)
|
static void |
addPostUserRegistrationHook(PostUserRegistrationHook hook)
|
void |
addToast(String id,
String message)
WRITEME: Document this method brpocock@star-hope.org |
void |
beforePage(javax.servlet.jsp.PageContext context)
Do stuff before starting on the page |
private void |
changePassword()
WRITEME: Document this method brpocock@star-hope.org |
private void |
checkForActiveMember()
WRITEME: Document this method brpocock@star-hope.org |
private void |
chooseAccountToPay()
Choose an account for which to pay |
void |
clearErrors()
Clear the enqueued errors set |
void |
clearErrorsFor(org.starhope.appius.mb.fields.MBFieldIdent field)
clear all errors |
void |
forgetVisitor()
Forget (log out) the user. |
static MBSession |
get(javax.servlet.http.HttpServletRequest request)
Convenience method for JSP's |
static MBSession |
get(javax.servlet.http.HttpSession httpSession)
Extract the MBSession from the HttpSession |
String |
getBestNextURI()
|
Calendar |
getBirthDate()
|
String |
getCharacterClass()
|
Enrolment |
getEnrolmentType()
WRITEME: Document this method brpocock@star-hope.org |
Map<org.starhope.appius.mb.fields.MBFieldIdent,EnumSet<MBErrorReason>> |
getErrors()
|
Map<org.starhope.appius.mb.fields.MBFieldIdent,EnumSet<MBErrorReason>> |
getErrorsAndClear()
|
Set<Pair<org.starhope.appius.mb.fields.MBFieldIdent,String>> |
getErrorToastsAndClear()
This gets all errors, whether associated with a particular field or not, and returns them for toasts and tool tips and such. |
String |
getExtraParam(String key)
Store an extra param |
org.starhope.appius.mb.fields.MBField<?> |
getField(org.starhope.appius.mb.fields.MBFieldIdent ident)
Find a field in the session that handles the given ident |
Set<org.starhope.appius.mb.fields.MBFieldIdent> |
getFieldsNeeded()
|
Set<org.starhope.appius.mb.fields.MBFieldIdent> |
getFieldsOn(String requestURI)
|
String |
getForgotPasswordAnswer()
|
String |
getForgotPasswordQuestion()
|
Set<MBGoal> |
getGoals()
|
String |
getLastURI()
|
String |
getLatestSource()
|
String |
getMail()
Deprecated. mailProvided |
String |
getPasswordRequested()
Deprecated. passwordRequested |
Payment |
getPayment()
|
String |
getPrepaidCookie()
Historically was "ibc" — prepaid card identification string of some kind |
String |
getRequestedUserName()
Deprecated. loginRequested |
String |
getSource()
Get the referral source for this user landing |
private User |
getTargetMember()
|
List<String> |
getToastsAndClear()
Get the toasts, and clear them. |
Parent |
getVisitorAsParent()
WRITEME: Document this method brpocock@star-hope.org |
User |
getVisitorAsUser()
WRITEME: Document this method brpocock@star-hope.org |
VisitorRole |
getVisitorRole()
WRITEME: Document this method brpocock@star-hope.org |
boolean |
hasAgreedToTerms()
WRITEME: Document this method brpocock@star-hope.org |
boolean |
hasAgreedToTerms(boolean really)
WRITEME: Document this method brpocock@star-hope.org |
boolean |
hasErrors()
|
private void |
logInParent()
WRITEME: Document this method brpocock@star-hope.org |
private void |
logInSelf()
WRITEME: Document this method brpocock@star-hope.org |
void |
logout(javax.servlet.http.HttpSession httpSession)
Destroy the association between this session object and the HTTP session provided |
static void |
mapConfirmField(org.starhope.appius.mb.fields.MBFieldIdent ident,
Set<String> fieldNames)
|
static void |
mapConfirmField(org.starhope.appius.mb.fields.MBFieldIdent ident,
String fieldName)
|
static void |
mapField(org.starhope.appius.mb.fields.MBFieldIdent ident,
Set<String> fieldNames)
|
static void |
mapField(org.starhope.appius.mb.fields.MBFieldIdent ident,
String fieldName)
|
private void |
payAccount()
WRITEME: Document this method brpocock@star-hope.org |
static void |
provideURL(Collection<org.starhope.appius.mb.fields.MBFieldIdent> fields,
String url)
Identify an URL which can be used to ask for a certain set of fields. |
static void |
provideURL(org.starhope.appius.mb.fields.MBFieldIdent[] fields,
String url)
Identify an URL which can be used to ask for a certain set of fields. |
private void |
registerParent()
Register a new parent account (but be lenient, in case they forgot they already have one) |
private void |
registerUser()
Create a new user account |
boolean |
remove(MBGoal goal)
|
static void |
setBeforePageHook(BeforePageHook newHook)
|
Calendar |
setBirthDate(String year,
String month,
String day)
WRITEME: Document this method brpocock@star-hope.org |
String |
setCharacterClass(String newClass)
WRITEME: Document this method brpocock@star-hope.org |
String |
setExtraParam(String key,
String value)
store something extra in the session for local handlers; use SPARINGLY |
void |
setForgottenPassword(String q,
String a)
WRITEME: Document this method brpocock@star-hope.org |
void |
setLatestSource(String newSource)
|
void |
setPrepaidCookie(String newCookie)
|
String |
setRequestedUserName(String login)
WRITEME: Document this method brpocock@star-hope.org |
private void |
setResponsibleMail()
WRITEME: Document this method brpocock@star-hope.org |
String |
setSource(String cookie)
WRITEME: Document this method brpocock@star-hope.org |
void |
setVisitorAsParent(Parent parent)
WRITEME: Document this method brpocock@star-hope.org |
void |
setVisitorAsUser(User sessionUser)
WRITEME: Document this method brpocock@star-hope.org |
static String |
stripIndex(String uri)
Strip the “index.jsp” and/or trailing “/” off a URI to get a normalised form for index pages |
String |
toString()
|
boolean |
wantToVisit(String pageURI)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final AtomicInteger serial
private static BeforePageHook beforePageHook
private static final EnumMap<org.starhope.appius.mb.fields.MBFieldIdent,Set<String>> fieldsMapConfirm
private static final EnumMap<org.starhope.appius.mb.fields.MBFieldIdent,Set<String>> fieldsMapInput
private static final Set<MBParamTranslator> paramTranslators
private static final Set<PostParentRegistrationHook> postParentRegistrationHooks
private static final Set<PostPaymentHook> postPaymentHooks
private static final Set<PostUserRegistrationHook> postUserRegistrationHooks
private static final long serialVersionUID
private static Map<String,EnumSet<org.starhope.appius.mb.fields.MBFieldIdent>> urls
public final org.starhope.appius.mb.fields.MBField_String address1
public final org.starhope.appius.mb.fields.MBField_String address2
public final org.starhope.appius.mb.fields.MBField_String buyerFamilyName
public final org.starhope.appius.mb.fields.MBField_String buyerGivenName
public final org.starhope.appius.mb.fields.MBField_Boolean canContact
public final org.starhope.appius.mb.fields.MBField_DataRecord<AvatarClass> characterClass
public final org.starhope.appius.mb.fields.MBField_Child child
public final org.starhope.appius.mb.fields.MBField_String city
public final org.starhope.appius.mb.fields.MBField_String country
public final MBField_NumericString creditCardCode
public final org.starhope.appius.mb.fields.MBField_Calendar creditCardExpiry
public final MBField_CreditCardNumber creditCardNumber
public final org.starhope.appius.mb.fields.MBField_String creditCardType
public final org.starhope.appius.mb.fields.MBField_Mail mailAuth
public final org.starhope.appius.mb.fields.MBField_DateOfBirth dateOfBirth
public final org.starhope.appius.mb.fields.MBField_DataRecord<Enrolment> enrolmentChosen
private final EnumMap<org.starhope.appius.mb.fields.MBFieldIdent,EnumSet<MBErrorReason>> errors
private final Set<String> errorToasts
private final Map<String,String> extraParams
public final org.starhope.appius.mb.fields.MBField_String forgotPasswordA
public final org.starhope.appius.mb.fields.MBField_String forgotPasswordQ
public final org.starhope.appius.mb.fields.MBField_String givenName
EnumSet<MBGoal> goals
public final org.starhope.appius.mb.fields.MBField_String loginAuth
public final org.starhope.appius.mb.fields.MBField_LoginRequest loginRequested
public final org.starhope.appius.mb.fields.MBField_Mail mailProvided
public final org.starhope.appius.mb.fields.MBField_Password passwordAuth
public final org.starhope.appius.mb.fields.MBField_Password passwordRequested
public final org.starhope.appius.mb.fields.MBField_Payment payment
public final org.starhope.appius.mb.fields.MBField_String phone
public final org.starhope.appius.mb.fields.MBField_String postalCode
public final org.starhope.appius.mb.fields.MBField_String prepaidCode
public final org.starhope.appius.mb.fields.MBField_String province
public final org.starhope.appius.mb.fields.MBField_Boolean_True rulesAgree
private String sourceCookie
public final org.starhope.appius.mb.fields.MBField_Boolean_True termsConditionsAgree
private final Map<String,String> toasts
private Parent visitorAsParent
visitorRole)
private User visitorAsUser
visitorAsUser)
private VisitorRole visitorRole
String latestSource
private final int mySerial
private String lastPage
private String latestPage
| Constructor Detail |
|---|
public MBSession()
| Method Detail |
|---|
public static void addParamTranslator(MBParamTranslator translator)
translator - A facility that may be able to translate
“unusual” fields submitted by forms into types that
can be understood by MBSessionpublic static void addPostEnrolmentHook(PostPaymentHook hook)
hook - A hook to be run after receiving an enrolment
payment. The interface provides different methods to
easily handle various cases.public static void addPostParentRegistrationHook(PostParentRegistrationHook hook)
hook - a hook to run after registering a new parent
successfullypublic static void addPostUserRegistrationHook(PostUserRegistrationHook hook)
hook - a hook to run after registering a new user
successfullypublic static MBSession get(javax.servlet.http.HttpServletRequest request)
request - Servlet request object
HttpSession
by get(HttpSession)public static MBSession get(javax.servlet.http.HttpSession httpSession)
MBSession from the HttpSession
httpSession - the HttpSession with the
MBSession stored in it
MBSession
public static void mapConfirmField(org.starhope.appius.mb.fields.MBFieldIdent ident,
Set<String> fieldNames)
ident - the M&B Field identifierfieldNames - the names of input confirmation fields from the
ServletRequest
public static void mapConfirmField(org.starhope.appius.mb.fields.MBFieldIdent ident,
String fieldName)
ident - the M&B Field identifierfieldName - the name of one input confirmation field from
the HttpParams
public static void mapField(org.starhope.appius.mb.fields.MBFieldIdent ident,
Set<String> fieldNames)
ident - the M&B Field identifierfieldNames - the names of input fields from the
HttpParams
public static void mapField(org.starhope.appius.mb.fields.MBFieldIdent ident,
String fieldName)
ident - the M&B Field identifierfieldName - the name of one input field from the
HttpParams
public static void provideURL(Collection<org.starhope.appius.mb.fields.MBFieldIdent> fields,
String url)
fields - fields presented at that URLurl - the URL
public static void provideURL(org.starhope.appius.mb.fields.MBFieldIdent[] fields,
String url)
fields - fields presented at that URLurl - the URLpublic static void setBeforePageHook(BeforePageHook newHook)
newHook - beforePage(PageContext) hook for
beforePageHook (singular)public static String stripIndex(String uri)
uri - The URI to be stripped
private void _fulfillGoals()
public void acceptInput(javax.servlet.ServletRequest params)
params - parameters provided by Tomcat (&c.)
public void add(org.starhope.appius.mb.fields.MBFieldIdent field,
MBErrorReason reason)
field - the field affected by the errorreason - what type of errorpublic boolean add(MBGoal goal)
goal - a (possibly new) goal that the user wants to achieve
public void addErrorToast(String text)
text - a new error message toast
public void addToast(String id,
String message)
id - WRITEMEmessage - WRITEMEpublic void beforePage(javax.servlet.jsp.PageContext context)
context - page contextprivate void changePassword()
private void checkForActiveMember()
private void chooseAccountToPay()
public void clearErrors()
public void clearErrorsFor(org.starhope.appius.mb.fields.MBFieldIdent field)
field - the fieldpublic void forgetVisitor()
public String getBestNextURI()
public Calendar getBirthDate()
public String getCharacterClass()
public Enrolment getEnrolmentType()
throws NotFoundException
NotFoundException - WRITEMEpublic Map<org.starhope.appius.mb.fields.MBFieldIdent,EnumSet<MBErrorReason>> getErrors()
public Map<org.starhope.appius.mb.fields.MBFieldIdent,EnumSet<MBErrorReason>> getErrorsAndClear()
public Set<Pair<org.starhope.appius.mb.fields.MBFieldIdent,String>> getErrorToastsAndClear()
This gets all errors, whether associated with a particular field or not, and returns them for toasts and tool tips and such. Toasts are returned with a null field entry.
This is not a Map, because one field could have multiple errors associated with it. However, the EnumSet implementation in the back end will ensure that a single error, even if detected multiple times, will only be reported once per field.
Both field-associated error codes and general toasts are cleared.
public String getExtraParam(String key)
key - dotted-notation unique ID, e.g.
com.tootsville.peanutCode
public org.starhope.appius.mb.fields.MBField<?> getField(org.starhope.appius.mb.fields.MBFieldIdent ident)
ident - the MBFieldIdent
<> in this session handling itpublic Set<org.starhope.appius.mb.fields.MBFieldIdent> getFieldsNeeded()
public Set<org.starhope.appius.mb.fields.MBFieldIdent> getFieldsOn(String requestURI)
requestURI - the page
public String getForgotPasswordAnswer()
getForgotPasswordQuestion()public String getForgotPasswordQuestion()
getForgotPasswordAnswer()public Set<MBGoal> getGoals()
public String getLastURI()
public String getLatestSource()
@Deprecated public String getMail()
mailProvided
@Deprecated public String getPasswordRequested()
passwordRequested
public Payment getPayment()
public String getPrepaidCookie()
@Deprecated public String getRequestedUserName()
loginRequested
public String getSource()
private User getTargetMember()
public List<String> getToastsAndClear()
public Parent getVisitorAsParent()
throws NotFoundException
NotFoundException - if the visitor isn't known to be a
parent
public User getVisitorAsUser()
throws NotFoundException
NotFoundException - WRITEMEpublic VisitorRole getVisitorRole()
public boolean hasAgreedToTerms()
public boolean hasAgreedToTerms(boolean really)
really - WRITEME
public boolean hasErrors()
private void logInParent()
private void logInSelf()
public void logout(javax.servlet.http.HttpSession httpSession)
httpSession - the session storing the referenceprivate void payAccount()
private void registerParent()
private void registerUser()
public boolean remove(MBGoal goal)
goal - the goal to remove (as achieved or decided against
it)
public Calendar setBirthDate(String year,
String month,
String day)
throws NumberFormatException,
GameLogicException
year - WRITEMEmonth - WRITEMEday - WRITEME
NumberFormatException - WRITEME
GameLogicException - if the date is impossible(-ish) for a
date of birthpublic String setCharacterClass(String newClass)
newClass - WRITEME
public String setExtraParam(String key,
String value)
key - dotted-notation unique ID, e.g.
com.tootsville.peanutCodevalue - arbitrary value; set to null to clear.
public void setForgottenPassword(String q,
String a)
q - WRITEMEa - WRITEMEpublic void setLatestSource(String newSource)
newSource - the latestSource to setpublic void setPrepaidCookie(String newCookie)
newCookie - the prepaidCookie to setpublic String setRequestedUserName(String login)
login - WRITEME
private void setResponsibleMail()
public String setSource(String cookie)
cookie - WRITEME
public void setVisitorAsParent(Parent parent)
parent - WRITEMEpublic void setVisitorAsUser(User sessionUser)
sessionUser - WRITEMEpublic String toString()
toString in class ObjectObject.toString()public boolean wantToVisit(String pageURI)
pageURI - page URI
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||