Search in sources :

Example 91 with ApplicationExceptions

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

the class ValidationRulesEditorForm method doValidate1.

/**
 * This method should be invoked to ensure a valid state of the FormBean. It will validate the data in the models and set the corresponding properties.
 * Errors will be raised in the FormBean, if any validation fails.
 * @param request The request stream
 * @return A true indicates validations went through successfully.
 */
public boolean doValidate1(HttpServletRequest request) throws FrameworkException, ApplicationExceptions {
    String value = null;
    ApplicationExceptions appExps = new ApplicationExceptions();
    value = getFileContentsWM().getValue();
    if (value != null && value.trim().length() == 0)
        value = null;
    try {
        // Create a factory object for creating DOM parsers
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        // Specifies that the parser produced by this factory will validate documents as they are parsed.
        factory.setValidating(true);
        // Now use the factory to create a DOM parser
        DocumentBuilder parser = factory.newDocumentBuilder();
        // Specifies the EntityResolver onceo resolve DTD used in XML documents
        parser.setEntityResolver(new DefaultEntityResolver());
        // Specifies the ErrorHandler to handle warning/error/fatalError conditions
        parser.setErrorHandler(new DefaultErrorHandler());
        Document document = parser.parse(new InputSource(new StringReader(value)));
    } catch (ParserConfigurationException e) {
        // Cannot pass e.toString() and pass as parameter as the the meesage contains quotes
        // which dows not work properly with displaying the messages
        appExps.add(new ConfigException(ConfigException.PROP_XML_FILE_PARSE_ERROR, StringHelper.convertToHTML(e.getMessage())));
        throw appExps;
    } catch (SAXException e) {
        appExps.add(new ConfigException(ConfigException.PROP_XML_FILE_PARSE_ERROR, StringHelper.convertToHTML(e.getMessage())));
        throw appExps;
    } catch (IOException e) {
        appExps.add(new ConfigException(ConfigException.PROP_XML_FILE_PARSE_ERROR, StringHelper.convertToHTML(e.getMessage())));
        throw appExps;
    }
    setFileContents(value);
    return true;
}
Also used : InputSource(org.xml.sax.InputSource) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) ConfigException(org.jaffa.applications.jaffa.modules.admin.exceptions.ConfigException) IOException(java.io.IOException) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException) DefaultEntityResolver(org.jaffa.util.DefaultEntityResolver) DocumentBuilder(javax.xml.parsers.DocumentBuilder) StringReader(java.io.StringReader) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) DefaultErrorHandler(org.jaffa.util.DefaultErrorHandler)

Example 92 with ApplicationExceptions

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

the class ViewerHyperlinkConfigAction method do_Refresh_Clicked.

/**
 * Clicked event handler for the field Refresh.
 * @return The FormKey.
 */
public FormKey do_Refresh_Clicked() {
    FormKey fk = null;
    ViewerHyperlinkConfigForm myForm = (ViewerHyperlinkConfigForm) form;
    ViewerHyperlinkConfigComponent myComp = (ViewerHyperlinkConfigComponent) myForm.getComponent();
    try {
        if (myComp.getCurrentScreenCounter() == 0)
            myComp.loadDomainFieldViewerComponentMappingFile();
        else
            myComp.loadKeyFieldPerViewerComponentFile();
    } catch (ApplicationExceptions e) {
        if (log.isDebugEnabled())
            log.debug("Refresh Failed");
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
    }
    if (fk == null)
        fk = myComp.determineFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FormKey(org.jaffa.presentation.portlet.FormKey)

Example 93 with ApplicationExceptions

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

the class ViewerHyperlinkConfigAction method do_Save_Clicked.

/**
 * Clicked event handler for the field Save.
 * @return The FormKey.
 */
public FormKey do_Save_Clicked() {
    FormKey fk = null;
    ViewerHyperlinkConfigForm myForm = (ViewerHyperlinkConfigForm) form;
    ViewerHyperlinkConfigComponent myComp = (ViewerHyperlinkConfigComponent) myForm.getComponent();
    try {
        if (invokeDoValidateForScreen(myComp.getCurrentScreenCounter())) {
            if (myComp.getCurrentScreenCounter() == 0)
                myComp.storeDomainFieldViewerComponentMappingFile();
            else
                myComp.storeKeyFieldPerViewerComponentFile();
        }
    } catch (ApplicationExceptions e) {
        if (log.isDebugEnabled())
            log.debug("Save Failed");
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
    }
    if (fk == null)
        fk = myComp.determineFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FormKey(org.jaffa.presentation.portlet.FormKey)

Example 94 with ApplicationExceptions

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

the class ViewerHyperlinkConfigComponent method storeFile.

private void storeFile(String fileName, String contents) throws ApplicationExceptions {
    Writer writer = null;
    try {
        writer = new BufferedWriter(new FileWriter(URLHelper.newExtendedURL(fileName).getPath(), false));
        writer.write(contents);
        writer.flush();
        if (log.isDebugEnabled())
            log.debug("Stored to the file: " + fileName + " and then flushing the cache in the TextTag");
        // flush the properties cache in the TextTag
        TextTag.reloadViewerHyperlinkConfig();
    } catch (MalformedURLException e) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new ViewerHyperlinkConfigException(ViewerHyperlinkConfigException.PROP_FILE_STORE_ERROR, fileName));
        throw appExps;
    } catch (IOException e) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new ViewerHyperlinkConfigException(ViewerHyperlinkConfigException.PROP_FILE_STORE_ERROR, fileName));
        throw appExps;
    } finally {
        try {
            if (writer != null)
                writer.close();
        } catch (IOException e) {
        // do nothing
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ViewerHyperlinkConfigException(org.jaffa.applications.jaffa.modules.admin.components.viewerhyperlinkconfig.ui.exceptions.ViewerHyperlinkConfigException)

Example 95 with ApplicationExceptions

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

the class BusinessEventLogFinderAction method do_Rows_View_Clicked.

// .//GEN-END:_2_be
// .//GEN-BEGIN:_do_Rows_View_Clicked_1_be
/**
 * Invokes the viewObject() method on the component.
 * @param rowNum The selected row on the Results screen.
 * @return The FormKey for the View screen.
 */
public FormKey do_Rows_View_Clicked(String rowNum) {
    FormKey fk = null;
    // .//GEN-END:_do_Rows_View_Clicked_1_be
    // Add custom code before processing the action //GEN-FIRST:_do_Rows_View_Clicked_1
    // .//GEN-LAST:_do_Rows_View_Clicked_1
    // .//GEN-BEGIN:_do_Rows_View_Clicked_2_be
    BusinessEventLogFinderForm myForm = (BusinessEventLogFinderForm) form;
    BusinessEventLogFinderComponent myComp = (BusinessEventLogFinderComponent) myForm.getComponent();
    GridModel model = (GridModel) myForm.getRowsWM();
    GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
    if (selectedRow != null) {
        try {
            // .//GEN-END:_do_Rows_View_Clicked_2_be
            // Add custom code before invoking the component //GEN-FIRST:_do_Rows_View_Clicked_2
            // .//GEN-LAST:_do_Rows_View_Clicked_2
            // .//GEN-BEGIN:_do_Rows_View_Clicked_3_be
            fk = myComp.viewObject((java.lang.String) selectedRow.get("logId"));
        } 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_Rows_View_Clicked_3_be
    // Add custom code after returning from the component //GEN-FIRST:_do_Rows_View_Clicked_3
    // .//GEN-LAST:_do_Rows_View_Clicked_3
    // .//GEN-BEGIN:_do_Rows_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 = myComp.getResultsFormKey();
    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)

Aggregations

ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)575 FrameworkException (org.jaffa.exceptions.FrameworkException)307 FormKey (org.jaffa.presentation.portlet.FormKey)205 ApplicationException (org.jaffa.exceptions.ApplicationException)116 GridModel (org.jaffa.presentation.portlet.widgets.model.GridModel)104 GridModelRow (org.jaffa.presentation.portlet.widgets.model.GridModelRow)103 UOW (org.jaffa.persistence.UOW)82 Criteria (org.jaffa.persistence.Criteria)66 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)59 MandatoryFieldException (org.jaffa.datatypes.exceptions.MandatoryFieldException)23 ValidationException (org.jaffa.datatypes.ValidationException)21 Iterator (java.util.Iterator)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)15 Method (java.lang.reflect.Method)15 FormTemplate (org.jaffa.modules.printing.domain.FormTemplate)15 DuplicateKeyException (org.jaffa.exceptions.DuplicateKeyException)14 OutputCommand (org.jaffa.modules.printing.domain.OutputCommand)11 MalformedURLException (java.net.MalformedURLException)10 UserRequest (org.jaffa.applications.jaffa.modules.user.domain.UserRequest)10 PrinterDefinition (org.jaffa.modules.printing.domain.PrinterDefinition)10