@Override
public IndexedUserDetails handleAddAccount(String type, String id,
String credentials, boolean isAnonymous) {
User currentUser = _currentUserStrategy.getCurrentUser(false);
UserIndexKey key = new UserIndexKey(type, id);
UserIndex index = _userService.getUserIndexForId(key);
boolean exists = index != null;
// New user?
if (exists) {
if (currentUser != null) {
User existingUser = index.getUser();
_userService.mergeUsers(existingUser, currentUser);
}
} else {
if (currentUser != null)
index = _userService.addUserIndexToUser(currentUser, key, credentials);