]> git.mxchange.org Git - jfinancials-ejb.git/commitdiff
Continued a bit:
authorRoland Haeder <roland@mxchange.org>
Mon, 10 Apr 2017 20:07:48 +0000 (22:07 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 10 Apr 2017 20:07:48 +0000 (22:07 +0200)
- not just cellphones, let's support any mobile phone
- implemented missing business methods
- tpzo fixed

src/java/org/mxchange/jphone/phonenumbers/mobileprovider/AddressbookMobileProviderSingletonBean.java
src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java
src/java/org/mxchange/jusercore/model/email_address/AddressbookUserEmailChangeSessionBean.java
src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java
src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java

index 1875fe4f2d43250e0dbd6c0b7d3941508fd84583..28b118df10caf8b9b2a80e88ed5fc88079b87349 100644 (file)
@@ -29,13 +29,8 @@ import org.mxchange.jcoreee.database.BaseDatabaseBean;
  * @author Roland Haeder<roland@mxchange.org>
  */
 @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
index 42fe13d58270b23cf92a135204643ec867e6cf90..ad83e3b9893294b6ce7f8db1479e0035d3e692d3 100644 (file)
@@ -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
index 06419b95a96fc5eb34359ef06990e0a16f6c4355..b4babf383ecc8173e9177cccd75f815f83058ea3 100644 (file)
@@ -37,7 +37,7 @@ import org.mxchange.jusercore.model.user.UserUtils;
  * @author Roland Haeder<roland@mxchange.org>
  */
 @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
index c9853a4686b7a107f71acaa11bd5cc05cc9d6530..bd36954d9f599be48d37fa7c8bd16bb991639c73 100644 (file)
@@ -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
index a4e57bd6e3d73793218e4bf71586c46b073b113c..3e3f67bcd480b76d7dd1b774628be3bcf820cf3c 100644 (file)
@@ -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