]> git.mxchange.org Git - juser-login-core.git/commitdiff
added events for locking/unlocking user accounts
authorRoland Häder <roland@mxchange.org>
Thu, 11 Aug 2016 10:37:38 +0000 (12:37 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 11 Aug 2016 10:37:38 +0000 (12:37 +0200)
src/org/mxchange/jusercore/events/user/locked/AdminLockedUserEvent.java [new file with mode: 0644]
src/org/mxchange/jusercore/events/user/locked/AdminUserLockedEvent.java [new file with mode: 0644]
src/org/mxchange/jusercore/events/user/unlocked/AdminUnlockedUserEvent.java [new file with mode: 0644]
src/org/mxchange/jusercore/events/user/unlocked/AdminUserUnlockedEvent.java [new file with mode: 0644]

diff --git a/src/org/mxchange/jusercore/events/user/locked/AdminLockedUserEvent.java b/src/org/mxchange/jusercore/events/user/locked/AdminLockedUserEvent.java
new file mode 100644 (file)
index 0000000..cd3196d
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.events.user.locked;
+
+import java.io.Serializable;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An interface for events being fired when an administrator locked a user
+ * account.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface AdminLockedUserEvent extends Serializable {
+
+       /**
+        * Getter for locked user instance
+        * <p>
+        * @return locked user instance
+        */
+       User getLockedUser ();
+
+}
diff --git a/src/org/mxchange/jusercore/events/user/locked/AdminUserLockedEvent.java b/src/org/mxchange/jusercore/events/user/locked/AdminUserLockedEvent.java
new file mode 100644 (file)
index 0000000..a2df3f9
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.events.user.locked;
+
+import java.text.MessageFormat;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An event being fired when the administrator has locked a user account.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public class AdminUserLockedEvent implements AdminLockedUserEvent {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 14_785_787_174_676_290L;
+
+       /**
+        * Locked user instance
+        */
+       private final User lockedUser;
+
+       /**
+        * Constructor with linked user instance
+        * <p>
+        * @param lockedUser Locked user instance
+        */
+       public AdminUserLockedEvent (final User lockedUser) {
+               // Is the user instance valid?
+               if (null == lockedUser) {
+                       // Throw NPE
+                       throw new NullPointerException("lockedUser is null"); //NOI18N
+               } else if (lockedUser.getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("lockedUser.userId is null"); //NOI18N
+               } else if (lockedUser.getUserId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("lockedUser.userId={0} is invalid.", lockedUser.getUserId())); //NOI18N
+               }
+
+               // Set it here
+               this.lockedUser = lockedUser;
+       }
+
+       @Override
+       public User getLockedUser () {
+               return this.lockedUser;
+       }
+
+}
diff --git a/src/org/mxchange/jusercore/events/user/unlocked/AdminUnlockedUserEvent.java b/src/org/mxchange/jusercore/events/user/unlocked/AdminUnlockedUserEvent.java
new file mode 100644 (file)
index 0000000..bc0c422
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.events.user.unlocked;
+
+import java.io.Serializable;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An interface for events being fired when an administrator unlocked a user
+ * account.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface AdminUnlockedUserEvent extends Serializable {
+
+       /**
+        * Getter for unlocked user instance
+        * <p>
+        * @return Unlocked user instance
+        */
+       User getUnlockedUser ();
+
+}
diff --git a/src/org/mxchange/jusercore/events/user/unlocked/AdminUserUnlockedEvent.java b/src/org/mxchange/jusercore/events/user/unlocked/AdminUserUnlockedEvent.java
new file mode 100644 (file)
index 0000000..145314b
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.events.user.unlocked;
+
+import java.text.MessageFormat;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An event being fired when the administrator has unlocked a user account.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public class AdminUserUnlockedEvent implements AdminUnlockedUserEvent {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 14_785_787_174_676_290L;
+
+       /**
+        * Unlocked user instance
+        */
+       private final User unlockedUser;
+
+       /**
+        * Constructor with linked user instance
+        * <p>
+        * @param unlockedUser Unlocked user instance
+        */
+       public AdminUserUnlockedEvent (final User unlockedUser) {
+               // Is the user instance valid?
+               if (null == unlockedUser) {
+                       // Throw NPE
+                       throw new NullPointerException("unlockedUser is null"); //NOI18N
+               } else if (unlockedUser.getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("unlockedUser.userId is null"); //NOI18N
+               } else if (unlockedUser.getUserId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("unlockedUser.userId={0} is invalid.", unlockedUser.getUserId())); //NOI18N
+               }
+
+               // Set it here
+               this.unlockedUser = unlockedUser;
+       }
+
+       @Override
+       public User getUnlockedUser () {
+               return this.unlockedUser;
+       }
+
+}