com.konakartadmin.bl
Class AdminMessageMgr

java.lang.Object
  extended by com.konakartadmin.bl.AdminBaseMgr
      extended by com.konakartadmin.bl.AdminMessageMgr
All Implemented Interfaces:
AdminMessageMgrIf

public class AdminMessageMgr
extends AdminBaseMgr
implements AdminMessageMgrIf

The AdminMessageMgr - for Managing Message Catalog Messages for the Admin Application


Nested Class Summary
protected  class AdminMessageMgr.StaticData
           
 
Field Summary
private static java.lang.String fileEncoding
           
protected static java.lang.String HELP_MESSAGE_CAT_PREFIX
          The prefix of the Help Message Catalogue file
protected static org.apache.commons.logging.Log log
          the log
protected static java.lang.String MESSAGE_CAT_PREFIX
          The prefix of the Main Message Catalogue file
protected static java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.lang.String>> msgsMap
          Hash Map containing the messages for each locale within another map.
protected static java.lang.String mutex
          Mutex for this manager
protected static java.util.Map<java.lang.String,AdminMessageMgr.StaticData> staticDataHM
          Hash Map that contains the static data
 
Fields inherited from class com.konakartadmin.bl.AdminBaseMgr
adminEng, baseMgrMutex, baseStaticDataHM, cDataEnd, cDataStart, kkConf, kkInstanceId, mgrFactory, STORE_ID, templateBaseDir
 
Constructor Summary
AdminMessageMgr(KKAdminIf eng)
          Constructor
 
Method Summary
 void addKkMsgOrderBy(com.konakart.bl.KKCriteria c, AdminKkMsgSearch search)
          Add the order by clause using the definition specified in the search criteria
private  void addKkMsgOrderBy(com.konakart.bl.KKCriteria c, java.lang.String orderBy)
           
 void addKkMsgSearchCriteria(com.konakart.bl.KKCriteria c, AdminKkMsgSearch search)
          Adds the search criteria for the KkMsg search
 void deleteMsg(java.lang.String key, int type, java.lang.String locale)
          Delete a Message
 void deleteMsgs(int type, java.lang.String locale)
          Delete all the messages with the specified type and locale
 boolean doesMsgExist(java.lang.String key, int type, java.lang.String locale)
          Does the message exist?
 java.lang.String exportMsgs(int type, java.lang.String locale)
          Export Messages
protected  java.lang.String getDefaultLanguageCode()
           
protected  java.lang.String getDefaultLocale()
           
static java.lang.String getFileEncoding()
          Returns the encoding used for the file.
protected  java.net.URL getHelpMessageFileURL(java.lang.String locale)
           
 java.lang.String getHelpMsg(java.lang.String msgKey, java.lang.String locale)
          Return the help message for the specified language and the specified key.
 java.lang.String getHelpMsgFromDatabase(java.lang.String msgKey, java.lang.String locale)
          Get the help screen message for the specified help message key from the database in the specified language.
protected  java.lang.String getHelpMsgFromProperties(java.util.Properties props, java.lang.String msgKey)
           
 int getKkMsgCount(AdminKkMsgSearch search)
          Returns a count of the number of Messages with the specified search criteria
 java.lang.String getMsg(java.lang.String msgKey)
          Gets a message with the specified key from the catalog of the default language.
 java.lang.String getMsg(java.lang.String msgKey, java.lang.String locale)
          Gets a message with the specified key from the catalog for the specified locale.
 AdminMessageSet getMsgs(java.lang.String locale)
          Return a set of admin application messages specified language.
 AdminMessageSet getMsgsFromDatabase(java.lang.String locale)
          Gets an AdminMessageSet for the specified locale from the database.
 java.lang.String getMsgValue(java.lang.String key, int type, java.lang.String locale)
          Get a Message Value
private  java.lang.String getPropertiesFileNameForCode(java.lang.String filenamePrefix, java.lang.String languageCode)
           
private  java.lang.String getPropertiesFileNameForLocale(java.lang.String filenamePrefix, java.lang.String locale)
           
 void importMsgs(int type, java.lang.String locale, java.lang.String msgString, boolean replace)
          Import Messages
 void insertMsg(java.lang.String key, int type, java.lang.String locale, java.lang.String value)
          Insert a Message
 java.util.Properties loadMessageProperties(java.lang.String messageFilePath)
          Load the contents of the file whose name is specified into a Properties object.
protected  org.apache.commons.configuration.Configuration readDefaultCatalog()
           
protected  org.apache.commons.configuration.Configuration readDefaultCatalogFromDatabase()
           
 void refreshConfigs()
          Retrieve some commonly-used properties and set the velocity log file location
 AdminKkMsgSearchResult searchMsg(AdminKkMsgSearch search, int groupSize, int offset)
          Retrieve all the messages that match the specified search criteria
static void setFileEncoding(java.lang.String fileEncoding)
          Sets the encoding used for the file.
 void updateMsg(java.lang.String key, int type, java.lang.String locale, java.lang.String value)
          Update a Message
 
Methods inherited from class com.konakartadmin.bl.AdminBaseMgr
addInsertAttr, addInsertAttr, checkIntIsSet, checkRequired, getAdminAddressMgr, getAdminAuditMgr, getAdminBillingMgr, getAdminBookableProductMgr, getAdminCatMgr, getAdminConfigMgr, getAdminCurrMgr, getAdminCustMgr, getAdminCustTagMgr, getAdminEmailMgr, getAdminEng, getAdminHtmlMgr, getAdminLanguageMgr, getAdminManuMgr, getAdminMessageMgr, getAdminMiscItemMgr, getAdminModulesMgr, getAdminMultiStoreMgr, getAdminOrderMgr, getAdminPdfMgr, getAdminProdAttrMgr, getAdminProdMgr, getAdminPromMgr, getAdminPublishProdMgr, getAdminReviewMgr, getAdminSearchRuleMgr, getAdminSecMgr, getAdminSolrMgr, getAdminStoreMgr, getAdminTagMgr, getAdminTaxMgr, getAdminValidationMgr, getAdminVelocityContextMgr, getAdminWishListMgr, getBooleanFromString, getExportXMLData, getIntFromString, getKkConfig, getKkInstanceId, getMode, getModeString, getMqMgr, getNewCriteria, getNewCriteria, getPostSearchText, getPreSearchText, getPropertyValue, getRecordCount, getRewardPointMgr, getSingleIntResult, getStoreId, getTemplate, getTemplateBase, getXml_io, init, isConfigSet, isEnterprise, isMultiStoreLanguagesShared, isMultiStoreMode, isMultiStoreShareCategories, isMultiStoreShareCustomers, isMultiStoreShareProducts, isMultiStoreSingleDBCSMode, isMultiStoreSingleDBMode, isMultiStoreSingleDBNonCSMode, manageException, removeCData, setAdminEng, setupWildCardRules, setWildCardAfter, setWildCardBefore, shutdownGracefully, shutdownGracefully, timestampStr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
the log


HELP_MESSAGE_CAT_PREFIX

protected static final java.lang.String HELP_MESSAGE_CAT_PREFIX
The prefix of the Help Message Catalogue file

See Also:
Constant Field Values

MESSAGE_CAT_PREFIX

protected static final java.lang.String MESSAGE_CAT_PREFIX
The prefix of the Main Message Catalogue file

See Also:
Constant Field Values

mutex

protected static java.lang.String mutex
Mutex for this manager


staticDataHM

protected static java.util.Map<java.lang.String,AdminMessageMgr.StaticData> staticDataHM
Hash Map that contains the static data


msgsMap

protected static java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.lang.String>> msgsMap
Hash Map containing the messages for each locale within another map. Currently it never gets refreshed. Just loaded once


fileEncoding

private static java.lang.String fileEncoding
Constructor Detail

AdminMessageMgr

public AdminMessageMgr(KKAdminIf eng)
                throws java.lang.Exception
Constructor

Parameters:
eng - KKAdmin engine
Throws:
java.lang.Exception
Method Detail

getMsgs

public AdminMessageSet getMsgs(java.lang.String locale)
                        throws KKAdminException
Description copied from interface: AdminMessageMgrIf
Return a set of admin application messages specified language. This is used to facilitate internationalization of the KonaKart Admin application - but it could also be used to internationalize any application via the KonaKart Admin API.

For file-based messages (where the configuration parameter USE_DB_FOR_MESSAGES = false) the messages are retrieved from a message properties file on the classpath that best-matches the specified language parameter. The name of the file starts with 'AdminMessages' and may have a language code or locale specification appended to it, and '.properties' added to the end. An example of such a file would be AdminMessages_de.properties. It first tries to find a file that matches the language_code exactly (this could be a full locale description such as 'de_DE' or 'pt_BR') and if no such file is found it tries to find one that matches just the first two characters (in this case 'de' and 'pt' respectively). When the specified language code is 'en' a file without any language or locale specification is used instead.

For database-based messages the language code specified must be the locale specified in the database. By default these will be the full locale names (eg. en_GB, de_DE, pt_BR etc). file for the locale or language code.

Specified by:
getMsgs in interface AdminMessageMgrIf
Parameters:
locale - See above... Either specify the full language locale or the 2-character language code. If null, the language code of the default language will be used.
Returns:
an AdminMessaegSet object
Throws:
KKAdminException

getMsgsFromDatabase

public AdminMessageSet getMsgsFromDatabase(java.lang.String locale)
                                    throws KKAdminException
Description copied from interface: AdminMessageMgrIf
Gets an AdminMessageSet for the specified locale from the database.

Specified by:
getMsgsFromDatabase in interface AdminMessageMgrIf
Parameters:
locale - the 5-letter locale code eg. en_GB, es_ES, de_DE etc
Returns:
an AdminMessaegSet object
Throws:
KKAdminException

getMsg

public java.lang.String getMsg(java.lang.String msgKey,
                               java.lang.String locale)
                        throws KKAdminException
Description copied from interface: AdminMessageMgrIf
Gets a message with the specified key from the catalog for the specified locale. This uses caching - it only reads the catalog once - the first time it's called.

This is for Admin Application messages only (type is KKConstants.MSG_TYP_ADMIN_APP)

Specified by:
getMsg in interface AdminMessageMgrIf
Parameters:
msgKey - the message key into the message catalog file
locale - the 5-letter locale code eg. en_GB, es_ES, de_DE etc
Returns:
the message associated with the key as a String
Throws:
KKAdminException

getHelpMsg

public java.lang.String getHelpMsg(java.lang.String msgKey,
                                   java.lang.String locale)
                            throws KKAdminException
Description copied from interface: AdminMessageMgrIf
Return the help message for the specified language and the specified key.

For file-based messages (where the configuration parameter USE_DB_FOR_MESSAGES = false) the message is retrieved from a message properties file on the classpath that best-matches the specified language parameter. The name of the file starts with 'AdminHelpMessages' and may have a language code or locale specification appended to it, and '.properties' added to the end. An example of such a file would be AdminHelpMessages_de.properties. It first tries to find a file that matches the language_code exactly (this could be a full locale description such as 'de_DE' or 'pt_BR') and if no such file is found it tries to find one that matches just the first two characters (in this case 'de' and 'pt' respectively). When the specified language code is 'en' a file without any language or locale specification is used instead.

For database-based messages the language code specified must be the locale specified in the database. By default these will be the full locale names (eg. en_GB, de_DE, pt_BR etc). file for the locale or language code.

Specified by:
getHelpMsg in interface AdminMessageMgrIf
Parameters:
msgKey - the key of the help message in the properties file. If null, a null help message is returned.
locale - the language code (if null it uses the current default language)
Returns:
the help message as a String
Throws:
KKAdminException

getHelpMessageFileURL

protected java.net.URL getHelpMessageFileURL(java.lang.String locale)
                                      throws KKAdminException
Throws:
KKAdminException

getHelpMsgFromProperties

protected java.lang.String getHelpMsgFromProperties(java.util.Properties props,
                                                    java.lang.String msgKey)
                                             throws KKAdminException
Throws:
KKAdminException

getHelpMsgFromDatabase

public java.lang.String getHelpMsgFromDatabase(java.lang.String msgKey,
                                               java.lang.String locale)
                                        throws KKAdminException
Description copied from interface: AdminMessageMgrIf
Get the help screen message for the specified help message key from the database in the specified language. No caching is done - it always re-reads the record from the database.

Specified by:
getHelpMsgFromDatabase in interface AdminMessageMgrIf
Parameters:
msgKey - the message key
locale - the 5-letter locale code eg. en_GB, es_ES, de_DE etc
Returns:
the help message as a String
Throws:
KKAdminException

loadMessageProperties

public java.util.Properties loadMessageProperties(java.lang.String messageFilePath)
                                           throws KKAdminException
Description copied from interface: AdminMessageMgrIf
Load the contents of the file whose name is specified into a Properties object.

Specified by:
loadMessageProperties in interface AdminMessageMgrIf
Parameters:
messageFilePath - the message filename
Returns:
the Properties object created
Throws:
KKAdminException

getMsg

public java.lang.String getMsg(java.lang.String msgKey)
                        throws KKAdminException
Description copied from interface: AdminMessageMgrIf
Gets a message with the specified key from the catalog of the default language. This uses caching - it only reads the catalog once - the first time it's called.

This is for Admin Application messages only (type is KKConstants.MSG_TYP_ADMIN_APP)

Specified by:
getMsg in interface AdminMessageMgrIf
Parameters:
msgKey - the message key into the message catalog file
Returns:
the message associated with the key as a String
Throws:
KKAdminException

getPropertiesFileNameForCode

private java.lang.String getPropertiesFileNameForCode(java.lang.String filenamePrefix,
                                                      java.lang.String languageCode)

getPropertiesFileNameForLocale

private java.lang.String getPropertiesFileNameForLocale(java.lang.String filenamePrefix,
                                                        java.lang.String locale)

readDefaultCatalog

protected org.apache.commons.configuration.Configuration readDefaultCatalog()
                                                                     throws KKAdminException
Throws:
KKAdminException

readDefaultCatalogFromDatabase

protected org.apache.commons.configuration.Configuration readDefaultCatalogFromDatabase()
                                                                                 throws KKAdminException
Throws:
KKAdminException

getDefaultLocale

protected java.lang.String getDefaultLocale()

getDefaultLanguageCode

protected java.lang.String getDefaultLanguageCode()

doesMsgExist

public boolean doesMsgExist(java.lang.String key,
                            int type,
                            java.lang.String locale)
                     throws KKAdminException
Description copied from interface: AdminMessageMgrIf
Does the message exist?

Specified by:
doesMsgExist in interface AdminMessageMgrIf
Returns:
true if the message exists, otherwise false
Throws:
KKAdminException

deleteMsgs

public void deleteMsgs(int type,
                       java.lang.String locale)
                throws KKAdminException,
                       org.apache.torque.TorqueException
Delete all the messages with the specified type and locale

Parameters:
type -
locale - this must not be null
Throws:
KKAdminException
org.apache.torque.TorqueException

deleteMsg

public void deleteMsg(java.lang.String key,
                      int type,
                      java.lang.String locale)
               throws KKAdminException
Description copied from interface: AdminMessageMgrIf
Delete a Message

Specified by:
deleteMsg in interface AdminMessageMgrIf
Parameters:
key - the message key
type - the message type (Use KKConstants.MSG_TYP_APPLICATION for application messages, KKConstants.MSG_TYP_ADMIN_APP for Admin App messages, KKConstants.MSG_TYP_Admin_HELP for Admin App Help messages)
locale - the message locale (eg. "en_GB"). If this is null the default locale for the store is used.
Throws:
KKAdminException

exportMsgs

public java.lang.String exportMsgs(int type,
                                   java.lang.String locale)
                            throws KKAdminException,
                                   org.apache.torque.TorqueException,
                                   com.workingdogs.village.DataSetException
Description copied from interface: AdminMessageMgrIf
Export Messages

Specified by:
exportMsgs in interface AdminMessageMgrIf
Parameters:
type - the message type (Use KKConstants.MSG_TYP_APPLICATION for application messages, KKConstants.MSG_TYP_ADMIN_APP for Admin App messages, KKConstants.MSG_TYP_Admin_HELP for Admin App Help messages)
locale - the message locale (eg. "en_GB"). If this is null the default locale for the store is used.
Returns:
msgString A String containing the messages in the format of a java properties file
Throws:
KKAdminException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

getMsgValue

public java.lang.String getMsgValue(java.lang.String key,
                                    int type,
                                    java.lang.String locale)
                             throws java.lang.Exception,
                                    KKAdminException,
                                    org.apache.torque.TorqueException,
                                    com.workingdogs.village.DataSetException
Description copied from interface: AdminMessageMgrIf
Get a Message Value

Specified by:
getMsgValue in interface AdminMessageMgrIf
Parameters:
key - the message key
type - the message type (Use KKConstants.MSG_TYP_APPLICATION for application messages, KKConstants.MSG_TYP_ADMIN_APP for Admin App messages, KKConstants.MSG_TYP_Admin_HELP for Admin App Help messages)
locale - the message locale (eg. "en_GB"). If this is null the default locale for the store is used.
Returns:
The message for the key, type and locale. If the message isn't found the String "[key:type:locale]" is returned.
Throws:
java.lang.Exception
KKAdminException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

importMsgs

public void importMsgs(int type,
                       java.lang.String locale,
                       java.lang.String msgString,
                       boolean replace)
                throws KKAdminException,
                       org.apache.torque.TorqueException
Description copied from interface: AdminMessageMgrIf
Import Messages

Specified by:
importMsgs in interface AdminMessageMgrIf
Parameters:
type - the message type (Use KKConstants.MSG_TYP_APPLICATION for application messages, KKConstants.MSG_TYP_ADMIN_APP for Admin App messages, KKConstants.MSG_TYP_Admin_HELP for Admin App Help messages)
locale - the message locale (eg. "en_GB"). If this is null the default locale for the store is used.
msgString - A String containing the messages to import in the format of a java properties file
replace - if true all the current messages for the specified type and locale are removed before importing the new messages. If false the new messages are appended and if a message key already exists it is replaced by the new message value being imported.
Throws:
KKAdminException
org.apache.torque.TorqueException

insertMsg

public void insertMsg(java.lang.String key,
                      int type,
                      java.lang.String locale,
                      java.lang.String value)
               throws KKAdminException
Description copied from interface: AdminMessageMgrIf
Insert a Message

Specified by:
insertMsg in interface AdminMessageMgrIf
Parameters:
key - the message key
type - the message type (Use KKConstants.MSG_TYP_APPLICATION for application messages, KKConstants.MSG_TYP_ADMIN_APP for Admin App messages, KKConstants.MSG_TYP_Admin_HELP for Admin App Help messages)
locale - the message locale (eg. "en_GB"). If this is null the default locale for the store is used.
value - the value of the message to be inserted
Throws:
KKAdminException

getKkMsgCount

public int getKkMsgCount(AdminKkMsgSearch search)
                  throws org.apache.torque.TorqueException,
                         com.workingdogs.village.DataSetException,
                         KKAdminException
Returns a count of the number of Messages with the specified search criteria

Parameters:
search - the AdminKkMsgSearch object that defines the search criteria
Returns:
A count of the number of messages with the specified search criteria
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKAdminException

addKkMsgSearchCriteria

public void addKkMsgSearchCriteria(com.konakart.bl.KKCriteria c,
                                   AdminKkMsgSearch search)
Adds the search criteria for the KkMsg search

Parameters:
c - the Criteria object
search - the AdminKkMsgSearch object that defines the search criteria

addKkMsgOrderBy

public void addKkMsgOrderBy(com.konakart.bl.KKCriteria c,
                            AdminKkMsgSearch search)
Add the order by clause using the definition specified in the search criteria

Parameters:
c - the KKCriteria object to update
search - the search criteria

addKkMsgOrderBy

private void addKkMsgOrderBy(com.konakart.bl.KKCriteria c,
                             java.lang.String orderBy)

searchMsg

public AdminKkMsgSearchResult searchMsg(AdminKkMsgSearch search,
                                        int groupSize,
                                        int offset)
                                 throws KKAdminException,
                                        org.apache.torque.TorqueException,
                                        com.workingdogs.village.DataSetException
Description copied from interface: AdminMessageMgrIf
Retrieve all the messages that match the specified search criteria

Specified by:
searchMsg in interface AdminMessageMgrIf
Parameters:
search - the AdminKkMsgSearch object that defines the search criteria
groupSize - a maximum of this many messages will be returned by each call (the group size)
offset - the offset in the record set that match the criteria from which records are returned
Returns:
An AdminKkMsgSearchResult object containing the messages that match the specified search criteria.
Throws:
KKAdminException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

updateMsg

public void updateMsg(java.lang.String key,
                      int type,
                      java.lang.String locale,
                      java.lang.String value)
               throws KKAdminException
Description copied from interface: AdminMessageMgrIf
Update a Message

Specified by:
updateMsg in interface AdminMessageMgrIf
Parameters:
key - the message key
type - the message type (Use KKConstants.MSG_TYP_APPLICATION for application messages, KKConstants.MSG_TYP_ADMIN_APP for Admin App messages, KKConstants.MSG_TYP_Admin_HELP for Admin App Help messages)
locale - the message locale (eg. "en_GB"). If this is null the default locale for the store is used.
value - the new value for the message
Throws:
KKAdminException

refreshConfigs

public void refreshConfigs()
                    throws KKAdminException
Retrieve some commonly-used properties and set the velocity log file location

Specified by:
refreshConfigs in interface AdminMessageMgrIf
Overrides:
refreshConfigs in class AdminBaseMgr
Throws:
KKAdminException

getFileEncoding

public static java.lang.String getFileEncoding()
Returns the encoding used for the file.

Returns:
fileEncoding

setFileEncoding

public static void setFileEncoding(java.lang.String fileEncoding)
Sets the encoding used for the file.

Parameters:
fileEncoding -


Copyright © 2011 DS Data Systems UK Ltd.