DeletedMessageStore dms = DeletedMessageStore.getInstance();
dms.setMessage(request);
dms.setSystem(source);
mReturncode = Constants.RC_NOK;
Message call = null;
try
{
try
{
// Zero: check handling of empty messages
if (!checkRequest(source, request))
{
/*
* Request shall not be processed but ignored
*/
call = new SimpleTextMessage(source);
try
{
((TextMessage) call).setRequestText(request.toString(),
source);
}
catch (XException e)
{
// This problem has already been traced
}
call.setReturncode(Constants.RC_OK);
}
else
{
/*
* Request shall be processed
*/
// First: create the message obejct
call = MessageFactory.createApplicationMessage(source);
// Second: initialise the message object by pasting in the
// request
// as content,
// then perfom the call the appropriate application object
// and record the response
if (Constants.TYPE_TEXT.equals(messageType))
{
((TextMessage) call).setRequestText((String) request,
source);
ApplicationFactory.callApplication(call);
// Get the response.
// The message is already transformed and structure
// information
// for serialising is attached to the source system.
mResponse = ((TextMessage) call).getResponseText();
}
else if (Constants.TYPE_OBJECT.equals(messageType))
{
((ObjectMessage) call)
.setRequestObject(request, source);
ApplicationFactory.callApplication(call);
// Get the response.
// The message is already transformed and structure
// information
// for serialising is attached to the source system.
mResponse = ((ObjectMessage) call).getResponseObject();
}
}
}
catch (Exception t)
{
/*
* Inner try-catch block catches all exceptions and converts
* them to XExceptions if necessary
*/
if (t instanceof XException)
{
throw (XException) t;
}
else
{
throw new XException(Constants.LOCATION_INTERN,
Constants.LAYER_APPLICATION,
Constants.PACKAGE_APPLICATION_ADAPTER, "0", t);
}
}
}
catch (XException e)
{
/*
* Outer try-catch block handles the XException
*/
if (call == null)
{
if (request == null)
{
request = "<null>";
}
call = new SimpleTextMessage(source);
try
{
((TextMessage) call).setRequestText(request.toString(),
source);
}
catch (XException e1)
{
// This problem has already been traced
}
}
call.setReturncode(Constants.RC_NOK);
if ((call.getErrortext() == null)
|| (call.getErrortext().length() == 0))
{
call.setErrortext(e.getMessage());
}
}
finally
{
mReturncode = call.getReturncode();
mErrormessage = call.getErrortext();
try
{
// Logging of the receiving-activity into the journal and
// closing the
// connection to the database.
call.setResponseTimestamp(new Date());
Journal journal = new Journal();
journal.log('R', source, call);
journal.commit();
} // try
catch (Exception t)