use of org.jaffa.exceptions.ApplicationExceptions in project jaffa-framework by jaffa-projects.
the class MenuNavigationForm method doValidate.
/**
* This method should be invoked to copy the fields from the FormBean to the component after successful validation.
* @return true of the values are copied successfully
*/
public boolean doValidate() throws FrameworkException, ApplicationExceptions {
String value = null;
ApplicationExceptions appExps = new ApplicationExceptions();
value = getFileContentsWM().getValue();
if (value == null || (value != null && value.trim().length() == 0)) {
appExps.add(new MenuNavigationException(MenuNavigationException.PROP_XML_FILE_PARSE_ERROR, StringHelper.convertToHTML(MessageHelper.findMessage("label.Jaffa.Admin.MenuNavigation.NoContent", null))));
throw appExps;
}
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 onceto 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) {
appExps.add(new MenuNavigationException(MenuNavigationException.PROP_XML_FILE_PARSE_ERROR, StringHelper.convertToHTML(e.getMessage())));
throw appExps;
} catch (SAXException e) {
appExps.add(new MenuNavigationException(MenuNavigationException.PROP_XML_FILE_PARSE_ERROR, StringHelper.convertToHTML(e.getMessage())));
throw appExps;
} catch (IOException e) {
appExps.add(new MenuNavigationException(MenuNavigationException.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 RolesEditorAction method do_CheckPolicy_Clicked.
/**
* This will re-render the screen with the original values.
* @return the FormKey for this screen.
*/
public FormKey do_CheckPolicy_Clicked() {
FormKey fk = null;
RolesEditorForm myForm = (RolesEditorForm) form;
RolesEditorComponent myComp = (RolesEditorComponent) component;
try {
fk = myComp.runCheckPolicy();
} catch (ApplicationExceptions e) {
myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
} catch (FrameworkException e) {
log.error(null, e);
myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
}
if (fk == null)
fk = myComp.getRolesEditorFormKey();
return fk;
}
use of org.jaffa.exceptions.ApplicationExceptions in project jaffa-framework by jaffa-projects.
the class RolesEditorAction method do_Save_Clicked.
/**
* Event Handler for the 'Save' clicked event.
* This will copy the values from the Form to the Component and then invoke the performSave() method on the component.
* Finally it'll get the latest file contents of the roles.xml file.
* @return the FormKey for this screen.
*/
public FormKey do_Save_Clicked() {
FormKey fk = null;
RolesEditorForm myForm = (RolesEditorForm) form;
RolesEditorComponent myComp = (RolesEditorComponent) component;
try {
// Copy the values from Form to Component
myForm.doValidate();
// save the file contents
myComp.performSave(request);
// Get the latest values
fk = do_Refresh_Clicked();
} catch (ApplicationExceptions e) {
myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
} catch (FrameworkException e) {
log.error(null, e);
myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
}
if (fk == null)
fk = myComp.getRolesEditorFormKey();
return fk;
}
use of org.jaffa.exceptions.ApplicationExceptions in project jaffa-framework by jaffa-projects.
the class ValidationRulesEditorAction method do_Save_Clicked.
/**
* Clicked event handler for the field Save.
* @return The FormKey.
*/
public FormKey do_Save_Clicked() {
FormKey fk = null;
ValidationRulesEditorForm myForm = (ValidationRulesEditorForm) form;
ValidationRulesEditorComponent myComp = (ValidationRulesEditorComponent) myForm.getComponent();
try {
// Copy the values from Form to Component
myForm.doValidate(request);
// save the file contents
myComp.performSave();
} catch (ApplicationExceptions e) {
myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
} catch (FrameworkException e) {
log.error(null, e);
myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
}
if (fk == null)
fk = myComp.determineFormKey();
return fk;
}
use of org.jaffa.exceptions.ApplicationExceptions in project jaffa-framework by jaffa-projects.
the class ValidationRulesEditorAction method do_CoreRulesUrl_Clicked.
/**
* Invoked if the core-rules URL is clicked
* @return The FormKey for the Update screen.
*/
public FormKey do_CoreRulesUrl_Clicked() {
ValidationRulesEditorForm myForm = (ValidationRulesEditorForm) form;
ValidationRulesEditorComponent myComp = (ValidationRulesEditorComponent) myForm.getComponent();
FormKey fk = null;
try {
String fileName = (String) Config.getProperty(Config.PROP_RULES_ENGINE_CORE_RULES_URL, null);
if (!fileName.equals(myComp.getValidationRulesFile())) {
myComp.setFileContents(null);
myComp.setValidationRulesFile(fileName);
myComp.loadFileContents();
}
myComp.determineAndSetNextScreen();
} catch (ApplicationExceptions e) {
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.determineFormKey();
return fk;
}
Aggregations