]> git.mxchange.org Git - addressbook-ejb.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Tue, 5 Sep 2017 20:03:36 +0000 (22:03 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 9 Sep 2017 18:53:34 +0000 (20:53 +0200)
- added new stateless session beans for administrative and general purposes for
  branch office data and implemented business methods
- moved allCompanyBasicData() to general bean as this is a general business method
- also had to switch EJB references (maybe one day lookup="" is required again?)
- added private method isContactFound() to check if contact is already registered
  or not there
- this method is now used to throw proper checked exceptions (which in turn your
  application must catch)
- implemented business method allCompanyBasicData()
- renamed getAllContacts() -> allContacts() as this is actually no getter
  following naming-convention
- renamed getUserNameList() -> allUserNames() for same reason
- in fillUserData() added more checks on parameter 'user' as usual in many
  places, including ifUserExists() and throw checked (wanted) exception if not
  found in persistence provider
- added 'final' whereever possible, better optimization
- used not NULL when not needed, allowing more 'final' to be set
- updated persistence unit (new namespace for branch office entity)
- relicensed under Affero GPLv3 (no change to e.g. MIT will happen)
- added TODOs

Signed-off-by: Roland Häder <roland@mxchange.org>
23 files changed:
docs/COPYING.software
src/conf/persistence.xml
src/java/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java
src/java/org/mxchange/jcontacts/contact/AddressbookAdminContactSessionBean.java
src/java/org/mxchange/jcontacts/contact/AddressbookContactSessionBean.java
src/java/org/mxchange/jcontacts/phone/AddressbookAdminContactPhoneSessionBean.java
src/java/org/mxchange/jcontactsbusiness/basicdata/AddressbookAdminBusinessDataSessionBean.java
src/java/org/mxchange/jcontactsbusiness/basicdata/AddressbookBusinessDataSessionBean.java
src/java/org/mxchange/jcontactsbusiness/branchoffice/FinancialsAdminBranchOfficeSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/branchoffice/FinancialsBranchOfficeSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/employee/AddressbookCompanyEmployeeSessionBean.java
src/java/org/mxchange/jcountry/data/AddressbookCountrySingletonBean.java
src/java/org/mxchange/jphone/phonenumbers/mobileprovider/AddressbookMobileProviderSingletonBean.java
src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java
src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookPhoneSessionBean.java
src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java
src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java
src/java/org/mxchange/jusercore/model/user/activity/AddressbookUserActivityLogMessageBean.java
src/java/org/mxchange/jusercore/model/user/email_address/AddressbookUserEmailChangeSessionBean.java
src/java/org/mxchange/jusercore/model/user/password_history/AddressbookUserPasswordHistorySessionBean.java
src/java/org/mxchange/juserlogincore/model/user/login/AddressbookUserLoginSessionBean.java
src/java/org/mxchange/juserlogincore/model/user/register/AddressbookUserRegistrationSessionBean.java
src/java/org/mxchange/juserlogincore/model/user/resendlink/AddressbookResendLinkSessionBean.java

index 94a9ed024d3859793618152ea559a168bbcbb5e2..dba13ed2ddf783ee8118c6a581dbf75305f816a3 100644 (file)
@@ -1,5 +1,5 @@
-                    GNU GENERAL PUBLIC LICENSE
-                       Version 3, 29 June 2007
+                    GNU AFFERO GENERAL PUBLIC LICENSE
+                       Version 3, 19 November 2007
 
  Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
  Everyone is permitted to copy and distribute verbatim copies
@@ -7,17 +7,15 @@
 
                             Preamble
 
-  The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
+  The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
 
   The licenses for most software and other practical works are designed
 to take away your freedom to share and change the works.  By contrast,
-the GNU General Public License is intended to guarantee your freedom to
+our General Public Licenses are intended to guarantee your freedom to
 share and change all versions of a program--to make sure it remains free
-software for all its users.  We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors.  You can apply it to
-your programs, too.
+software for all its users.
 
   When we speak of free software, we are referring to freedom, not
 price.  Our General Public Licenses are designed to make sure that you
@@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you
 want it, that you can change the software or use pieces of it in new
 free programs, and that you know you can do these things.
 
-  To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights.  Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received.  You must make sure that they, too, receive
-or can get the source code.  And you must show them these terms so they
-know their rights.
-
-  Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
-  For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software.  For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
-  Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so.  This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software.  The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable.  Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products.  If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
-  Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary.  To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
+  Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+  A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate.  Many developers of free software are heartened and
+encouraged by the resulting cooperation.  However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+  The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community.  It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server.  Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+  An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals.  This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
 
   The precise terms and conditions for copying, distribution and
 modification follow.
@@ -72,7 +60,7 @@ modification follow.
 
   0. Definitions.
 
-  "This License" refers to version 3 of the GNU General Public License.
+  "This License" refers to version 3 of the GNU Affero General Public License.
 
   "Copyright" also means copyright-like laws that apply to other kinds of
 works, such as semiconductor masks.
@@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey
 the Program, the only way you could satisfy both those terms and this
 License would be to refrain entirely from conveying the Program.
 
-  13. Use with the GNU Affero General Public License.
+  13. Remote Network Interaction; Use with the GNU General Public License.
+
+  Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software.  This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
 
   Notwithstanding any other provision of this License, you have
 permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
+under version 3 of the GNU General Public License into a single
 combined work, and to convey the resulting work.  The terms of this
 License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
 
   14. Revised Versions of this License.
 
   The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
+the GNU Affero General Public License from time to time.  Such new versions
+will be similar in spirit to the present version, but may differ in detail to
 address new problems or concerns.
 
   Each version is given a distinguishing version number.  If the
-Program specifies that a certain numbered version of the GNU General
+Program specifies that a certain numbered version of the GNU Affero General
 Public License "or any later version" applies to it, you have the
 option of following the terms and conditions either of that numbered
 version or of any later version published by the Free Software
 Foundation.  If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
+GNU Affero General Public License, you may choose any version ever published
 by the Free Software Foundation.
 
   If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
+versions of the GNU Affero General Public License can be used, that proxy's
 public statement of acceptance of a version permanently authorizes you
 to choose that version for the Program.
 
@@ -635,40 +633,29 @@ the "copyright" line and a pointer to where the full notice is found.
     Copyright (C) <year>  <name of author>
 
     This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
+    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 General Public License for more details.
+    GNU Affero General Public License for more details.
 
-    You should have received a copy of the GNU General Public License
+    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/>.
 
 Also add information on how to contact you by electronic and paper mail.
 
-  If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
-    <program>  Copyright (C) <year>  <name of author>
-    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
+  If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source.  For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code.  There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
 
   You should also get your employer (if you work as a programmer) or school,
 if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
+For more information on this, and how to apply and follow the GNU AGPL, see
 <http://www.gnu.org/licenses/>.
-
-  The GNU General Public License does not permit incorporating your program
-into proprietary programs.  If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library.  If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.  But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
index d56e8402e55b02bc4e4bdd6ba65c7afc27dee8c5..9f423056e2a1da38b039d859cf0540a58771dd12 100644 (file)
@@ -7,7 +7,7 @@
     <class>org.mxchange.jaddressbookshare.model.addressbook.shared.AddressbookShare</class>
     <class>org.mxchange.jcontacts.contact.UserContact</class>
     <class>org.mxchange.jcontactsbusiness.basicdata.CompanyBasicData</class>
-    <class>org.mxchange.jcontactsbusiness.branch.CompanyBranchOffice</class>
+    <class>org.mxchange.jcontactsbusiness.branchoffice.CompanyBranchOffice</class>
     <class>org.mxchange.jcontactsbusiness.department.CompanyDepartment</class>
     <class>org.mxchange.jcontactsbusiness.employee.CompanyEmployee</class>
     <class>org.mxchange.jcontactsbusiness.headquarters.CompanyHeadquartersData</class>
index b74a841dcbfe23b70e3d35fb87970bdafd267a9b..61fe751fde3d2fbf7e838cd6662590e94478099c 100644 (file)
@@ -26,17 +26,17 @@ import javax.jms.ObjectMessage;
 import javax.mail.Address;
 import javax.mail.internet.AddressException;
 import javax.mail.internet.InternetAddress;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.ContactUtils;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontacts.model.contact.ContactUtils;
 import org.mxchange.jcoreee.database.BaseDatabaseBean;
 import org.mxchange.jmailee.model.delivery.wrapper.EmailDeliveryWrapper;
 import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.fax.FaxNumbers;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.landline.LandLineNumbers;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.mobile.MobileNumbers;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.fax.FaxNumbers;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumbers;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumbers;
 import org.mxchange.jphone.utils.PhoneUtils;
 import org.mxchange.jusercore.model.user.LoginUser;
 import org.mxchange.jusercore.model.user.User;
@@ -89,9 +89,9 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                }
 
                // Get all phone instances
-               DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
-               DialableFaxNumber faxNumber = contact.getContactFaxNumber();
-               DialableMobileNumber mobileNumber = contact.getContactMobileNumber();
+               final DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
+               final DialableFaxNumber faxNumber = contact.getContactFaxNumber();
+               final DialableMobileNumber mobileNumber = contact.getContactMobileNumber();
 
                // Debug message
                this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: landLineNumber={1},faxNumber={2},mobileNumber={3}", this.getClass().getSimpleName(), landLineNumber, faxNumber, mobileNumber)); //NOI18N
@@ -117,7 +117,7 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                // Is a mobile number instance set?
                if ((mobileNumber instanceof DialableMobileNumber) && (mobileNumber.getPhoneId() == null)) {
                        // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: Setting created timestamp for cellphone number ...", this.getClass().getSimpleName())); //NOI18N
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: Setting created timestamp for mobile number ...", this.getClass().getSimpleName())); //NOI18N
 
                        // Set updated timestamp
                        mobileNumber.setPhoneEntryCreated(new GregorianCalendar());
@@ -152,7 +152,13 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                }
 
                // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.getDetached: fetchedNumber.phoneId={1}", this.getClass().getSimpleName(), fetchedNumber.getPhoneId())); //NOI18N
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
+
+               // Init query instance
+               final DialableMobileNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
 
                // Default is null
                DialableMobileNumber managedNumber = null;
@@ -160,7 +166,9 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                // Is there a difference?
                if (!PhoneUtils.isSameMobileNumber(mobileNumber, fetchedNumber)) {
                        // Merge this entry
-                       managedNumber = this.getEntityManager().merge(fetchedNumber);
+                       managedNumber = this.getEntityManager().merge(foundNumber);
+
+                       // @TODO Copy all
                }
 
                // Trace message
@@ -195,7 +203,13 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                }
 
                // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.getDetached: fetchedNumber.phoneId={1}", this.getClass().getSimpleName(), fetchedNumber.getPhoneId())); //NOI18N
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
+
+               // Init query instance
+               final DialableLandLineNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
 
                // Default is null
                DialableLandLineNumber managedNumber = null;
@@ -203,7 +217,9 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                // Is there a difference?
                if (!PhoneUtils.isSameLandLineNumber(landLineNumber, fetchedNumber)) {
                        // Merge this entry
-                       managedNumber = this.getEntityManager().merge(fetchedNumber);
+                       managedNumber = this.getEntityManager().merge(foundNumber);
+
+                       // @TODO Copy all
                }
 
                // Trace message
@@ -238,7 +254,13 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                }
 
                // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.getDetached: fetchedNumber.phoneId={1}", this.getClass().getSimpleName(), fetchedNumber.getPhoneId())); //NOI18N
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
+
+               // Init query instance
+               final DialableFaxNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
 
                // Default is null
                DialableFaxNumber managedNumber = null;
@@ -246,7 +268,9 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                // Is there a difference?
                if (!PhoneUtils.isSameFaxNumber(faxNumber, fetchedNumber)) {
                        // Merge this entry
-                       managedNumber = this.getEntityManager().merge(fetchedNumber);
+                       managedNumber = this.getEntityManager().merge(foundNumber);
+
+                       // @TODO Copy all
                }
 
                // Trace message
@@ -289,7 +313,7 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                }
 
                // Try to find it (should be there)
-               User managedUser = this.getEntityManager().find(LoginUser.class, user.getUserId());
+               final User managedUser = this.getEntityManager().find(LoginUser.class, user.getUserId());
 
                // Should be there
                assert (managedUser instanceof User) : "managedUser is null"; //NOI18N
@@ -325,34 +349,34 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                }
 
                // Get contact from it and find it
-               Contact managedContact = this.getEntityManager().find(detachedContact.getClass(), detachedContact.getContactId());
+               final Contact foundContact = this.getEntityManager().find(detachedContact.getClass(), detachedContact.getContactId());
 
                // Should be found
-               assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", detachedContact.getContactId()); //NOI18N
+               assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", detachedContact.getContactId()); //NOI18N
 
                // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateUserPersonalData: managedContact.contactId={1}", this.getClass().getSimpleName(), managedContact.getContactId())); //NOI18N
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateUserPersonalData: foundContact.contactId={1}", this.getClass().getSimpleName(), foundContact.getContactId())); //NOI18N
 
                // Is a fax number set?
                if (detachedContact.getContactFaxNumber() instanceof DialableFaxNumber) {
                        // Make fax numbers managed
-                       managedContact.setContactFaxNumber(this.getManaged(detachedContact.getContactFaxNumber(), detachedContact.getContactFaxNumber()));
+                       foundContact.setContactFaxNumber(this.getManaged(detachedContact.getContactFaxNumber(), detachedContact.getContactFaxNumber()));
                }
 
                // Is a land-line number set?
                if (detachedContact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
                        // Make land-line numbers managed
-                       managedContact.setContactLandLineNumber(this.getManaged(detachedContact.getContactLandLineNumber(), detachedContact.getContactLandLineNumber()));
+                       foundContact.setContactLandLineNumber(this.getManaged(detachedContact.getContactLandLineNumber(), detachedContact.getContactLandLineNumber()));
                }
 
                // Is a mobile number set?
                if (detachedContact.getContactMobileNumber() instanceof DialableMobileNumber) {
                        // Make mobile numbers managed
-                       managedContact.setContactMobileNumber(this.getManaged(detachedContact.getContactMobileNumber(), detachedContact.getContactMobileNumber()));
+                       foundContact.setContactMobileNumber(this.getManaged(detachedContact.getContactMobileNumber(), detachedContact.getContactMobileNumber()));
                }
 
-               // Set updated timestamp
-               managedContact.setContactUpdated(new GregorianCalendar());
+               // Merge contact instance
+               final Contact managedContact = this.getEntityManager().merge(foundContact);
 
                // Copy all
                ContactUtils.copyAll(detachedContact, managedContact);
@@ -365,7 +389,7 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
        }
 
        /**
-        * Merges given (detached) contact's cellphone, land-line and fax numbers
+        * Merges given (detached) contact's mobile, land-line and fax numbers
         * <p>
         * @param detachedContact Detached contact instance
         */
@@ -386,23 +410,23 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                }
 
                // Get all instances
-               DialableMobileNumber cellphone = detachedContact.getContactMobileNumber();
-               DialableLandLineNumber landLine = detachedContact.getContactLandLineNumber();
-               DialableFaxNumber fax = detachedContact.getContactFaxNumber();
+               final DialableMobileNumber mobile = detachedContact.getContactMobileNumber();
+               final DialableLandLineNumber landLine = detachedContact.getContactLandLineNumber();
+               final DialableFaxNumber fax = detachedContact.getContactFaxNumber();
 
-               // Is there a  cellphone instance set?
-               if (cellphone instanceof DialableMobileNumber) {
+               // Is there a  mobile instance set?
+               if (mobile instanceof DialableMobileNumber) {
                        // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: cellphone.phoneId={0} is being updated ...", cellphone.getPhoneId())); //NOI18N
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: mobile.phoneId={0} is being updated ...", mobile.getPhoneId())); //NOI18N
 
                        // Then find it, too
-                       DialableMobileNumber foundMobile = this.getEntityManager().find(cellphone.getClass(), cellphone.getPhoneId());
+                       final DialableMobileNumber foundMobile = this.getEntityManager().find(mobile.getClass(), mobile.getPhoneId());
 
                        // Should be there
                        assert (foundMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", foundMobile.getPhoneId()); //NOI18N
 
                        // Then merge it, too
-                       DialableMobileNumber managedMobile = this.getEntityManager().merge(foundMobile);
+                       final DialableMobileNumber managedMobile = this.getEntityManager().merge(foundMobile);
 
                        // Should be there
                        assert (managedMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", managedMobile.getPhoneId()); //NOI18N
@@ -420,13 +444,13 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                        this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: fax.phoneId={0} is being updated ...", fax.getPhoneId())); //NOI18N
 
                        // Then find it, too
-                       DialableFaxNumber foundFax = this.getEntityManager().find(fax.getClass(), fax.getPhoneId());
+                       final DialableFaxNumber foundFax = this.getEntityManager().find(fax.getClass(), fax.getPhoneId());
 
                        // Should be there
                        assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N
 
                        // Then merge it, too
-                       DialableFaxNumber managedFax = this.getEntityManager().merge(foundFax);
+                       final DialableFaxNumber managedFax = this.getEntityManager().merge(foundFax);
 
                        // Should be there
                        assert (managedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", managedFax.getPhoneId()); //NOI18N
@@ -444,13 +468,13 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                        this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLine.phoneId={0} is being updated ...", landLine.getPhoneId())); //NOI18N
 
                        // Then find it, too
-                       DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLine.getClass(), landLine.getPhoneId());
+                       final DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLine.getClass(), landLine.getPhoneId());
 
                        // Should be there
                        assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId()); //NOI18N
 
                        // Then merge it, too
-                       DialableLandLineNumber managedLandLine = this.getEntityManager().merge(foundLandLine);
+                       final DialableLandLineNumber managedLandLine = this.getEntityManager().merge(foundLandLine);
 
                        // Should be there
                        assert (managedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", managedLandLine.getPhoneId()); //NOI18N
@@ -533,7 +557,7 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                }
 
                // Set all values
-               Properties variables = UserUtils.getAllUserFields(user);
+               final Properties variables = UserUtils.getAllUserFields(user);
 
                // Set base URL and random password
                variables.put("baseUrl", baseUrl); //NOI18N
@@ -545,7 +569,7 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                }
 
                // Init addresss
-               Address recipientAddress;
+               final Address recipientAddress;
 
                try {
                        // Create email address and set
@@ -557,7 +581,7 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
 
                // Prepare mail wrapper
                // @TODO Language from message bundle
-               WrapableEmailDelivery emailWrapper = new EmailDeliveryWrapper(recipientAddress, subjectLine, templateName, variables, user.getUserLocale());
+               final WrapableEmailDelivery emailWrapper = new EmailDeliveryWrapper(recipientAddress, subjectLine, templateName, variables, user.getUserLocale());
 
                try {
                        // Send out email change
@@ -595,20 +619,20 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                        throw new NullPointerException("other is null"); //NOI18N
                } else if (!Objects.equals(contact, other)) {
                        // Not same instances
-                       throw new IllegalArgumentException(MessageFormat.format("contact={0} and other={1} are not equal!", contact, other)); //NOI18N
+                       throw new IllegalArgumentException(MessageFormat.format("{0}.setAllContactPhoneEntries: contact={1} and other={2} are not equal!", this.getClass().getSimpleName(), contact, other)); //NOI18N
                }
 
                // Debug message
                this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: other.contactMobileNumber={0}", other.getContactMobileNumber())); //NOI18N
 
-               // Is other cellphone not set?
+               // Is other mobile not set?
                if ((other.getContactMobileNumber() == null) || (PhoneUtils.isSameMobileNumber(contact.getContactMobileNumber(), other.getContactMobileNumber()))) {
                        // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: Copying cellphone entry ...", this.getClass().getSimpleName())); //NOI18N
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: Copying mobile entry ...", this.getClass().getSimpleName())); //NOI18N
 
                        // Is the fax number set?
                        if (other.getContactMobileNumber() instanceof DialableMobileNumber) {
-                               // Copy cellphone number
+                               // Copy mobile number
                                contact.setContactMobileNumber(this.getManaged(other.getContactMobileNumber(), contact.getContactMobileNumber()));
                        } else {
                                // Null it
@@ -619,7 +643,7 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                // Debug message
                this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: other.contactLandLineNumber={0}", other.getContactLandLineNumber())); //NOI18N
 
-               // Is other cellphone not set?
+               // Is other mobile not set?
                if ((other.getContactLandLineNumber() == null) || (PhoneUtils.isSameLandLineNumber(contact.getContactLandLineNumber(), other.getContactLandLineNumber()))) {
                        // Debug message
                        this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: Copying land-line entry ...", this.getClass().getSimpleName())); //NOI18N
@@ -637,7 +661,7 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                // Debug message
                this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: other.contactFaxNumber={1}", this.getClass().getSimpleName(), other.getContactFaxNumber())); //NOI18N
 
-               // Is other cellphone not set?
+               // Is other mobile not set?
                if ((other.getContactFaxNumber() == null) || (PhoneUtils.isSameFaxNumber(contact.getContactFaxNumber(), other.getContactFaxNumber()))) {
                        // Debug message
                        this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: Copying fax entry ...", this.getClass().getSimpleName())); //NOI18N
@@ -684,9 +708,9 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                }
 
                // Get all phone instances
-               DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
-               DialableFaxNumber faxNumber = contact.getContactFaxNumber();
-               DialableMobileNumber mobileNumber = contact.getContactMobileNumber();
+               final DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
+               final DialableFaxNumber faxNumber = contact.getContactFaxNumber();
+               final DialableMobileNumber mobileNumber = contact.getContactMobileNumber();
 
                // Flags and instances must be constistent
                if (isMobileUnlinked && mobileNumber instanceof DialableMobileNumber) {
@@ -721,7 +745,7 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                // Is a mobile number instance set?
                if ((mobileNumber instanceof DialableMobileNumber) && (mobileNumber.getPhoneId() instanceof Long) && (mobileNumber.getPhoneId() > 0)) {
                        // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesUpdated: Setting updated timestamp for cellphone number ...", this.getClass().getSimpleName())); //NOI18N
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesUpdated: Setting updated timestamp for mobile number ...", this.getClass().getSimpleName())); //NOI18N
 
                        // Set updated timestamp
                        mobileNumber.setPhoneEntryUpdated(new GregorianCalendar());
index baff6545675467789bbab824a5759caa9daf1d70..9a9d048c5fd19055837363562fc7a8a55e286d61 100644 (file)
@@ -20,7 +20,12 @@ import java.text.MessageFormat;
 import java.util.GregorianCalendar;
 import javax.ejb.Stateless;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
 import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
+import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
+import org.mxchange.jcontacts.model.contact.AdminContactSessionBeanRemote;
+import org.mxchange.jcontacts.model.contact.Contact;
 
 /**
  * An administrative contact EJB
@@ -55,6 +60,9 @@ public class AddressbookAdminContactSessionBean extends BaseAddressbookDatabaseB
                } else if (contact.getContactId() != null) {
                        // Should be null
                        throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} - is not null", contact.getContactId())); //NOI18N
+               } else if (this.isContactFound(contact)) {
+                       // Already registered
+                       throw new ContactAlreadyAddedException(contact);
                }
 
                // Set created timestamp
@@ -77,7 +85,7 @@ public class AddressbookAdminContactSessionBean extends BaseAddressbookDatabaseB
        }
 
        @Override
-       public void deleteContactData (final Contact contact) {
+       public void deleteContactData (final Contact contact) throws ContactNotFoundException {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteContactData: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
 
@@ -91,6 +99,9 @@ public class AddressbookAdminContactSessionBean extends BaseAddressbookDatabaseB
                } else if (contact.getContactId() < 1) {
                        // Not valid
                        throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
+               } else if (!this.isContactFound(contact)) {
+                       // Contact not found
+                       throw new ContactNotFoundException(contact.getContactId());
                }
 
                // Merge it to get a managed entity back
@@ -103,4 +114,43 @@ public class AddressbookAdminContactSessionBean extends BaseAddressbookDatabaseB
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteContactData: EXIT!", this.getClass().getSimpleName())); //NOI18N
        }
 
+       /**
+        * Determines if the given contact is found
+        * <p>
+        * @param contact Contact instance
+        * <p>
+        * @return Whether the contact has been found
+        */
+       private boolean isContactFound (final Contact contact) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactRegistered: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
+
+               // Create query
+               Query query = this.getEntityManager().createNamedQuery("SearchContact"); //NOI18N
+
+               // Set parameter
+               query.setParameter("contact", contact); //NOI18N
+               query.setMaxResults(1);
+
+               // Default is not found
+               boolean isFound = false;
+
+               // Try it
+               try {
+                       // Try to find instance
+                       Contact dummy = (Contact) query.getSingleResult();
+
+                       // Mark as found
+                       isFound = true;
+               } catch (final NoResultException e) {
+                       // No result found
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactRegistered: isFound={1} - EXIT!", this.getClass().getSimpleName(), isFound)); //NOI18N
+
+               // Return flag
+               return isFound;
+       }
+
 }
index 2610872f0258f580cfcce43096ceb87758a5962d..99ae63148b9eaa7b1728eaa57025ba3df7d15a0c 100644 (file)
@@ -25,6 +25,9 @@ import javax.persistence.NoResultException;
 import javax.persistence.Query;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
 import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontacts.model.contact.ContactUtils;
+import org.mxchange.jcontacts.model.contact.UserContact;
 
 /**
  * A contact EJB
@@ -47,6 +50,44 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                super();
        }
 
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<Contact> allContacts () {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getAllContacts - CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Create query instance
+               final Query query = this.getEntityManager().createNamedQuery("AllContacts"); //NOI18N
+
+               // Get list
+               final List<Contact> contacts = query.getResultList();
+
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getAllContacts: contacts.size()={1} - EXIT!", this.getClass().getSimpleName(), contacts.size())); //NOI18N
+
+               // Return it
+               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 Contact findContactByEmailAddress (final String emailAddress) throws ContactNotFoundException {
                // Log trace message
@@ -62,13 +103,14 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                }
 
                // Get query instance
-               Query query = this.getEntityManager().createNamedQuery("SearchContactByEmailAddress", UserContact.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchContactByEmailAddress", UserContact.class); //NOI18N
 
-               // Set parameter
+               // Set parameter and limit
                query.setParameter("emailAddress", emailAddress); //NOI18N
+               query.setMaxResults(1);
 
                // Init contact instance
-               Contact contact;
+               final Contact contact;
 
                // Try to find a result
                try {
@@ -104,13 +146,14 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                }
 
                // Get query instance
-               Query query = this.getEntityManager().createNamedQuery("SearchContactById", UserContact.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchContactById", UserContact.class); //NOI18N
 
                // Set parameter
                query.setParameter("contactId", contactId); //NOI18N
+               query.setMaxResults(1);
 
                // Init contact instance
-               Contact contact;
+               final Contact contact;
 
                // Try to find a result
                try {
@@ -131,44 +174,6 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                return contact;
        }
 
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<Contact> getAllContacts () {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getAllContacts - CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Create query instance
-               Query query = this.getEntityManager().createNamedQuery("AllContacts"); //NOI18N
-
-               // Get list
-               List<Contact> contacts = query.getResultList();
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getAllContacts: contacts.size()={1} - EXIT!", this.getClass().getSimpleName(), contacts.size())); //NOI18N
-
-               // Return it
-               return contacts;
-       }
-
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<String> getEmailAddressList () {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList - CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Create query instance
-               Query query = this.getEntityManager().createNamedQuery("AllContactEmailAddresses"); //NOI18N
-
-               // Get list
-               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
@@ -188,7 +193,7 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
 
                try {
                        // Ask other method for contact instance
-                       Contact contact = this.findContactByEmailAddress(emailAddress);
+                       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
@@ -229,7 +234,7 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                Contact foundContact = null;
 
                // Get whole list
-               List<Contact> contacts = this.getAllContacts();
+               final List<Contact> contacts = this.allContacts();
 
                // Is the list empty?
                if (contacts.isEmpty()) {
@@ -239,7 +244,7 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                }
 
                // Get iterator
-               Iterator<Contact> iterator = contacts.iterator();
+               final Iterator<Contact> iterator = contacts.iterator();
 
                // Loop through all
                while (iterator.hasNext()) {
index 8ef28c260cd0941e9ebbe5a72f2707c8da90d3dd..b520b1f91f2cd67a3fd8d83834e5efe14a3a8922 100644 (file)
@@ -22,14 +22,14 @@ import java.util.Objects;
 import javax.ejb.EJB;
 import javax.ejb.Stateless;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
-import org.mxchange.jcontacts.contact.UserContact;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
+import org.mxchange.jcontacts.model.phone.AdminContactsPhoneSessionBeanRemote;
 import org.mxchange.jphone.exceptions.PhoneNumberAlreadyLinkedException;
 import org.mxchange.jphone.exceptions.PhoneNumberNotLinkedException;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
 
 /**
  * A session EJB for administrative contact's phone number purposes
@@ -102,20 +102,17 @@ public class AddressbookAdminContactPhoneSessionBean extends BaseAddressbookData
                        throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid", faxNumber.getPhoneNumber())); //NOI18N
                }
 
-               // Find contact
-               Contact managedContact = this.getEntityManager().find(UserContact.class, contact.getContactId());
-
-               // Merge phone number
-               DialableFaxNumber managedNumber = this.getEntityManager().merge(faxNumber);
-
                // Set fax number in contact
-               managedContact.setContactFaxNumber(managedNumber);
+               contact.setContactFaxNumber(faxNumber);
+
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingFaxNumberWithContact: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingFaxNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
 
                // Return it
-               return managedContact;
+               return updatedContact;
        }
 
        @Override
@@ -162,20 +159,17 @@ public class AddressbookAdminContactPhoneSessionBean extends BaseAddressbookData
                        throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid", landLineNumber.getPhoneNumber())); //NOI18N
                }
 
-               // Find contact
-               Contact managedContact = this.getEntityManager().find(UserContact.class, contact.getContactId());
-
-               // Merge phone number
-               DialableLandLineNumber managedNumber = this.getEntityManager().merge(landLineNumber);
+               // Set land-line number in contact
+               contact.setContactLandLineNumber(landLineNumber);
 
-               // Set fax number in contact
-               managedContact.setContactLandLineNumber(managedNumber);
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingLandLineNumberWithContact: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingLandLineNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
 
                // Return it
-               return managedContact;
+               return updatedContact;
        }
 
        @Override
@@ -216,20 +210,17 @@ public class AddressbookAdminContactPhoneSessionBean extends BaseAddressbookData
                        throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
                }
 
-               // Find contact
-               Contact managedContact = this.getEntityManager().find(UserContact.class, contact.getContactId());
+               // Set mobile number in contact
+               contact.setContactMobileNumber(mobileNumber);
 
-               // Merge phone number
-               DialableMobileNumber managedNumber = this.getEntityManager().merge(mobileNumber);
-
-               // Set fax number in contact
-               managedContact.setContactMobileNumber(managedNumber);
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingMobileNumberWithContact: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingMobileNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
 
                // Return it
-               return managedContact;
+               return updatedContact;
        }
 
        @Override
@@ -276,23 +267,17 @@ public class AddressbookAdminContactPhoneSessionBean extends BaseAddressbookData
                // Set created instance
                faxNumber.setPhoneEntryCreated(new GregorianCalendar());
 
-               // Persist it
-               this.getEntityManager().persist(faxNumber);
-
-               // Flush it
-               this.getEntityManager().flush();
-
-               // Find contact
-               Contact managedContact = this.getEntityManager().find(UserContact.class, contact.getContactId());
-
                // Set fax number in contact
-               managedContact.setContactFaxNumber(faxNumber);
+               contact.setContactFaxNumber(faxNumber);
+
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewFaxNumberWithContact: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewFaxNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
 
                // Return it
-               return managedContact;
+               return updatedContact;
        }
 
        @Override
@@ -339,23 +324,17 @@ public class AddressbookAdminContactPhoneSessionBean extends BaseAddressbookData
                // Set created instance
                landLineNumber.setPhoneEntryCreated(new GregorianCalendar());
 
-               // Persist it
-               this.getEntityManager().persist(landLineNumber);
+               // Set landLine number in contact
+               contact.setContactLandLineNumber(landLineNumber);
 
-               // Flush it
-               this.getEntityManager().flush();
-
-               // Find contact
-               Contact managedContact = this.getEntityManager().find(UserContact.class, contact.getContactId());
-
-               // Set land-line number in contact
-               managedContact.setContactLandLineNumber(landLineNumber);
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewLandLineNumberWithContact: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewLandLineNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
 
                // Return it
-               return managedContact;
+               return updatedContact;
        }
 
        @Override
@@ -396,23 +375,17 @@ public class AddressbookAdminContactPhoneSessionBean extends BaseAddressbookData
                // Set created instance
                mobileNumber.setPhoneEntryCreated(new GregorianCalendar());
 
-               // Persist it
-               this.getEntityManager().persist(mobileNumber);
+               // Set mobile number in contact
+               contact.setContactMobileNumber(mobileNumber);
 
-               // Flush it
-               this.getEntityManager().flush();
-
-               // Find contact
-               Contact managedContact = this.getEntityManager().find(UserContact.class, contact.getContactId());
-
-               // Set land-line number in contact
-               managedContact.setContactMobileNumber(mobileNumber);
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewMobileNumberWithContact: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewMobileNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
 
                // Return it
-               return managedContact;
+               return updatedContact;
        }
 
        @Override
@@ -444,17 +417,17 @@ public class AddressbookAdminContactPhoneSessionBean extends BaseAddressbookData
                        throw new IllegalArgumentException(MessageFormat.format("contact.contactFaxNumber.phoneId={0} and faxNumber.phoneId={1} are not the same.", contact.getContactFaxNumber().getPhoneId(), faxNumber.getPhoneId())); //NOI18N
                }
 
-               // Find contact
-               Contact managedContact = this.getEntityManager().find(UserContact.class, contact.getContactId());
-
                // Remove it from contact
-               managedContact.setContactFaxNumber(null);
+               contact.setContactFaxNumber(null);
+
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkFaxDataFromContact: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkFaxDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
 
                // Return it
-               return managedContact;
+               return updatedContact;
        }
 
        @Override
@@ -486,17 +459,17 @@ public class AddressbookAdminContactPhoneSessionBean extends BaseAddressbookData
                        throw new IllegalArgumentException(MessageFormat.format("contact.contactLandLineNumber.phoneId={0} and landLineNumber.phoneId={1} are not the same.", contact.getContactLandLineNumber().getPhoneId(), landLineNumber.getPhoneId())); //NOI18N
                }
 
-               // Find contact
-               Contact managedContact = this.getEntityManager().find(UserContact.class, contact.getContactId());
-
                // Remove it from contact
-               managedContact.setContactLandLineNumber(null);
+               contact.setContactLandLineNumber(null);
+
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkLandLineDataFromContact: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkLandLineDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
 
                // Return it
-               return managedContact;
+               return updatedContact;
        }
 
        @Override
@@ -528,17 +501,17 @@ public class AddressbookAdminContactPhoneSessionBean extends BaseAddressbookData
                        throw new IllegalArgumentException(MessageFormat.format("contact.contactMobileNumber.phoneId={0} and mobileNumber.phoneId={1} are not the same.", contact.getContactMobileNumber().getPhoneId(), mobileNumber.getPhoneId())); //NOI18N
                }
 
-               // Find contact
-               Contact managedContact = this.getEntityManager().find(UserContact.class, contact.getContactId());
-
                // Remove it from contact
-               managedContact.setContactMobileNumber(null);
+               contact.setContactMobileNumber(null);
+
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkMobileDataFromContact: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkMobileDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
 
                // Return it
-               return managedContact;
+               return updatedContact;
        }
 
 }
index 5cce597719e3f2ce51f708a3f90693b4a62d90d0..d5091eac2b0de1979890c0710f353db583124051 100644 (file)
@@ -20,10 +20,12 @@ import java.text.MessageFormat;
 import java.util.GregorianCalendar;
 import java.util.List;
 import java.util.Objects;
+import javax.ejb.EJB;
 import javax.ejb.Stateless;
-import javax.persistence.Query;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
 import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataAlreadyAddedException;
+import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
+import org.mxchange.jcontactsbusiness.model.basicdata.BusinessDataSessionBeanRemote;
 
 /**
  * An administrative stateless session bean for business data
@@ -38,6 +40,12 @@ public class AddressbookAdminBusinessDataSessionBean extends BaseAddressbookData
         */
        private static final long serialVersionUID = 56_389_504_892_184_572L;
 
+       /**
+        * Administrative EJB
+        */
+       @EJB
+       private BusinessDataSessionBeanRemote businessDataBean;
+
        /**
         * Default constructor
         */
@@ -61,7 +69,7 @@ public class AddressbookAdminBusinessDataSessionBean extends BaseAddressbookData
                }
 
                // Get all available entries
-               List<BusinessBasicData> list = this.allCompanyBasicData();
+               final List<BusinessBasicData> list = this.businessDataBean.allCompanyBasicData();
 
                // Is the list filled?
                if (!list.isEmpty()) {
@@ -91,23 +99,4 @@ public class AddressbookAdminBusinessDataSessionBean extends BaseAddressbookData
                return basicData;
        }
 
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<BusinessBasicData> allCompanyBasicData () {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBusinessContacts: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Get query
-               Query query = this.getEntityManager().createNamedQuery("AllBusinessData"); //NOI18N
-
-               // Get list from it
-               List<BusinessBasicData> list = query.getResultList();
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBusinessContacts: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
-
-               // Return it
-               return list;
-       }
-
 }
index eb05909ac3be0ca380320ba350c496759745e6bb..3ca7e063b329246978cde201a985e813a250370b 100644 (file)
@@ -19,12 +19,12 @@ package org.mxchange.jcontactsbusiness.basicdata;
 import java.text.MessageFormat;
 import java.util.List;
 import java.util.Objects;
-import javax.ejb.EJB;
 import javax.ejb.Stateless;
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
 import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataNotFoundException;
+import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
 
 /**
  * A stateless session bean for business data
@@ -39,12 +39,6 @@ public class AddressbookBusinessDataSessionBean extends BaseAddressbookDatabaseB
         */
        private static final long serialVersionUID = 56_389_504_892_184_571L;
 
-       /**
-        * Administrative EJB
-        */
-       @EJB
-       private AdminBusinessDataSessionBeanRemote adminBusinessDataBean;
-
        /**
         * Default constructor
         */
@@ -53,19 +47,38 @@ public class AddressbookBusinessDataSessionBean extends BaseAddressbookDatabaseB
                super();
        }
 
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<BusinessBasicData> allCompanyBasicData () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBusinessContacts: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Get query
+               final Query query = this.getEntityManager().createNamedQuery("AllBusinessData"); //NOI18N
+
+               // Get list from it
+               final List<BusinessBasicData> list = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBusinessContacts: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+               // Return it
+               return list;
+       }
+
        @Override
        public BusinessBasicData findBasicDataById (final Long companyDataId) throws BusinessDataNotFoundException {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Get query
-               Query query = this.getEntityManager().createNamedQuery("SearchBusinessDataById", CompanyBasicData.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchBusinessDataById", CompanyBasicData.class); //NOI18N
 
                // Set parameter
                query.setParameter("companyDataId", companyDataId); //NOI18N
 
                // Get single instance
-               BusinessBasicData businessData = null;
+               final BusinessBasicData businessData;
 
                // Try to find a result
                try {
@@ -104,7 +117,7 @@ public class AddressbookBusinessDataSessionBean extends BaseAddressbookDatabaseB
                Boolean isCompanyNameUsed = Boolean.FALSE;
 
                // Get whole list
-               List<BusinessBasicData> list = this.adminBusinessDataBean.allCompanyBasicData();
+               final List<BusinessBasicData> list = this.allCompanyBasicData();
 
                // Check whole list
                for (final BusinessBasicData basicData : list) {
diff --git a/src/java/org/mxchange/jcontactsbusiness/branchoffice/FinancialsAdminBranchOfficeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/branchoffice/FinancialsAdminBranchOfficeSessionBean.java
new file mode 100644 (file)
index 0000000..9e6b1cc
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * 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.branchoffice;
+
+import javax.ejb.Stateless;
+import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean;
+
+/**
+ * A stateless session bean for administrative branch office purposes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "adminBranchOffice", description = "An administrative statless bean for handling branch office data (all)")
+public class FinancialsAdminBranchOfficeSessionBean extends BaseFinancialsDatabaseBean implements AdminBranchOfficeSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 58_467_386_571_701L;
+
+}
diff --git a/src/java/org/mxchange/jcontactsbusiness/branchoffice/FinancialsBranchOfficeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/branchoffice/FinancialsBranchOfficeSessionBean.java
new file mode 100644 (file)
index 0000000..0d720c7
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * 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.branchoffice;
+
+import java.text.MessageFormat;
+import java.util.List;
+import javax.ejb.Stateless;
+import javax.persistence.Query;
+import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean;
+
+/**
+ * A stateless session bean for general branch office purposes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "branchOffice", description = "A general statless bean for handling branch office data (all)")
+public class FinancialsBranchOfficeSessionBean extends BaseFinancialsDatabaseBean implements BranchOfficeSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 58_467_386_571_701L;
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<BranchOffice> allBranchOffices () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBranchOffices: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Get query
+               final Query query = this.getEntityManager().createNamedQuery("AllBranchOffices"); //NOI18N
+
+               // Get list from it
+               final List<BranchOffice> list = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBranchOffices: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+               // Return it
+               return list;
+       }
+
+}
index 234997b6a5a2dac21af0377e30884500f1921ce3..18aa92973c2856e4d894601ea9253fb60cdc3b77 100644 (file)
@@ -51,10 +51,10 @@ public class AddressbookCompanyEmployeeSessionBean extends BaseAddressbookDataba
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCompanyEmployees(): CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Get named query
-               Query query = this.getEntityManager().createNamedQuery("AllCompanyEmployees"); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("AllCompanyEmployees"); //NOI18N
 
                // Get list form it
-               List<Employee> employees = query.getResultList();
+               final List<Employee> employees = query.getResultList();
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCompanyEmployees(): employees.size()={1} - EXIT!", this.getClass().getSimpleName(), employees.size())); //NOI18N
@@ -78,13 +78,13 @@ public class AddressbookCompanyEmployeeSessionBean extends BaseAddressbookDataba
                }
 
                // Now get named query
-               Query query = this.getEntityManager().createNamedQuery("SearchCompanyEmployeeById"); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchCompanyEmployeeById"); //NOI18N
 
                // Set parameter
                query.setParameter("employeeId", employeeId); //NOI18N
 
                // Declare instance
-               Employee employee;
+               final Employee employee;
 
                // Try to find a result
                try {
index 8d1f5a47b409a28875b65d9aa92987d7ed9bc723..751aee2c07c7cd7b0976b8d811a4afcbf84cf40e 100644 (file)
@@ -94,10 +94,10 @@ public class AddressbookCountrySingletonBean extends BaseAddressbookDatabaseBean
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCountries: CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Init query
-               Query query = this.getEntityManager().createNamedQuery("AllCountries", CountryData.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("AllCountries", CountryData.class); //NOI18N
 
                // Get list
-               List<Country> countries = query.getResultList();
+               final List<Country> countries = query.getResultList();
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCountries: countries.size()={1} - EXIT!", this.getClass().getSimpleName(), countries.size())); //NOI18N
@@ -133,7 +133,7 @@ public class AddressbookCountrySingletonBean extends BaseAddressbookDatabaseBean
                boolean isAdded = false;
 
                // Get query instance
-               Query query = this.getEntityManager().createNamedQuery("SearchCountryByCodeI18nKey", CountryData.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchCountryByCodeI18nKey", CountryData.class); //NOI18N
 
                // Assign all parameters
                query.setParameter("code", country.getCountryCode()); //NOI18N
@@ -142,7 +142,7 @@ public class AddressbookCountrySingletonBean extends BaseAddressbookDatabaseBean
                // Try to get a single result
                try {
                        // Get single result
-                       Country foundCountry = (Country) query.getSingleResult();
+                       final Country foundCountry = (Country) query.getSingleResult();
 
                        // Found it?
                        isAdded = (foundCountry instanceof Country);
index 3de71394963f9c27ee1e3c85a49870f074c83dcc..1877f08f014de0fe32612eaf6d7720161a625065 100644 (file)
@@ -47,15 +47,15 @@ public class AddressbookMobileProviderSingletonBean extends BaseAddressbookDatab
 
        @Override
        @SuppressWarnings ("unchecked")
-       public List<MobileProvider> allMobileProvider () {
+       public List<MobileProvider> allMobileProviders () {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileProvider: CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Init query
-               Query query = this.getEntityManager().createNamedQuery("AllMobileProvider", CellphoneProvider.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("AllMobileProvider", CellphoneProvider.class); //NOI18N
 
                // Get list from it
-               List<MobileProvider> mobileProviders = query.getResultList();
+               final List<MobileProvider> mobileProviders = query.getResultList();
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileProvider: mobileProviders.size()={1} - EXIT!", this.getClass().getSimpleName(), mobileProviders.size())); //NOI18N
index 1d63242ca9e3b204d9aa017f34627d4e90237a72..3b5a5d4955b30a180e3c7c595b33f73c534494c3 100644 (file)
@@ -20,12 +20,12 @@ 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.fax.FaxNumbers;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.landline.LandLineNumbers;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.mobile.MobileNumbers;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.fax.FaxNumbers;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumbers;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumbers;
 
 /**
  * An EJB for administrative phone purposes
@@ -87,7 +87,7 @@ public class AddressbookAdminPhoneSessionBean extends BaseAddressbookDatabaseBea
                }
 
                // Get a managed instance
-               DialableFaxNumber managedNumber = this.getEntityManager().getReference(faxNumber.getClass(), faxNumber.getPhoneId());
+               final DialableFaxNumber managedNumber = this.getEntityManager().getReference(faxNumber.getClass(), faxNumber.getPhoneId());
 
                // Remove it from database
                this.getEntityManager().remove(managedNumber);
@@ -135,7 +135,7 @@ public class AddressbookAdminPhoneSessionBean extends BaseAddressbookDatabaseBea
                }
 
                // Get a managed instance
-               DialableLandLineNumber managedNumber = this.getEntityManager().getReference(landLineNumber.getClass(), landLineNumber.getPhoneId());
+               final DialableLandLineNumber managedNumber = this.getEntityManager().getReference(landLineNumber.getClass(), landLineNumber.getPhoneId());
 
                // Remove it from database
                this.getEntityManager().remove(managedNumber);
@@ -177,7 +177,7 @@ public class AddressbookAdminPhoneSessionBean extends BaseAddressbookDatabaseBea
                }
 
                // Get a managed instance
-               DialableMobileNumber managedNumber = this.getEntityManager().getReference(mobileNumber.getClass(), mobileNumber.getPhoneId());
+               final DialableMobileNumber managedNumber = this.getEntityManager().getReference(mobileNumber.getClass(), mobileNumber.getPhoneId());
 
                // Remove it from database
                this.getEntityManager().remove(managedNumber);
@@ -225,7 +225,7 @@ public class AddressbookAdminPhoneSessionBean extends BaseAddressbookDatabaseBea
                }
 
                // Get contact from it and find it
-               DialableFaxNumber managedNumber = this.getEntityManager().find(faxNumber.getClass(), faxNumber.getPhoneId());
+               final DialableFaxNumber managedNumber = this.getEntityManager().find(faxNumber.getClass(), faxNumber.getPhoneId());
 
                // Should be found
                assert (managedNumber instanceof DialableFaxNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", faxNumber.getPhoneId()); //NOI18N
@@ -283,7 +283,7 @@ public class AddressbookAdminPhoneSessionBean extends BaseAddressbookDatabaseBea
                }
 
                // Get contact from it and find it
-               DialableLandLineNumber managedNumber = this.getEntityManager().find(landLineNumber.getClass(), landLineNumber.getPhoneId());
+               final DialableLandLineNumber managedNumber = this.getEntityManager().find(landLineNumber.getClass(), landLineNumber.getPhoneId());
 
                // Should be found
                assert (managedNumber instanceof DialableLandLineNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", landLineNumber.getPhoneId()); //NOI18N
@@ -335,7 +335,7 @@ public class AddressbookAdminPhoneSessionBean extends BaseAddressbookDatabaseBea
                }
 
                // Get contact from it and find it
-               DialableMobileNumber managedNumber = this.getEntityManager().find(mobileNumber.getClass(), mobileNumber.getPhoneId());
+               final DialableMobileNumber managedNumber = this.getEntityManager().find(mobileNumber.getClass(), mobileNumber.getPhoneId());
 
                // Should be found
                assert (managedNumber instanceof DialableMobileNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", mobileNumber.getPhoneId()); //NOI18N
index 63084f5470f1610f851c8181c2b6ea1d16c782dd..4bae357a7383912cdedb5965fa4f48b9575109e4 100644 (file)
@@ -23,12 +23,12 @@ import javax.persistence.NoResultException;
 import javax.persistence.Query;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
 import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.mobile.MobileNumber;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
 
 /**
  * A general phone EJB
@@ -58,10 +58,10 @@ public class AddressbookPhoneSessionBean extends BaseAddressbookDatabaseBean imp
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allFaxNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Get query
-               Query query = this.getEntityManager().createNamedQuery("AllFaxNumbers", FaxNumber.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("AllFaxNumbers", FaxNumber.class); //NOI18N
 
                // Get list from it
-               List<DialableFaxNumber> list = query.getResultList();
+               final List<DialableFaxNumber> list = query.getResultList();
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allFaxNumbers: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
@@ -77,10 +77,10 @@ public class AddressbookPhoneSessionBean extends BaseAddressbookDatabaseBean imp
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allLandLineNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Get query
-               Query query = this.getEntityManager().createNamedQuery("AllLandLineNumbers", LandLineNumber.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("AllLandLineNumbers", LandLineNumber.class); //NOI18N
 
                // Get list from it
-               List<DialableLandLineNumber> list = query.getResultList();
+               final List<DialableLandLineNumber> list = query.getResultList();
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allLandLineNumbers: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
@@ -96,10 +96,10 @@ public class AddressbookPhoneSessionBean extends BaseAddressbookDatabaseBean imp
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Get query
-               Query query = this.getEntityManager().createNamedQuery("AllMobileNumbers", MobileNumber.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("AllMobileNumbers", MobileNumber.class); //NOI18N
 
                // Get list from it
-               List<DialableMobileNumber> list = query.getResultList();
+               final List<DialableMobileNumber> list = query.getResultList();
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileNumbers: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
@@ -123,13 +123,13 @@ public class AddressbookPhoneSessionBean extends BaseAddressbookDatabaseBean imp
                }
 
                // Now find it
-               Query query = this.getEntityManager().createNamedQuery("SearchFaxNumberId", FaxNumber.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchFaxNumberId", FaxNumber.class); //NOI18N
 
                // Set parameter
                query.setParameter("faxNumberId", faxNumberId); //NOI18N
 
                // Init instance
-               DialableFaxNumber faxNumber = null;
+               final DialableFaxNumber faxNumber;
 
                // Try to get a result
                try {
@@ -141,7 +141,7 @@ public class AddressbookPhoneSessionBean extends BaseAddressbookDatabaseBean imp
                }
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findFaxNumberById: cellphone={1} - EXIT!", this.getClass().getSimpleName(), faxNumber)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findFaxNumberById: mobile={1} - EXIT!", this.getClass().getSimpleName(), faxNumber)); //NOI18N
 
                // Return found instance
                return faxNumber;
@@ -162,13 +162,13 @@ public class AddressbookPhoneSessionBean extends BaseAddressbookDatabaseBean imp
                }
 
                // Now find it
-               Query query = this.getEntityManager().createNamedQuery("SearchLandLineNumberId", LandLineNumber.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchLandLineNumberId", LandLineNumber.class); //NOI18N
 
                // Set parameter
                query.setParameter("landLineNumberId", landLineNumberId); //NOI18N
 
                // Init instance
-               DialableLandLineNumber landLineNumber = null;
+               final DialableLandLineNumber landLineNumber;
 
                // Try to get a result
                try {
@@ -180,7 +180,7 @@ public class AddressbookPhoneSessionBean extends BaseAddressbookDatabaseBean imp
                }
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findLandLineNumberById: cellphone={1} - EXIT!", this.getClass().getSimpleName(), landLineNumber)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findLandLineNumberById: mobile={1} - EXIT!", this.getClass().getSimpleName(), landLineNumber)); //NOI18N
 
                // Return found instance
                return landLineNumber;
@@ -201,28 +201,28 @@ public class AddressbookPhoneSessionBean extends BaseAddressbookDatabaseBean imp
                }
 
                // Now find it
-               Query query = this.getEntityManager().createNamedQuery("SearchMobileNumberId", MobileNumber.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchMobileNumberId", MobileNumber.class); //NOI18N
 
                // Set parameter
                query.setParameter("mobileNumberId", mobileNumberId); //NOI18N
 
                // Init instance
-               DialableMobileNumber cellphone = null;
+               final DialableMobileNumber mobile;
 
                // Try to get a result
                try {
                        // Get a single result
-                       cellphone = (DialableMobileNumber) query.getSingleResult();
+                       mobile = (DialableMobileNumber) query.getSingleResult();
                } catch (NoResultException ex) {
                        // The entry was not found, so throw it again
                        throw new PhoneEntityNotFoundException(mobileNumberId, ex);
                }
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findMobileNumberById: cellphone={1} - EXIT!", this.getClass().getSimpleName(), cellphone)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findMobileNumberById: mobile={1} - EXIT!", this.getClass().getSimpleName(), mobile)); //NOI18N
 
                // Return found instance
-               return cellphone;
+               return mobile;
        }
 
 }
index e2e86d78995ca1101210e9137c89378574e44a00..5648a7cb8d7496bb3a210d243ab8139cbbd81033 100644 (file)
@@ -21,7 +21,7 @@ import java.util.GregorianCalendar;
 import javax.ejb.EJB;
 import javax.ejb.Stateless;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
-import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
 import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
@@ -140,7 +140,7 @@ public class AddressbookAdminUserSessionBean extends BaseAddressbookDatabaseBean
                }
 
                // Get a managed instance
-               User managedUser = this.getManagedUser(user);
+               final 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
@@ -182,13 +182,10 @@ public class AddressbookAdminUserSessionBean extends BaseAddressbookDatabaseBean
                }
 
                // Try to find the contact
-               Contact managedContact = this.getEntityManager().find(user.getUserContact().getClass(), user.getUserContact().getContactId());
-
-               // Should be found!
-               assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", user.getUserContact().getContactId()); //NOI18N
+               final Contact foundContact = this.getEntityManager().find(user.getUserContact().getClass(), user.getUserContact().getContactId());
 
                // Set detached object in rexcruiter instance
-               user.setUserContact(managedContact);
+               user.setUserContact(foundContact);
 
                // Set timestamp
                user.setUserCreated(new GregorianCalendar());
@@ -259,18 +256,18 @@ public class AddressbookAdminUserSessionBean extends BaseAddressbookDatabaseBean
                user.setUserLastLockedReason(userLockReason);
 
                // Update user
-               User managedUser = this.userBean.updateUserData(user);
+               final User updatedUser = this.userBean.updateUserData(user);
 
                // @TODO Create user lock history entry
                // Send out email
                // @TODO externalize subject line
-               this.sendEmail("User account locked", "user_account_locked", managedUser, baseUrl, null); //NOI18N
+               this.sendEmail("User account locked", "user_account_locked", updatedUser, baseUrl, null); //NOI18N
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.lockUserAccount: managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.lockUserAccount: updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N
 
                // Return detached (and updated) user
-               return managedUser;
+               return updatedUser;
        }
 
        @Override
@@ -318,18 +315,18 @@ public class AddressbookAdminUserSessionBean extends BaseAddressbookDatabaseBean
                user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
 
                // Update user
-               User managedUser = this.userBean.updateUserData(user);
+               final User updatedUser = this.userBean.updateUserData(user);
 
                // @TODO Create user lock history entry
                // Send out email
                // @TODO externalize subject line
-               this.sendEmail("User account unlocked", "user_account_unlocked", managedUser, baseUrl, null); //NOI18N
+               this.sendEmail("User account unlocked", "user_account_unlocked", updatedUser, baseUrl, null); //NOI18N
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.lockUserAccount: managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.lockUserAccount: updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N
 
                // Return changed account
-               return managedUser;
+               return updatedUser;
        }
 
 }
index 093283ab36fd337111a4483557abc706323ef1de..01d9083dc684f8d2f007b1749fcfe99af258ff91 100644 (file)
@@ -26,14 +26,14 @@ import javax.persistence.NoResultException;
 import javax.persistence.PersistenceException;
 import javax.persistence.Query;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.ContactUtils;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.fax.FaxNumbers;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.landline.LandLineNumbers;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.mobile.MobileNumbers;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontacts.model.contact.ContactUtils;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.fax.FaxNumbers;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumbers;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumbers;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
 import org.mxchange.jusercore.exceptions.UserStatusLockedException;
@@ -78,7 +78,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMemberPublicVisibleUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Get named query
-               Query query = this.getEntityManager().createNamedQuery("AllMemberPublicUsers", LoginUser.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("AllMemberPublicUsers", LoginUser.class); //NOI18N
 
                // Set parameters
                query.setParameter("status", UserAccountStatus.CONFIRMED); //NOI18N
@@ -86,7 +86,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                query.setParameter("public", ProfileMode.PUBLIC); //NOI18N
 
                // Get result
-               List<User> users = query.getResultList();
+               final List<User> users = query.getResultList();
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMemberPublicVisibleUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N
@@ -102,14 +102,14 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allPublicUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Get named query
-               Query query = this.getEntityManager().createNamedQuery("AllPublicUsers", LoginUser.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("AllPublicUsers", LoginUser.class); //NOI18N
 
                // Set parameters
                query.setParameter("status", UserAccountStatus.CONFIRMED); //NOI18N
                query.setParameter("mode", ProfileMode.PUBLIC); //NOI18N
 
                // Get result
-               List<User> users = query.getResultList();
+               final List<User> users = query.getResultList();
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allPublicUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N
@@ -118,6 +118,25 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                return users;
        }
 
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<String> allUserNames () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserNameList: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Get query
+               final Query query = this.getEntityManager().createNamedQuery("AllUserNames", String.class); //NOI18N
+
+               // Get result list
+               final List<String> userNameList = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserNameList: userNameList.size()={1} - EXIT!", this.getClass().getSimpleName(), userNameList.size())); //NOI18N
+
+               // Return it
+               return userNameList;
+       }
+
        @Override
        @SuppressWarnings ("unchecked")
        public List<User> allUsers () {
@@ -125,10 +144,10 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Get named query
-               Query query = this.getEntityManager().createNamedQuery("AllUsers", LoginUser.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("AllUsers", LoginUser.class); //NOI18N
 
                // Get result
-               List<User> users = query.getResultList();
+               final List<User> users = query.getResultList();
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N
@@ -161,16 +180,10 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                } else if (user.getUserConfirmKey() == null) {
                        // Throw NPE
                        throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
-               } else if (null == baseUrl) {
-                       // Throw it again
-                       throw new NullPointerException("baseUrl is null"); //NOI18N
-               } else if (baseUrl.isEmpty()) {
-                       // Invalid parameter
-                       throw new IllegalArgumentException("baseUrl is empty"); //NOI18N
                }
 
                // Update user account
-               User managedUser = this.updateUserData(user);
+               final User managedUser = this.updateUserData(user);
 
                // Update user status and remove confirmation key
                managedUser.setUserAccountStatus(UserAccountStatus.CONFIRMED);
@@ -188,7 +201,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
        }
 
        @Override
-       public User fillUserData (final User user) {
+       public User fillUserData (final User user) throws UserNotFoundException {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fillUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
 
@@ -196,16 +209,25 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                if (null == user) {
                        // Abort here
                        throw new NullPointerException("user is null"); //NOI18N
+               } else if (user.getUserName() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("user.userName is null");
+               } else if (user.getUserName().isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("user.userName is empty");
+               } else if (!this.ifUserExists(user)) {
+                       // User does not exist
+                       throw new UserNotFoundException(user);
                }
 
                // Try to locate it
-               Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
 
                // Set parameter
                query.setParameter("userName", user.getUserName()); //NOI18N
 
                // Initialize variable
-               User foundUser = null;
+               final User foundUser;
 
                // Try it
                try {
@@ -214,6 +236,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                } catch (final NoResultException ex) {
                        // Log it
                        this.getLoggerBeanLocal().logException(ex);
+                       return null;
                }
 
                // Trace message
@@ -241,13 +264,13 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                }
 
                // Create query instance
-               Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
 
                // Set user id
                query.setParameter("id", userId); //NOI18N
 
                // Fetch the result, it should be there by now
-               User user = (User) query.getSingleResult();
+               final User user = (User) query.getSingleResult();
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findUserById: user={1} - EXIT!", this.getClass().getSimpleName(), user)); //NOI18N
@@ -262,7 +285,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.generateRandomUserName - CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Get full list
-               List<String> userList = this.getUserNameList();
+               final List<String> userList = this.allUserNames();
 
                // Init variable
                String userName = null;
@@ -287,10 +310,10 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Get query
-               Query query = this.getEntityManager().createNamedQuery("AllEmailAddresses", String.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("AllEmailAddresses", String.class); //NOI18N
 
                // Get result list
-               List<String> emailAddressList = query.getResultList();
+               final List<String> emailAddressList = query.getResultList();
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: emailAddressList.size()={1} - EXIT!", this.getClass().getSimpleName(), emailAddressList.size())); //NOI18N
@@ -299,25 +322,6 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                return emailAddressList;
        }
 
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<String> getUserNameList () {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserNameList: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Get query
-               Query query = this.getEntityManager().createNamedQuery("AllUserNames", String.class); //NOI18N
-
-               // Get result list
-               List<String> userNameList = query.getResultList();
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserNameList: userNameList.size()={1} - EXIT!", this.getClass().getSimpleName(), userNameList.size())); //NOI18N
-
-               // Return it
-               return userNameList;
-       }
-
        @Override
        public boolean ifUserExists (final User user) {
                // Trace message
@@ -336,14 +340,15 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                }
 
                // Generate query
-               Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
 
                // Set parameter
                query.setParameter("id", user.getUserId()); //NOI18N
 
                // Try this
                try {
-                       User dummy = (User) query.getSingleResult();
+                       // Try to get single result
+                       final User dummy = (User) query.getSingleResult();
 
                        // Debug message
                        this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserExists: dummy.id={0} found.", dummy.getUserId())); //NOI18N
@@ -383,14 +388,15 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                }
 
                // Generate query
-               Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
 
                // Set parameter
                query.setParameter("id", userId); //NOI18N
 
                // Try this
                try {
-                       User dummy = (User) query.getSingleResult();
+                       // Try to get single result
+                       final User dummy = (User) query.getSingleResult();
 
                        // Debug message
                        this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserIdExists: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
@@ -430,14 +436,15 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                }
 
                // Generate query
-               Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
 
                // Set parameter
                query.setParameter("userName", userName); //NOI18N
 
                // Try this
                try {
-                       User dummy = (User) query.getSingleResult();
+                       // Try to get single result
+                       final User dummy = (User) query.getSingleResult();
 
                        // Debug message
                        this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserNameExists: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
@@ -468,14 +475,15 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                }
 
                // Generate query
-               Query query = this.getEntityManager().createNamedQuery("SearchUserByEmailAddress", LoginUser.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchUserByEmailAddress", LoginUser.class); //NOI18N
 
                // Set parameter
                query.setParameter("emailAddress", user.getUserContact().getContactEmailAddress()); //NOI18N
 
                // Search for it
                try {
-                       User dummy = (User) query.getSingleResult();
+                       // Try to get single result
+                       final User dummy = (User) query.getSingleResult();
 
                        // Debug message
                        this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
@@ -512,14 +520,15 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                }
 
                // Generate query
-               Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
 
                // Set parameter
                query.setParameter("userName", user.getUserName()); //NOI18N
 
                // Try this
                try {
-                       User dummy = (User) query.getSingleResult();
+                       // Try to get single result
+                       final User dummy = (User) query.getSingleResult();
 
                        // Debug message
                        this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isUserNameRegistered: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
@@ -571,13 +580,19 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                user.setUserContact(null);
 
                // Find the instance
-               User managedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
+               final User foundUser = this.getEntityManager().find(user.getClass(), user.getUserId());
 
                // Should be found!
-               assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
+               assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
+
+               // Merge user
+               final User managedUser = this.getEntityManager().merge(foundUser);
+
+               // Should be found!
+               assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not merged, but should be.", managedUser.getUserId()); //NOI18N
 
                // Copy all data
-               UserUtils.copyAll(user, managedUser);
+               UserUtils.copyAll(managedUser, managedUser);
 
                // Set as updated
                managedUser.setUserUpdated(new GregorianCalendar());
@@ -637,7 +652,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                }
 
                // Call other method
-               User managedUser = this.updateUserData(user);
+               final User managedUser = this.updateUserData(user);
 
                // Update user account
                managedUser.setUserUpdated(new GregorianCalendar());
@@ -649,15 +664,12 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                entry.setUserPasswordHistoryCreated(new GregorianCalendar());
 
                // Merge user to make sure it is not re-persisted
-               User mergedUser = this.getEntityManager().merge(managedUser);
+               final User mergedUser = this.getEntityManager().merge(managedUser);
                entry.setUserPasswordHistoryUser(mergedUser);
 
                // Persist it
                this.getEntityManager().persist(entry);
 
-               // Flush it to get id number back
-               this.getEntityManager().flush();
-
                // Send email to user
                this.sendEmail("User password change", "user_password_change", managedUser, baseUrl, null); //NOI18N
 
@@ -692,7 +704,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                }
 
                // Find the instance
-               User managedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
+               final User managedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
 
                // Should be found!
                assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
@@ -705,25 +717,28 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                managedUser.getUserContact().setContactUpdated(new GregorianCalendar());
 
                // Get contact from it and find it
-               Contact managedContact = this.getEntityManager().find(user.getUserContact().getClass(), user.getUserContact().getContactId());
+               final Contact foundContact = this.getEntityManager().find(managedUser.getUserContact().getClass(), managedUser.getUserContact().getContactId());
 
                // Should be found
-               assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", user.getUserContact().getContactId()); //NOI18N
+               assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", managedUser.getUserContact().getContactId()); //NOI18N
 
                // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: managedContact.contactId={0}", managedContact.getContactId())); //NOI18N
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: contact.contactId={0}", foundContact.getContactId())); //NOI18N
+
+               // Merge contact instance
+               final Contact managedContact = this.getEntityManager().merge(foundContact);
 
                // Copy all
-               ContactUtils.copyAll(user.getUserContact(), managedContact);
+               ContactUtils.copyAll(managedUser.getUserContact(), managedContact);
 
                // Set it back in user
-               user.setUserContact(managedContact);
+               managedUser.setUserContact(managedContact);
 
                // Should be found!
-               assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not merged, but should be.", user.getUserContact().getContactId()); //NOI18N
+               assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not merged, but should be.", managedUser.getUserContact().getContactId()); //NOI18N
 
                // Get mobile instance
-               DialableMobileNumber mobileNumber = managedContact.getContactMobileNumber();
+               final DialableMobileNumber mobileNumber = managedContact.getContactMobileNumber();
 
                // Is there a  mobile instance set?
                if (mobileNumber instanceof DialableMobileNumber) {
@@ -731,13 +746,13 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                        this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: mobile.phoneId={0} is being updated ...", mobileNumber.getPhoneId())); //NOI18N
 
                        // Then find it, too
-                       DialableMobileNumber foundMobile = this.getEntityManager().find(mobileNumber.getClass(), mobileNumber.getPhoneId());
+                       final DialableMobileNumber foundMobile = this.getEntityManager().find(mobileNumber.getClass(), mobileNumber.getPhoneId());
 
                        // Should be there
                        assert (foundMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", foundMobile.getPhoneId()); //NOI18N
 
                        // Then merge it, too
-                       DialableMobileNumber managedMobile = this.getEntityManager().merge(foundMobile);
+                       final DialableMobileNumber managedMobile = this.getEntityManager().merge(foundMobile);
 
                        // Should be there
                        assert (managedMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", managedMobile.getPhoneId()); //NOI18N
@@ -746,25 +761,25 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                        MobileNumbers.copyAll(managedUser.getUserContact().getContactMobileNumber(), managedMobile);
 
                        // Set it back
-                       managedContact.setContactMobileNumber(this.getManaged(mobileNumber, mobileNumber));
+                       managedContact.setContactMobileNumber(managedMobile);
                }
 
                // Get mobile instance
-               DialableFaxNumber faxNumber = managedContact.getContactFaxNumber();
+               final DialableFaxNumber faxNumber = managedContact.getContactFaxNumber();
 
                // Is there a  fax instance set?
                if (faxNumber instanceof DialableFaxNumber) {
                        // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: faxNumber.phoneId={0} is being updated ...", faxNumber.getPhoneId())); //NOI18N
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: fax.phoneId={0} is being updated ...", faxNumber.getPhoneId())); //NOI18N
 
                        // Then find it, too
-                       DialableFaxNumber foundFax = this.getEntityManager().find(faxNumber.getClass(), faxNumber.getPhoneId());
+                       final DialableFaxNumber foundFax = this.getEntityManager().find(faxNumber.getClass(), faxNumber.getPhoneId());
 
                        // Should be there
                        assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N
 
                        // Then merge it, too
-                       DialableFaxNumber managedFax = this.getEntityManager().merge(foundFax);
+                       final DialableFaxNumber managedFax = this.getEntityManager().merge(foundFax);
 
                        // Should be there
                        assert (managedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", managedFax.getPhoneId()); //NOI18N
@@ -777,21 +792,21 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                }
 
                // Get mobile instance
-               DialableLandLineNumber landLineNumber = managedContact.getContactLandLineNumber();
+               final DialableLandLineNumber landLineNumber = managedContact.getContactLandLineNumber();
 
                // Is there a  fax instance set?
                if (landLineNumber instanceof DialableLandLineNumber) {
                        // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLineNumber.phoneId={0} is being updated ...", landLineNumber.getPhoneId())); //NOI18N
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLine.phoneId={0} is being updated ...", landLineNumber.getPhoneId())); //NOI18N
 
                        // Then find it, too
-                       DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLineNumber.getClass(), landLineNumber.getPhoneId());
+                       final DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLineNumber.getClass(), landLineNumber.getPhoneId());
 
                        // Should be there
                        assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId()); //NOI18N
 
                        // Then merge it, too
-                       DialableLandLineNumber managedLandLine = this.getEntityManager().merge(foundLandLine);
+                       final DialableLandLineNumber managedLandLine = this.getEntityManager().merge(foundLandLine);
 
                        // Should be there
                        assert (managedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", managedLandLine.getPhoneId()); //NOI18N
index 4d8b70e29ee533c65317078bbb280a0658df24ae..a069dc1c3aaef7030e7e4d929d3c1d17316af732 100644 (file)
@@ -76,10 +76,10 @@ public class AddressbookUserActivityLogMessageBean extends BaseAddressbookDataba
                }
 
                // Securely cast it
-               ObjectMessage objectMessage = (ObjectMessage) message;
+               final ObjectMessage objectMessage = (ObjectMessage) message;
 
                // Init variable
-               Serializable serializable;
+               final Serializable serializable;
 
                try {
                        // Get object from message
@@ -103,7 +103,7 @@ public class AddressbookUserActivityLogMessageBean extends BaseAddressbookDataba
                }
 
                // Securely cast it
-               LogableUserActivity userActivity = (LogableUserActivity) serializable;
+               final LogableUserActivity userActivity = (LogableUserActivity) serializable;
 
                // Should be valid
                if (null == userActivity) {
@@ -136,7 +136,7 @@ public class AddressbookUserActivityLogMessageBean extends BaseAddressbookDataba
                }
 
                // Make user instance managed
-               User managedUser = this.getManagedUser(userActivity.getActivityUser());
+               final User managedUser = this.getManagedUser(userActivity.getActivityUser());
 
                // Set it back
                userActivity.setActivityUser(managedUser);
index 008e75d25369f04168fd312ceb80c3b95a02c5b7..baa607b871ae57b4ee6742b67d40c2402c023a75 100644 (file)
@@ -64,10 +64,10 @@ public class AddressbookUserEmailChangeSessionBean extends BaseAddressbookDataba
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allQueuedAddresses: CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Get named query
-               Query query = this.getEntityManager().createNamedQuery("AllEmailAddressChanges", String.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("AllEmailAddressChanges", String.class); //NOI18N
 
                // Get all entries
-               List<String> emailAddresses = query.getResultList();
+               final List<String> emailAddresses = query.getResultList();
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allQueuedAddresses: emailAddresses.size()={1} - EXIT!", this.getClass().getSimpleName(), emailAddresses.size())); //NOI18N
@@ -125,7 +125,7 @@ public class AddressbookUserEmailChangeSessionBean extends BaseAddressbookDataba
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressEnqueued: emailAddress={1} - CALLED!", this.getClass().getSimpleName(), emailAddress)); //NOI18N
 
                // Create query instance
-               Query query = this.getEntityManager().createNamedQuery("SearchEmailChangeByEmail"); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchEmailChangeByEmail"); //NOI18N
 
                // Add email address as parameter
                query.setParameter("email", emailAddress); //NOI18N
@@ -136,7 +136,7 @@ public class AddressbookUserEmailChangeSessionBean extends BaseAddressbookDataba
                // Try it
                try {
                        // Try to get single result
-                       ChangeableEmailAddress dummy = (ChangeableEmailAddress) query.getSingleResult();
+                       final ChangeableEmailAddress dummy = (ChangeableEmailAddress) query.getSingleResult();
 
                        // Found it
                        isFound = true;
@@ -209,7 +209,7 @@ public class AddressbookUserEmailChangeSessionBean extends BaseAddressbookDataba
                        hash = UserLoginUtils.encryptPassword(String.format("%s:%s", emailAddress.getEmailAddress(), emailAddress.toString())); //NOI18N
 
                        // The hash *may* be unique, better test it
-                       Query query = this.getEntityManager().createNamedQuery("SearchEmailChangeByHash", EmailAddressChange.class); //NOI18N
+                       final Query query = this.getEntityManager().createNamedQuery("SearchEmailChangeByHash", EmailAddressChange.class); //NOI18N
 
                        // Set hash as parameter
                        query.setParameter("hash", hash); //NOI18N
@@ -217,7 +217,7 @@ public class AddressbookUserEmailChangeSessionBean extends BaseAddressbookDataba
                        // Try to get single result
                        try {
                                // Get single result
-                               ChangeableEmailAddress dummy = (ChangeableEmailAddress) query.getSingleResult();
+                               final ChangeableEmailAddress dummy = (ChangeableEmailAddress) query.getSingleResult();
                        } catch (final NoResultException ex) {
                                // Not found
                                isUsed = false;
index dfb25030b92b1b082e50a71d2272729c7cc1434a..d8855b3602059f682f50ef6f67e28cc8fc48c057 100644 (file)
@@ -63,13 +63,13 @@ public class AddressbookUserPasswordHistorySessionBean extends BaseAddressbookDa
                }
 
                // Get named query
-               Query query = this.getEntityManager().createNamedQuery("AllUsersHistoryEntries", UserPasswordHistory.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("AllUsersHistoryEntries", UserPasswordHistory.class); //NOI18N
 
                // Set parameter
                query.setParameter("user", user); //NOI18N
 
                // Get full history
-               List<PasswordHistory> history = query.getResultList();
+               final List<PasswordHistory> history = query.getResultList();
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserPasswordHistory(): history.size()={1} - EXIT !", this.getClass().getSimpleName(), history.size())); //NOI18N
index b0f4cf479b0f62d413b8de05af21b74682395ede..dd9c8fb8d941e475aeb95d2a6abc97030246424a 100644 (file)
@@ -95,7 +95,7 @@ public class AddressbookUserLoginSessionBean extends BaseAddressbookDatabaseBean
                }
 
                // Get user instance from persistance
-               User updatedUser = this.userBean.fillUserData(container.getUser());
+               final User updatedUser = this.userBean.fillUserData(container.getUser());
 
                // Debug message
                this.getLoggerBeanLocal().logDebug(MessageFormat.format("loginUser: updatedUser={0}", updatedUser)); //NOI18N
index 60bade06ee21b7f3467cdda2062daa1372eaffb5..4a514f8f55145bc83973f1fa09142079436b325b 100644 (file)
@@ -77,7 +77,7 @@ public class AddressbookUserRegistrationSessionBean extends BaseAddressbookDatab
                }
 
                // Create named instance
-               Query query = this.getEntityManager().createNamedQuery("SearchUserByConfirmKey", LoginUser.class); //NOI18N
+               final Query query = this.getEntityManager().createNamedQuery("SearchUserByConfirmKey", LoginUser.class); //NOI18N
 
                // Init confirmation key
                String confirmationKey = null;
@@ -85,7 +85,7 @@ public class AddressbookUserRegistrationSessionBean extends BaseAddressbookDatab
                // Find a free one
                while (confirmationKey == null) {
                        // Create new one
-                       String key = UserLoginUtils.generatedConfirmationKey(user);
+                       final String key = UserLoginUtils.generatedConfirmationKey(user);
 
                        // Set key as parameter
                        query.setParameter("confirmKey", key); //NOI18N
@@ -93,7 +93,7 @@ public class AddressbookUserRegistrationSessionBean extends BaseAddressbookDatab
                        // Try it
                        try {
                                // Get contact instance
-                               Contact contact = (Contact) query.getSingleResult();
+                               final Contact contact = (Contact) query.getSingleResult();
 
                                // Warning message
                                this.getLoggerBeanLocal().logWarning(MessageFormat.format("{0}.generateConfirmationKey: key {1} already found: contact.contactId={2}", this.getClass().getSimpleName(), key, contact.getContactId())); //NOI18N
@@ -177,7 +177,7 @@ public class AddressbookUserRegistrationSessionBean extends BaseAddressbookDatab
                }
 
                // Call other EJB
-               User addedUser = this.adminUserBean.addUser(user);
+               final User addedUser = this.adminUserBean.addUser(user);
 
                // Default template is with no random password
                String templateName = "user_registration"; //NOI18N
index 77d5f446aa1e047e120f73dc599e3fdb36072597..f879b063cd56ac1814f7010dfa9c556f87155dbd 100644 (file)
@@ -96,13 +96,13 @@ public class AddressbookResendLinkSessionBean extends BaseAddressbookDatabaseBea
                }
 
                // Get new registration key
-               String confirmationKey = this.registerBean.generateConfirmationKey(user);
+               final String confirmationKey = this.registerBean.generateConfirmationKey(user);
 
                // Debug message
                this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.resendConfirmationLink: confirmationKey={1}", this.getClass().getSimpleName(), confirmationKey)); //NOI18N
 
                // Get managed instance
-               User managedUser = this.getEntityManager().find(LoginUser.class, user.getUserId());
+               final User managedUser = this.getEntityManager().find(LoginUser.class, user.getUserId());
 
                // Set it in user
                managedUser.setUserConfirmKey(confirmationKey);