Search in sources :

Example 41 with FrameworkException

use of org.jaffa.exceptions.FrameworkException in project jaffa-framework by jaffa-projects.

the class QueueViewerTx method addRelatedDtos.

private void addRelatedDtos(QueueViewerInDto input, QueueViewerOutDto output) throws FrameworkException, ApplicationExceptions {
    Message[] messages = null;
    if (input.getMessageMode() == null || input.getMessageMode() == MessageModeEnum.PENDING)
        messages = JmsBrowser.getPendingMessages(input.getQueueName(), input.getFilter());
    else
        log.warn("Messages cannot be retrieved since unsupported messageMode '" + input.getMessageMode() + "' has been passed");
    try {
        // Determine the header elements for the queue
        QueueInfo queueInfo = ConfigurationService.getInstance().getQueueInfo(input.getQueueName());
        if (queueInfo != null && queueInfo.getDisplayParam() != null) {
            List<HeaderElementDto> headerElementDtos = new LinkedList<HeaderElementDto>();
            for (DisplayParam displayParam : queueInfo.getDisplayParam()) {
                HeaderElementDto headerElementDto = new HeaderElementDto();
                headerElementDto.setName(displayParam.getName());
                headerElementDto.setLabel(displayParam.getLabel());
                headerElementDtos.add(headerElementDto);
            }
            output.setHeaderElements(headerElementDtos.toArray(new HeaderElementDto[headerElementDtos.size()]));
        }
        if (messages != null && messages.length > 0) {
            List<MessageDto> messageDtos = new LinkedList<MessageDto>();
            String[] manageableMessages = null;
            for (Message message : messages) {
                MessageDto messageDto = new MessageDto();
                messageDto.setMessageId(message.getJMSMessageID());
                if (input.getMessageMode() == MessageModeEnum.IN_PROCESS) {
                    messageDto.setManageable(Arrays.binarySearch(manageableMessages, message.getJMSMessageID()) >= 0 ? Boolean.TRUE : Boolean.FALSE);
                } else
                    messageDto.setManageable(Boolean.FALSE);
                // Evaluate the header elements for the message
                if (queueInfo != null && queueInfo.getDisplayParam() != null) {
                    List<HeaderElementDto> headerElementDtos = new LinkedList<HeaderElementDto>();
                    for (DisplayParam displayParam : queueInfo.getDisplayParam()) {
                        HeaderElementDto headerElementDto = new HeaderElementDto();
                        headerElementDto.setName(displayParam.getName());
                        headerElementDto.setLabel(displayParam.getLabel());
                        Object value = message.getObjectProperty(displayParam.getName());
                        if (value == null) {
                            // Use bean intropsection to extract the value of the property
                            try {
                                if (displayParam.getName().equals("JMSTimestamp")) {
                                    value = message.getJMSTimestamp() != 0 ? new DateTime(message.getJMSTimestamp()) : null;
                                } else {
                                    value = BeanHelper.getField(message, displayParam.getName());
                                }
                            } catch (Exception e) {
                            // do nothing
                            }
                        }
                        if (value != null)
                            headerElementDto.setValue(Formatter.format(value));
                        headerElementDtos.add(headerElementDto);
                    }
                    messageDto.setHeaderElements(headerElementDtos.toArray(new HeaderElementDto[headerElementDtos.size()]));
                }
                messageDtos.add(messageDto);
            }
            output.setMessages(messageDtos.toArray(new MessageDto[messageDtos.size()]));
        }
    } catch (JMSException e) {
        throw new JaffaMessagingFrameworkException(JaffaMessagingFrameworkException.MESSAGE_INFO_MISSING, null, e);
    }
}
Also used : Message(javax.jms.Message) JMSException(javax.jms.JMSException) LinkedList(java.util.LinkedList) DateTime(org.jaffa.datatypes.DateTime) FrameworkException(org.jaffa.exceptions.FrameworkException) JMSException(javax.jms.JMSException)

Example 42 with FrameworkException

use of org.jaffa.exceptions.FrameworkException in project jaffa-framework by jaffa-projects.

the class QueueViewerAction method do_Refresh_Clicked.

public FormKey do_Refresh_Clicked() {
    FormKey fk = null;
    QueueViewerForm myForm = (QueueViewerForm) form;
    QueueViewerComponent myComp = (QueueViewerComponent) myForm.getComponent();
    try {
        if (myForm.doValidate(request))
            myComp.doInquiry();
    } catch (ApplicationExceptions e) {
        if (log.isDebugEnabled())
            log.debug("Refresh Failed");
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
    } catch (FrameworkException e) {
        log.error(null, e);
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
    }
    // Direct User back to current form
    if (fk == null)
        fk = myComp.getViewerFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) FormKey(org.jaffa.presentation.portlet.FormKey)

Example 43 with FrameworkException

use of org.jaffa.exceptions.FrameworkException in project jaffa-framework by jaffa-projects.

the class QueueViewerAction method do_RelatedQueueHeader_Delete_Clicked.

public FormKey do_RelatedQueueHeader_Delete_Clicked(String rowNum) {
    FormKey fk = null;
    QueueViewerForm myForm = (QueueViewerForm) form;
    QueueViewerComponent myComp = (QueueViewerComponent) myForm.getComponent();
    try {
        // This will stop double submits
        performTokenValidation(request);
        GridModel model = (GridModel) myForm.getRelatedQueueHeaderWM();
        GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
        if (selectedRow != null)
            fk = myComp.deleteMessage((java.lang.String) selectedRow.get("messageId"));
        // Invoke QueueView Listener
        myComp.invokeQueueViewerListeners();
    } catch (ApplicationExceptions e) {
        if (log.isDebugEnabled())
            log.debug("RelatedQueueHeader_Delete Failed");
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
    } catch (FrameworkException e) {
        log.error(null, e);
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
    }
    // Direct User back to current form
    if (fk == null)
        fk = myComp.getViewerFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel) FormKey(org.jaffa.presentation.portlet.FormKey) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Example 44 with FrameworkException

use of org.jaffa.exceptions.FrameworkException in project jaffa-framework by jaffa-projects.

the class QueueViewerAction method do_RelatedQueueHeader_View_Clicked.

public FormKey do_RelatedQueueHeader_View_Clicked(String rowNum) {
    FormKey fk = null;
    QueueViewerForm myForm = (QueueViewerForm) form;
    QueueViewerComponent myComp = (QueueViewerComponent) myForm.getComponent();
    try {
        GridModel model = (GridModel) myForm.getRelatedQueueHeaderWM();
        GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
        if (selectedRow != null)
            fk = myComp.viewMessage((java.lang.String) selectedRow.get("messageId"));
    } catch (ApplicationExceptions e) {
        if (log.isDebugEnabled())
            log.debug("RelatedQueueHeader_View Failed");
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
    } catch (FrameworkException e) {
        log.error(null, e);
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
    }
    // The Viewer will be rendered in a new window
    // We don't want to see the existing HistoryNav in that window
    // Hence, initialize the HistoryNav
    HistoryNav.initializeHistoryNav(request);
    // Direct User back to current form
    if (fk == null)
        fk = myComp.getViewerFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel) FormKey(org.jaffa.presentation.portlet.FormKey) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Example 45 with FrameworkException

use of org.jaffa.exceptions.FrameworkException in project jaffa-framework by jaffa-projects.

the class DefaultValueEditorAction method do_Save_Clicked.

/**
 * Clicked event handler for the field Save.
 * @return The FormKey.
 */
public FormKey do_Save_Clicked() {
    FormKey fk = null;
    DefaultValueEditorForm myForm = (DefaultValueEditorForm) form;
    DefaultValueEditorComponent myComp = (DefaultValueEditorComponent) myForm.getComponent();
    try {
        if (invokeDoValidateForScreen(myComp.getCurrentScreenCounter())) {
            myComp.saveDefaultValues();
        }
    } catch (FrameworkException e) {
        log.error(null, e);
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
    }
    fk = myComp.determineFormKey();
    return fk;
}
Also used : FrameworkException(org.jaffa.exceptions.FrameworkException) FormKey(org.jaffa.presentation.portlet.FormKey)

Aggregations

FrameworkException (org.jaffa.exceptions.FrameworkException)348 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)293 FormKey (org.jaffa.presentation.portlet.FormKey)204 ApplicationException (org.jaffa.exceptions.ApplicationException)101 GridModel (org.jaffa.presentation.portlet.widgets.model.GridModel)100 GridModelRow (org.jaffa.presentation.portlet.widgets.model.GridModelRow)99 UOW (org.jaffa.persistence.UOW)87 InvocationTargetException (java.lang.reflect.InvocationTargetException)16 Method (java.lang.reflect.Method)14 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)12 Iterator (java.util.Iterator)11 IPersistent (org.jaffa.persistence.IPersistent)10 Map (java.util.Map)9 FormTemplate (org.jaffa.modules.printing.domain.FormTemplate)9 Criteria (org.jaffa.persistence.Criteria)9 LinkedHashMap (java.util.LinkedHashMap)7 Attachment (org.jaffa.components.attachment.domain.Attachment)6 InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)6 MultipleDomainObjectsFoundException (org.jaffa.exceptions.MultipleDomainObjectsFoundException)6 FormDefinition (org.jaffa.modules.printing.domain.FormDefinition)6