Tutorials > Management Center > Create the Project BOD service module
Add language specific exception messages
In this lesson, you add language-specific exception messages to the properties files used by the mediators and commands. You write the mediator and command code in a later lesson.
Procedure
Import the com.mycompany.commerce.project.logging package:
The following sample code is taken from ProjectApplicationMessageKeys.java:
- Expand Project-Server > ejbModule.
- Right-click the com.mycompany.commerce.project.logging package and click Import. Expand General and select File System. Click Next.
- Navigate to the temporary location where you unzipped RecipeServices.zip.
- Navigate to the com.mycompany.commerce.project.logging folder in the temporary location.
- Select all files in the folder. Click Finish. Click Yes to All to overwrite any existing files. The ProjectApplicationMessageKeys.java and the WcProjectMessages.properties files will be replaced.
/** * Constant for the message that the Project description is too long. */ public static final String _APP_PROJECT_SHORT_DESCRIPTION_TOO_LONG = "_APP_PROJECT_SHORT_DESCRIPTION_TOO_LONG"; /** * Constant for the message that the Project description is too long. */ public static final String _APP_PROJECT_LONG_DESCRIPTION_TOO_LONG = "_APP_PROJECT_LONG_DESCRIPTION_TOO_LONG"; /** * Constant for the message that an ProjectCollection Description could not * be found. */ public static final String _APP_PROJECTCOLLECTION_DESCRIPTION_NOT_FOUND = "_APP_PROJECTCOLLECTION_DESCRIPTION_NOT_FOUND"; /** * Constant for the message that an Project Instruction could not be found. */ public static final String _APP_PROJECT_INSTRUCTION_NOT_FOUND = "_APP_PROJECT_INSTRUCTION_NOT_FOUND"; /** * Constant for the message that an Project Material could not be found. */ public static final String _APP_PROJECT_MATERIAL_NOT_FOUND = "_APP_PROJECT_MATERIAL_NOT_FOUND"; /** * Constant for the message that there are errors while getting store id. */ public static final String _ERR_EXCEPTION_GETTING_STORE_ID = "_ERR_EXCEPTION_GETTING_STORE_ID"; /** * Constant for the message that there are errors while getting language id. */ public static final String _ERR_EXCEPTION_GETTING_LANGUAGE_ID = "_ERR_EXCEPTION_GETTING_LANGUAGE_ID"; /** * Constant for the message that the Project material name cannot be empty. */ public static final String _APP_PROJECT_MATERIAL_NAME_EMPTY = "_APP_PROJECT_MATERIAL_NAME_EMPTY"; /** * Constant for the message that the catentry id is duplicate. */ public static final String _APP_PROJECT_CATENTRY_DUPLICATE = "_APP_PROJECT_CATENTRY_DUPLICATE";
The following sample code is taken from the WcProjectMessages.properties file:
_APP_PROJECT_SHORT_DESCRIPTION_TOO_LONG = Short Description is too long _APP_PROJECT_LONG_DESCRIPTION_TOO_LONG = Long Description is too long _APP_PROJECTCOLLECTION_DESCRIPTION_NOT_FOUND = The noun ProjectCollection/Description is not found _APP_PROJECT_INSTRUCTION_NOT_FOUND = The noun Project/Instruction is not found _APP_PROJECT_MATERIAL_NOT_FOUND = The noun Project/Material is not found _ERR_EXCEPTION_GETTING_STORE_ID = Cannot get store id _ERR_EXCEPTION_GETTING_LANGUAGE_ID = Cannot get language id _APP_PROJECT_MATERIAL_NAME_EMPTY= Save failed.The name is empty _APP_PROJECT_CATENTRY_DUPLICATE= Save failed. The catentry is duplicated