Search in sources :

Example 1 with HeaderElementDto

use of org.jaffa.modules.messaging.components.messageviewer.dto.HeaderElementDto in project jaffa-framework by jaffa-projects.

the class MessageViewerTx method buildDto.

/**
 * Obtains the Message based on the messageMode and creates the output.
 */
private MessageViewerOutDto buildDto(MessageViewerInDto input) throws FrameworkException, ApplicationExceptions {
    try {
        Message message = findMessage(input);
        MessageViewerOutDto output = new MessageViewerOutDto();
        output.setJMSMessageID(input.getJMSMessageID());
        output.setError(message.getStringProperty(JmsBrowser.HEADER_ERROR_DETAILS));
        output.setPriority(new Long(message.getJMSPriority()));
        output.setHasPriorityAccess(JmsBrowser.hasChangePriorityAccess(message.getStringProperty(JmsBrowser.HEADER_ORIGINAL_QUEUE_NAME)));
        output.setJMSDestination(message.getJMSDestination());
        output.setJMSDeliveryMode(message.getJMSDeliveryMode());
        output.setJMSTimestamp(message.getJMSTimestamp() != 0 ? new DateTime(message.getJMSTimestamp()) : null);
        output.setJMSCorrelationID(message.getJMSCorrelationID());
        output.setJMSReplyTo(message.getJMSReplyTo());
        try {
            output.setJMSRedelivered(message.getJMSRedelivered());
        } catch (Exception e) {
        // JBossMessaging throws "java.lang.IllegalStateException: This should never be called directly". Do nothing
        }
        output.setJMSType(message.getJMSType());
        output.setJMSExpiration(message.getJMSExpiration());
        if (message instanceof TextMessage)
            output.setPayLoad(((TextMessage) message).getText());
        // Generate a Map of header elements, keyed by the name of each header element
        // Ignore Error Details as we are showing it in a separate section
        Map<String, HeaderElementDto> headerElements = new LinkedHashMap<String, HeaderElementDto>();
        for (Enumeration e = message.getPropertyNames(); e.hasMoreElements(); ) {
            String name = (String) e.nextElement();
            if (!JmsBrowser.HEADER_ERROR_DETAILS.equals(name)) {
                String value = Formatter.format(message.getObjectProperty(name));
                HeaderElementDto headerElement = headerElements.get(name);
                if (headerElement == null) {
                    headerElement = new HeaderElementDto();
                    headerElement.setName(name);
                    headerElements.put(name, headerElement);
                }
                headerElement.setValue(value);
            }
        }
        // Add labels to the header-elements based on the QueueInfo
        // It is possible that a display-param points to a property on the Message (eg. JMSMessageID, JMSPriority etc.)
        // Use bean intropsection to extract the value of that property
        QueueInfo queueInfo = ConfigurationService.getInstance().getQueueInfo(message.getStringProperty(JmsBrowser.HEADER_ORIGINAL_QUEUE_NAME));
        if (queueInfo != null && queueInfo.getDisplayParam() != null) {
            for (DisplayParam displayParam : queueInfo.getDisplayParam()) {
                HeaderElementDto headerElement = headerElements.get(displayParam.getName());
                if (headerElement == null) {
                    try {
                        headerElement = new HeaderElementDto();
                        headerElement.setName(displayParam.getName());
                        headerElement.setLabel(displayParam.getLabel());
                        headerElements.put(displayParam.getName(), headerElement);
                        if (displayParam.getName().equals("JMSTimestamp")) {
                            String value = message.getJMSTimestamp() != 0 ? Formatter.format(new DateTime(message.getJMSTimestamp())) : null;
                            headerElement.setValue(value);
                        } else {
                            String value = Formatter.format(BeanHelper.getField(message, displayParam.getName()));
                            headerElement.setValue(value);
                        }
                    } catch (Exception e) {
                    // do nothing
                    }
                } else {
                    headerElement.setLabel(displayParam.getLabel());
                }
            }
        }
        output.setHeaderElements(headerElements.values().toArray(new HeaderElementDto[headerElements.values().size()]));
        buildBusinessEventLogDto(input, output, message);
        return output;
    } catch (JMSException e) {
        throw new JaffaMessagingFrameworkException(JaffaMessagingFrameworkException.MESSAGE_INFO_MISSING, null, e);
    }
}
Also used : MessageViewerOutDto(org.jaffa.modules.messaging.components.messageviewer.dto.MessageViewerOutDto) QueueInfo(org.jaffa.modules.messaging.services.configdomain.QueueInfo) Enumeration(java.util.Enumeration) Message(javax.jms.Message) TextMessage(javax.jms.TextMessage) JaffaMessagingFrameworkException(org.jaffa.modules.messaging.services.JaffaMessagingFrameworkException) JMSException(javax.jms.JMSException) DateTime(org.jaffa.datatypes.DateTime) FrameworkException(org.jaffa.exceptions.FrameworkException) JaffaMessagingFrameworkException(org.jaffa.modules.messaging.services.JaffaMessagingFrameworkException) JMSException(javax.jms.JMSException) LinkedHashMap(java.util.LinkedHashMap) HeaderElementDto(org.jaffa.modules.messaging.components.messageviewer.dto.HeaderElementDto) DisplayParam(org.jaffa.modules.messaging.services.configdomain.DisplayParam) TextMessage(javax.jms.TextMessage)

Example 2 with HeaderElementDto

use of org.jaffa.modules.messaging.components.messageviewer.dto.HeaderElementDto in project jaffa-framework by jaffa-projects.

the class MessageViewerForm method populateHeaders.

private void populateHeaders(GridModel rows) {
    rows.clearRows();
    MessageViewerOutDto outputDto = ((MessageViewerComponent) getComponent()).getMessageViewerOutDto();
    if (outputDto != null) {
        HeaderElementDto[] headerElements = outputDto.getHeaderElements();
        if (headerElements != null) {
            for (HeaderElementDto headerElement : headerElements) {
                if (headerElement.getLabel() != null) {
                    GridModelRow row = rows.newRow();
                    row.addElement("name", headerElement.getName());
                    row.addElement("value", headerElement.getValue());
                    row.addElement("label", headerElement.getLabel());
                }
            }
        }
    }
}
Also used : MessageViewerOutDto(org.jaffa.modules.messaging.components.messageviewer.dto.MessageViewerOutDto) HeaderElementDto(org.jaffa.modules.messaging.components.messageviewer.dto.HeaderElementDto) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Example 3 with HeaderElementDto

use of org.jaffa.modules.messaging.components.messageviewer.dto.HeaderElementDto in project jaffa-framework by jaffa-projects.

the class MessageViewerForm method populateTechnicalDetails.

private void populateTechnicalDetails(GridModel rows) {
    rows.clearRows();
    MessageViewerOutDto outputDto = ((MessageViewerComponent) getComponent()).getMessageViewerOutDto();
    if (outputDto != null) {
        HeaderElementDto[] headerElements = outputDto.getHeaderElements();
        if (headerElements != null) {
            for (HeaderElementDto headerElement : headerElements) {
                if (headerElement.getLabel() == null) {
                    GridModelRow row = rows.newRow();
                    row.addElement("name", headerElement.getName());
                    row.addElement("value", headerElement.getValue());
                    row.addElement("label", headerElement.getName());
                }
            }
        }
    }
}
Also used : MessageViewerOutDto(org.jaffa.modules.messaging.components.messageviewer.dto.MessageViewerOutDto) HeaderElementDto(org.jaffa.modules.messaging.components.messageviewer.dto.HeaderElementDto) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Aggregations

HeaderElementDto (org.jaffa.modules.messaging.components.messageviewer.dto.HeaderElementDto)3 MessageViewerOutDto (org.jaffa.modules.messaging.components.messageviewer.dto.MessageViewerOutDto)3 GridModelRow (org.jaffa.presentation.portlet.widgets.model.GridModelRow)2 Enumeration (java.util.Enumeration)1 LinkedHashMap (java.util.LinkedHashMap)1 JMSException (javax.jms.JMSException)1 Message (javax.jms.Message)1 TextMessage (javax.jms.TextMessage)1 DateTime (org.jaffa.datatypes.DateTime)1 FrameworkException (org.jaffa.exceptions.FrameworkException)1 JaffaMessagingFrameworkException (org.jaffa.modules.messaging.services.JaffaMessagingFrameworkException)1 DisplayParam (org.jaffa.modules.messaging.services.configdomain.DisplayParam)1 QueueInfo (org.jaffa.modules.messaging.services.configdomain.QueueInfo)1