]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Please cherry-pick:
authorRoland Haeder <roland@mxchange.org>
Thu, 6 Jul 2017 08:19:36 +0000 (10:19 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 10 Jul 2017 07:53:55 +0000 (09:53 +0200)
- It is generally beanHelper ...

src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java

index 735134d72c7ee39441786a22070d39e74ebe8167..4bdd8372697960fdc75b613f86b3832ec1ea70de 100644 (file)
-/*
- * Copyright (C) 2016, 2017 Roland Häder GmbH
- *
- * 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.jfinancials.beans.helper;
-
-import java.text.MessageFormat;
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.inject.Named;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jfinancials.beans.contact.FinancialsAdminContactWebRequestController;
-import org.mxchange.jfinancials.beans.phone.FinancialsAdminPhoneWebRequestController;
-import org.mxchange.jfinancials.beans.user.FinancialsAdminUserWebRequestController;
-import org.mxchange.jfinancials.beans.user.FinancialsUserWebSessionController;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A general helper for beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("adminHelper")
-@RequestScoped
-public class FinancialsWebRequestHelperBean implements FinancialsWebRequestHelperController {
-
-       /**
-        * Call-stack instance (5 may show BeanELResolver.getValue as caller)
-        */
-       private static final short THREAD_STACK = 5;
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 17_258_793_567_145_701L;
-
-       /**
-        * Administrative contact controller
-        */
-       @Inject
-       private FinancialsAdminContactWebRequestController adminContactController;
-
-       /**
-        * Administrative phone controller
-        */
-       @Inject
-       private FinancialsAdminPhoneWebRequestController adminPhoneController;
-
-       /**
-        * Administrative user controller
-        */
-       @Inject
-       private FinancialsAdminUserWebRequestController adminUserController;
-
-       /**
-        * Contact instance
-        */
-       private Contact contact;
-
-       /**
-        * Fax number
-        */
-       private DialableFaxNumber faxNumber;
-
-       /**
-        * Land-line number
-        */
-       private DialableLandLineNumber landLineNumber;
-
-       /**
-        * Mobile number
-        */
-       private DialableMobileNumber mobileNumber;
-
-       /**
-        * User instance
-        */
-       private User user;
-
-       /**
-        * Regular user controller
-        */
-       @Inject
-       private FinancialsUserWebSessionController userController;
-
-       /**
-        * Default constructor
-        */
-       public FinancialsWebRequestHelperBean () {
-               // Call super constructor
-               super();
-
-               // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[3].getClassName(), Thread.currentThread().getStackTrace()[3].getMethodName());
-               // System.out.println(MessageFormat.format("{0}: Constructed, caller: {1}", this.getClass().getSimpleName(), caller));
-       }
-
-       @Override
-       public void copyContactToController () {
-               // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());
-               // System.out.println(MessageFormat.format("{0}.copyContactToController: CALLED, caller: {2}", this.getClass().getSimpleName(), this.contact, caller));
-
-               // Validate contact instance
-               if (this.getContact() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("this.contact is null"); //NOI18N
-               } else if (this.getContact().getContactId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.contact.contactId is null"); //NOI18N
-               } else if (this.getContact().getContactId() < 1) {
-                       // Not valid
-                       throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N
-               }
-
-               // Set all phone instances
-               this.setPhoneInstances(this.getContact());
-
-               // Set all fields: user
-               this.adminContactController.copyContactToController(this.getContact());
-       }
-
-       @Override
-       public void copyFaxNumberToController () {
-               // Validate fax instance
-               if (this.getFaxNumber() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("this.faxNumber is null");
-               } else if (this.getFaxNumber().getPhoneId() == null) {
-                       // Throw again
-                       throw new NullPointerException("this.faxNumber.phoneId is null");
-               } else if (this.getFaxNumber().getPhoneId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneId={0} is not valid", this.getFaxNumber().getPhoneId()));
-               } else if (this.getFaxNumber().getPhoneAreaCode() == null) {
-                       // Throw again
-                       throw new NullPointerException("this.faxNumber.phoneAreaCode is null");
-               } else if (this.getFaxNumber().getPhoneAreaCode() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode()));
-               } else if (this.getFaxNumber().getPhoneCountry() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.faxNumber.phoneCountry is null");
-               } else if (this.getFaxNumber().getPhoneCountry().getCountryId() == null) {
-                       // ... throw again
-                       throw new NullPointerException("this.faxNumber.phoneCountry.countryId is null");
-               } else if (this.getFaxNumber().getPhoneCountry().getCountryId() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneCountry.countryId={0} is invalid", this.getFaxNumber().getPhoneCountry().getCountryId()));
-               } else if (this.getFaxNumber().getPhoneNumber() == null) {
-                       // Throw NPE again ...
-                       throw new NullPointerException("this.faxNumber.phoneNumber is null");
-               } else if (this.getFaxNumber().getPhoneNumber() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneNumber={0} is not valid", this.getFaxNumber().getPhoneNumber()));
-               }
-
-               // Copy all (changeable) data fields to admin controller
-               this.adminPhoneController.setPhoneAreaCode(this.getFaxNumber().getPhoneAreaCode());
-               this.adminPhoneController.setPhoneCountry(this.getFaxNumber().getPhoneCountry());
-               this.adminPhoneController.setPhoneNumber(this.getFaxNumber().getPhoneNumber());
-       }
-
-       @Override
-       public void copyLandLineNumberToController () {
-               // Validate land-line instance
-               if (this.getLandLineNumber() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("this.landLineNumber is null");
-               } else if (this.getLandLineNumber().getPhoneId() == null) {
-                       // Throw again
-                       throw new NullPointerException("this.landLineNumber.phoneId is null");
-               } else if (this.getLandLineNumber().getPhoneId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneId={0} is not valid", this.getLandLineNumber().getPhoneId()));
-               } else if (this.getLandLineNumber().getPhoneAreaCode() == null) {
-                       // Throw again
-                       throw new NullPointerException("this.landLineNumber.phoneAreaCode is null");
-               } else if (this.getLandLineNumber().getPhoneAreaCode() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode()));
-               } else if (this.getLandLineNumber().getPhoneCountry() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.landLineNumber.phoneCountry is null");
-               } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() == null) {
-                       // ... throw again
-                       throw new NullPointerException("this.landLineNumber.phoneCountry.countryId is null");
-               } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneCountry.countryId={0} is invalid", this.getLandLineNumber().getPhoneCountry().getCountryId()));
-               } else if (this.getLandLineNumber().getPhoneNumber() == null) {
-                       // Throw NPE again ...
-                       throw new NullPointerException("this.landLineNumber.phoneNumber is null");
-               } else if (this.getLandLineNumber().getPhoneNumber() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneNumber={0} is not valid", this.getLandLineNumber().getPhoneNumber()));
-               }
-
-               // Copy all (changeable) data fields to admin controller
-               this.adminPhoneController.setPhoneAreaCode(this.getLandLineNumber().getPhoneAreaCode());
-               this.adminPhoneController.setPhoneCountry(this.getLandLineNumber().getPhoneCountry());
-               this.adminPhoneController.setPhoneNumber(this.getLandLineNumber().getPhoneNumber());
-       }
-
-       @Override
-       public void copyMobileNumberToController () {
-               // Validate mobile instance
-               if (this.getMobileNumber() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("this.mobileNumber is null");
-               } else if (this.getMobileNumber().getPhoneId() == null) {
-                       // Throw again
-                       throw new NullPointerException("this.mobileNumber.phoneId is null");
-               } else if (this.getMobileNumber().getPhoneId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneId={0} is not valid", this.getMobileNumber().getPhoneId()));
-               } else if (this.getMobileNumber().getMobileProvider() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.mobileNumber.mobileProvider is null");
-               } else if (this.getMobileNumber().getMobileProvider().getProviderId() == null) {
-                       // ... throw again
-                       throw new NullPointerException("this.mobileNumber.mobileProvider.providerId is null");
-               } else if (this.getMobileNumber().getMobileProvider().getProviderId() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileProvider.providerId={0} is invalid", this.getMobileNumber().getMobileProvider().getProviderId()));
-               } else if (this.getMobileNumber().getPhoneNumber() == null) {
-                       // Throw NPE again ...
-                       throw new NullPointerException("this.mobileNumber.phoneNumber is null");
-               } else if (this.getMobileNumber().getPhoneNumber() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneNumber={0} is not valid", this.getMobileNumber().getPhoneNumber()));
-               }
-
-               // Copy all (changeable) data fields to admin controller
-               this.adminPhoneController.setMobileProvider(this.getMobileNumber().getMobileProvider());
-               this.adminPhoneController.setPhoneNumber(this.getMobileNumber().getPhoneNumber());
-       }
-
-       @Override
-       public void copyUserToController () {
-               // Log message
-               //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - CALLED!"); //NOI18N
-
-               // Validate user instance
-               if (this.getUser() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("this.user is null"); //NOI18N
-               } else if (this.getUser().getUserId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.user.userId is null"); //NOI18N
-               } else if (this.getUser().getUserId() < 1) {
-                       // Not valid
-                       throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N
-               }
-
-               // Get contact
-               Contact userContact = this.getUser().getUserContact();
-
-               // Set contact here, too. This avoids parameters that cannot auto-complete in IDEs.
-               this.setContact(userContact);
-
-               // Set all phone instances
-               this.setPhoneInstances(userContact);
-
-               // Set all fields: user
-               this.userController.setUserName(this.getUser().getUserName());
-               this.adminUserController.setUserName(this.getUser().getUserName());
-       }
-
-       @Override
-       public Contact getContact () {
-               // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());
-               // System.out.println(MessageFormat.format("{0}: Returning this.contact={1}, caller: {2}", this.getClass().getSimpleName(), this.contact, caller));
-               return this.contact;
-       }
-
-       @Override
-       public void setContact (final Contact contact) {
-               // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());
-               // System.out.println(MessageFormat.format("{0}: Setting contact={1}, previous: {2}, caller: {3}", this.getClass().getSimpleName(), contact, this.contact, caller));
-               this.contact = contact;
-       }
-
-       @Override
-       public String getContactUsageMessageKey (final Contact contact) {
-               // The contact must be valid
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // Throw again ...
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
-               }
-
-               // Default key is "unused"
-               String messageKey = "CONTACT_IS_UNUSED"; //NOI18N
-
-               // Check user contact
-               boolean isUserContact = this.userController.isContactFound(contact);
-
-               // Check user first
-               if (isUserContact) {
-                       // Only user
-                       messageKey = "CONTACT_IS_USER"; //NOI18N
-               }
-
-               // Return message key
-               return messageKey;
-       }
-
-       @Override
-       public DialableFaxNumber getFaxNumber () {
-               return this.faxNumber;
-       }
-
-       @Override
-       public void setFaxNumber (final DialableFaxNumber faxNumber) {
-               this.faxNumber = faxNumber;
-       }
-
-       @Override
-       public DialableLandLineNumber getLandLineNumber () {
-               return this.landLineNumber;
-       }
-
-       @Override
-       public void setLandLineNumber (final DialableLandLineNumber landLineNumber) {
-               this.landLineNumber = landLineNumber;
-       }
-
-       @Override
-       public DialableMobileNumber getMobileNumber () {
-               return this.mobileNumber;
-       }
-
-       @Override
-       public void setMobileNumber (final DialableMobileNumber mobileNumber) {
-               this.mobileNumber = mobileNumber;
-       }
-
-       @Override
-       public User getUser () {
-               return this.user;
-       }
-
-       @Override
-       public void setUser (final User user) {
-               this.user = user;
-       }
-
-       /**
-        * Set's all given contact's phone instances: land-line, mobile and
-        * faxNumber
-        * <p>
-        * @param contact Contact to set phone instances for
-        */
-       private void setPhoneInstances (final Contact contact) {
-               // The contact must be valid
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // Throw again ...
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
-               }
-
-               // Is mobile set?
-               if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
-                       // Yes, then set it in admin controller
-                       this.setMobileNumber(contact.getContactMobileNumber());
-               }
-
-               // Is land-line set?
-               if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
-                       // Yes, then set it in admin controller
-                       this.setLandLineNumber(contact.getContactLandLineNumber());
-               }
-
-               // Is faxNumber set?
-               if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
-                       // Yes, then set it in admin controller
-                       this.setFaxNumber(contact.getContactFaxNumber());
-               }
-       }
-
-}
+/*\r
+ * Copyright (C) 2016, 2017 Roland Häder GmbH\r
+ *\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU Affero General Public License as\r
+ * published by the Free Software Foundation, either version 3 of the\r
+ * License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU Affero General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Affero General Public License\r
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+ */\r
+package org.mxchange.jfinancials.beans.helper;\r
+\r
+import java.text.MessageFormat;\r
+import javax.enterprise.context.RequestScoped;\r
+import javax.inject.Inject;\r
+import javax.inject.Named;\r
+import org.mxchange.jcontacts.contact.Contact;\r
+import org.mxchange.jfinancials.beans.contact.FinancialsAdminContactWebRequestController;\r
+import org.mxchange.jfinancials.beans.phone.FinancialsAdminPhoneWebRequestController;\r
+import org.mxchange.jfinancials.beans.user.FinancialsAdminUserWebRequestController;\r
+import org.mxchange.jfinancials.beans.user.FinancialsUserWebSessionController;\r
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;\r
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;\r
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;\r
+import org.mxchange.jusercore.model.user.User;\r
+\r
+/**\r
+ * A general helper for beans\r
+ * <p>\r
+ * @author Roland Häder<roland@mxchange.org>\r
+ */\r
+@Named ("beanHelper")\r
+@RequestScoped\r
+public class FinancialsWebRequestHelperBean implements FinancialsWebRequestHelperController {\r
+\r
+       /**\r
+        * Call-stack instance (5 may show BeanELResolver.getValue as caller)\r
+        */\r
+       private static final short THREAD_STACK = 5;\r
+\r
+       /**\r
+        * Serial number\r
+        */\r
+       private static final long serialVersionUID = 17_258_793_567_145_701L;\r
+\r
+       /**\r
+        * Administrative contact controller\r
+        */\r
+       @Inject\r
+       private FinancialsAdminContactWebRequestController adminContactController;\r
+\r
+       /**\r
+        * Administrative phone controller\r
+        */\r
+       @Inject\r
+       private FinancialsAdminPhoneWebRequestController adminPhoneController;\r
+\r
+       /**\r
+        * Administrative user controller\r
+        */\r
+       @Inject\r
+       private FinancialsAdminUserWebRequestController adminUserController;\r
+\r
+       /**\r
+        * Contact instance\r
+        */\r
+       private Contact contact;\r
+\r
+       /**\r
+        * Fax number\r
+        */\r
+       private DialableFaxNumber faxNumber;\r
+\r
+       /**\r
+        * Land-line number\r
+        */\r
+       private DialableLandLineNumber landLineNumber;\r
+\r
+       /**\r
+        * Mobile number\r
+        */\r
+       private DialableMobileNumber mobileNumber;\r
+\r
+       /**\r
+        * User instance\r
+        */\r
+       private User user;\r
+\r
+       /**\r
+        * Regular user controller\r
+        */\r
+       @Inject\r
+       private FinancialsUserWebSessionController userController;\r
+\r
+       /**\r
+        * Default constructor\r
+        */\r
+       public FinancialsWebRequestHelperBean () {\r
+               // Call super constructor\r
+               super();\r
+\r
+               // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[3].getClassName(), Thread.currentThread().getStackTrace()[3].getMethodName());\r
+               // System.out.println(MessageFormat.format("{0}: Constructed, caller: {1}", this.getClass().getSimpleName(), caller));\r
+       }\r
+\r
+       @Override\r
+       public void copyContactToController () {\r
+               // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());\r
+               // System.out.println(MessageFormat.format("{0}.copyContactToController: CALLED, caller: {2}", this.getClass().getSimpleName(), this.contact, caller));\r
+\r
+               // Validate contact instance\r
+               if (this.getContact() == null) {\r
+                       // Throw NPE\r
+                       throw new NullPointerException("this.contact is null"); //NOI18N\r
+               } else if (this.getContact().getContactId() == null) {\r
+                       // Throw NPE again\r
+                       throw new NullPointerException("this.contact.contactId is null"); //NOI18N\r
+               } else if (this.getContact().getContactId() < 1) {\r
+                       // Not valid\r
+                       throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N\r
+               }\r
+\r
+               // Set all phone instances\r
+               this.setPhoneInstances(this.getContact());\r
+\r
+               // Set all fields: user\r
+               this.adminContactController.copyContactToController(this.getContact());\r
+       }\r
+\r
+       @Override\r
+       public void copyFaxNumberToController () {\r
+               // Validate fax instance\r
+               if (this.getFaxNumber() == null) {\r
+                       // Throw NPE\r
+                       throw new NullPointerException("this.faxNumber is null");\r
+               } else if (this.getFaxNumber().getPhoneId() == null) {\r
+                       // Throw again\r
+                       throw new NullPointerException("this.faxNumber.phoneId is null");\r
+               } else if (this.getFaxNumber().getPhoneId() < 1) {\r
+                       // Invalid id number\r
+                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneId={0} is not valid", this.getFaxNumber().getPhoneId()));\r
+               } else if (this.getFaxNumber().getPhoneAreaCode() == null) {\r
+                       // Throw again\r
+                       throw new NullPointerException("this.faxNumber.phoneAreaCode is null");\r
+               } else if (this.getFaxNumber().getPhoneAreaCode() < 1) {\r
+                       // Invalid id number\r
+                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode()));\r
+               } else if (this.getFaxNumber().getPhoneCountry() == null) {\r
+                       // Throw NPE again\r
+                       throw new NullPointerException("this.faxNumber.phoneCountry is null");\r
+               } else if (this.getFaxNumber().getPhoneCountry().getCountryId() == null) {\r
+                       // ... throw again\r
+                       throw new NullPointerException("this.faxNumber.phoneCountry.countryId is null");\r
+               } else if (this.getFaxNumber().getPhoneCountry().getCountryId() < 1) {\r
+                       // Invalid id\r
+                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneCountry.countryId={0} is invalid", this.getFaxNumber().getPhoneCountry().getCountryId()));\r
+               } else if (this.getFaxNumber().getPhoneNumber() == null) {\r
+                       // Throw NPE again ...\r
+                       throw new NullPointerException("this.faxNumber.phoneNumber is null");\r
+               } else if (this.getFaxNumber().getPhoneNumber() < 1) {\r
+                       // Invalid id number\r
+                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneNumber={0} is not valid", this.getFaxNumber().getPhoneNumber()));\r
+               }\r
+\r
+               // Copy all (changeable) data fields to admin controller\r
+               this.adminPhoneController.setPhoneAreaCode(this.getFaxNumber().getPhoneAreaCode());\r
+               this.adminPhoneController.setPhoneCountry(this.getFaxNumber().getPhoneCountry());\r
+               this.adminPhoneController.setPhoneNumber(this.getFaxNumber().getPhoneNumber());\r
+       }\r
+\r
+       @Override\r
+       public void copyLandLineNumberToController () {\r
+               // Validate land-line instance\r
+               if (this.getLandLineNumber() == null) {\r
+                       // Throw NPE\r
+                       throw new NullPointerException("this.landLineNumber is null");\r
+               } else if (this.getLandLineNumber().getPhoneId() == null) {\r
+                       // Throw again\r
+                       throw new NullPointerException("this.landLineNumber.phoneId is null");\r
+               } else if (this.getLandLineNumber().getPhoneId() < 1) {\r
+                       // Invalid id number\r
+                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneId={0} is not valid", this.getLandLineNumber().getPhoneId()));\r
+               } else if (this.getLandLineNumber().getPhoneAreaCode() == null) {\r
+                       // Throw again\r
+                       throw new NullPointerException("this.landLineNumber.phoneAreaCode is null");\r
+               } else if (this.getLandLineNumber().getPhoneAreaCode() < 1) {\r
+                       // Invalid id number\r
+                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode()));\r
+               } else if (this.getLandLineNumber().getPhoneCountry() == null) {\r
+                       // Throw NPE again\r
+                       throw new NullPointerException("this.landLineNumber.phoneCountry is null");\r
+               } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() == null) {\r
+                       // ... throw again\r
+                       throw new NullPointerException("this.landLineNumber.phoneCountry.countryId is null");\r
+               } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() < 1) {\r
+                       // Invalid id\r
+                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneCountry.countryId={0} is invalid", this.getLandLineNumber().getPhoneCountry().getCountryId()));\r
+               } else if (this.getLandLineNumber().getPhoneNumber() == null) {\r
+                       // Throw NPE again ...\r
+                       throw new NullPointerException("this.landLineNumber.phoneNumber is null");\r
+               } else if (this.getLandLineNumber().getPhoneNumber() < 1) {\r
+                       // Invalid id number\r
+                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneNumber={0} is not valid", this.getLandLineNumber().getPhoneNumber()));\r
+               }\r
+\r
+               // Copy all (changeable) data fields to admin controller\r
+               this.adminPhoneController.setPhoneAreaCode(this.getLandLineNumber().getPhoneAreaCode());\r
+               this.adminPhoneController.setPhoneCountry(this.getLandLineNumber().getPhoneCountry());\r
+               this.adminPhoneController.setPhoneNumber(this.getLandLineNumber().getPhoneNumber());\r
+       }\r
+\r
+       @Override\r
+       public void copyMobileNumberToController () {\r
+               // Validate mobile instance\r
+               if (this.getMobileNumber() == null) {\r
+                       // Throw NPE\r
+                       throw new NullPointerException("this.mobileNumber is null");\r
+               } else if (this.getMobileNumber().getPhoneId() == null) {\r
+                       // Throw again\r
+                       throw new NullPointerException("this.mobileNumber.phoneId is null");\r
+               } else if (this.getMobileNumber().getPhoneId() < 1) {\r
+                       // Invalid id number\r
+                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneId={0} is not valid", this.getMobileNumber().getPhoneId()));\r
+               } else if (this.getMobileNumber().getMobileProvider() == null) {\r
+                       // Throw NPE again\r
+                       throw new NullPointerException("this.mobileNumber.mobileProvider is null");\r
+               } else if (this.getMobileNumber().getMobileProvider().getProviderId() == null) {\r
+                       // ... throw again\r
+                       throw new NullPointerException("this.mobileNumber.mobileProvider.providerId is null");\r
+               } else if (this.getMobileNumber().getMobileProvider().getProviderId() < 1) {\r
+                       // Invalid id\r
+                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileProvider.providerId={0} is invalid", this.getMobileNumber().getMobileProvider().getProviderId()));\r
+               } else if (this.getMobileNumber().getPhoneNumber() == null) {\r
+                       // Throw NPE again ...\r
+                       throw new NullPointerException("this.mobileNumber.phoneNumber is null");\r
+               } else if (this.getMobileNumber().getPhoneNumber() < 1) {\r
+                       // Invalid id number\r
+                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneNumber={0} is not valid", this.getMobileNumber().getPhoneNumber()));\r
+               }\r
+\r
+               // Copy all (changeable) data fields to admin controller\r
+               this.adminPhoneController.setMobileProvider(this.getMobileNumber().getMobileProvider());\r
+               this.adminPhoneController.setPhoneNumber(this.getMobileNumber().getPhoneNumber());\r
+       }\r
+\r
+       @Override\r
+       public void copyUserToController () {\r
+               // Log message\r
+               //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - CALLED!"); //NOI18N\r
+\r
+               // Validate user instance\r
+               if (this.getUser() == null) {\r
+                       // Throw NPE\r
+                       throw new NullPointerException("this.user is null"); //NOI18N\r
+               } else if (this.getUser().getUserId() == null) {\r
+                       // Throw NPE again\r
+                       throw new NullPointerException("this.user.userId is null"); //NOI18N\r
+               } else if (this.getUser().getUserId() < 1) {\r
+                       // Not valid\r
+                       throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N\r
+               }\r
+\r
+               // Get contact\r
+               Contact userContact = this.getUser().getUserContact();\r
+\r
+               // Set contact here, too. This avoids parameters that cannot auto-complete in IDEs.\r
+               this.setContact(userContact);\r
+\r
+               // Set all phone instances\r
+               this.setPhoneInstances(userContact);\r
+\r
+               // Set all fields: user\r
+               this.userController.setUserName(this.getUser().getUserName());\r
+               this.adminUserController.setUserName(this.getUser().getUserName());\r
+       }\r
+\r
+       @Override\r
+       public Contact getContact () {\r
+               // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());\r
+               // System.out.println(MessageFormat.format("{0}: Returning this.contact={1}, caller: {2}", this.getClass().getSimpleName(), this.contact, caller));\r
+               return this.contact;\r
+       }\r
+\r
+       @Override\r
+       public void setContact (final Contact contact) {\r
+               // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());\r
+               // System.out.println(MessageFormat.format("{0}: Setting contact={1}, previous: {2}, caller: {3}", this.getClass().getSimpleName(), contact, this.contact, caller));\r
+               this.contact = contact;\r
+       }\r
+\r
+       @Override\r
+       public String getContactUsageMessageKey (final Contact contact) {\r
+               // The contact must be valid\r
+               if (null == contact) {\r
+                       // Throw NPE\r
+                       throw new NullPointerException("contact is null"); //NOI18N\r
+               } else if (contact.getContactId() == null) {\r
+                       // Throw again ...\r
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N\r
+               } else if (contact.getContactId() < 1) {\r
+                       // Not valid\r
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N\r
+               }\r
+\r
+               // Default key is "unused"\r
+               String messageKey = "CONTACT_IS_UNUSED"; //NOI18N\r
+\r
+               // Check user contact\r
+               boolean isUserContact = this.userController.isContactFound(contact);\r
+\r
+               // Check user first\r
+               if (isUserContact) {\r
+                       // Only user\r
+                       messageKey = "CONTACT_IS_USER"; //NOI18N\r
+               }\r
+\r
+               // Return message key\r
+               return messageKey;\r
+       }\r
+\r
+       @Override\r
+       public DialableFaxNumber getFaxNumber () {\r
+               return this.faxNumber;\r
+       }\r
+\r
+       @Override\r
+       public void setFaxNumber (final DialableFaxNumber faxNumber) {\r
+               this.faxNumber = faxNumber;\r
+       }\r
+\r
+       @Override\r
+       public DialableLandLineNumber getLandLineNumber () {\r
+               return this.landLineNumber;\r
+       }\r
+\r
+       @Override\r
+       public void setLandLineNumber (final DialableLandLineNumber landLineNumber) {\r
+               this.landLineNumber = landLineNumber;\r
+       }\r
+\r
+       @Override\r
+       public DialableMobileNumber getMobileNumber () {\r
+               return this.mobileNumber;\r
+       }\r
+\r
+       @Override\r
+       public void setMobileNumber (final DialableMobileNumber mobileNumber) {\r
+               this.mobileNumber = mobileNumber;\r
+       }\r
+\r
+       @Override\r
+       public User getUser () {\r
+               return this.user;\r
+       }\r
+\r
+       @Override\r
+       public void setUser (final User user) {\r
+               this.user = user;\r
+       }\r
+\r
+       /**\r
+        * Set's all given contact's phone instances: land-line, mobile and\r
+        * faxNumber\r
+        * <p>\r
+        * @param contact Contact to set phone instances for\r
+        */\r
+       private void setPhoneInstances (final Contact contact) {\r
+               // The contact must be valid\r
+               if (null == contact) {\r
+                       // Throw NPE\r
+                       throw new NullPointerException("contact is null"); //NOI18N\r
+               } else if (contact.getContactId() == null) {\r
+                       // Throw again ...\r
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N\r
+               } else if (contact.getContactId() < 1) {\r
+                       // Not valid\r
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N\r
+               }\r
+\r
+               // Is mobile set?\r
+               if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {\r
+                       // Yes, then set it in admin controller\r
+                       this.setMobileNumber(contact.getContactMobileNumber());\r
+               }\r
+\r
+               // Is land-line set?\r
+               if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {\r
+                       // Yes, then set it in admin controller\r
+                       this.setLandLineNumber(contact.getContactLandLineNumber());\r
+               }\r
+\r
+               // Is faxNumber set?\r
+               if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {\r
+                       // Yes, then set it in admin controller\r
+                       this.setFaxNumber(contact.getContactFaxNumber());\r
+               }\r
+       }\r
+\r
+}\r