From: Roland Häder Date: Sat, 1 Feb 2020 04:31:24 +0000 (+0100) Subject: Don't cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b8a87cab3b27990a8a53db2feccffcfcb4dd3cd5;p=addressbook-ejb.git Don't cherry-pick: - cleaned up some parts, that have strangely not being cherry-picked Signed-off-by: Roland Häder --- 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/AddressbookAdminHeadquarterSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquarterSessionBean.java new file mode 100644 index 0000000..88261ac --- /dev/null +++ b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquarterSessionBean.java @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2017, 2018 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcontactsbusiness.model.headquarter; + +import java.text.MessageFormat; +import java.util.Date; +import java.util.List; +import javax.ejb.EJB; +import javax.ejb.Stateless; +import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterAlreadyAddedException; +import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; +import org.mxchange.jcountry.model.data.Country; +import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; +import org.mxchange.jusercore.model.user.User; + +/** + * A stateless session bean for administrative branch office purposes + *

+ * @author Roland Häder + */ +@Stateless (name = "adminHeadquarter", description = "An administrative statless bean for handling branch office data (all)") +public class AddressbookAdminHeadquarterSessionBean extends BaseAddressbookEnterpriseBean implements AdminHeadquarterSessionBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 58_467_386_571_701L; + + /** + * General branch office bean + */ + @EJB (lookup = "java:global/addressbook-ejb/headquarter!org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote") + private HeadquarterSessionBeanRemote headquarterBean; + + /** + * Default constructor + */ + public AddressbookAdminHeadquarterSessionBean () { + // Call super constructor + super(); + } + + @Override + public Headquarter addHeadquarter (final Headquarter headquarter) throws HeadquarterAlreadyAddedException { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addHeadquarter(): headquarter={1} - CALLED!", this.getClass().getSimpleName(), headquarter)); //NOI18N + + // Validate parameter + if (null == headquarter) { + // Throw NPE + throw new NullPointerException("headquarter is null"); //NOI18N + } else if (headquarter.getHeadquarterId() instanceof Long) { + // Should not happen + throw new IllegalArgumentException("headquarter.branchId should not be set."); //NOI18N + } else if (this.isHeadquarterFound(headquarter)) { + // Already added, abort here + throw new HeadquarterAlreadyAddedException(headquarter); + } + + // Add created timestamp + headquarter.setHeadquarterCreated(new Date()); + + // Is user instance set? + if (headquarter.getHeadquarterUserOwner() instanceof User) { + // Get managed instance back + final User managedUser = this.createManaged(headquarter.getHeadquarterUserOwner()); + + // Set it back in branch office + headquarter.setHeadquarterUserOwner(managedUser); + } + + // Is user instance set? + if (headquarter.getHeadquarterCountry() instanceof Country) { + // Get managed instance back + final Country managedCountry = this.createManaged(headquarter.getHeadquarterCountry()); + + // Set it back in branch office + headquarter.setHeadquarterCountry(managedCountry); + } + + // Set "created" timestamp on any number assigned + this.setAllPhoneEntriesCreated(headquarter); + + // Get opening times + final List openingTimes = headquarter.getHeadquarterOpeningTimes(); + + // Debugging: + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.addHeadquarter(): headquarter.headquarterOpeningTimes={1}", this.getClass().getSimpleName(), openingTimes)); + + // Is opening times set and not empty? + if ((openingTimes instanceof List) && (!openingTimes.isEmpty())) { + // Add created timestamp for all times + this.setAllOpeningTimesCreated(openingTimes); + } else { + // Set all to null + headquarter.setHeadquarterOpeningTimes(null); + } + + // Persist it + this.getEntityManager().persist(headquarter); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addHeadquarter(): headquarter.branchId={1} - EXIT!", this.getClass().getSimpleName(), headquarter.getHeadquarterId())); //NOI18N + + // Return updated instance + return headquarter; + } + + /** + * Checks if given branch office's address is already persisted. The whole + * (persisted) list is being loaded and each address is being matched + * against the given branch office's address. + *

+ * @param headquarter Headquarter office being checked + *

+ * @return Whether it has been found + */ + private boolean isHeadquarterFound (final Headquarter headquarter) { + // Get whole list + final List headquarters = this.headquarterBean.allHeadquarters(); + + // Default is not found + boolean isFound = false; + + // Check all single addresses + for (final Headquarter hq : headquarters) { + // Is the same address found? + if (Headquarters.isSameAddress(hq, headquarter)) { + // Found one + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + +} diff --git a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquartersSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquartersSessionBean.java deleted file mode 100644 index 88261ac..0000000 --- a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquartersSessionBean.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2017, 2018 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jcontactsbusiness.model.headquarter; - -import java.text.MessageFormat; -import java.util.Date; -import java.util.List; -import javax.ejb.EJB; -import javax.ejb.Stateless; -import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterAlreadyAddedException; -import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; -import org.mxchange.jcountry.model.data.Country; -import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; -import org.mxchange.jusercore.model.user.User; - -/** - * A stateless session bean for administrative branch office purposes - *

- * @author Roland Häder - */ -@Stateless (name = "adminHeadquarter", description = "An administrative statless bean for handling branch office data (all)") -public class AddressbookAdminHeadquarterSessionBean extends BaseAddressbookEnterpriseBean implements AdminHeadquarterSessionBeanRemote { - - /** - * Serial number - */ - private static final long serialVersionUID = 58_467_386_571_701L; - - /** - * General branch office bean - */ - @EJB (lookup = "java:global/addressbook-ejb/headquarter!org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote") - private HeadquarterSessionBeanRemote headquarterBean; - - /** - * Default constructor - */ - public AddressbookAdminHeadquarterSessionBean () { - // Call super constructor - super(); - } - - @Override - public Headquarter addHeadquarter (final Headquarter headquarter) throws HeadquarterAlreadyAddedException { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addHeadquarter(): headquarter={1} - CALLED!", this.getClass().getSimpleName(), headquarter)); //NOI18N - - // Validate parameter - if (null == headquarter) { - // Throw NPE - throw new NullPointerException("headquarter is null"); //NOI18N - } else if (headquarter.getHeadquarterId() instanceof Long) { - // Should not happen - throw new IllegalArgumentException("headquarter.branchId should not be set."); //NOI18N - } else if (this.isHeadquarterFound(headquarter)) { - // Already added, abort here - throw new HeadquarterAlreadyAddedException(headquarter); - } - - // Add created timestamp - headquarter.setHeadquarterCreated(new Date()); - - // Is user instance set? - if (headquarter.getHeadquarterUserOwner() instanceof User) { - // Get managed instance back - final User managedUser = this.createManaged(headquarter.getHeadquarterUserOwner()); - - // Set it back in branch office - headquarter.setHeadquarterUserOwner(managedUser); - } - - // Is user instance set? - if (headquarter.getHeadquarterCountry() instanceof Country) { - // Get managed instance back - final Country managedCountry = this.createManaged(headquarter.getHeadquarterCountry()); - - // Set it back in branch office - headquarter.setHeadquarterCountry(managedCountry); - } - - // Set "created" timestamp on any number assigned - this.setAllPhoneEntriesCreated(headquarter); - - // Get opening times - final List openingTimes = headquarter.getHeadquarterOpeningTimes(); - - // Debugging: - this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.addHeadquarter(): headquarter.headquarterOpeningTimes={1}", this.getClass().getSimpleName(), openingTimes)); - - // Is opening times set and not empty? - if ((openingTimes instanceof List) && (!openingTimes.isEmpty())) { - // Add created timestamp for all times - this.setAllOpeningTimesCreated(openingTimes); - } else { - // Set all to null - headquarter.setHeadquarterOpeningTimes(null); - } - - // Persist it - this.getEntityManager().persist(headquarter); - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addHeadquarter(): headquarter.branchId={1} - EXIT!", this.getClass().getSimpleName(), headquarter.getHeadquarterId())); //NOI18N - - // Return updated instance - return headquarter; - } - - /** - * Checks if given branch office's address is already persisted. The whole - * (persisted) list is being loaded and each address is being matched - * against the given branch office's address. - *

- * @param headquarter Headquarter office being checked - *

- * @return Whether it has been found - */ - private boolean isHeadquarterFound (final Headquarter headquarter) { - // Get whole list - final List headquarters = this.headquarterBean.allHeadquarters(); - - // Default is not found - boolean isFound = false; - - // Check all single addresses - for (final Headquarter hq : headquarters) { - // Is the same address found? - if (Headquarters.isSameAddress(hq, headquarter)) { - // Found one - isFound = true; - break; - } - } - - // Return flag - return isFound; - } - -} diff --git a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquarterSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquarterSessionBean.java new file mode 100644 index 0000000..a309bd0 --- /dev/null +++ b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquarterSessionBean.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2017, 2018 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcontactsbusiness.model.headquarter; + +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; +import java.text.MessageFormat; +import java.util.List; +import javax.ejb.Stateless; +import javax.persistence.Query; +import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; +import org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote; + +/** + * A stateless session bean for general headquarter purposes + *

+ * @author Roland Häder + */ +@Stateless (name = "headquarter", description = "A general statless bean for handling headquarter data (all)") +public class AddressbookHeadquarterSessionBean extends BaseAddressbookEnterpriseBean implements HeadquarterSessionBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 58_467_386_571_701L; + + @Override + @SuppressWarnings ("unchecked") + public List allHeadquarters () { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allHeadquarters: CALLED!", this.getClass().getSimpleName())); //NOI18N + + // Get query + final Query query = this.getEntityManager().createNamedQuery("AllHeadquarters"); //NOI18N + + // Get list from it + final List list = query.getResultList(); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allHeadquarters: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N + + // Return it + return list; + } + +} diff --git a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquartersSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquartersSessionBean.java deleted file mode 100644 index a309bd0..0000000 --- a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquartersSessionBean.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2017, 2018 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jcontactsbusiness.model.headquarter; - -import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; -import java.text.MessageFormat; -import java.util.List; -import javax.ejb.Stateless; -import javax.persistence.Query; -import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; -import org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote; - -/** - * A stateless session bean for general headquarter purposes - *

- * @author Roland Häder - */ -@Stateless (name = "headquarter", description = "A general statless bean for handling headquarter data (all)") -public class AddressbookHeadquarterSessionBean extends BaseAddressbookEnterpriseBean implements HeadquarterSessionBeanRemote { - - /** - * Serial number - */ - private static final long serialVersionUID = 58_467_386_571_701L; - - @Override - @SuppressWarnings ("unchecked") - public List allHeadquarters () { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allHeadquarters: CALLED!", this.getClass().getSimpleName())); //NOI18N - - // Get query - final Query query = this.getEntityManager().createNamedQuery("AllHeadquarters"); //NOI18N - - // Get list from it - final List list = query.getResultList(); - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allHeadquarters: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N - - // Return it - return list; - } - -} 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); }