public void validate(final ServiceActionContext inActionContext) throws ValidationException
{
HashMap<String, Serializable> personData = (HashMap<String, Serializable>) inActionContext.getParams();
ValidationHelper vHelper = new ValidationHelper();
ValidationException ve = new ValidationException();
String title = (String) vHelper.getAndCheckStringFieldExist(personData, PersonModelView.TITILE_KEY, true, ve);
vHelper.stringMeetsRequirments(PersonModelView.TITILE_KEY, title, ve, "Title is required.",
Person.MAX_TITLE_LENGTH, Person.TITLE_MESSAGE, null, null);
String perferredName = (String) vHelper.getAndCheckStringFieldExist(personData,
PersonModelView.PREFERREDNAME_KEY, true, ve);
vHelper.stringMeetsRequirments(PersonModelView.PREFERREDNAME_KEY, perferredName, ve, PREFERREDNAME_MESSAGE,
+DEFAULT_MAX_STRING_LENGTH, PREFERREDNAME_MESSAGE, "^[a-zA-Z\\'\\`\\ \\-]+$",
"Display Name has invalid characters.");
String description = (String) vHelper.getAndCheckStringFieldExist(personData, PersonModelView.DESCRIPTION_KEY,
true, ve);
vHelper.stringMeetsRequirments(PersonModelView.DESCRIPTION_KEY, description, ve, null,
Person.MAX_JOB_DESCRIPTION_LENGTH, Person.JOB_DESCRIPTION_MESSAGE, null, null);
String workNumber = (String) vHelper.getAndCheckStringFieldExist(personData, PersonModelView.WORKPHONE_KEY,
true, ve);
vHelper.stringMeetsRequirments(PersonModelView.WORKPHONE_KEY, workNumber, ve, null,
Person.MAX_PHONE_NUMBER_LENGTH, Person.PHONE_NUMBER_MESSAGE, null, null);
// TODO: Commented out to fix person update for 1.5, but future of phone numbers is uncertain right now as spec
// shows us
// collecting a number, but not displaying it,
// Also, prod db shows more people have entered fax numbers than either of the other two numbers (which is
// weird)
// so we may want to wait before dropping all that data.
// will submit to Lisa for clarification before deleteing this fuctionality all the way through the entity/db,
// losing
// a lot of data.
// String cellNumber = (String) vHelper.getAndCheckStringFieldExist(personData, PersonModelView.CELLPHONE_KEY,
// true, ve);
// vHelper.stringMeetsRequirments(PersonModelView.CELLPHONE_KEY, cellNumber, ve, null,
// Person.MAX_PHONE_NUMBER_LENGTH, Person.PHONE_NUMBER_MESSAGE, null, null);
//
// String faxNumber = (String) vHelper.getAndCheckStringFieldExist(personData, PersonModelView.FAX_KEY, true,
// ve);
// vHelper.stringMeetsRequirments(PersonModelView.FAX_KEY, faxNumber, ve, null, Person.MAX_PHONE_NUMBER_LENGTH,
// Person.FAX_NUMBER_MESSAGE, null, null);
String email = (String) vHelper.getAndCheckStringFieldExist(personData, PersonModelView.EMAIL_KEY, true, ve);
if (vHelper.stringMeetsRequirments(PersonModelView.EMAIL_KEY, email, ve, EMAIL_REQUIRED_MESSAGE,
DEFAULT_MAX_STRING_LENGTH, EMAIL_LENGTH_MESSAGE, null, null)
&& StringUtils.isNotBlank(email))
{
try
{
emailValidator.validate(email);
}
catch (ValidationException ex)
{
ve.addError(PersonModelView.EMAIL_KEY, ex.getMessage());
}
}
String skills = (String) vHelper.getAndCheckStringFieldExist(personData, PersonModelView.SKILLS_KEY, true, ve);
if (skills != null)
{
if (!vHelper.validBackgroundItems(skills))
{
ve.addError(PersonModelView.SKILLS_KEY, PersonModelView.SKILLS_MESSAGE);
}
}
if (!ve.getErrors().isEmpty())
{
throw ve;
}
}