|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.konakartadmin.bl.AdminBaseMgr
com.konakartadmin.bl.AdminMessageMgr
public class AdminMessageMgr
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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static org.apache.commons.logging.Log log
protected static final java.lang.String HELP_MESSAGE_CAT_PREFIX
protected static final java.lang.String MESSAGE_CAT_PREFIX
protected static java.lang.String mutex
protected static java.util.Map<java.lang.String,AdminMessageMgr.StaticData> staticDataHM
protected static java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.lang.String>> msgsMap
private static java.lang.String fileEncoding
Constructor Detail |
---|
public AdminMessageMgr(KKAdminIf eng) throws java.lang.Exception
eng
- KKAdmin engine
java.lang.Exception
Method Detail |
---|
public AdminMessageSet getMsgs(java.lang.String locale) throws KKAdminException
AdminMessageMgrIf
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.
getMsgs
in interface AdminMessageMgrIf
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.
KKAdminException
public AdminMessageSet getMsgsFromDatabase(java.lang.String locale) throws KKAdminException
AdminMessageMgrIf
getMsgsFromDatabase
in interface AdminMessageMgrIf
locale
- the 5-letter locale code eg. en_GB, es_ES, de_DE etc
KKAdminException
public java.lang.String getMsg(java.lang.String msgKey, java.lang.String locale) throws KKAdminException
AdminMessageMgrIf
This is for Admin Application messages only (type is KKConstants.MSG_TYP_ADMIN_APP)
getMsg
in interface AdminMessageMgrIf
msgKey
- the message key into the message catalog filelocale
- the 5-letter locale code eg. en_GB, es_ES, de_DE etc
KKAdminException
public java.lang.String getHelpMsg(java.lang.String msgKey, java.lang.String locale) throws KKAdminException
AdminMessageMgrIf
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.
getHelpMsg
in interface AdminMessageMgrIf
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)
KKAdminException
protected java.net.URL getHelpMessageFileURL(java.lang.String locale) throws KKAdminException
KKAdminException
protected java.lang.String getHelpMsgFromProperties(java.util.Properties props, java.lang.String msgKey) throws KKAdminException
KKAdminException
public java.lang.String getHelpMsgFromDatabase(java.lang.String msgKey, java.lang.String locale) throws KKAdminException
AdminMessageMgrIf
getHelpMsgFromDatabase
in interface AdminMessageMgrIf
msgKey
- the message keylocale
- the 5-letter locale code eg. en_GB, es_ES, de_DE etc
KKAdminException
public java.util.Properties loadMessageProperties(java.lang.String messageFilePath) throws KKAdminException
AdminMessageMgrIf
loadMessageProperties
in interface AdminMessageMgrIf
messageFilePath
- the message filename
KKAdminException
public java.lang.String getMsg(java.lang.String msgKey) throws KKAdminException
AdminMessageMgrIf
This is for Admin Application messages only (type is KKConstants.MSG_TYP_ADMIN_APP)
getMsg
in interface AdminMessageMgrIf
msgKey
- the message key into the message catalog file
KKAdminException
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)
protected org.apache.commons.configuration.Configuration readDefaultCatalog() throws KKAdminException
KKAdminException
protected org.apache.commons.configuration.Configuration readDefaultCatalogFromDatabase() throws KKAdminException
KKAdminException
protected java.lang.String getDefaultLocale()
protected java.lang.String getDefaultLanguageCode()
public boolean doesMsgExist(java.lang.String key, int type, java.lang.String locale) throws KKAdminException
AdminMessageMgrIf
doesMsgExist
in interface AdminMessageMgrIf
KKAdminException
public void deleteMsgs(int type, java.lang.String locale) throws KKAdminException, org.apache.torque.TorqueException
type
- locale
- this must not be null
KKAdminException
org.apache.torque.TorqueException
public void deleteMsg(java.lang.String key, int type, java.lang.String locale) throws KKAdminException
AdminMessageMgrIf
deleteMsg
in interface AdminMessageMgrIf
key
- the message keytype
- 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.
KKAdminException
public java.lang.String exportMsgs(int type, java.lang.String locale) throws KKAdminException, org.apache.torque.TorqueException, com.workingdogs.village.DataSetException
AdminMessageMgrIf
exportMsgs
in interface AdminMessageMgrIf
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.
KKAdminException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
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
AdminMessageMgrIf
getMsgValue
in interface AdminMessageMgrIf
key
- the message keytype
- 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.
java.lang.Exception
KKAdminException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
public void importMsgs(int type, java.lang.String locale, java.lang.String msgString, boolean replace) throws KKAdminException, org.apache.torque.TorqueException
AdminMessageMgrIf
importMsgs
in interface AdminMessageMgrIf
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 filereplace
- 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.
KKAdminException
org.apache.torque.TorqueException
public void insertMsg(java.lang.String key, int type, java.lang.String locale, java.lang.String value) throws KKAdminException
AdminMessageMgrIf
insertMsg
in interface AdminMessageMgrIf
key
- the message keytype
- 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
KKAdminException
public int getKkMsgCount(AdminKkMsgSearch search) throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, KKAdminException
search
- the AdminKkMsgSearch object that defines the search criteria
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKAdminException
public void addKkMsgSearchCriteria(com.konakart.bl.KKCriteria c, AdminKkMsgSearch search)
c
- the Criteria objectsearch
- the AdminKkMsgSearch object that defines the search criteriapublic void addKkMsgOrderBy(com.konakart.bl.KKCriteria c, AdminKkMsgSearch search)
c
- the KKCriteria object to updatesearch
- the search criteriaprivate void addKkMsgOrderBy(com.konakart.bl.KKCriteria c, java.lang.String orderBy)
public AdminKkMsgSearchResult searchMsg(AdminKkMsgSearch search, int groupSize, int offset) throws KKAdminException, org.apache.torque.TorqueException, com.workingdogs.village.DataSetException
AdminMessageMgrIf
searchMsg
in interface AdminMessageMgrIf
search
- the AdminKkMsgSearch object that defines the search criteriagroupSize
- 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
KKAdminException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
public void updateMsg(java.lang.String key, int type, java.lang.String locale, java.lang.String value) throws KKAdminException
AdminMessageMgrIf
updateMsg
in interface AdminMessageMgrIf
key
- the message keytype
- 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
KKAdminException
public void refreshConfigs() throws KKAdminException
refreshConfigs
in interface AdminMessageMgrIf
refreshConfigs
in class AdminBaseMgr
KKAdminException
public static java.lang.String getFileEncoding()
public static void setFileEncoding(java.lang.String fileEncoding)
fileEncoding
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |