* @return
*/
protected Map<String, Object> validate(final String context, final String type, String value, final HttpServletRequest request) {
value = value == null ? "" : value;
final Map<String, Object> jsonResponse = new HashMap<String, Object>();
final ValidateOperations validateOperations = new ValidateOperations(getSecurityService());
boolean valid = false;
if ("email".equals(type)) {
if (value.isEmpty() || value.length() < ValidateOperations.MIN_EMAIL_LENGTH) {
log.debug("validate email emtpy");
jsonResponse.put("msg", getMessage("secure.email.emtpy", request, null));
} else {
valid = validateOperations.validateUserEmail(value, null);
log.debug("validate EMAIL"+valid);
if (valid) {
jsonResponse.put("msg", getMessage("secure.email.valid", request, null));
} else {
jsonResponse.put("msg", getMessage("secure.email.notvalid", request, null));
}
}
} else if("username".equals(type)) {
valid = validateOperations.validateUsername(value, null);
if(value.isEmpty() || value.length() < ValidateOperations.MIN_USERNAME_LENGTH) {
log.debug("validate username emtpy");
jsonResponse.put("msg", getMessage("secure.username.empty", request, null));
} else {
log.debug("validate username NO emtpy");