public UserAccountRequestResponseWrapper put(Context context, Request request, Response response, Object payload)
throws ResourceException
{
UserAccountRequestResponseWrapper result = new UserAccountRequestResponseWrapper();
UserAccount dto = ((UserAccountRequestResponseWrapper) payload).getData();
try {
User user = getSecuritySystem().getUser(getUserId(request));
user.setFirstName(dto.getFirstName());
user.setLastName(dto.getLastName());
user.setEmailAddress(dto.getEmail());
userAccountManager.updateAccount(user);
result.setData(nexusToRestModel(user, request));
}
catch (InvalidConfigurationException e) {
handleInvalidConfigurationException(e);
return null;
}
catch (UserNotFoundException e) {
String msg = "User account '" + getUserId(request) + "' not found.";
getLogger().debug(msg, e);
throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, msg);
}
catch (NoSuchUserManagerException e) {
ErrorResponse errorResponse = getErrorResponse("*", e.getMessage());
throw new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Unable to update account '"
+ dto.getUserId() + "'.", errorResponse);
}
catch (AuthorizationException e) {
throw new ResourceException(Status.CLIENT_ERROR_FORBIDDEN, "Not allowed to update account '" + dto.getUserId()
+ "'.");
}
return result;
}