From 66ca1037182ebdcc35ad87ef8b4f16984642fb42 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 11 Aug 2016 12:37:38 +0200 Subject: [PATCH] added events for locking/unlocking user accounts --- .../user/locked/AdminLockedUserEvent.java | 37 +++++++++++ .../user/locked/AdminUserLockedEvent.java | 66 +++++++++++++++++++ .../user/unlocked/AdminUnlockedUserEvent.java | 37 +++++++++++ .../user/unlocked/AdminUserUnlockedEvent.java | 66 +++++++++++++++++++ 4 files changed, 206 insertions(+) create mode 100644 src/org/mxchange/jusercore/events/user/locked/AdminLockedUserEvent.java create mode 100644 src/org/mxchange/jusercore/events/user/locked/AdminUserLockedEvent.java create mode 100644 src/org/mxchange/jusercore/events/user/unlocked/AdminUnlockedUserEvent.java create mode 100644 src/org/mxchange/jusercore/events/user/unlocked/AdminUserUnlockedEvent.java 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 index 0000000..cd3196d --- /dev/null +++ b/src/org/mxchange/jusercore/events/user/locked/AdminLockedUserEvent.java @@ -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 . + */ +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. + *

+ * @author Roland Haeder + */ +public interface AdminLockedUserEvent extends Serializable { + + /** + * Getter for locked user instance + *

+ * @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 index 0000000..a2df3f9 --- /dev/null +++ b/src/org/mxchange/jusercore/events/user/locked/AdminUserLockedEvent.java @@ -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 . + */ +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. + *

+ * @author Roland Haeder + */ +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 + *

+ * @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 index 0000000..bc0c422 --- /dev/null +++ b/src/org/mxchange/jusercore/events/user/unlocked/AdminUnlockedUserEvent.java @@ -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 . + */ +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. + *

+ * @author Roland Haeder + */ +public interface AdminUnlockedUserEvent extends Serializable { + + /** + * Getter for unlocked user instance + *

+ * @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 index 0000000..145314b --- /dev/null +++ b/src/org/mxchange/jusercore/events/user/unlocked/AdminUserUnlockedEvent.java @@ -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 . + */ +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. + *

+ * @author Roland Haeder + */ +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 + *

+ * @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; + } + +} -- 2.39.5