]> git.mxchange.org Git - jfinancials-ejb.git/blobdiff - src/java/org/mxchange/jcontacts/model/contact/FinancialsContactSessionBean.java
Please cherry-pick/rename:
[jfinancials-ejb.git] / src / java / org / mxchange / jcontacts / model / contact / FinancialsContactSessionBean.java
index 5828cb4b846664313294ea78a471e0dd72d448fc..a2db3210a5e712aab94d51d2d80fcf1a868b2eec 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016, 2017 Roland Häder
+ * Copyright (C) 2016 - 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
@@ -66,62 +66,6 @@ public class FinancialsContactSessionBean extends BaseFinancialsDatabaseBean imp
                return contacts;
        }
 
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<String> allEmailAddresses () {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList - CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Create query instance
-               final Query query = this.getEntityManager().createNamedQuery("AllContactEmailAddresses"); //NOI18N
-
-               // Get list
-               final List<String> emailAddresses = query.getResultList();
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: emailAddresses.size()={1} - EXIT!", this.getClass().getSimpleName(), emailAddresses.size())); //NOI18N
-
-               // Return it
-               return emailAddresses;
-       }
-
-       @Override
-       public boolean isEmailAddressRegistered (final String emailAddress) {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: emailAddress={1} - CALLED!", this.getClass().getSimpleName(), emailAddress)); //NOI18N
-
-               // The email address should be valid
-               if (null == emailAddress) {
-                       // Is null
-                       throw new NullPointerException("emailAddress is null"); //NOI18N
-               } else if (emailAddress.isEmpty()) {
-                       // Is empty
-                       throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
-               }
-
-               // Default is not found
-               boolean isFound = false;
-
-               try {
-                       // Ask other method for contact instance
-                       final Contact contact = this.findContactByEmailAddress(emailAddress);
-
-                       // Log debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: Found contact={1} for emailAddress={2}", this.getClass().getSimpleName(), contact, emailAddress)); //NOI18N
-
-                       // It is found ...
-                       isFound = true;
-               } catch (final ContactNotFoundException ex) {
-                       // @TODO Was not found, log exception for spam check?
-               }
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: isFound={1} - EXIT!", this.getClass().getSimpleName(), isFound)); //NOI18N
-
-               // Return status
-               return isFound;
-       }
-
        @Override
        public Contact lookupContact (final Contact contact) {
                // Log trace message
@@ -160,7 +104,7 @@ public class FinancialsContactSessionBean extends BaseFinancialsDatabaseBean imp
                // Loop through all
                while (iterator.hasNext()) {
                        // Get contact
-                       Contact next = iterator.next();
+                       final Contact next = iterator.next();
 
                        // Is same contact?
                        if ((Objects.equals(contact, next)) || (ContactUtils.isSameContact(contact, next))) {
@@ -201,7 +145,7 @@ public class FinancialsContactSessionBean extends BaseFinancialsDatabaseBean imp
                this.setAllContactPhoneEntriesUpdated(contact, isCellphoneUnlinked, isLandlineUnlinked, isFaxUnlinked);
 
                // Merge mobile, land-line and fix
-               Contact detachedContact = this.mergeContactData(contact);
+               final Contact detachedContact = this.mergeContactData(contact);
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: detachedContact={1} - EXIT!", this.getClass().getSimpleName(), detachedContact)); //NOI18N
@@ -228,12 +172,12 @@ public class FinancialsContactSessionBean extends BaseFinancialsDatabaseBean imp
                }
 
                // Is cell phone/land-line/fax number unlinked?
-               boolean isCellphoneUnlinked = (contact.getContactMobileNumber() == null);
-               boolean isLandLineUnlinked = (contact.getContactLandLineNumber() == null);
-               boolean isFaxUnlinked = (contact.getContactFaxNumber() == null);
+               final boolean isCellphoneUnlinked = (contact.getContactMobileNumber() == null);
+               final boolean isLandLineUnlinked = (contact.getContactLandLineNumber() == null);
+               final boolean isFaxUnlinked = (contact.getContactFaxNumber() == null);
 
                // Call other Method
-               Contact detachedContact = this.updateContactData(contact, isCellphoneUnlinked, isLandLineUnlinked, isFaxUnlinked);
+               final Contact detachedContact = this.updateContactData(contact, isCellphoneUnlinked, isLandLineUnlinked, isFaxUnlinked);
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: detachedContact={1} - EXIT!", this.getClass().getSimpleName(), detachedContact)); //NOI18N
@@ -242,57 +186,6 @@ public class FinancialsContactSessionBean extends BaseFinancialsDatabaseBean imp
                return detachedContact;
        }
 
-       /**
-        * Returns a contact instance which has the given email address.
-        * <p>
-        * @param emailAddress Email address
-        * <p>
-        * @return Contact instance
-        * <p>
-        * @throws ContactNotFoundException If the contact was not found
-        */
-       private Contact findContactByEmailAddress (final String emailAddress) throws ContactNotFoundException {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: emailAddress={1} - CALLED!", this.getClass().getSimpleName(), emailAddress)); //NOI18N
-
-               // The parameter must be valid
-               if (null == emailAddress) {
-                       // Throw NPE
-                       throw new NullPointerException("emailAddress is null"); //NOI18N
-               } else if (emailAddress.isEmpty()) {
-                       // Not valid
-                       throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
-               }
-
-               // Get query instance
-               final Query query = this.getEntityManager().createNamedQuery("SearchContactByEmailAddress", UserContact.class); //NOI18N
-
-               // Set parameter and limit
-               query.setParameter("emailAddress", emailAddress); //NOI18N
-               query.setMaxResults(1);
-
-               // Init contact instance
-               final Contact contact;
-
-               // Try to find a result
-               try {
-                       // Find a single result
-                       contact = (Contact) query.getSingleResult();
-
-                       // Log trace message
-                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: Found contact={1}", this.getClass().getSimpleName(), contact)); //NOI18N
-               } catch (final NoResultException ex) {
-                       // No result found
-                       throw new ContactNotFoundException(emailAddress, ex);
-               }
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: contact={1} - EXIT!", this.getClass().getSimpleName(), contact)); //NOI18N
-
-               // Return found instance
-               return contact;
-       }
-
        /**
         * Returns a contact instance which has the given id number.
         * <p>