From 1ac0e3ac89a770b726a5942ad5cb9ec9011de852 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 11 Aug 2016 13:56:46 +0200 Subject: [PATCH] Continued with lock/unlock user: (cherry-pick) - added event observer for locking/unlocking users MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../beans/user/JobsUserWebSessionBean.java | 44 +++++++++++++++++++ .../user/JobsUserWebSessionController.java | 24 ++++++++++ 2 files changed, 68 insertions(+) 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 *

-- 2.39.5