use of org.jaffa.datatypes.exceptions.MandatoryFieldException in project jaffa-framework by jaffa-projects.
the class UserRequestMaintenanceForm method passwordFieldCheck.
// .//GEN-END:_doValidateMain_2_be
// All the custom code goes here //GEN-FIRST:_custom
/**
* Perform password checks
*/
private boolean passwordFieldCheck(HttpServletRequest request) {
boolean valid = true;
String pass1 = getPassword1WM().getValue();
if (pass1 != null && pass1.length() == 0)
pass1 = null;
pass1 = Parser.parseString(pass1);
String pass2 = getPassword2WM().getValue();
if (pass2 != null && pass2.length() == 0)
pass2 = null;
pass2 = Parser.parseString(pass2);
if (pass1 == null && ((UserRequestMaintenanceComponent) getComponent()).isCreateMode()) {
raiseError(request, UserMeta.META_PASSWORD.getLabelToken(), new MandatoryFieldException(UserMeta.META_PASSWORD.getLabelToken()));
valid = false;
}
if (pass2 == null && ((UserRequestMaintenanceComponent) getComponent()).isCreateMode()) {
raiseError(request, "[label.Jaffa.User.User.VerifyPassword]", new MandatoryFieldException("[label.Jaffa.User.User.VerifyPassword]"));
valid = false;
}
if ((pass1 != null && !pass1.equals(pass2)) || (pass2 != null && !pass2.equals(pass1))) {
raiseError(request, UserMeta.META_PASSWORD.getLabelToken(), new ActionMessage("error.Jaffa.User.UserMaintenance.InvalidPassword.Different"));
valid = false;
}
return valid;
}
use of org.jaffa.datatypes.exceptions.MandatoryFieldException in project jaffa-framework by jaffa-projects.
the class UserRequestViewerComponent method display.
// .//GEN-END:_UserRequestViewerOutDto_1_be
// .//GEN-BEGIN:_display_1_be
/**
* This retrieves the details for the UserRequest.
* @throws ApplicationExceptions This will be thrown in case any invalid data has been set, or if no data has been set.
* @throws FrameworkException Indicates some system error.
* @return The FormKey for the View screen.
*/
public FormKey display() throws ApplicationExceptions, FrameworkException {
ApplicationExceptions appExps = null;
// .//GEN-BEGIN:_display_2_be
if (getRequestId() == null) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(new MandatoryFieldException(UserRequestMeta.META_REQUEST_ID.getLabelToken()));
}
if (appExps != null && appExps.size() > 0)
throw appExps;
doInquiry();
return getViewerFormKey();
}
use of org.jaffa.datatypes.exceptions.MandatoryFieldException in project jaffa-framework by jaffa-projects.
the class FormTemplateMaintenanceForm method doValidate0.
// .//GEN-END:_doValidate_2_be
// .//GEN-BEGIN:_doValidateMain_1_be
/**
* 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 doValidate0(HttpServletRequest request) {
boolean valid = true;
try {
String htmlString = getFormIdWM().getValue();
if (htmlString != null && htmlString.length() == 0)
htmlString = null;
java.lang.Long value = (java.lang.Long) FieldValidator.validateData(htmlString, (IntegerFieldMetaData) FormTemplateMeta.META_FORM_ID, true);
if (value == null)
throw new MandatoryFieldException(((IntegerFieldMetaData) FormTemplateMeta.META_FORM_ID).getLabelToken());
setFormId(value);
} catch (ValidationException e) {
valid = false;
raiseError(request, ((IntegerFieldMetaData) FormTemplateMeta.META_FORM_ID).getLabelToken(), e);
}
try {
String htmlString = getTemplateDataWM().getValue();
if (htmlString != null && htmlString.length() == 0)
htmlString = null;
byte[] value = (byte[]) FieldValidator.validateData(htmlString, (RawFieldMetaData) FormTemplateMeta.META_TEMPLATE_DATA, true);
setTemplateData(value);
} catch (ValidationException e) {
valid = false;
raiseError(request, ((RawFieldMetaData) FormTemplateMeta.META_TEMPLATE_DATA).getLabelToken(), e);
}
try {
String htmlString = getLayoutDataWM().getValue();
if (htmlString != null && htmlString.length() == 0)
htmlString = null;
byte[] value = (byte[]) FieldValidator.validateData(htmlString, (RawFieldMetaData) FormTemplateMeta.META_LAYOUT_DATA, true);
setLayoutData(value);
} catch (ValidationException e) {
valid = false;
raiseError(request, ((RawFieldMetaData) FormTemplateMeta.META_LAYOUT_DATA).getLabelToken(), e);
}
// .//GEN-BEGIN:_doValidateMain_2_be
return valid;
}
use of org.jaffa.datatypes.exceptions.MandatoryFieldException in project jaffa-framework by jaffa-projects.
the class OutputCommandViewerComponent method display.
// .//GEN-END:_OutputCommandViewerOutDto_1_be
// .//GEN-BEGIN:_display_1_be
/**
* This retrieves the details for the OutputCommand.
* @throws ApplicationExceptions This will be thrown in case any invalid data has been set, or if no data has been set.
* @throws FrameworkException Indicates some system error.
* @return The FormKey for the View screen.
*/
public FormKey display() throws ApplicationExceptions, FrameworkException {
ApplicationExceptions appExps = null;
// .//GEN-BEGIN:_display_2_be
if (getOutputCommandId() == null) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(new MandatoryFieldException(OutputCommandMeta.META_OUTPUT_COMMAND_ID.getLabelToken()));
}
if (appExps != null && appExps.size() > 0)
throw appExps;
doInquiry();
return getViewerFormKey();
}
use of org.jaffa.datatypes.exceptions.MandatoryFieldException in project jaffa-framework by jaffa-projects.
the class BatchValidatorTest method testValidationException.
/**
* Test that a validation exception is returned to the caller of the validation method
*
* @throws org.jaffa.exceptions.FrameworkException
*
* @throws org.jaffa.exceptions.ApplicationException
*/
@Test(expected = ApplicationException.class)
public void testValidationException() throws FrameworkException, ApplicationException {
// validator that will throw exception on validation
Validator mockValidator = mock(Validator.class);
doThrow(new MandatoryFieldException()).when(mockValidator).validate(anyObject());
// create bulk validator with a sub-validators that will throw an exception
BatchValidator validator = new BatchValidator();
validator.getValidatorSet().add(mockValidator);
// call validate
validator.validate(new Object());
}
Aggregations