From: Roland Haeder Date: Mon, 10 Apr 2017 20:07:48 +0000 (+0200) Subject: Continued a bit: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fa5e986297e48d7558269d7fb4df80c0793b2d14;p=addressbook-ejb.git Continued a bit: - not just cellphones, let's support any mobile phone - implemented missing business methods - tpzo fixed --- diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/AddressbookMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/AddressbookMobileProviderSingletonBean.java index 1875fe4..28b118d 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/AddressbookMobileProviderSingletonBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/AddressbookMobileProviderSingletonBean.java @@ -29,13 +29,8 @@ import org.mxchange.jcoreee.database.BaseDatabaseBean; * @author Roland Haeder */ @Startup -<<<<<<< HEAD:src/java/org/mxchange/jphone/phonenumbers/mobileprovider/AddressbookMobileProviderSingletonBean.java @Singleton (name = "mobileprovider", description = "A singleton session bean for SMS provider informations") public class AddressbookMobileProviderSingletonBean extends BaseDatabaseBean implements MobileProviderSingletonBeanRemote { -======= -@Singleton (name = "mobileProvider", description = "A singleton session bean for SMS provider informations") -public class LandingMobileProviderSingletonBean extends BaseLandingDatabaseBean implements MobileProviderSingletonBeanRemote { ->>>>>>> 3b7cccf... Please cherry-pick::src/java/org/mxchange/jphone/phonenumbers/mobileprovider/LandingMobileProviderSingletonBean.java /** * Serial number diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java index 42fe13d..ad83e3b 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java @@ -20,6 +20,8 @@ import java.text.MessageFormat; import java.util.GregorianCalendar; import javax.ejb.Stateless; import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean; +import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; /** @@ -35,6 +37,90 @@ public class AddressbookAdminPhoneSessionBean extends BaseAddressbookDatabaseBea */ private static final long serialVersionUID = 18_597_165_817_401_853L; + @Override + public void deleteFaxData (final DialableFaxNumber faxNumber) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: faxNumber={1} - CALLED!", this.getClass().getSimpleName(), faxNumber)); + + // Is all data set + if (null == faxNumber) { + // Not set, throw NPE + throw new NullPointerException("faxNumber is null"); //NOI18N + } else if (faxNumber.getPhoneId() == null) { + // Throw NPE again + throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N + } else if (faxNumber.getPhoneId() < 1) { + // Invalid number + throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N + } else if (faxNumber.getPhoneCountry()== null) { + // Throw NPE + throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N + } else if (faxNumber.getPhoneCountry().getCountryId()== null) { + // ... throw again + throw new NullPointerException("faxNumber.phoneCountry.countryId is null"); //NOI18N + } else if (faxNumber.getPhoneCountry().getCountryId() < 1) { + // Id not valid + throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneCountry.countryId={0} is not valid.", faxNumber.getPhoneCountry().getCountryId())); //NOI18N + } else if (faxNumber.getPhoneNumber() == null) { + // Throw NPE again + throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N + } else if (faxNumber.getPhoneNumber() < 1) { + // Throw NPE again + throw new NullPointerException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid.", faxNumber.getPhoneNumber())); //NOI18N + } + + // Merge it to get a managed entity back + DialableFaxNumber managedNumber = this.getEntityManager().getReference(faxNumber.getClass(), faxNumber.getPhoneId()); + + // Remove it from database + this.getEntityManager().remove(managedNumber); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: EXIT!", this.getClass().getSimpleName())); + } + + @Override + public void deleteLandLineData (final DialableLandLineNumber landLineNumber) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: landLineNumber={1} - CALLED!", this.getClass().getSimpleName(), landLineNumber)); + + // Is all data set + if (null == landLineNumber) { + // Not set, throw NPE + throw new NullPointerException("landLineNumber is null"); //NOI18N + } else if (landLineNumber.getPhoneId() == null) { + // Throw NPE again + throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N + } else if (landLineNumber.getPhoneId() < 1) { + // Invalid number + throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N + } else if (landLineNumber.getPhoneCountry()== null) { + // Throw NPE + throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N + } else if (landLineNumber.getPhoneCountry().getCountryId()== null) { + // ... throw again + throw new NullPointerException("landLineNumber.phoneCountry.countryId is null"); //NOI18N + } else if (landLineNumber.getPhoneCountry().getCountryId() < 1) { + // Id not valid + throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneCountry.countryId={0} is not valid.", landLineNumber.getPhoneCountry().getCountryId())); //NOI18N + } else if (landLineNumber.getPhoneNumber() == null) { + // Throw NPE again + throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N + } else if (landLineNumber.getPhoneNumber() < 1) { + // Throw NPE again + throw new NullPointerException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid.", landLineNumber.getPhoneNumber())); //NOI18N + } + + // Merge it to get a managed entity back + DialableLandLineNumber managedNumber = this.getEntityManager().getReference(landLineNumber.getClass(), landLineNumber.getPhoneId()); + + // Remove it from database + this.getEntityManager().remove(managedNumber); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: EXIT!", this.getClass().getSimpleName())); + } + @Override public void deleteMobileData (final DialableMobileNumber mobileNumber) { // Trace message @@ -77,6 +163,16 @@ public class AddressbookAdminPhoneSessionBean extends BaseAddressbookDatabaseBea this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: EXIT!", this.getClass().getSimpleName())); } + @Override + public DialableFaxNumber updateFaxData (DialableFaxNumber faxNumber) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public DialableLandLineNumber updateLandLineData (DialableLandLineNumber landLineNumber) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + @Override public DialableMobileNumber updateMobileData (final DialableMobileNumber mobileNumber) { // Trace message diff --git a/src/java/org/mxchange/jusercore/model/email_address/AddressbookUserEmailChangeSessionBean.java b/src/java/org/mxchange/jusercore/model/email_address/AddressbookUserEmailChangeSessionBean.java index 06419b9..b4babf3 100644 --- a/src/java/org/mxchange/jusercore/model/email_address/AddressbookUserEmailChangeSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/email_address/AddressbookUserEmailChangeSessionBean.java @@ -37,7 +37,7 @@ import org.mxchange.jusercore.model.user.UserUtils; * @author Roland Haeder */ @Stateless (name = "userEmailChange", description = "A bean handling user email changes") -public class AddressbookUserEmailChangeSessionBean extends BaseAddressbookDatabaseBean implements EmailChangeSessionBeanRemote { +public class AddressbookUserEmailChangeSessionBean extends BaseAddressbookDatabaseBean implements UserEmailChangeSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java index c9853a4..bd36954 100644 --- a/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java @@ -109,6 +109,51 @@ public class AddressbookAdminUserSessionBean extends BaseAddressbookDatabaseBean return user; } + @Override + public void deleteUser (final User user, final String userDeleteReason) throws UserNotFoundException { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteUser: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N + + // user should not be null + if (null == user) { + // Abort here + throw new NullPointerException("user is null"); //NOI18N + } else if (user.getUserId() == null) { + // Id is set + throw new NullPointerException("user.userId is null"); //NOI18N + } else if (user.getUserId() < 1) { + // Not valid id number + throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N + } else if (user.getUserContact() == null) { + // Throw NPE again + throw new NullPointerException("user.userContact is null"); //NOI18N + } else if (user.getUserContact().getContactId() == null) { + // Throw NPE again + throw new NullPointerException("user.userContact.contactId is null"); //NOI18N + } else if (user.getUserContact().getContactId() < 1) { + // Not valid id number + throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is not valid", user.getUserContact().getContactId())); //NOI18N + } else if (user.getUserAccountStatus() == null) { + // Throw NPE again + throw new NullPointerException("user.userAccountStatus is null"); //NOI18N + } else if (!this.userBean.ifUserExists(user)) { + // Name already found + throw new UserNotFoundException(user); + } + + // Get a managed instance + User managedUser = this.getManagedUser(user); + + // Should be found! + assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N + + // Delete it + this.getEntityManager().remove(managedUser); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteUser: EXIT!", this.getClass().getSimpleName())); //NOI18N + } + @Override public User linkUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException { // Trace message diff --git a/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java index a4e57bd..3e3f67b 100644 --- a/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java @@ -598,9 +598,9 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl } @Override - public PasswordHistory updateUserPassword (final User user) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException { + public PasswordHistory updateUserPassword (final User user, final String baseUrl) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N // user should not be null if (null == user) { @@ -618,6 +618,12 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl } else if (!this.ifUserExists(user)) { // User does not exist throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N + } else if (null == baseUrl) { + // Abort here + throw new NullPointerException("password is null"); //NOI18N + } else if (baseUrl.isEmpty()) { + // Abort here + throw new IllegalArgumentException("password is empty"); //NOI18N } // Call other method