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;
}
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;
}
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;
}
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
}
}
}
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;
}
Aggregations