From: Roland Häder Date: Thu, 11 Aug 2016 11:56:46 +0000 (+0200) Subject: Continued with lock/unlock user: (cherry-pick) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1ac0e3ac89a770b726a5942ad5cb9ec9011de852;p=jjobs-war.git Continued with lock/unlock user: (cherry-pick) - added event observer for locking/unlocking users Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java index add5d092..b38a4236 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java @@ -43,7 +43,9 @@ import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent; 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.locked.AdminLockedUserEvent; import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent; +import org.mxchange.jusercore.events.user.unlocked.AdminUnlockedUserEvent; import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent; import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent; import org.mxchange.jusercore.events.user.update.UserUpdatedPersonalDataEvent; @@ -207,6 +209,48 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterAdminAddedUserEvent: EXIT!"); //NOI18N } + @Override + public void afterAdminLockedUserEvent (@Observes final AdminLockedUserEvent event) { + // event should not be null + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getLockedUser() == null) { + // Throw NPE again + throw new NullPointerException("event.lockedUser is null"); //NOI18N + } else if (event.getLockedUser().getUserId() == null) { + // userId is null + throw new NullPointerException("event.lockedUser.userId is null"); //NOI18N + } else if (event.getLockedUser().getUserId() < 1) { + // Not avalid id + 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()); + } + + @Override + public void afterAdminUnlockedUserEvent (@Observes final AdminUnlockedUserEvent event) { + // event should not be null + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getUnlockedUser() == null) { + // Throw NPE again + throw new NullPointerException("event.unlockedUser is null"); //NOI18N + } else if (event.getUnlockedUser().getUserId() == null) { + // userId is null + throw new NullPointerException("event.unlockedUser.userId is null"); //NOI18N + } else if (event.getUnlockedUser().getUserId() < 1) { + // Not avalid id + 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()); + } + @Override public void afterAdminUpdatedUserDataEvent (@Observes final AdminUpdatedUserDataEvent event) { // Trace message diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java index 418a251b..13c57204 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java @@ -23,7 +23,10 @@ import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent; 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; import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent; import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent; import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException; @@ -50,6 +53,27 @@ public interface JobsUserWebSessionController extends Serializable { */ void afterAdminAddedUserEvent (final AdminAddedUserEvent event); + /** + * Event observer for linked users with existing contact data + *

+ * @param event Event being fired + */ + void afterAdminLinkedUserEvent (final AdminLinkedUserEvent event); + + /** + * Event observer for locked users + *

+ * @param event Event being fired + */ + void afterAdminLockedUserEvent (final AdminLockedUserEvent event); + + /** + * Event observer for unlocked users + *

+ * @param event Event being fired + */ + void afterAdminUnlockedUserEvent (final AdminUnlockedUserEvent event); + /** * Event observer for updated user data by administrator *