import org.mxchange.jusercore.events.login.UserLoggedInEvent;
import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
+import org.mxchange.jusercore.events.user.linked.AdminLinkedUserEvent;
import org.mxchange.jusercore.events.user.locked.AdminLockedUserEvent;
import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
import org.mxchange.jusercore.events.user.unlocked.AdminUnlockedUserEvent;
throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
}
- // Add user uniquely
- this.uniqueAddUser(event.getAddedUser());
+ // Update user list
+ this.updateList(event.getAddedUser());
// Clear all data
this.clear();
// Set user id again
this.setUserId(event.getAddedUser().getUserId());
+ }
+
+ @Override
+ public void afterAdminLinkedUserEvent (@Observes final AdminLinkedUserEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getLinkedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.linkedUser is null"); //NOI18N
+ } else if (event.getLinkedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.linkedUser.userId is null"); //NOI18N
+ } else if (event.getLinkedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getLinkedUser());
+
+ // Clear all data
+ this.clear();
// Trace message
//* NOISY-DEBUG: */ System.out.println("UserWebBean:afterAdminAddedUserEvent: EXIT!"); //NOI18N
throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLockedUser(), event.getLockedUser().getUserId())); //NOI18N
}
- // Add user uniquely
- this.uniqueAddUser(event.getLockedUser());
+ // Update user list
+ this.updateList(event.getLockedUser());
}
@Override
throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUnlockedUser(), event.getUnlockedUser().getUserId())); //NOI18N
}
- // Add user uniquely
- this.uniqueAddUser(event.getUnlockedUser());
+ // Update user list
+ this.updateList(event.getUnlockedUser());
}
@Override
throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedUser(), event.getUpdatedUser().getUserId())); //NOI18N
}
- // Update list
+ // Update user list
this.updateList(event.getUpdatedUser());
// Clear all data
// Clear all data
this.clear();
- // Add user uniquely
- this.uniqueAddUser(registeredUser);
+ // Update user list
+ this.updateList(registeredUser);
// Add user name
this.addUserName(registeredUser);
throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getConfirmedUser(), event.getConfirmedUser().getUserId())); //NOI18N
}
- // Add user uniquely
- this.uniqueAddUser(event.getConfirmedUser());
+ // Update user list
+ this.updateList(event.getConfirmedUser());
}
@Override
throw new IllegalArgumentException(MessageFormat.format("event.passwordHistory.userPasswordHistoryId={0} is in valid", event.getPasswordHistory().getUserPasswordHistoryId())); //NOI18N
}
- // All fine, so update list
+ // Update user list
this.updateList(event.getPasswordHistory().getUserPasswordHistoryUser());
}
throw new IllegalArgumentException(MessageFormat.format("event.updatedUser.userId={0} is in valid", event.getUpdatedUser().getUserId())); //NOI18N
}
- // All fine, so update list
+ // Update user list
this.updateList(event.getUpdatedUser());
}
if (null == user) {
// Throw NPE
throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("user.userContact is null"); //NOI18N
} else if (user.getUserId() == null) {
// ... again NPE
throw new NullPointerException("user.userId is null"); //NOI18N
throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
}
- // Get iterator
+ // Get iterator from list
Iterator<User> iterator = this.userList.iterator();
- // Look whole list
+ // "Walk" through all entries
while (iterator.hasNext()) {
// Get next element
User next = iterator.next();
- // Is the same user id?
+ // Is user id number the same?
if (Objects.equals(user.getUserId(), next.getUserId())) {
- // Found it, so remove it
+ // Found entry, so remove it and abort
this.userList.remove(next);
break;
}
}
- // Re-add item
+ // Re-add user
this.userList.add(user);
}