* @param nickname nickname to set to the user.
* @return the updated user or null when error occurs.
*/
public Data.User register(Context context, String nickname) {
final User user = context.getUser();
if(user.getNickname() != null) {
return null;
}
// FIXME you can do a better check ...
if(nickname == null || "".equals(nickname.trim())) {
return null;
}
// Check the nickname is not already used.
final List<Data.User> users =
dao.filterUsersOnNickname(context, null, FilterOperator.EQUAL, nickname);
if(users != null && !users.isEmpty()) {
logger.severe("try to register with '" + nickname +"' but already used");
}
// Update the user.
user.setNickname(nickname);
dao.save(context, user);
return user;
}