public class BaseAction
extends com.opensymphony.xwork2.ActionSupport
implements org.apache.struts2.interceptor.ServletRequestAware, org.apache.struts2.interceptor.SessionAware
Modifier and Type | Field and Description |
---|---|
protected static int |
ACTION_CONFIRM_ORDER |
protected static int |
ACTION_CUSTOMER_LOGIN |
protected static int |
ACTION_ENTER_CHECKOUT |
protected static int |
ACTION_NEW_CUSTOMER_VISIT |
protected static int |
ACTION_PAYMENT_METHOD_SELECTED |
protected static int |
ACTION_PRODUCT_VIEWED |
protected static int |
ACTION_REMOVE_FROM_CART |
protected static java.lang.String |
AGREED_COOKIES |
protected static KKAppEng |
appEng
Copy of the KKAppEng
|
protected static int |
COOKIE_MAX_AGE_IN_SECS |
protected static java.lang.String |
CUSTOMER_LOCALE |
protected static java.lang.String |
CUSTOMER_NAME |
protected static java.lang.String |
CUSTOMER_UUID |
protected static java.lang.String |
GUEST_CUSTOMER_ID |
protected static java.lang.String |
KKLOGIN |
protected org.apache.commons.logging.Log |
log
The
Log instance for this application. |
protected static java.lang.String |
MY_ACCOUNT_URL
To set the url in the breadcrumb for My Account
|
protected static java.lang.String |
SEO_DELIM |
protected static int |
SEO_DIRECTORY |
protected static int |
SEO_OFF |
protected static int |
SEO_PARAMETERS |
protected static java.lang.String |
SEO_PRODS_FOR_MANU |
protected static int |
SEO_PRODS_FOR_MANU_CODE |
protected static java.lang.String |
SEO_SEARCH_BY_MANU_BY_LINK |
protected static int |
SEO_SEARCH_BY_MANU_BY_LINK_CODE |
protected static java.lang.String |
SEO_SEL_CAT |
protected static int |
SEO_SEL_CAT_CODE |
protected static java.lang.String |
SEO_SEL_PROD |
protected static int |
SEO_SEL_PROD_CODE |
protected static java.lang.String |
SEO_TYPE |
protected static int |
SEO_TYPE_LENGTH |
java.util.Map<java.lang.String,java.lang.Object> |
strutsSession
Struts session
|
protected static java.lang.String |
TAG_BIRTH_DATE |
static java.lang.String |
TAG_CART_TOTAL
Customer tag
|
protected static java.lang.String |
TAG_CATEGORIES_TIME_VIEWED |
protected static java.lang.String |
TAG_CATEGORIES_VIEWED |
protected static java.lang.String |
TAG_COUNTRY_CODE |
protected static java.lang.String |
TAG_IS_MALE |
protected static java.lang.String |
TAG_LOGIN_DATE |
protected static java.lang.String |
TAG_MANUFACTURERS_TIME_VIEWED |
protected static java.lang.String |
TAG_MANUFACTURERS_VIEWED |
protected static java.lang.String |
TAG_ORDER_PAGE_SIZE |
protected static java.lang.String |
TAG_PROD_PAGE_SIZE |
static java.lang.String |
TAG_PRODUCTS_IN_CART
Customer tag
|
static java.lang.String |
TAG_PRODUCTS_IN_WISHLIST
Customer tag
|
static java.lang.String |
TAG_PRODUCTS_TIME_IN_CART
Customer tag
|
static java.lang.String |
TAG_PRODUCTS_TIME_IN_WISHLIST
Customer tag
|
protected static java.lang.String |
TAG_PRODUCTS_TIME_VIEWED |
protected static java.lang.String |
TAG_PRODUCTS_VIEWED |
protected static java.lang.String |
TAG_REVIEW_PAGE_SIZE |
protected static java.lang.String |
TAG_SEARCH_STRING |
static java.lang.String |
TAG_WISHLIST_TOTAL
Customer tag
|
protected static java.lang.String |
WELCOME |
Constructor and Description |
---|
BaseAction() |
Modifier and Type | Method and Description |
---|---|
protected void |
changeSession(javax.servlet.http.HttpServletRequest request)
Creates a new session when we switch to SSL to avoid hackers using the current session id
(which may have been visible on the URL) to log into the application
|
protected java.lang.String |
checkSSL(KKAppEng eng,
javax.servlet.http.HttpServletRequest request,
int custId,
boolean forceSSL)
Determines whether we are using SSL or not.
|
protected java.lang.String |
escapeFormInput(java.lang.String inputStr)
Common method used to encode certain characters.
|
java.lang.String |
getBaseURL(javax.servlet.http.HttpServletRequest request,
boolean addContext)
Returns the base URL
|
protected com.konakart.appif.CustomerEventIf |
getCustomerEvent(KKAppEng kkAppEng,
int action)
Returns a customer event object with the action and customer id attributes populated.
|
protected java.lang.String |
getForward(javax.servlet.http.HttpServletRequest request,
java.lang.Exception e,
java.lang.String cause,
java.lang.String message,
java.lang.String forward)
If the application sends us a KKException with the cause equal to a more detailed exception
such as KKPasswordDoesntMatchException, sometimes the application has to be able to detect
this so that it can handle the exception by sending an error message back to the screen.
|
KKAppEng |
getJspEng() |
protected KKAppEng |
getKKAppEng(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Sets the variable kkAppEng to the KKAppEng instance saved in the session.
|
protected java.lang.String |
getKKCookie(java.lang.String attrId,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
KKAppEng kkAppEng)
Utility method to read a KKCookie.
|
protected java.lang.String |
getKKCookie(java.lang.String customerUuid,
java.lang.String attrId,
KKAppEng kkAppEng)
Utility method to read a KKCookie when we have the CustomerUuid
|
java.lang.String |
getRedirectURL(javax.servlet.http.HttpServletRequest request)
Returns the base redirect URL used in AJAX calls
|
protected java.lang.String |
handleException(javax.servlet.http.HttpServletRequest request,
java.lang.Exception e)
A common method that contains the code to deal with exceptions
|
protected void |
insertCustomerEvent(KKAppEng kkAppEng,
int action)
Shortcut method for inserting a customer event passing no custom event data
|
protected void |
insertCustomerEvent(KKAppEng kkAppEng,
int action,
java.math.BigDecimal dec1)
Shortcut method for inserting a customer event passing a decimal as event data
|
protected void |
insertCustomerEvent(KKAppEng kkAppEng,
int action,
int int1)
Shortcut method for inserting a customer event passing an integer as event data
|
protected void |
insertCustomerEvent(KKAppEng kkAppEng,
int action,
java.lang.String str1)
Shortcut method for inserting a customer event passing a string as event data
|
protected void |
insertCustomerEvent(KKAppEng kkAppEng,
int action,
java.lang.String str1,
java.lang.String str2,
int int1,
int int2,
java.math.BigDecimal dec1,
java.math.BigDecimal dec2)
Inserts a customer event where all of the available parameters are passed
|
protected java.lang.String |
kkURLEncode(java.lang.String in)
A URL encoder which converts spaces to "-" and doesn't encode forward or back slashes since
many app servers don't accept these because of security issues.
|
protected int |
loggedIn(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
KKAppEng kkAppEng,
java.lang.String forwardAfterLogin)
Checks to see whether we are logged in.
|
protected int |
loggedIn(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
KKAppEng kkAppEng,
java.lang.String forwardAfterLogin,
boolean checkXSRF,
java.lang.String xsrfToken)
Checks to see whether we are logged in.
|
protected int |
loggedIn(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
KKAppEng kkAppEng,
java.lang.String forwardAfterLogin,
java.lang.String xsrfToken)
Checks to see whether we are logged in.
|
protected com.konakart.appif.LoginResultIf |
login(KKAppEng kkAppEng,
javax.servlet.http.HttpServletRequest request,
java.lang.String loginUsername,
java.lang.String password)
Method changes the session before performing the login in order to avoid a Session Fixation
attack.
|
protected void |
manageCookieLogout(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
KKAppEng kkAppEng)
When we log out, ensure that the new guest customer that is created has the id saved in the
browser cookie.
|
java.lang.String |
noNull(java.lang.String in)
Utility method called from JSPs to return an empty string when the value of the input string
is null.
|
void |
setJspEng(KKAppEng jspEng) |
protected void |
setKKCookie(java.lang.String attrId,
java.lang.String attrValue,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
KKAppEng kkAppEng)
Utility method that can be used to set a KKCookie.
|
protected void |
setKKCookie(java.lang.String customerUuid,
java.lang.String attrId,
java.lang.String attrValue,
KKAppEng kkAppEng)
Utility method to set a KKCookie when we have the customerUuid
|
void |
setServletRequest(javax.servlet.http.HttpServletRequest arg0)
Required for implementing ServletRequestAware interface
|
void |
setSession(java.util.Map<java.lang.String,java.lang.Object> session)
Required for implementing SessionAware interface
|
protected void |
setupResponseForSEORedirect(javax.servlet.http.HttpServletResponse response)
Common code for setting up the redirect response.
|
protected void |
setupResponseForSSLRedirect(javax.servlet.http.HttpServletResponse response,
java.lang.String redirForward)
Common code for setting up the redirect response when switching from HTTP to HTTPS and vice
versa
|
protected void |
updateRecentlyViewedProducts(KKAppEng kkAppEng,
com.konakart.appif.CustomerTagIf oldTag,
com.konakart.appif.CustomerTagIf newTag)
Method called when a customer logs in or logs out.
|
addActionError, addActionMessage, addFieldError, clearActionErrors, clearErrors, clearErrorsAndMessages, clearFieldErrors, clearMessages, clone, doDefault, execute, getActionErrors, getActionMessages, getErrorMessages, getErrors, getFieldErrors, getFormatted, getLocale, getText, getText, getText, getText, getText, getText, getText, getText, getText, getTexts, getTexts, hasActionErrors, hasActionMessages, hasErrors, hasFieldErrors, hasKey, input, pause, setActionErrors, setActionMessages, setContainer, setFieldErrors, validate
protected org.apache.commons.logging.Log log
Log
instance for this application.protected static final java.lang.String KKLOGIN
protected static final java.lang.String WELCOME
protected static final java.lang.String GUEST_CUSTOMER_ID
protected static final java.lang.String CUSTOMER_LOCALE
protected static final java.lang.String CUSTOMER_NAME
protected static final java.lang.String CUSTOMER_UUID
protected static final java.lang.String AGREED_COOKIES
protected static final int COOKIE_MAX_AGE_IN_SECS
protected static final int ACTION_NEW_CUSTOMER_VISIT
protected static final int ACTION_CUSTOMER_LOGIN
protected static final int ACTION_ENTER_CHECKOUT
protected static final int ACTION_CONFIRM_ORDER
protected static final int ACTION_PAYMENT_METHOD_SELECTED
protected static final int ACTION_REMOVE_FROM_CART
protected static final int ACTION_PRODUCT_VIEWED
protected static final java.lang.String TAG_PRODUCTS_TIME_VIEWED
protected static final java.lang.String TAG_PRODUCTS_VIEWED
protected static final java.lang.String TAG_CATEGORIES_VIEWED
protected static final java.lang.String TAG_CATEGORIES_TIME_VIEWED
protected static final java.lang.String TAG_MANUFACTURERS_VIEWED
protected static final java.lang.String TAG_MANUFACTURERS_TIME_VIEWED
protected static final java.lang.String TAG_SEARCH_STRING
protected static final java.lang.String TAG_COUNTRY_CODE
protected static final java.lang.String TAG_BIRTH_DATE
protected static final java.lang.String TAG_LOGIN_DATE
protected static final java.lang.String TAG_IS_MALE
protected static final java.lang.String TAG_PROD_PAGE_SIZE
protected static final java.lang.String TAG_ORDER_PAGE_SIZE
protected static final java.lang.String TAG_REVIEW_PAGE_SIZE
protected static final java.lang.String SEO_DELIM
protected static final java.lang.String SEO_TYPE
protected static final int SEO_TYPE_LENGTH
protected static final int SEO_SEL_CAT_CODE
protected static final java.lang.String SEO_SEL_CAT
protected static final int SEO_SEL_PROD_CODE
protected static final java.lang.String SEO_SEL_PROD
protected static final int SEO_SEARCH_BY_MANU_BY_LINK_CODE
protected static final java.lang.String SEO_SEARCH_BY_MANU_BY_LINK
protected static final int SEO_PRODS_FOR_MANU_CODE
protected static final java.lang.String SEO_PRODS_FOR_MANU
protected static final int SEO_OFF
protected static final int SEO_PARAMETERS
protected static final int SEO_DIRECTORY
public static final java.lang.String TAG_PRODUCTS_IN_CART
public static final java.lang.String TAG_PRODUCTS_TIME_IN_CART
public static final java.lang.String TAG_PRODUCTS_IN_WISHLIST
public static final java.lang.String TAG_PRODUCTS_TIME_IN_WISHLIST
public static final java.lang.String TAG_CART_TOTAL
public static final java.lang.String TAG_WISHLIST_TOTAL
public java.util.Map<java.lang.String,java.lang.Object> strutsSession
protected static KKAppEng appEng
protected static final java.lang.String MY_ACCOUNT_URL
protected KKAppEng getKKAppEng(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws KKAppException, com.konakart.app.KKException
request
- the HttpServletRequest requestresponse
- the HttpServletResponse responsecom.konakart.app.KKException
- unexpected exception in KonaKartKKAppException
- unexpected exception in the application engineprotected java.lang.String handleException(javax.servlet.http.HttpServletRequest request, java.lang.Exception e)
request
- the HttpServletRequest requeste
- Exception to handleprotected int loggedIn(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, KKAppEng kkAppEng, java.lang.String forwardAfterLogin) throws com.konakart.app.KKException, KKAppException
kkAppEng
- The KonaKart client engine instanceforwardAfterLogin
- tells us which page to forward to after login.request
- the HttpServletRequest requestresponse
- the HttpServletResponse responsecom.konakart.app.KKException
- unexpected exception in KonaKartKKAppException
- unexpected exception in the application engineprotected int loggedIn(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, KKAppEng kkAppEng, java.lang.String forwardAfterLogin, java.lang.String xsrfToken) throws com.konakart.app.KKException, KKAppException
kkAppEng
- The KonaKart client engine instanceforwardAfterLogin
- tells us which page to forward to after login.request
- the HttpServletRequest requestresponse
- the HttpServletResponse responsexsrfToken
- XSRF tokencom.konakart.app.KKException
- unexpected exception in KonaKartKKAppException
- unexpected exception in the application engineprotected int loggedIn(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, KKAppEng kkAppEng, java.lang.String forwardAfterLogin, boolean checkXSRF, java.lang.String xsrfToken) throws com.konakart.app.KKException, KKAppException
kkAppEng
- The KonaKart client engine instanceforwardAfterLogin
- tells us which page to forward to after login.request
- the HttpServletRequest requestresponse
- the HttpServletResponse responsecheckXSRF
- whether or not to check the XSRF tokenxsrfToken
- XSRF tokencom.konakart.app.KKException
- unexpected exception in KonaKartKKAppException
- unexpected exception in the application engineprotected java.lang.String getForward(javax.servlet.http.HttpServletRequest request, java.lang.Exception e, java.lang.String cause, java.lang.String message, java.lang.String forward)
request
- the HttpServletRequest requeste
- The exception that has been capturedcause
- The name of the cause Exception to look for i.e. KKPasswordDoesntMatchExceptionmessage
- The message to send out to the applicationforward
- The forward if we detect the causeprotected java.lang.String checkSSL(KKAppEng eng, javax.servlet.http.HttpServletRequest request, int custId, boolean forceSSL) throws com.konakart.app.KKException
eng
- a KonaKart Application enginerequest
- the HttpServletRequest requestcustId
- The customer idforceSSL
- Set to true if we should force SSL.com.konakart.app.KKException
- unexpected exception in KonaKartprotected void setKKCookie(java.lang.String attrId, java.lang.String attrValue, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, KKAppEng kkAppEng) throws com.konakart.app.KKException
attrId
- the attrIdattrValue
- the attrValuerequest
- the HttpServletRequest requestresponse
- the HttpServletResponse responsekkAppEng
- the kkAppEngcom.konakart.app.KKException
- unexpected exception in KonaKartprotected void setKKCookie(java.lang.String customerUuid, java.lang.String attrId, java.lang.String attrValue, KKAppEng kkAppEng) throws com.konakart.app.KKException
customerUuid
- the customerUuidattrId
- the attrIdattrValue
- the attrValuekkAppEng
- the kkAppEngcom.konakart.app.KKException
- unexpected exception in KonaKartprotected java.lang.String getKKCookie(java.lang.String attrId, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, KKAppEng kkAppEng) throws com.konakart.app.KKException
attrId
- the attrIdrequest
- the HttpServletRequest requestresponse
- the HttpServletResponse responsekkAppEng
- the kkAppEngcom.konakart.app.KKException
- unexpected exception in KonaKartprotected java.lang.String getKKCookie(java.lang.String customerUuid, java.lang.String attrId, KKAppEng kkAppEng) throws com.konakart.app.KKException
customerUuid
- the customerUuidattrId
- the attrIdkkAppEng
- the kkAppEngcom.konakart.app.KKException
- unexpected exception in KonaKartprotected void manageCookieLogout(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, KKAppEng kkAppEng) throws com.konakart.app.KKException, KKAppException
request
- the HttpServletRequest requestresponse
- the HttpServletResponse responsekkAppEng
- the kkAppEngcom.konakart.app.KKException
- unexpected exception in KonaKartKKAppException
- unexpected exception in the application engineprotected com.konakart.appif.CustomerEventIf getCustomerEvent(KKAppEng kkAppEng, int action)
kkAppEng
- App eng instanceaction
- Event actionprotected void insertCustomerEvent(KKAppEng kkAppEng, int action, java.lang.String str1, java.lang.String str2, int int1, int int2, java.math.BigDecimal dec1, java.math.BigDecimal dec2) throws com.konakart.app.KKException
kkAppEng
- App eng instanceaction
- Event actionstr1
- the str1str2
- the str2int1
- the int1int2
- the int2dec1
- the dec1dec2
- the dec2com.konakart.app.KKException
- unexpected exception in KonaKartprotected void insertCustomerEvent(KKAppEng kkAppEng, int action) throws com.konakart.app.KKException
kkAppEng
- the kkAppEngaction
- the actioncom.konakart.app.KKException
- unexpected exception in KonaKartprotected void insertCustomerEvent(KKAppEng kkAppEng, int action, int int1) throws com.konakart.app.KKException
kkAppEng
- the kkAppEngaction
- the actionint1
- the int1com.konakart.app.KKException
- unexpected exception in KonaKartprotected void insertCustomerEvent(KKAppEng kkAppEng, int action, java.lang.String str1) throws com.konakart.app.KKException
kkAppEng
- the kkAppEngaction
- the actionstr1
- the str1com.konakart.app.KKException
- unexpected exception in KonaKartprotected void insertCustomerEvent(KKAppEng kkAppEng, int action, java.math.BigDecimal dec1) throws com.konakart.app.KKException
kkAppEng
- the kkAppEngaction
- the actiondec1
- the dec1com.konakart.app.KKException
- unexpected exception in KonaKartprotected void updateRecentlyViewedProducts(KKAppEng kkAppEng, com.konakart.appif.CustomerTagIf oldTag, com.konakart.appif.CustomerTagIf newTag) throws KKAppException, com.konakart.app.KKException
kkAppEng
- the KonaKart Application engineoldTag
- When logging in, it is the tag of the guest customer. When logging out, it is the
tag of the logged in customer.newTag
- When logging in, it is the tag of the logged in customer. When logging out, it is
the tag of the guest customer.com.konakart.app.KKException
- unexpected exception in KonaKartKKAppException
- unexpected exception in the application engineprotected com.konakart.appif.LoginResultIf login(KKAppEng kkAppEng, javax.servlet.http.HttpServletRequest request, java.lang.String loginUsername, java.lang.String password) throws com.konakart.app.KKException, KKAppException
kkAppEng
- the kkAppEngrequest
- the HttpServletRequest requestloginUsername
- the loginUsernamepassword
- the passwordcom.konakart.app.KKException
- unexpected exception in KonaKartKKAppException
- unexpected exception in the application engineprotected void changeSession(javax.servlet.http.HttpServletRequest request)
request
- the HttpServletRequest requestprotected void setupResponseForSEORedirect(javax.servlet.http.HttpServletResponse response)
response
- the HttpServletResponse responseprotected void setupResponseForSSLRedirect(javax.servlet.http.HttpServletResponse response, java.lang.String redirForward)
response
- the HttpServletResponse responseredirForward
- the redirect forward to set in the Location parameter in the header of the
responseprotected java.lang.String kkURLEncode(java.lang.String in) throws java.io.UnsupportedEncodingException
in
- the injava.io.UnsupportedEncodingException
- an unexpected UnsupportedEncodingException exceptionpublic void setServletRequest(javax.servlet.http.HttpServletRequest arg0)
setServletRequest
in interface org.apache.struts2.interceptor.ServletRequestAware
public void setSession(java.util.Map<java.lang.String,java.lang.Object> session)
setSession
in interface org.apache.struts2.interceptor.SessionAware
public java.lang.String noNull(java.lang.String in)
in
- the inpublic java.lang.String getRedirectURL(javax.servlet.http.HttpServletRequest request)
request
- the HttpServletRequest requestpublic java.lang.String getBaseURL(javax.servlet.http.HttpServletRequest request, boolean addContext)
request
- the HttpServletRequest requestaddContext
- If true the result looks like http://localhost:8780/konakart otherwise it's like
http://localhost:8780public KKAppEng getJspEng()
public void setJspEng(KKAppEng jspEng)
jspEng
- the jspEng to setprotected java.lang.String escapeFormInput(java.lang.String inputStr)
'"&<>
since most
people use UTF-8 encoding. If you want to encode many more HTML characters you can use the
Apache StringEscapeUtils as follows
return StringEscapeUtils.escapeHtml4(inputStr);
inputStr
- the inputStrCopyright © 2018 DS Data Systems UK Ltd.