From b8a87cab3b27990a8a53db2feccffcfcb4dd3cd5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 1 Feb 2020 05:31:24 +0100 Subject: [PATCH] Don't cherry-pick: - cleaned up some parts, that have strangely not being cherry-picked MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../BaseAddressbookEnterpriseBean.java | 38 +--------------- .../addressbook/AddressbookSessionBean.java | 4 +- ...dressbookAdminHeadquarterSessionBean.java} | 0 ...=> AddressbookHeadquarterSessionBean.java} | 0 .../user/AddressbookAdminUserSessionBean.java | 17 +++---- .../AddressbookUserLoginSessionBean.java | 17 ++----- ...ddressbookUserRegistrationSessionBean.java | 44 ++----------------- 7 files changed, 15 insertions(+), 105 deletions(-) rename src/java/org/mxchange/jcontactsbusiness/model/headquarter/{AddressbookAdminHeadquartersSessionBean.java => AddressbookAdminHeadquarterSessionBean.java} (100%) rename src/java/org/mxchange/jcontactsbusiness/model/headquarter/{AddressbookHeadquartersSessionBean.java => AddressbookHeadquarterSessionBean.java} (100%) diff --git a/src/java/org/mxchange/addressbook/enterprise/BaseAddressbookEnterpriseBean.java b/src/java/org/mxchange/addressbook/enterprise/BaseAddressbookEnterpriseBean.java index 73f8fe7..931a436 100644 --- a/src/java/org/mxchange/addressbook/enterprise/BaseAddressbookEnterpriseBean.java +++ b/src/java/org/mxchange/addressbook/enterprise/BaseAddressbookEnterpriseBean.java @@ -35,7 +35,6 @@ import org.mxchange.jcontactsbusiness.model.department.Department; import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition; -import org.mxchange.jcontactsbusiness.model.jobposition.JobPosition; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; import org.mxchange.jcoreee.bean.ejb.BaseEnterpriseBean; import org.mxchange.jcountry.model.data.Country; @@ -300,7 +299,7 @@ public abstract class BaseAddressbookEnterpriseBean extends BaseEnterpriseBean { } /** - * Get back a managed instance from given jobPosition + * Get back a managed instance from given job position *

* @param jobPosition Unmanaged/detached job position instance *

@@ -371,41 +370,6 @@ public abstract class BaseAddressbookEnterpriseBean extends BaseEnterpriseBean { return managedHeadquarter; } - /** - * Get back a managed instance from given job position - *

- * @param jobPosition Unmanaged/detached job position instance - *

- * @return Managed job position instance - */ - protected JobPosition createManaged (final JobPosition jobPosition) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: jobPosition={1} - CALLED!", this.getClass().getSimpleName(), jobPosition)); //NOI18N - - // user should not be null - if (null == jobPosition) { - // Abort here - throw new NullPointerException("jobPosition is null"); //NOI18N - } else if (jobPosition.getJobPositionId() == null) { - // Id is set - throw new NullPointerException("jobPosition.jobPositionId is null"); //NOI18N - } else if (jobPosition.getJobPositionId() < 1) { - // Id is set - throw new IllegalArgumentException(MessageFormat.format("jobPosition.jobPositionId={0} is invalid", jobPosition.getJobPositionId())); //NOI18N - } - - // Try to find it (should be there) - final JobPosition managedJobPosition = this.getEntityManager().find(jobPosition.getClass(), jobPosition.getJobPositionId()); - - // Should be there - assert (managedJobPosition instanceof JobPosition) : "managedJobPosition is null"; //NOI18N - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedJobPosition={1} - EXIT!", this.getClass().getSimpleName(), managedJobPosition)); //NOI18N - - // Return it - return managedJobPosition; - } /** * Get back a managed instance from given mobile provider diff --git a/src/java/org/mxchange/jaddressbook/model/addressbook/AddressbookSessionBean.java b/src/java/org/mxchange/jaddressbook/model/addressbook/AddressbookSessionBean.java index e8975cc..b17c12f 100644 --- a/src/java/org/mxchange/jaddressbook/model/addressbook/AddressbookSessionBean.java +++ b/src/java/org/mxchange/jaddressbook/model/addressbook/AddressbookSessionBean.java @@ -17,7 +17,7 @@ package org.mxchange.jaddressbook.model.addressbook; import java.text.MessageFormat; -import java.util.GregorianCalendar; +import java.util.Date; import java.util.List; import javax.ejb.Stateless; import javax.persistence.NoResultException; @@ -101,7 +101,7 @@ public class AddressbookSessionBean extends BaseAddressbookEnterpriseBean implem } // Add timestamp of creation - addressbook.setAddressbookCreated(new GregorianCalendar()); + addressbook.setAddressbookCreated(new Date()); // Persist it now this.getEntityManager().persist(addressbook); diff --git a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquartersSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquarterSessionBean.java similarity index 100% rename from src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquartersSessionBean.java rename to src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquarterSessionBean.java diff --git a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquartersSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquarterSessionBean.java similarity index 100% rename from src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquartersSessionBean.java rename to src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquarterSessionBean.java diff --git a/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java index cbf7dbd..2ddc6f3 100644 --- a/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java @@ -20,8 +20,8 @@ import java.text.MessageFormat; import java.util.Date; import javax.ejb.EJB; import javax.ejb.Stateless; -import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; import org.mxchange.jcontacts.model.contact.Contact; +import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException; import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException; import org.mxchange.jusercore.exceptions.UserNotFoundException; @@ -29,7 +29,6 @@ import org.mxchange.jusercore.exceptions.UserStatusConfirmedException; import org.mxchange.jusercore.exceptions.UserStatusLockedException; import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException; import org.mxchange.jusercore.model.user.status.UserAccountStatus; -import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote; /** * An administrative user EJB @@ -44,16 +43,10 @@ public class AddressbookAdminUserSessionBean extends BaseAddressbookEnterpriseBe */ private static final long serialVersionUID = 542_145_347_916L; - /** - * Registration EJB - */ - @EJB - private UserRegistrationSessionBeanRemote registerBean; - /** * Regular user bean */ - @EJB + @EJB (lookup = "java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote") private UserSessionBeanRemote userBean; /** @@ -73,16 +66,16 @@ public class AddressbookAdminUserSessionBean extends BaseAddressbookEnterpriseBe if (null == user) { // Abort here throw new NullPointerException("user is null"); //NOI18N - } else if (user.getUserId() instanceof Long) { + } else if (user.getUserId() != null) { // Not allowed here throw new IllegalStateException(MessageFormat.format("user.userId must be null, is: {0}", user.getUserId())); //NOI18N } // Check if user is registered - if (this.registerBean.isUserNameRegistered(user)) { + if (this.userBean.isUserNameRegistered(user)) { // Abort here throw new UserNameAlreadyRegisteredException(user); - } else if (this.registerBean.isEmailAddressRegistered(user)) { + } else if (this.userBean.isEmailAddressRegistered(user)) { // Abort here throw new EmailAddressAlreadyRegisteredException(user); } diff --git a/src/java/org/mxchange/juserlogincore/model/user/login/AddressbookUserLoginSessionBean.java b/src/java/org/mxchange/juserlogincore/model/user/login/AddressbookUserLoginSessionBean.java index 4c239d5..3d0fcf1 100644 --- a/src/java/org/mxchange/juserlogincore/model/user/login/AddressbookUserLoginSessionBean.java +++ b/src/java/org/mxchange/juserlogincore/model/user/login/AddressbookUserLoginSessionBean.java @@ -29,14 +29,13 @@ import org.mxchange.jusercore.model.user.status.UserAccountStatus; import org.mxchange.juserlogincore.container.login.LoginContainer; import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException; import org.mxchange.juserlogincore.login.UserLoginUtils; -import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote; /** * A session EJB for user logins *

* @author Roland Häder */ -@Stateless (name = "userLogin", description = "A bean handling the user login for Addressbook project") +@Stateless (name = "userLogin", description = "A bean handling the application-specific user login") public class AddressbookUserLoginSessionBean extends BaseAddressbookEnterpriseBean implements UserLoginSessionBeanRemote { /** @@ -44,16 +43,10 @@ public class AddressbookUserLoginSessionBean extends BaseAddressbookEnterpriseBe */ private static final long serialVersionUID = 21_785_978_127_581_965L; - /** - * Registration EJB - */ - @EJB - private UserRegistrationSessionBeanRemote registerBean; - /** * User EJB */ - @EJB + @EJB (lookup = "java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote") private UserSessionBeanRemote userBean; /** @@ -69,10 +62,6 @@ public class AddressbookUserLoginSessionBean extends BaseAddressbookEnterpriseBe // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.loginUser: container={1} - CALLED!", this.getClass().getSimpleName(), container)); //NOI18N - // Check some beans - assert (this.userBean instanceof UserSessionBeanRemote) : "this.userBean is not set"; //NOI18N - assert (this.registerBean instanceof UserRegistrationSessionBeanRemote) : "this.registerBean is not set"; //NOI18N - // user should not be null if (null == container) { // Abort here @@ -89,7 +78,7 @@ public class AddressbookUserLoginSessionBean extends BaseAddressbookEnterpriseBe } // Is the account there? - if (!this.registerBean.isUserNameRegistered(container.getUser())) { + if (!this.userBean.isUserNameRegistered(container.getUser())) { // Not registered throw new UserNotFoundException(container.getUser()); } diff --git a/src/java/org/mxchange/juserlogincore/model/user/register/AddressbookUserRegistrationSessionBean.java b/src/java/org/mxchange/juserlogincore/model/user/register/AddressbookUserRegistrationSessionBean.java index e0a01aa..805a17b 100644 --- a/src/java/org/mxchange/juserlogincore/model/user/register/AddressbookUserRegistrationSessionBean.java +++ b/src/java/org/mxchange/juserlogincore/model/user/register/AddressbookUserRegistrationSessionBean.java @@ -48,13 +48,13 @@ public class AddressbookUserRegistrationSessionBean extends BaseAddressbookEnter /** * Administrative user bean */ - @EJB + @EJB (lookup = "java:global/addressbook-ejb/adminUser!org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote") private AdminUserSessionBeanRemote adminUserBean; /** * Regular user EJB */ - @EJB + @EJB (lookup = "java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote") private UserSessionBeanRemote userBean; /** @@ -111,42 +111,6 @@ public class AddressbookUserRegistrationSessionBean extends BaseAddressbookEnter return confirmationKey; } - @Override - public boolean isEmailAddressRegistered (final User user) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N - - // Check bean - assert (this.userBean instanceof UserSessionBeanRemote) : "this.userBean is not set"; //NOI18N - - // user should not be null - if (null == user) { - // Abort here - throw new NullPointerException("user is null"); //NOI18N - } - - // Call other bean - return this.userBean.isEmailAddressRegistered(user); - } - - @Override - public boolean isUserNameRegistered (final User user) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isUserNameRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N - - // Check bean - assert (this.userBean instanceof UserSessionBeanRemote) : "this.userBean is not set"; //NOI18N - - // user should not be null - if (null == user) { - // Abort here - throw new NullPointerException("user is null"); //NOI18N - } - - // Call other bean - return this.userBean.isUserNameRegistered(user); - } - @Override public User registerUser (final User user, final String baseUrl, final String randomPassword) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException { // Trace message @@ -168,10 +132,10 @@ public class AddressbookUserRegistrationSessionBean extends BaseAddressbookEnter } // Check if user is registered - if (this.isUserNameRegistered(user)) { + if (this.userBean.isUserNameRegistered(user)) { // Abort here throw new UserNameAlreadyRegisteredException(user); - } else if (this.isEmailAddressRegistered(user)) { + } else if (this.userBean.isEmailAddressRegistered(user)) { // Abort here throw new EmailAddressAlreadyRegisteredException(user); } -- 2.39.5