]> git.mxchange.org Git - addressbook-ejb.git/commitdiff
Don't cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sat, 1 Feb 2020 04:31:24 +0000 (05:31 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 1 Feb 2020 04:31:24 +0000 (05:31 +0100)
- cleaned up some parts, that have strangely not being cherry-picked

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/addressbook/enterprise/BaseAddressbookEnterpriseBean.java
src/java/org/mxchange/jaddressbook/model/addressbook/AddressbookSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquarterSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquartersSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquarterSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquartersSessionBean.java [deleted file]
src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java
src/java/org/mxchange/juserlogincore/model/user/login/AddressbookUserLoginSessionBean.java
src/java/org/mxchange/juserlogincore/model/user/register/AddressbookUserRegistrationSessionBean.java

index 73f8fe71fd2e74f5fa91d423bc865edc3f93871e..931a43628eb3d1c597d8e43648112f9170829094 100644 (file)
@@ -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
         * <p>
         * @param jobPosition Unmanaged/detached job position instance
         * <p>
@@ -371,41 +370,6 @@ public abstract class BaseAddressbookEnterpriseBean extends BaseEnterpriseBean {
                return managedHeadquarter;
        }
 
-       /**
-        * Get back a managed instance from given job position
-        * <p>
-        * @param jobPosition Unmanaged/detached job position instance
-        * <p>
-        * @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
index e8975ccf9166e575ca91e7fc063e5e2f395727a4..b17c12f5b7cdbf457fef07099cac5b28b8af2057 100644 (file)
@@ -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 (file)
index 0000000..88261ac
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@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<OpeningTime> 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.
+        * <p>
+        * @param headquarter Headquarter office being checked
+        * <p>
+        * @return Whether it has been found
+        */
+       private boolean isHeadquarterFound (final Headquarter headquarter) {
+               // Get whole list
+               final List<Headquarter> 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 (file)
index 88261ac..0000000
+++ /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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@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<OpeningTime> 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.
-        * <p>
-        * @param headquarter Headquarter office being checked
-        * <p>
-        * @return Whether it has been found
-        */
-       private boolean isHeadquarterFound (final Headquarter headquarter) {
-               // Get whole list
-               final List<Headquarter> 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 (file)
index 0000000..a309bd0
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@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<Headquarter> 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<Headquarter> 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 (file)
index a309bd0..0000000
+++ /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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@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<Headquarter> 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<Headquarter> 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;
-       }
-
-}
index cbf7dbd1cfc9a941063a058a2d7315a4d8eeecd5..2ddc6f309d68590b272985a88f9f9605445f7f2a 100644 (file)
@@ -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);
                }
index 4c239d5dd9be0a4784e3a15fbf96717c83193bea..3d0fcf11b4ba056f4d8002def883d0ac49c2abbe 100644 (file)
@@ -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
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@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());
                }
index e0a01aae1496fbfe31fc6d7c30e36e1609db65c7..805a17b8f6b77211fdfda4054c79fdad0f90083a 100644 (file)
@@ -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);
                }