}
catch (EnterpriseConfigurationObjectException eoce) {
logger.fatal("[GreetingRequestCommand] Error retrieving a Greeting " +
"object from AppConfig: The exception is: " + eoce.getMessage());
}
Greetee greetee = new Greetee();
try {
greetee = (Greetee)getAppConfig().getObjectByType(greetee.getClass()
.getName());
}
catch (EnterpriseConfigurationObjectException eoce) {
logger.fatal("[GreetingRequestCommand] Error retrieving a Greeting " +
"object from AppConfig: The exception is: " + eoce.getMessage());
}
// Handle a Generate-Request.
if (msgAction.equalsIgnoreCase("Generate")) {
logger.info("[GreetingRequestCommand] Handling an " +
"org.any-openeai-enterprise.CoreApplication.Greeting.Generate-Request" +
" message.");
Element eGreetee = inDoc.getRootElement().getChild("DataArea")
.getChild("Greetee");
// Verify that Greetee element is not null; if it is, reply with an error.
if (eGreetee == null) {
String errType = "application";
String errCode = "OpenEAI-1015";
String errDesc = "Invalid generate element found in the Generate-" +
"Request message. This command expects a Greetee.";
logger.fatal("[GreetingRequestCommand] " + errDesc);
logger.fatal("Message sent in is: \n" + getMessageBody(inDoc));
ArrayList errors = new ArrayList();
errors.add(buildError(errType, errCode, errDesc));
String replyContents =
buildReplyDocumentWithErrors(eControlArea, localResponseDoc, errors);
return getMessage(msg, replyContents);
}
// Now build a Greetee object from the Greetee element in the message.
try {
greetee.buildObjectFromInput(eGreetee);
}
catch (EnterpriseLayoutException ele) {
// There was an error building the Greetee object from a Greetee
// element.
String errType = "application";
String errCode = "EnterpriseGreetingService-1001";
String errDesc = "An error occurred building Greetee object from the " +
"Greetee element in the Generate-Request message. The exception " +
"is: " + ele.getMessage();
logger.fatal("[GreeteeRequestCommand] " + errDesc);
logger.fatal("Message sent in is: \n" + getMessageBody(inDoc));
ArrayList errors = new ArrayList();
errors.add(buildError(errType, errCode, errDesc));
String replyContents =
buildReplyDocumentWithErrors(eControlArea, localResponseDoc, errors);
return getMessage(msg, replyContents);
}
// Generate the greeting.
try {
if (greetee.getFullName() != null && greetee.getFullName() != "") {
// There is a greetee with a name to greet. Prepare the greeting text.
greeting.setText("Hello, " + greetee.getFullName() + "!");
}
else {
// There is no greetee with a name to greet. Use the default greeting
// text.
greeting.setText(getDefaultGreetingText());
}
}
catch (EnterpriseFieldException efe) {
// An error occurred setting the value of the greeting text. Log it and
// reply with an error.
String errType = "application";
String errCode = "EnterpriseGreetingService-1002";
String errDesc = "An error occurred setting the value of the " +
"greeting text. The exception is: " + efe.getMessage();
logger.fatal("[GreetingRequestCommand " + errDesc);
ArrayList errors = new ArrayList();
errors.add(buildError(errType, errCode, errDesc));
String replyContents =
buildReplyDocumentWithErrors(eControlArea, localResponseDoc, errors);
return getMessage(msg, replyContents);
}
// Set the TestId.
greeting.setTestId(greetee.getTestId());
// Get pub/sub producer to use in this transaction.
PubSubProducer pub = null;
try {
pub = (PubSubProducer)m_pubSubProducerPool.getProducer();