mil.dod.th.ose.remote/src/mil/dod/th/ose/remote/MessageRouterImpl.java
private void tryCallMessageServiceHandleMessage(final TerraHarvestMessage message, 
            final TerraHarvestPayload payload, final RemoteChannel channel)
    {
        TerraHarvestMessage errorMessage;//NOCHECKSTYLE will get assigned in if statement
        final MessageService messageService = m_MessageServices.get(payload.getNamespace());       
        if (messageService == null)
        {
            //no service found
            m_Log.warning("No remote message service found for namespace %s", payload.getNamespace());
            
            errorMessage = TerraHarvestMessageUtil.buildErrorResponseMessage(message, ErrorCode.NO_MESSAGE_SERVICE, 
                    "No remote message service found to handle the message: " + payload.getNamespace());
            channel.queueMessage(errorMessage);
            return;
        }

        ErrorCode errorCode;
        String errorMsg;
        Exception exception;
        try
        {
            messageService.handleMessage(message, payload, channel);
            return;
        }
        catch (final IOException e)
        {
            exception = e;
            errorMsg = String.format("Failed IO operation when handling [%s] namespace message: %s", 
                    payload.getNamespace(), e.getMessage());
            errorCode = ErrorCode.INVALID_REQUEST;
        }
        catch (final IllegalArgumentException e)
        {
            exception = e;
            errorMsg = String.format("Invalid value when handling [%s] namespace message: %s", 
                    payload.getNamespace(), e.getMessage());
            errorCode = ErrorCode.INVALID_VALUE;
        }
        catch (final IllegalStateException e)
        {
            exception = e;
            errorMsg = String.format("Illegal state when handling [%s] namespace message: %s", 
                    payload.getNamespace(), e.getMessage());
            errorCode = ErrorCode.ILLEGAL_STATE;
        }
        catch (final UnmarshalException e)
        {
            exception = e;
            errorMsg = String.format("JAXB error when handling [%s] namespace message: %s", 
                    payload.getNamespace(), e.getMessage());
            errorCode = ErrorCode.JAXB_ERROR;
        }
        catch (final ObjectConverterException e)
        {
            exception = e;
            errorMsg = String.format("Proto converter error when handling [%s] namespace message: %s", 
                    payload.getNamespace(), e.getMessage());
            errorCode = ErrorCode.CONVERTER_ERROR;
        }
        catch (final Exception e)
        {
            exception = e;
            errorMsg = String.format("%s when handling [%s] namespace message: %s", 
                    e.getClass().getSimpleName(), payload.getNamespace(), e.getMessage());
            errorCode = ErrorCode.INTERNAL_ERROR;
        }
        
        m_Log.error(exception, errorMsg);
        errorMessage = TerraHarvestMessageUtil.buildErrorResponseMessage(message, errorCode, errorMsg);
        channel.queueMessage(errorMessage);
    }
/**
     * Method that retrieves the message service for the given namespace and then attempts to call the handle message
     * method.
     * 
     * @param message
     *      the message that was received
     * @param payload
     *      the payload that was received
     * @param channel
     *      the remote channel that should be used to send any error messages
     */
Method that retrieves the message service for the given namespace and then attempts to call the handle message
method.

@param message
the message that was received
@param payload
the payload that was received
@param channel
the remote channel that should be used to send any error messages
Method that retrieves the message service for the given namespace and then attempts to call the handle message method . @param message the message that was received @param payload the payload that was received @param channel the remote channel that should be used to send any error messages
private void tryCallMessageServiceHandleMessage(final TerraHarvestMessage message, 
            final TerraHarvestPayload payload, final RemoteChannel channel)
    {
        TerraHarvestMessage errorMessage;
        final MessageService messageService = m_MessageServices.get(payload.getNamespace());       
        if (messageService == null)
        {
            m_Log.warning("No remote message service found for namespace %s", payload.getNamespace());
            errorMessage = TerraHarvestMessageUtil.buildErrorResponseMessage(message, ErrorCode.NO_MESSAGE_SERVICE, 
                    "No remote message service found to handle the message: " + payload.getNamespace());
            channel.queueMessage(errorMessage);
            return;
        }
        ErrorCode errorCode;
        String errorMsg;
        Exception exception;
        try
        {
            messageService.handleMessage(message, payload, channel);
            return;
        }
        catch (final IOException e)
        {
            exception = e;
            errorMsg = String.format("Failed IO operation when handling [%s] namespace message: %s", 
                    payload.getNamespace(), e.getMessage());
            errorCode = ErrorCode.INVALID_REQUEST;
        }
        catch (final IllegalArgumentException e)
        {
            exception = e;
            errorMsg = String.format("Invalid value when handling [%s] namespace message: %s", 
                    payload.getNamespace(), e.getMessage());
            errorCode = ErrorCode.INVALID_VALUE;
        }
        catch (final IllegalStateException e)
        {
            exception = e;
            errorMsg = String.format("Illegal state when handling [%s] namespace message: %s", 
                    payload.getNamespace(), e.getMessage());
            errorCode = ErrorCode.ILLEGAL_STATE;
        }
        catch (final UnmarshalException e)
        {
            exception = e;
            errorMsg = String.format("JAXB error when handling [%s] namespace message: %s", 
                    payload.getNamespace(), e.getMessage());
            errorCode = ErrorCode.JAXB_ERROR;
        }
        catch (final ObjectConverterException e)
        {
            exception = e;
            errorMsg = String.format("Proto converter error when handling [%s] namespace message: %s", 
                    payload.getNamespace(), e.getMessage());
            errorCode = ErrorCode.CONVERTER_ERROR;
        }
        catch (final Exception e)
        {
            exception = e;
            errorMsg = String.format("%s when handling [%s] namespace message: %s", 
                    e.getClass().getSimpleName(), payload.getNamespace(), e.getMessage());
            errorCode = ErrorCode.INTERNAL_ERROR;
        }
        m_Log.error(exception, errorMsg);
        errorMessage = TerraHarvestMessageUtil.buildErrorResponseMessage(message, errorCode, errorMsg);
        channel.queueMessage(errorMessage);
    }
private void tryCallMessageServiceHandleMessage ( final TerraHarvestMessage message , final TerraHarvestPayload payload , final RemoteChannel channel ) { TerraHarvestMessage errorMessage ; final MessageService messageService = m_MessageServices . get ( payload . getNamespace ( ) ) ; if ( messageService == null ) { m_Log . warning ( "No remote message service found for namespace %s" , payload . getNamespace ( ) ) ; errorMessage = TerraHarvestMessageUtil . buildErrorResponseMessage ( message , ErrorCode . NO_MESSAGE_SERVICE , "No remote message service found to handle the message: " + payload . getNamespace ( ) ) ; channel . queueMessage ( errorMessage ) ; return ; } ErrorCode errorCode ; String errorMsg ; Exception exception ; try { messageService . handleMessage ( message , payload , channel ) ; return ; } catch ( final IOException e ) { exception = e ; errorMsg = String . format ( "Failed IO operation when handling [%s] namespace message: %s" , payload . getNamespace ( ) , e . getMessage ( ) ) ; errorCode = ErrorCode . INVALID_REQUEST ; } catch ( final IllegalArgumentException e ) { exception = e ; errorMsg = String . format ( "Invalid value when handling [%s] namespace message: %s" , payload . getNamespace ( ) , e . getMessage ( ) ) ; errorCode = ErrorCode . INVALID_VALUE ; } catch ( final IllegalStateException e ) { exception = e ; errorMsg = String . format ( "Illegal state when handling [%s] namespace message: %s" , payload . getNamespace ( ) , e . getMessage ( ) ) ; errorCode = ErrorCode . ILLEGAL_STATE ; } catch ( final UnmarshalException e ) { exception = e ; errorMsg = String . format ( "JAXB error when handling [%s] namespace message: %s" , payload . getNamespace ( ) , e . getMessage ( ) ) ; errorCode = ErrorCode . JAXB_ERROR ; } catch ( final ObjectConverterException e ) { exception = e ; errorMsg = String . format ( "Proto converter error when handling [%s] namespace message: %s" , payload . getNamespace ( ) , e . getMessage ( ) ) ; errorCode = ErrorCode . CONVERTER_ERROR ; } catch ( final Exception e ) { exception = e ; errorMsg = String . format ( "%s when handling [%s] namespace message: %s" , e . getClass ( ) . getSimpleName ( ) , payload . getNamespace ( ) , e . getMessage ( ) ) ; errorCode = ErrorCode . INTERNAL_ERROR ; } m_Log . error ( exception , errorMsg ) ; errorMessage = TerraHarvestMessageUtil . buildErrorResponseMessage ( message , errorCode , errorMsg ) ; channel . queueMessage ( errorMessage ) ; }
Method that retrieves the message service for the given namespace and then attempts to call the handle message
 method.
Method that retrieves the message service for the given namespace and then attempts to call the handle message method .
//NOCHECKSTYLE will get assigned in if statement //no service found