use of org.jaffa.exceptions.FrameworkException 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;
}
use of org.jaffa.exceptions.FrameworkException in project jaffa-framework by jaffa-projects.
the class ExceptionHelper method throwAF.
/**
* This method will loop through the input exception and its cause, looking for an instance of ApplicationException or ApplicationExceptions or FrameworkException.
* If ApplicationException is found, it'll be thrown wrapped inside a new ApplicationExceptions instance.
* If ApplicationExceptions is found, it'll be thrown as is.
* If FrameworkException is found, it'll be thrown as is.
* Else the input exception will be returned.
* @param exception The input.
* @throws ApplicationExceptions if found in the cause stack of the input exception.
* @throws FrameworkException if found in the cause stack of the input exception.
* @return the input exception if neither ApplicationException nor ApplicationExceptions nor FrameworkException are found in the cause stack of the input exception.
*/
public static Throwable throwAF(Throwable exception) throws ApplicationExceptions, FrameworkException {
ApplicationExceptions appExps = extractApplicationExceptions(exception);
if (appExps != null)
throw appExps;
FrameworkException fe = extractFrameworkException(exception);
if (fe != null)
throw fe;
return exception;
}
use of org.jaffa.exceptions.FrameworkException in project jaffa-framework by jaffa-projects.
the class LabelHelper method setLabel.
public static void setLabel(String token, String value) throws FrameworkException {
Map map = new HashMap();
map.put(OVERRIDE, value);
Map labels = new HashMap();
labels.put(token, map);
try {
performSave(labels);
} catch (FrameworkException e) {
// do nothing
throw e;
}
}
use of org.jaffa.exceptions.FrameworkException in project jaffa-framework by jaffa-projects.
the class RulesEngine method invokeRules.
/**
* This will invoke all the rules for a field.
*/
private static void invokeRules(Object fieldValue, UOW uow, boolean doOnlyMandatory, String labelToken, FieldMetaData fieldMetaData) throws ValidationException, FrameworkException {
RuleMetaData[] rules = fieldMetaData.getRules();
for (int i = 0; i < rules.length; i++) {
RuleMetaData rule = rules[i];
IFieldValidator validator = null;
try {
FieldValidatorMetaData fieldValidatorMetaData = ValidatorMetaDataService.getFieldValidatorMetaData(rule.getName());
if (!doOnlyMandatory || fieldValidatorMetaData.getMandatory()) {
// Create an instance of the validator
validator = (IFieldValidator) Class.forName(fieldValidatorMetaData.getClassName()).newInstance();
// Perform the initialization
validator.init();
// Set some values
validator.setValue(fieldValue);
validator.setLabelToken(labelToken);
validator.setUow(uow);
// Set the Parameters, if specified in the validators.xml file
if (fieldValidatorMetaData.getParameters() != null) {
for (Iterator itr = fieldValidatorMetaData.getParameters().entrySet().iterator(); itr.hasNext(); ) {
Map.Entry me = (Map.Entry) itr.next();
BeanHelper.setField(validator, (String) me.getKey(), (String) me.getValue());
}
}
// Set the Parameters provided in the rules.xml file
for (Iterator itr = rule.getParameters().entrySet().iterator(); itr.hasNext(); ) {
Map.Entry me = (Map.Entry) itr.next();
BeanHelper.setField(validator, (String) me.getKey(), (String) me.getValue());
}
// Now perform validation
if (log.isDebugEnabled())
log.debug("Invoking the rule " + rule.getName() + " for field " + fieldMetaData.getName());
validator.validate();
}
} catch (ValidationException e) {
throw e;
} catch (FrameworkException e) {
throw e;
} catch (Exception e) {
String str = "Error thrown while trying to invoke the rules for the field '" + labelToken + "', having the value '" + fieldValue + "', using the fieldMetaData - " + fieldMetaData;
log.error(str, e);
throw new RulesEngineException(RulesEngineException.RULE_INVOCATION_FAILED, new Object[] { labelToken, fieldValue }, e);
} finally {
if (validator != null) {
validator.cleanup();
validator = null;
}
}
}
}
use of org.jaffa.exceptions.FrameworkException in project jaffa-framework by jaffa-projects.
the class GenericForeignKeyFieldValidator method validate.
/**
* The RulesEngine will invoke this method to perform the field validation.
* @throws ValidationException if any validation rule fails.
* @throws FrameworkException if any framework error occurs.
*/
public void validate() throws ValidationException, FrameworkException {
if (getValue() != null) {
UOW uow = getUow();
boolean localUow = (uow == null);
try {
if (localUow)
uow = new UOW();
Criteria c = new Criteria();
c.setTable(getDomainClassName());
c.addCriteria(getFieldNameForTable(), getTableName());
c.addCriteria(getFieldNameForField(), getFieldName());
c.addCriteria(getFieldNameForValue(), getValue().toString());
Collection col = uow.query(c);
if (col.size() == 0) {
// Invalid value. Display the list of valid values in the error message
StringBuffer validValues = new StringBuffer();
c = new Criteria();
c.setTable(getDomainClassName());
c.addCriteria(getFieldNameForTable(), getTableName());
c.addCriteria(getFieldNameForField(), getFieldName());
c.addOrderBy(getFieldNameForValue(), Criteria.ORDER_BY_ASC);
for (Iterator i = uow.query(c).iterator(); i.hasNext(); ) {
try {
Object value = BeanHelper.getField(i.next(), getFieldNameForValue());
if (validValues.length() > 0)
validValues.append(',');
validValues.append(value);
} catch (Exception e) {
// do nothing
}
}
String str = "Generic ForeignKey validation failed for the value '" + getValue() + "' against the table/field - " + getTableName() + '/' + getFieldName() + ". Valid values are " + validValues.toString();
log.error(str);
throw new InvalidGenericForeignKeyException(getLabelToken(), new Object[] { getTableName(), getFieldName(), validValues.toString() });
}
} finally {
if (localUow && uow != null)
uow.rollback();
}
}
}
Aggregations