Search in sources :

Example 36 with FrameworkException

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

the class FormDefinitionMaintenanceTx method prevalidateUpdate.

// .//GEN-END:_retrieve_1_be
// .//GEN-BEGIN:_prevalidateUpdate_1_be
/**
 * This method is used to perform prevalidations before updating an existing instance of FormDefinition.
 * @param input The new values for the domain object.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The object details.
 */
public FormDefinitionMaintenancePrevalidateOutDto prevalidateUpdate(FormDefinitionMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // Print Debug Information for the input
        if (log.isDebugEnabled())
            log.debug("Input: " + (input != null ? input.toString() : null));
        // create the UOW
        uow = new UOW();
        // Preprocess the input
        preprocess(uow, input);
        // Retrieve the object
        FormDefinition domain = load(uow, input);
        // Ensure the domain object has not been modified
        domainObjectChangedTest(input.getPerformDirtyReadCheck(), domain, input.getLastChangedOn());
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Update the domain object
        updateDomain(uow, input, domain, true);
        FormTemplate formTemplate = createOrLoadFormTemplate(uow, input, domain, true);
        // Build the outbound dto
        FormDefinitionMaintenancePrevalidateOutDto output = createPrevalidateOutDto(uow, domain, input);
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Output: " + (output != null ? output.toString() : null));
        return output;
    } catch (FrameworkException e) {
        // If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
        if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
            throw (ApplicationExceptions) e.getCause();
        } else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
            ApplicationExceptions appExps = new ApplicationExceptions();
            appExps.add((ApplicationException) e.getCause());
            throw appExps;
        } else
            throw e;
    } finally {
        if (uow != null)
            uow.rollback();
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) FormTemplate(org.jaffa.modules.printing.domain.FormTemplate) UOW(org.jaffa.persistence.UOW) FormDefinition(org.jaffa.modules.printing.domain.FormDefinition)

Example 37 with FrameworkException

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

the class BusinessEventLogViewerAction method do_RelatedAttachment_View_Clicked.

/**
 * Invokes the viewAttachment() method on the component.
 * @param rowNum The selected row on the Grid.
 * @return The FormKey for the View screen of the Attachment object.
 */
public FormKey do_RelatedAttachment_View_Clicked(String rowNum) {
    FormKey fk = null;
    // .//GEN-END:do_RelatedAttachment_View_Clicked_1_be
    // Add custom code before processing the action//GEN-FIRST:do_RelatedAttachment_View_Clicked_1
    // .//GEN-LAST:do_RelatedAttachment_View_Clicked_1
    // .//GEN-BEGIN:do_RelatedAttachment_View_Clicked_2_be
    BusinessEventLogViewerForm myForm = (BusinessEventLogViewerForm) form;
    BusinessEventLogViewerComponent myComp = (BusinessEventLogViewerComponent) myForm.getComponent();
    GridModel model = (GridModel) myForm.getRelatedAttachmentWM();
    GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
    if (selectedRow != null) {
        try {
            // .//GEN-END:do_RelatedAttachment_View_Clicked_2_be
            // Add custom code before invoking the component//GEN-FIRST:do_RelatedAttachment_View_Clicked_2
            // .//GEN-LAST:do_RelatedAttachment_View_Clicked_2
            // .//GEN-BEGIN:do_RelatedAttachment_View_Clicked_3_be
            fk = myComp.viewAttachment((java.lang.String) selectedRow.get("attachmentId"));
        } catch (ApplicationExceptions e) {
            if (log.isDebugEnabled())
                log.debug("Viewer Failed");
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
        } catch (FrameworkException e) {
            log.error(null, e);
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
        }
    }
    // .//GEN-END:do_RelatedAttachment_View_Clicked_3_be
    // Add custom code before returning//GEN-FIRST:do_RelatedAttachment_View_Clicked_3
    // .//GEN-LAST:do_RelatedAttachment_View_Clicked_3
    // .//GEN-BEGIN:do_RelatedAttachment_View_Clicked_4_be
    // 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 = new FormKey(myForm.NAME, myComp.getComponentId());
    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 38 with FrameworkException

use of org.jaffa.exceptions.FrameworkException 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 39 with FrameworkException

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

the class QueueListAction method do_Refresh_Clicked.

public FormKey do_Refresh_Clicked() {
    FormKey fk = null;
    QueueListForm myForm = (QueueListForm) form;
    QueueListComponent myComp = (QueueListComponent) myForm.getComponent();
    try {
        fk = myComp.displayResults();
    } 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.getResultsFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) FormKey(org.jaffa.presentation.portlet.FormKey)

Example 40 with FrameworkException

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

the class QueueListComponent method viewMessages.

public FormKey viewMessages(String queue, MessageModeEnum messageMode) throws ApplicationExceptions, FrameworkException {
    QueueViewerComponent viewComponent = (QueueViewerComponent) run("Jaffa.Messaging.QueueViewer");
    viewComponent.setReturnToFormKey(getResultsFormKey());
    viewComponent.setQueue(queue);
    viewComponent.setMessageMode(messageMode);
    viewComponent.addQueueViewerListener(new IQueueViewerListener() {

        public void processDone(EventObject source) throws ApplicationExceptions, FrameworkException {
            displayResults();
        }
    });
    return viewComponent.display();
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) IQueueViewerListener(org.jaffa.modules.messaging.components.queueviewer.ui.IQueueViewerListener) FrameworkException(org.jaffa.exceptions.FrameworkException) QueueViewerComponent(org.jaffa.modules.messaging.components.queueviewer.ui.QueueViewerComponent) EventObject(java.util.EventObject)

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