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);
}