com.konakart.al
Class KKAppEng

java.lang.Object
  extended by com.konakart.al.KKAppEng

public class KKAppEng
extends java.lang.Object

This is the entry point for all method calls to the KonaKart client engine. The idea behind the client engine is that each application user instantiates a copy and continues to use the same copy which keeps state for the user. The Struts Actions call methods to retrieve data from the server engine or perform transactions, whereas the JSPs normally call methods to display data which has been cached by the client engine.

This object can be used to get an instance of one of the manager objects such as the CustomerMgr() and the CategoryMgr(). It can also be used to get an instance of the server engine using the getEng() method. Examples of how to use these calls can be obtained from the Struts Action Classes which are shipped in source code format.


Field Summary
static java.lang.String KONAKART_KEY
          Key used to store the KonaKart object within the session.
protected  org.apache.commons.logging.Log log
           
 CurrentNavigation nav
          Used to keep track of where we are.
 
Constructor Summary
KKAppEng()
          Constructor for engine created when a user creates a new session.
KKAppEng(java.lang.String propertiesPath)
          Constructor called by struts when the servlet container is started.
 
Method Summary
 boolean displayPriceWithTax()
          Called by the UI to determine whether to display prices with tax.
 java.lang.String formatPrice(java.math.BigDecimal number)
          Used to create a string in order to visualize a price.
 java.lang.String formatPrice(java.math.BigDecimal number, java.lang.String currencyCode)
          Used to create a string in order to visualize a price.
 BasketMgr getBasketMgr()
          Used to get an instance of the BasketMgr.
 ConfigCacheUpdater getCacheUpdateThread()
           
 CategoryMgr getCategoryMgr()
          Used to get an instance of the CategoryMgr.
 java.lang.String getConfig(java.lang.String key)
          Returns the configuration value for the key passed in as a parameter.
 java.lang.String getCustom1()
          Can be used for any custom logic
 java.lang.String getCustom2()
          Can be used for any custom logic
 java.lang.String getCustom3()
          Can be used for any custom logic
 java.lang.String getCustom4()
          Can be used for any custom logic
 java.lang.String getCustom5()
          Can be used for any custom logic
 CustomerMgr getCustomerMgr()
          Used to get an instance of the CustomerMgr.
 java.lang.String getDateAsString(java.util.Calendar date)
          The date template defined in com.konakart.al.Constants.dateTemplate is used to format the date.
static java.lang.String getDdbasePath()
           
 com.konakart.appif.KKEngIf getEng()
          Returns an instance of the KonaKart server engine so that methods may be called directly on it.
 java.lang.String getForwardAfterLogin()
          The forwardAfterLogin is stored for the cases where the user wants to perform some action such as writing a review, which requires him to be logged in.
 int getHeadingImageHeight()
          The headingImageHeight is set by a configuration parameter.
 int getHeadingImageWidth()
          The headingImageWidth is set by a configuration parameter.
 int getLangId()
          Get the current language Id.
 java.lang.String getLocale()
          Get the current locale.
 java.lang.String getMetaDescription()
          Used by the JSPs to set the content of the meta description tag.
 java.lang.String getMetaKeywords()
          Used by the JSPs to set the content of the meta keywords tag.
 java.lang.String[] getNav()
          Get an array of strings that define the current navigation.
 java.lang.String getNowAsString()
          The date template defined in com.konakart.al.Constants.dateTemplate is used to get the current date and time.
 OrderMgr getOrderMgr()
          Used to get an instance of the OrderMgr.
 java.lang.String getPageTitle()
          Used by the JSPs to set the content of the title tag.
 ProductMgr getProductMgr()
          Used to get an instance of the ProductMgr.
 ReviewMgr getReviewMgr()
          Used to get an instance of the ReviewMgr.
 java.lang.String getSEARCH_ALL()
          This is a constant used for searching all products.
 java.lang.String getSessionId()
          Returns the session id of the currently logged in customer.
 int getSmallImageHeight()
          The smallImageHeight is set by a configuration parameter.
 int getSmallImageWidth()
          The smallImageWidth is set by a configuration parameter.
static java.lang.String getSslBaseUrl()
          The default condition is that the sslBaseUrl isn't used unless the SSL_BASE_URL configuration variable is set.
static java.lang.String getSslPort()
          The standard port "443" is used unless it is overidden by the SSL_PORT_NUMBER configuration variable.
static java.lang.String getStandardPort()
          The standard port "80" is used unless it is overidden by the STANDARD_PORT_NUMBER configuration.
 int getSubcatImageHeight()
          The subcatImageHeight is set by a configuration parameter.
 int getSubcatImageWidth()
          The subcatImageWidth is set by a configuration parameter.
 java.lang.String getXMLOverHTTPResp()
          XMLOverHTTPResp is used to temporary store an XML response.
static boolean isDdAsAttachment()
          The value is read from the DD_DOWNLOAD_AS_ATTACHMENT configuration variable.
static boolean isEnableSSL()
          Whether SSL is enabled or not is determined by the ENABLE_SSL configuration variable.
 void logout()
          Log-off and reset some variables.
 void refreshAllClientConfigs()
          Refresh the configuration variables.
protected  void refreshAllManagers()
          Refresh all manager caches
 java.lang.String removeCData(java.lang.String stringIn)
          Returns the string passed in as stringIn without the CData information.
 void reset()
          Puts the Konakart object back into it's original state with no categories or products selected.
 void setCustom1(java.lang.String custom1)
          Can be used for any custom logic
 void setCustom2(java.lang.String custom2)
          Can be used for any custom logic
 void setCustom3(java.lang.String custom3)
          Can be used for any custom logic
 void setCustom4(java.lang.String custom4)
          Can be used for any custom logic
 void setCustom5(java.lang.String custom5)
          Can be used for any custom logic
static void setDdAsAttachment(boolean ddAsAttachment)
          The value is read from the DD_DOWNLOAD_AS_ATTACHMENT configuration variable.
static void setDdbasePath(java.lang.String ddbasePath)
          The value of the Digital Download base path is read from the DD_BASE_PATH configuration variable.
static void setEnableSSL(boolean enableSSL)
          Whether SSL is enabled or not is determined by the ENABLE_SSL configuration variable.
 void setForwardAfterLogin(java.lang.String forwardAfterLogin)
          The forwardAfterLogin is stored for the cases where the user wants to perform some action such as writing a review, which requires him to be logged in.
 void setLangId(int langId)
          Set the languageId with the id passed in as a parameter.
 void setLocale(java.lang.String lowerCaseCode, java.lang.String upperCaseCode)
          Used to change the locale of the application from the default locale.
 void setMetaDescription(java.lang.String metaDescription)
          Used by the JSPs to set the content of the meta description tag.
 void setMetaKeywords(java.lang.String metaKeywords)
          Used by the JSPs to set the content of the meta keywords tag.
 void setPageTitle(java.lang.String pageTitle)
          Used by the JSPs to set the content of the title tag.
 void setSessionId(java.lang.String sessionId)
          Set the sessionId with the string passed in as a parameter.
static void setSslPort(java.lang.String sslPort)
          The standard port "443" is used unless it is overidden by the SSL_PORT_NUMBER configuration variable.
static void setStandardPort(java.lang.String standardPort)
          The standard port "80" is used unless it is overidden by the STANDARD_PORT_NUMBER configuration.
 void setXMLOverHTTPResp(java.lang.String overHTTPResp)
          XMLOverHTTPResp is used to temporary store an XML response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected org.apache.commons.logging.Log log

KONAKART_KEY

public static final java.lang.String KONAKART_KEY
Key used to store the KonaKart object within the session.

See Also:
Constant Field Values

nav

public CurrentNavigation nav
Used to keep track of where we are. Header.jsp uses it to display our current position within the application. i.e. Top >> Catalog >> Checkout

Constructor Detail

KKAppEng

public KKAppEng(java.lang.String propertiesPath)
         throws com.konakart.app.KKException,
                KKAppException
Constructor called by struts when the servlet container is started. In the struts-config.xml file, the plugin com.konakart.plugins.KKEngPlugin is instantiated which in turn calls this method.

Parameters:
propertiesPath - The name of the properties file (e.g. konakart.properties) which should be in the class path.
Throws:
com.konakart.app.KKException
KKAppException

KKAppEng

public KKAppEng()
         throws KKAppException,
                com.konakart.app.KKException
Constructor for engine created when a user creates a new session. This is called in com.konakart.actions.BaseAction .

Throws:
KKAppException
com.konakart.app.KKException
Method Detail

refreshAllClientConfigs

public void refreshAllClientConfigs()
                             throws com.konakart.app.KKException,
                                    KKAppException
Refresh the configuration variables. It is the ConfigCacheUpdater that calls this method when the configuration variables have been changed and at the start of the day to do the first initialisation. It isn't called from anywhere else.

Throws:
KKAppException
com.konakart.app.KKException

refreshAllManagers

protected void refreshAllManagers()
                           throws com.konakart.app.KKException,
                                  KKAppException
Refresh all manager caches

Throws:
com.konakart.app.KKException
KKAppException

reset

public void reset()
           throws com.konakart.app.KKException
Puts the Konakart object back into it's original state with no categories or products selected.

Throws:
com.konakart.app.KKException

setLocale

public void setLocale(java.lang.String lowerCaseCode,
                      java.lang.String upperCaseCode)
               throws com.konakart.app.KKException,
                      KKAppException
Used to change the locale of the application from the default locale. The category tree already exists for all locales and all calls to the engine use the new locale so that product descriptions etc. are in the correct language. For the case of en_GB, the lower case code would be "en" and the upper case code would be "GB".

Parameters:
lowerCaseCode - This is the two letter country code in lower case characters (i.e. it, en etc.)
upperCaseCode - This is the two letter country code in upper case characters (i.e. IT, GB etc.)
Throws:
com.konakart.app.KKException
KKAppException

getLocale

public java.lang.String getLocale()
Get the current locale.

Returns:
Returns the current locale.

getConfig

public java.lang.String getConfig(java.lang.String key)
Returns the configuration value for the key passed in as a parameter. If the key is not found, then null is returned.

Parameters:
key -
Returns:
Returns Configuration value

formatPrice

public java.lang.String formatPrice(java.math.BigDecimal number)
                             throws com.konakart.app.KKException,
                                    KKAppException
Used to create a string in order to visualize a price. It ensures that the decimal places, the thousands separator and the currency symbol are correct. Uses the default currency.

Parameters:
number - to be formatted
Returns:
The formatted price
Throws:
com.konakart.app.KKException
KKAppException

formatPrice

public java.lang.String formatPrice(java.math.BigDecimal number,
                                    java.lang.String currencyCode)
                             throws com.konakart.app.KKException,
                                    KKAppException
Used to create a string in order to visualize a price. It ensures that the decimal places, the thousands separator and the currency symbol are correct. An entry must exist in the database for the currency code passed in as a parameter.

Parameters:
number - to be formatted
currencyCode - Three letter currency code (USD, GBP, EUR etc.)
Returns:
The formatted price
Throws:
com.konakart.app.KKException
KKAppException

getCategoryMgr

public CategoryMgr getCategoryMgr()
Used to get an instance of the CategoryMgr.

Returns:
Returns the CategoryMgr.

getProductMgr

public ProductMgr getProductMgr()
Used to get an instance of the ProductMgr.

Returns:
Returns the ProductMgr.

getLangId

public int getLangId()
Get the current language Id.

Returns:
Returns the langId.

setLangId

public void setLangId(int langId)
Set the languageId with the id passed in as a parameter.

Parameters:
langId - The langId to set.

getReviewMgr

public ReviewMgr getReviewMgr()
Used to get an instance of the ReviewMgr.

Returns:
Returns the ReviewMgr.

getNav

public java.lang.String[] getNav()
Get an array of strings that define the current navigation. i.e. Top >> Catalog >> Product Details

Returns:
Returns the nav.

getSEARCH_ALL

public java.lang.String getSEARCH_ALL()
This is a constant used for searching all products.

Returns:
Returns the sEARCH_ALL.

getSessionId

public java.lang.String getSessionId()
Returns the session id of the currently logged in customer.

Returns:
Returns the sessionId.

getForwardAfterLogin

public java.lang.String getForwardAfterLogin()
The forwardAfterLogin is stored for the cases where the user wants to perform some action such as writing a review, which requires him to be logged in. Here we store the forward to the "write review" page so that after the login we can open this page up automatically.

Returns:
Returns the forwardAfterLogin.

setForwardAfterLogin

public void setForwardAfterLogin(java.lang.String forwardAfterLogin)
The forwardAfterLogin is stored for the cases where the user wants to perform some action such as writing a review, which requires him to be logged in. Here we store the forward to the "write review" page so that after the login we can open this page up automatically.

Parameters:
forwardAfterLogin - The forwardAfterLogin to set.

getEng

public com.konakart.appif.KKEngIf getEng()
Returns an instance of the KonaKart server engine so that methods may be called directly on it.

Returns:
Returns a KonaKart server engine

getDateAsString

public java.lang.String getDateAsString(java.util.Calendar date)
The date template defined in com.konakart.al.Constants.dateTemplate is used to format the date.

Parameters:
date -
Returns:
Returns a date as a formatted string

getNowAsString

public java.lang.String getNowAsString()
The date template defined in com.konakart.al.Constants.dateTemplate is used to get the current date and time.

Returns:
Returns the current date as a formatted string

removeCData

public java.lang.String removeCData(java.lang.String stringIn)
Returns the string passed in as stringIn without the CData information. i.e. It removes '' from the end of the string.

Parameters:
stringIn -
Returns:
stringIn without the CDATA info

logout

public void logout()
            throws com.konakart.app.KKException
Log-off and reset some variables.

Throws:
com.konakart.app.KKException

getOrderMgr

public OrderMgr getOrderMgr()
Used to get an instance of the OrderMgr.

Returns:
Returns the OrderMgr.

getHeadingImageHeight

public int getHeadingImageHeight()
The headingImageHeight is set by a configuration parameter.

Returns:
Returns the headingImageHeight.

getHeadingImageWidth

public int getHeadingImageWidth()
The headingImageWidth is set by a configuration parameter.

Returns:
Returns the headingImageWidth.

getSmallImageHeight

public int getSmallImageHeight()
The smallImageHeight is set by a configuration parameter.

Returns:
Returns the smallImageHeight.

getSmallImageWidth

public int getSmallImageWidth()
The smallImageWidth is set by a configuration parameter.

Returns:
Returns the smallImageWidth.

getSubcatImageHeight

public int getSubcatImageHeight()
The subcatImageHeight is set by a configuration parameter.

Returns:
Returns the subcatImageHeight.

getSubcatImageWidth

public int getSubcatImageWidth()
The subcatImageWidth is set by a configuration parameter.

Returns:
Returns the subcatImageWidth.

displayPriceWithTax

public boolean displayPriceWithTax()
Called by the UI to determine whether to display prices with tax.

Returns:
True if we should display prices with tax

getBasketMgr

public BasketMgr getBasketMgr()
Used to get an instance of the BasketMgr.

Returns:
Returns the basketMgr.

getCustomerMgr

public CustomerMgr getCustomerMgr()
Used to get an instance of the CustomerMgr.

Returns:
Returns the customerMgr.

setSessionId

public void setSessionId(java.lang.String sessionId)
Set the sessionId with the string passed in as a parameter.

Parameters:
sessionId - The sessionId to set.

getXMLOverHTTPResp

public java.lang.String getXMLOverHTTPResp()
XMLOverHTTPResp is used to temporary store an XML response.

Returns:
Returns the xMLOverHTTPResp.

setXMLOverHTTPResp

public void setXMLOverHTTPResp(java.lang.String overHTTPResp)
XMLOverHTTPResp is used to temporary store an XML response.

Parameters:
overHTTPResp - The xMLOverHTTPResp to set.

isEnableSSL

public static boolean isEnableSSL()
Whether SSL is enabled or not is determined by the ENABLE_SSL configuration variable.

Returns:
Returns the enableSSL.

setEnableSSL

public static void setEnableSSL(boolean enableSSL)
Whether SSL is enabled or not is determined by the ENABLE_SSL configuration variable.

Parameters:
enableSSL - The enableSSL to set.

getSslPort

public static java.lang.String getSslPort()
The standard port "443" is used unless it is overidden by the SSL_PORT_NUMBER configuration variable.

Returns:
Returns the sslPort.

setSslPort

public static void setSslPort(java.lang.String sslPort)
The standard port "443" is used unless it is overidden by the SSL_PORT_NUMBER configuration variable.

Parameters:
sslPort - The sslPort to set.

getStandardPort

public static java.lang.String getStandardPort()
The standard port "80" is used unless it is overidden by the STANDARD_PORT_NUMBER configuration.

Returns:
Returns the standardPort.

setStandardPort

public static void setStandardPort(java.lang.String standardPort)
The standard port "80" is used unless it is overidden by the STANDARD_PORT_NUMBER configuration.

Parameters:
standardPort - The standardPort to set.

getCacheUpdateThread

public ConfigCacheUpdater getCacheUpdateThread()
Returns:
Returns the cacheUpdateThread.

getPageTitle

public java.lang.String getPageTitle()
Used by the JSPs to set the content of the title tag. The value is determined based on a template which is in the Messages.properties file. The template can be different depending on whether we are viewing a single product or a list of products for a manufacturer, or a list of products within a category.

Returns:
Returns the pageTitle.

setPageTitle

public void setPageTitle(java.lang.String pageTitle)
Used by the JSPs to set the content of the title tag. The value is determined based on a template which is in the Messages.properties file. The template can be different depending on whether we are viewing a single product or a list of products for a manufacturer, or a list of products within a category.

Parameters:
pageTitle - The pageTitle to set.

getMetaDescription

public java.lang.String getMetaDescription()
Used by the JSPs to set the content of the meta description tag. The value is determined based on a template which is in the Messages.properties file. The template can be different depending on whether we are viewing a single product or a list of products for a manufacturer, or a list of products within a category.

Returns:
Returns the metaDescription.

setMetaDescription

public void setMetaDescription(java.lang.String metaDescription)
Used by the JSPs to set the content of the meta description tag. The value is determined based on a template which is in the Messages.properties file. The template can be different depending on whether we are viewing a single product or a list of products for a manufacturer, or a list of products within a category.

Parameters:
metaDescription - The metaDescription to set.

getMetaKeywords

public java.lang.String getMetaKeywords()
Used by the JSPs to set the content of the meta keywords tag. The value is determined based on a template which is in the Messages.properties file.

Returns:
Returns the metaKeywords.

setMetaKeywords

public void setMetaKeywords(java.lang.String metaKeywords)
Used by the JSPs to set the content of the meta keywords tag. The value is determined based on a template which is in the Messages.properties file.

Parameters:
metaKeywords - The metaKeywords to set.

getSslBaseUrl

public static java.lang.String getSslBaseUrl()
The default condition is that the sslBaseUrl isn't used unless the SSL_BASE_URL configuration variable is set. Normally just the port is changed to switch between SSL and non SSL. However in some cases SSL communication may need a different URL.

Returns:
Returns the sslBaseUrl.

getDdbasePath

public static java.lang.String getDdbasePath()
Returns:
Returns the ddbasePath.

setDdbasePath

public static void setDdbasePath(java.lang.String ddbasePath)
The value of the Digital Download base path is read from the DD_BASE_PATH configuration variable. The base path is prepended to the file path in order to get the full path of the file.

Parameters:
ddbasePath - The ddbasePath to set.

isDdAsAttachment

public static boolean isDdAsAttachment()
The value is read from the DD_DOWNLOAD_AS_ATTACHMENT configuration variable. When set to true, the digital download product is downloaded as an attachment that can be saved to disk. When set to false, the digital download product may be viewed within the browser.

Returns:
Returns the ddAsAttachment.

setDdAsAttachment

public static void setDdAsAttachment(boolean ddAsAttachment)
The value is read from the DD_DOWNLOAD_AS_ATTACHMENT configuration variable. When set to true, the digital download product is downloaded as an attachment that can be saved to disk. When set to false, the digital download product may be viewed within the browser.

Parameters:
ddAsAttachment - The ddAsAttachment to set.

getCustom1

public java.lang.String getCustom1()
Can be used for any custom logic

Returns:
Returns the custom1.

setCustom1

public void setCustom1(java.lang.String custom1)
Can be used for any custom logic

Parameters:
custom1 - The custom1 to set.

getCustom2

public java.lang.String getCustom2()
Can be used for any custom logic

Returns:
Returns the custom2.

setCustom2

public void setCustom2(java.lang.String custom2)
Can be used for any custom logic

Parameters:
custom2 - The custom2 to set.

getCustom3

public java.lang.String getCustom3()
Can be used for any custom logic

Returns:
Returns the custom3.

setCustom3

public void setCustom3(java.lang.String custom3)
Can be used for any custom logic

Parameters:
custom3 - The custom3 to set.

getCustom4

public java.lang.String getCustom4()
Can be used for any custom logic

Returns:
Returns the custom4.

setCustom4

public void setCustom4(java.lang.String custom4)
Can be used for any custom logic

Parameters:
custom4 - The custom4 to set.

getCustom5

public java.lang.String getCustom5()
Can be used for any custom logic

Returns:
Returns the custom5.

setCustom5

public void setCustom5(java.lang.String custom5)
Can be used for any custom logic

Parameters:
custom5 - The custom5 to set.


Copyright © 2006 DS Data Systems UK Ltd.