From 266040fb89a82537b788a9d38b5a9c295c3a42d3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 6 May 2016 13:06:52 +0200 Subject: [PATCH] Introduced createUserLogin() (safe to cherry-pick) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../AddressbookUserLoginWebSessionBean.java | 2 +- .../user/AddressbookUserWebSessionBean.java | 27 +++++++++++++++++++ .../AddressbookUserWebSessionController.java | 7 +++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java index ae742ceb..38b4ee8e 100644 --- a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java @@ -113,7 +113,7 @@ public class AddressbookUserLoginWebSessionBean implements AddressbookUserLoginW @Override public String doLogin () { // Get user instance - User user = this.userController.createUserInstance(); + User user = this.userController.createUserLogin(); // Create login container LoginContainer container = new UserLoginContainer(user, this.userController.getUserPassword()); diff --git a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java index 93a52e5f..f20cb812 100644 --- a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java @@ -364,6 +364,33 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC return localUser; } + @Override + public User createUserLogin () { + // Trace message + //* NOISY-DEBUG */ System.out.println(MessageFormat.format("{0}.createUserLogin: CALLED!", this.getClass().getSimpleName())); + + // Is all data set? + if (this.getUserName() == null) { + // Throw NPE + throw new NullPointerException("recruiterName is null"); //NOI18N + } else if (this.getUserName().isEmpty()) { + // Is empty + throw new IllegalStateException("recruiterName is empty."); //NOI18N + } + + // Create new recruiter instance + User recruiter = new LoginUser(); + + // Update all data ... + recruiter.setUserName(this.getUserName()); + + // Trace message + //* NOISY-DEBUG */ System.out.println(MessageFormat.format("{0}.createUserLogin: recruiter={1} - EXIT!", this.getClass().getSimpleName(), recruiter)); + + // Return the new instance + return recruiter; + } + @Override public String doChangePersonalData () { // This method shall only be called if the user is logged-in diff --git a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionController.java b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionController.java index 7ae377a3..edac6cce 100644 --- a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionController.java +++ b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionController.java @@ -149,6 +149,13 @@ public interface AddressbookUserWebSessionController extends Serializable { */ User createUserInstance (); + /** + * Creates a user instance for login phase + *

+ * @return User instance + */ + User createUserLogin (); + /** * Getter for user id *

-- 2.39.5