JsonMappingException, IOException {
log.debug("update profile type:" + type);
log.debug("update profile data:" + data);
try {
final SecurityOperations security = getSecurityService();
final ValidateOperations operations = new ValidateOperations(security);
final HashMap<String, Object> listError = new HashMap<String, Object>();
//filter data
data = filterValue(data);
if (type.equals(Profile.EMAIL.toString())) {
//TODO: review pattern email format validator.
log.debug("update email");
final UserAccount account = getSecurityService().getUserAccount(getUserPrincipalUsername());
if (operations.validateUserEmail(data, account)) {
security.updateAccountProfile(Profile.EMAIL, data);
setSuccesResponse();
} else {
listError.put(type, getMessage("e_005", request, null));
}
} else if(type.equals(Profile.USERNAME.toString())) {
log.debug("update username");
final UserAccount account = getSecurityService().getUserAccount(getUserPrincipalUsername());
if (operations.validateUsername(data, account)) {
security.updateAccountProfile(Profile.USERNAME, data);
setSuccesResponse(getMessage("settings_config_profile_success", request, null));
} else {
listError.put(type, getMessage("e_018", request, null));
}
} else if(type.equals(Profile.PICTURE.toString())) {
log.debug("update PICTURE");
security.updateAccountProfile(Profile.PICTURE, data);
setSuccesResponse(getMessage("settings_config_picture_success", request, null));
} else if(type.equals(Profile.WELCOME.toString())) {
log.debug("update WELCOME");
security.updateAccountProfile(Profile.WELCOME, data);
setSuccesResponse(getMessage("settings_welcome", request, null));
} else if(type.equals(Profile.PAGE_INFO.toString())) {
log.debug("update PAGE_INFO");
security.updateAccountProfile(Profile.PAGE_INFO, data);
setSuccesResponse(getMessage("settings_page_info", request, null));
} else {
setError(getMessage("e_023", request, null), response);
}
if (!listError.isEmpty()) {