From: Roland Häder Date: Thu, 22 Sep 2022 17:20:23 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2f80b11692d131157c28db1e01dd5115669f3f6f;p=addressbook-ejb.git Please cherry-pick: - registerBean is no longer used here (old, removed code) - baseUrl should never be NULL or empty - user.userContact must be valid Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java index c613b19..85e5dc5 100644 --- a/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java @@ -69,6 +69,12 @@ public class AddressbookAdminUserSessionBean extends BaseAddressbookEnterpriseBe } else if (user.getUserId() != null) { // Not allowed here throw new IllegalStateException(MessageFormat.format("user.userId must be null, is: {0}", user.getUserId())); //NOI18N + } else if (null == user.getUserContact()) { + // Abort here + throw new NullPointerException("user.contact is null"); //NOI18N + } else if (user.getUserContact().getContactId() != null) { + // Not allowed here + throw new IllegalStateException(MessageFormat.format("user.userContact.contactId must be null, is: {0}", user.getUserId())); //NOI18N } // Check if user is registered diff --git a/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java index 4eed341..ea279c9 100644 --- a/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java @@ -20,7 +20,6 @@ import java.text.MessageFormat; import java.util.Date; import java.util.List; import java.util.Objects; -import javax.ejb.EJB; import javax.ejb.EJBException; import javax.ejb.Stateless; import javax.persistence.Query; @@ -40,7 +39,6 @@ import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException; import org.mxchange.jusercore.model.user.password_history.PasswordHistory; import org.mxchange.jusercore.model.user.password_history.UserPasswordHistory; import org.mxchange.jusercore.model.user.status.UserAccountStatus; -import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote; /** * A user EJB @@ -55,12 +53,6 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im */ private static final long serialVersionUID = 542_145_347_916L; - /** - * Registration EJB - */ - @EJB (lookup = "java:global/addressbook-ejb/userRegistration!org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote") - private UserRegistrationSessionBeanRemote registerBean; - /** * Default constructor */ @@ -93,6 +85,12 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im } else if (user.getUserConfirmKey() == null) { // Throw NPE throw new NullPointerException("user.userConfirmKey is null"); //NOI18N + } else if (null == baseUrl) { + // Throw NPE again + throw new NullPointerException("baseUrl is null"); //NOI18N + } else if (baseUrl.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("baseUrl is empty"); //NOI18N } // Update user account @@ -360,7 +358,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im managedUser.setUserUpdated(new Date()); // Create history entry - PasswordHistory entry = new UserPasswordHistory(user.getUserEncryptedPassword(), managedUser); + final PasswordHistory entry = new UserPasswordHistory(user.getUserEncryptedPassword(), managedUser); // Set created timestamp entry.setUserPasswordHistoryCreated(new Date());