]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java
Rewritten a lot:
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / contact / PizzaAdminContactWebRequestBean.java
1 /*
2  * Copyright (C) 2016 Roland Haeder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License as
6  * published by the Free Software Foundation, either version 3 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Affero General Public License for more details.
13  *
14  * You should have received a copy of the GNU Affero General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.pizzaapplication.beans.contact;
18
19 import java.text.MessageFormat;
20 import java.util.Date;
21 import java.util.Iterator;
22 import javax.annotation.PostConstruct;
23 import javax.enterprise.context.RequestScoped;
24 import javax.enterprise.event.Event;
25 import javax.enterprise.inject.Any;
26 import javax.faces.view.facelets.FaceletException;
27 import javax.inject.Inject;
28 import javax.inject.Named;
29 import javax.naming.Context;
30 import javax.naming.InitialContext;
31 import javax.naming.NamingException;
32 import org.mxchange.jcontacts.contact.Contact;
33 import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
34 import org.mxchange.jcontacts.contact.UserContact;
35 import org.mxchange.jcontacts.contact.gender.Gender;
36 import org.mxchange.jcontacts.contact.utils.ContactUtils;
37 import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
38 import org.mxchange.jcontacts.events.contact.add.AdminContactAddedEvent;
39 import org.mxchange.jcontacts.events.contact.update.AdminContactUpdatedEvent;
40 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
41 import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
42 import org.mxchange.jcountry.data.Country;
43 import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber;
44 import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
45 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
46 import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
47 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
48 import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
49 import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
50 import org.mxchange.pizzaapplication.beans.BasePizzaController;
51 import org.mxchange.pizzaapplication.beans.helper.PizzaAdminWebRequestController;
52
53 /**
54  * Administrative user bean (controller)
55  * <p>
56  * @author Roland Haeder<roland@mxchange.org>
57  */
58 @Named ("adminContactController")
59 @RequestScoped
60 public class PizzaAdminContactWebRequestBean extends BasePizzaController implements PizzaAdminContactWebRequestController {
61
62         /**
63          * Serial number
64          */
65         private static final long serialVersionUID = 542_145_347_916L;
66
67         /**
68          * An event fired when the administrator has added a new contact
69          */
70         @Inject
71         @Any
72         private Event<AdminAddedContactEvent> addedContactEvent;
73
74         /**
75          * Admin helper instance
76          */
77         @Inject
78         private PizzaAdminWebRequestController adminHelper;
79
80         /**
81          * Birth day
82          */
83         private Date birthday;
84
85         /**
86          * Cellphone number's carrier
87          */
88         private MobileProvider cellphoneCarrier;
89
90         /**
91          * Cellphone id number
92          */
93         private Long cellphoneId;
94
95         /**
96          * Cellphone number
97          */
98         private Long cellphoneNumber;
99
100         /**
101          * City
102          */
103         private String city;
104
105         /**
106          * Optional comments
107          */
108         private String comment;
109
110         /**
111          * Remote contact bean
112          */
113         private final ContactSessionBeanRemote contactBean;
114
115         /**
116          * General contact controller
117          */
118         @Inject
119         private PizzaContactWebSessionController contactController;
120
121         /**
122          * Contact id
123          */
124         private Long contactId;
125
126         /**
127          * Country instance
128          */
129         private Country country;
130
131         /**
132          * Email address
133          */
134         private String emailAddress;
135
136         /**
137          * Family name
138          */
139         private String familyName;
140
141         /**
142          * Fax number's area code
143          */
144         private Integer faxAreaCode;
145
146         /**
147          * Country instance for fax number
148          */
149         private Country faxCountry;
150
151         /**
152          * Fax id number
153          */
154         private Long faxId;
155
156         /**
157          * Fax number
158          */
159         private Long faxNumber;
160
161         /**
162          * First name
163          */
164         private String firstName;
165
166         /**
167          * Gender instance
168          */
169         private Gender gender;
170
171         /**
172          * House number
173          */
174         private Short houseNumber;
175
176         /**
177          * Whether a cellphone entry has been unlinked
178          */
179         private boolean isCellphoneUnlinked;
180
181         /**
182          * Whether a fax entry has been unlinked
183          */
184         private boolean isFaxUnlinked;
185
186         /**
187          * Whether a land-line number has been unlinked
188          */
189         private boolean isLandLineUnlinked;
190
191         /**
192          * Land-line id number
193          */
194         private Long landLineId;
195
196         /**
197          * Phone number area code
198          */
199         private Integer phoneAreaCode;
200
201         /**
202          * Country instance for phone number
203          */
204         private Country phoneCountry;
205
206         /**
207          * Phone number
208          */
209         private Long phoneNumber;
210
211         /**
212          * Street
213          */
214         private String street;
215
216         /**
217          * An event fired when the administrator has updated contact data
218          */
219         @Inject
220         @Any
221         private Event<AdminUpdatedContactEvent> updatedContactEvent;
222
223         /**
224          * ZIP code
225          */
226         private Integer zipCode;
227
228         /**
229          * Default constructor
230          */
231         public PizzaAdminContactWebRequestBean () {
232                 // Try it
233                 try {
234                         // Get initial context
235                         Context context = new InitialContext();
236
237                         // Try to lookup
238                         this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/PizzaService-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
239                 } catch (final NamingException e) {
240                         // Throw again
241                         throw new FaceletException(e);
242                 }
243         }
244
245         @Override
246         public String addContact () {
247                 // Create new contact instance
248                 Contact contact = this.createContactInstance();
249
250                 // Default is not same contact
251                 if (this.isSameContactFound(contact)) {
252                         // Already registered
253                         throw new FaceletException(new ContactAlreadyAddedException(contact));
254                 }
255
256                 // Init contact
257                 Contact updatedContact;
258
259                 // Try to call EJB
260                 try {
261                         // Call EJB
262                         updatedContact = this.contactBean.addContact(contact);
263                 } catch (final ContactAlreadyAddedException ex) {
264                         // Throw again
265                         throw new FaceletException(ex);
266                 }
267
268                 // Fire event
269                 this.addedContactEvent.fire(new AdminContactAddedEvent(updatedContact));
270
271                 // Clear this bean
272                 this.clear();
273
274                 // Return outcome
275                 return "admin_list_contact"; //NOI18N
276         }
277
278         @Override
279         public void copyContactToController (final Contact contact) {
280                 // Log message
281                 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AdminContactController::copyContactToController(): contact={0} - CALLED!", contact)); //NOI18N
282
283                 // The contact instance must be valid
284                 if (null == contact) {
285                         // Throw NPE again
286                         throw new NullPointerException("contact is null"); //NOI18N
287                 } else if (contact.getContactId() == null) {
288                         // Throw NPE again
289                         throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
290                 } else if (contact.getContactId() < 1) {
291                         // Not valid
292                         throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
293                 }
294
295                 // Set all fields: contact
296                 this.setContactId(contact.getContactId());
297                 this.setBirthday(contact.getContactBirthday());
298                 this.setCity(contact.getContactCity());
299                 this.setComment(contact.getContactComment());
300                 this.setCountry(contact.getContactCountry());
301                 this.setEmailAddress(contact.getContactEmailAddress());
302                 this.setFamilyName(contact.getContactFamilyName());
303                 this.setFirstName(contact.getContactFirstName());
304                 this.setGender(contact.getContactGender());
305                 this.setHouseNumber(contact.getContactHouseNumber());
306                 this.setStreet(contact.getContactStreet());
307                 this.setZipCode(contact.getContactZipCode());
308
309                 // Is the cell phone set?
310                 if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) {
311                         // ... cellphone data
312                         this.setCellphoneId(contact.getContactCellphoneNumber().getPhoneId());
313                         this.setCellphoneCarrier(contact.getContactCellphoneNumber().getCellphoneProvider());
314                         this.setCellphoneNumber(contact.getContactCellphoneNumber().getPhoneNumber());
315                 }
316
317                 // Is the fax set?
318                 if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
319                         // ... fax data
320                         this.setFaxId(contact.getContactFaxNumber().getPhoneId());
321                         this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode());
322                         this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry());
323                         this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber());
324                 }
325
326                 // Is the land-line number set?
327                 if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
328                         // .. land-line data
329                         this.setLandLineId(contact.getContactLandLineNumber().getPhoneId());
330                         this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode());
331                         this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry());
332                         this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber());
333                 }
334
335                 // Log message
336                 //* NOISY-DEBUG: */ System.out.println("AdminContactController::copyContactToController(): EXIT!"); //NOI18N
337         }
338
339         @Override
340         public Contact createContactInstance () {
341                 // Are all minimum fields set?
342                 if (this.getGender() == null) {
343                         // Throw NPE
344                         throw new NullPointerException("gender is null"); //NOI18N
345                 } else if (this.getFirstName() == null) {
346                         // Throw NPE
347                         throw new NullPointerException("firstName is null"); //NOI18N
348                 } else if (this.getFirstName().isEmpty()) {
349                         // Empty string
350                         throw new IllegalStateException("firstName is empty"); //NOI18N
351                 } else if (this.getFamilyName() == null) {
352                         // Throw NPE
353                         throw new NullPointerException("familyName is null"); //NOI18N
354                 } else if (this.getFamilyName().isEmpty()) {
355                         // Empty string
356                         throw new IllegalStateException("familyName is empty"); //NOI18N
357                 }
358
359                 // Generate phone number
360                 DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
361                 DialableCellphoneNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber());
362                 DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
363
364                 // Create new instance
365                 Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
366
367                 // Add all others
368                 contact.setContactBirthday(this.getBirthday());
369                 contact.setContactStreet(this.getStreet());
370                 contact.setContactHouseNumber(this.getHouseNumber());
371                 contact.setContactZipCode(this.getZipCode());
372                 contact.setContactCity(this.getCity());
373                 contact.setContactCountry(this.getCountry());
374                 contact.setContactEmailAddress(this.getEmailAddress());
375                 contact.setContactBirthday(this.getBirthday());
376                 contact.setContactComment(this.getComment());
377
378                 // Set ownContact
379                 contact.setContactOwnContact(Boolean.TRUE);
380
381                 // Don't set null or wrong references
382                 if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) {
383                         // Now the number must be given
384                         if (phone.getPhoneAreaCode() == null) {
385                                 // Is null
386                                 throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
387                         } else if (phone.getPhoneAreaCode() < 1) {
388                                 // Abort here
389                                 throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
390                         } else if (phone.getPhoneNumber() == null) {
391                                 // Is null
392                                 throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
393                         } else if (phone.getPhoneNumber() < 1) {
394                                 // Abort here
395                                 throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
396                         }
397
398                         // Set phone number
399                         contact.setContactLandLineNumber(phone);
400                 }
401
402                 // Don't set null or wrong references
403                 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
404                         // Now the number must be given
405                         if (fax.getPhoneAreaCode() == null) {
406                                 // Is null
407                                 throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
408                         } else if (fax.getPhoneAreaCode() < 1) {
409                                 // Abort here
410                                 throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
411                         } else if (fax.getPhoneNumber() == null) {
412                                 // Is null
413                                 throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
414                         } else if (fax.getPhoneNumber() < 1) {
415                                 // Abort here
416                                 throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
417                         }
418
419                         // Set fax number
420                         contact.setContactFaxNumber(fax);
421                 }
422
423                 // Is the provider set?
424                 if ((cellphone instanceof DialableCellphoneNumber) && (this.getCellphoneCarrier() instanceof MobileProvider) && (this.getCellphoneNumber() != null) && (this.getCellphoneNumber() > 0)) {
425                         // Is the number set?
426                         if (cellphone.getPhoneNumber() == null) {
427                                 // Is null
428                                 throw new NullPointerException("cellphone.phoneNumber is null"); //NOI18N
429                         } else if (cellphone.getPhoneNumber() < 1) {
430                                 // Abort here
431                                 throw new IllegalArgumentException("cellphone.phoneNumber is zero or below."); //NOI18N
432                         }
433
434                         // Set cellphone number
435                         contact.setContactCellphoneNumber(cellphone);
436                 }
437
438                 // Return it
439                 return contact;
440         }
441
442         @Override
443         public String editContactData () {
444                 // Get contact instance
445                 Contact contact = this.adminHelper.getContact();
446
447                 // Check if contact instance is in helper and valid
448                 if (null == contact) {
449                         // Throw NPE
450                         throw new NullPointerException("adminHelper.contact is null"); //NOI18N
451                 } else if (contact.getContactId() == null) {
452                         // Throw NPE again
453                         throw new NullPointerException("adminHelper.contact.contactId is null"); //NOI18N //NOI18N
454                 } else if (contact.getContactId() < 1) {
455                         // Invalid id
456                         throw new IllegalStateException(MessageFormat.format("adminHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
457                 }
458
459                 // Update all data in contact
460                 this.updateContactData(contact);
461
462                 // Call EJB for updating contact data
463                 Contact updatedContact = this.contactBean.updateContactData(contact, this.isCellphoneUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
464
465                 // Fire event
466                 this.updatedContactEvent.fire(new AdminContactUpdatedEvent(updatedContact));
467
468                 // Clear bean
469                 this.clear();
470
471                 // Return to contact list (for now)
472                 return "admin_list_contact"; //NOI18N
473         }
474
475         @Override
476         @SuppressWarnings ("ReturnOfDateField")
477         public Date getBirthday () {
478                 return this.birthday;
479         }
480
481         @Override
482         @SuppressWarnings ("AssignmentToDateFieldFromParameter")
483         public void setBirthday (final Date birthday) {
484                 this.birthday = birthday;
485         }
486
487         @Override
488         public MobileProvider getCellphoneCarrier () {
489                 return this.cellphoneCarrier;
490         }
491
492         @Override
493         public void setCellphoneCarrier (final MobileProvider cellphoneCarrier) {
494                 this.cellphoneCarrier = cellphoneCarrier;
495         }
496
497         @Override
498         public Long getCellphoneId () {
499                 return this.cellphoneId;
500         }
501
502         @Override
503         public void setCellphoneId (final Long cellphoneId) {
504                 this.cellphoneId = cellphoneId;
505         }
506
507         @Override
508         public Long getCellphoneNumber () {
509                 return this.cellphoneNumber;
510         }
511
512         @Override
513         public void setCellphoneNumber (Long cellphoneNumber) {
514                 this.cellphoneNumber = cellphoneNumber;
515         }
516
517         @Override
518         public String getCity () {
519                 return this.city;
520         }
521
522         @Override
523         public void setCity (final String city) {
524                 this.city = city;
525         }
526
527         @Override
528         public String getComment () {
529                 return this.comment;
530         }
531
532         @Override
533         public void setComment (final String comment) {
534                 this.comment = comment;
535         }
536
537         @Override
538         public Long getContactId () {
539                 return this.contactId;
540         }
541
542         @Override
543         public void setContactId (final Long contactId) {
544                 this.contactId = contactId;
545         }
546
547         @Override
548         public Country getCountry () {
549                 return this.country;
550         }
551
552         @Override
553         public void setCountry (final Country country) {
554                 this.country = country;
555         }
556
557         @Override
558         public String getEmailAddress () {
559                 return this.emailAddress;
560         }
561
562         @Override
563         public void setEmailAddress (final String emailAddress) {
564                 this.emailAddress = emailAddress;
565         }
566
567         @Override
568         public String getFamilyName () {
569                 return this.familyName;
570         }
571
572         @Override
573         public void setFamilyName (final String familyName) {
574                 this.familyName = familyName;
575         }
576
577         @Override
578         public Integer getFaxAreaCode () {
579                 return this.faxAreaCode;
580         }
581
582         @Override
583         public void setFaxAreaCode (final Integer faxAreaCode) {
584                 this.faxAreaCode = faxAreaCode;
585         }
586
587         @Override
588         public Country getFaxCountry () {
589                 return this.faxCountry;
590         }
591
592         @Override
593         public void setFaxCountry (final Country faxCountry) {
594                 this.faxCountry = faxCountry;
595         }
596
597         @Override
598         public Long getFaxId () {
599                 return this.faxId;
600         }
601
602         @Override
603         public void setFaxId (final Long faxId) {
604                 this.faxId = faxId;
605         }
606
607         @Override
608         public Long getFaxNumber () {
609                 return this.faxNumber;
610         }
611
612         @Override
613         public void setFaxNumber (final Long faxNumber) {
614                 this.faxNumber = faxNumber;
615         }
616
617         @Override
618         public String getFirstName () {
619                 return this.firstName;
620         }
621
622         @Override
623         public void setFirstName (final String firstName) {
624                 this.firstName = firstName;
625         }
626
627         @Override
628         public Gender getGender () {
629                 return this.gender;
630         }
631
632         @Override
633         public void setGender (final Gender gender) {
634                 this.gender = gender;
635         }
636
637         @Override
638         public Short getHouseNumber () {
639                 return this.houseNumber;
640         }
641
642         @Override
643         public void setHouseNumber (final Short houseNumber) {
644                 this.houseNumber = houseNumber;
645         }
646
647         @Override
648         public Long getLandLineId () {
649                 return this.landLineId;
650         }
651
652         @Override
653         public void setLandLineId (final Long landLineId) {
654                 this.landLineId = landLineId;
655         }
656
657         @Override
658         public Integer getPhoneAreaCode () {
659                 return this.phoneAreaCode;
660         }
661
662         @Override
663         public void setPhoneAreaCode (final Integer phoneAreaCode) {
664                 this.phoneAreaCode = phoneAreaCode;
665         }
666
667         @Override
668         public Country getPhoneCountry () {
669                 return this.phoneCountry;
670         }
671
672         @Override
673         public void setPhoneCountry (final Country phoneCountry) {
674                 this.phoneCountry = phoneCountry;
675         }
676
677         @Override
678         public Long getPhoneNumber () {
679                 return this.phoneNumber;
680         }
681
682         @Override
683         public void setPhoneNumber (final Long phoneNumber) {
684                 this.phoneNumber = phoneNumber;
685         }
686
687         @Override
688         public String getStreet () {
689                 return this.street;
690         }
691
692         @Override
693         public void setStreet (final String street) {
694                 this.street = street;
695         }
696
697         @Override
698         public Integer getZipCode () {
699                 return this.zipCode;
700         }
701
702         @Override
703         public void setZipCode (final Integer zipCode) {
704                 this.zipCode = zipCode;
705         }
706
707         /**
708          * Post-initialization of this class
709          */
710         @PostConstruct
711         public void init () {
712         }
713
714         /**
715          * Clears this bean
716          */
717         private void clear () {
718                 // Clear all data
719                 // - personal data
720                 this.setGender(Gender.UNKNOWN);
721                 this.setFirstName(null);
722                 this.setFamilyName(null);
723                 this.setStreet(null);
724                 this.setHouseNumber(null);
725                 this.setZipCode(null);
726                 this.setCity(null);
727                 this.setCountry(null);
728
729                 // - contact data
730                 this.setEmailAddress(null);
731                 this.setPhoneCountry(null);
732                 this.setPhoneAreaCode(null);
733                 this.setPhoneNumber(null);
734                 this.setCellphoneCarrier(null);
735                 this.setCellphoneNumber(null);
736                 this.setFaxCountry(null);
737                 this.setFaxAreaCode(null);
738                 this.setFaxNumber(null);
739
740                 // - other data
741                 this.setBirthday(null);
742                 this.setComment(null);
743         }
744
745         /**
746          * Checks whether the given contact is found
747          * <p>
748          * @param contact Contact inastance
749          *
750          * @return Wether contact has been found
751          */
752         private boolean isSameContactFound (final Contact contact) {
753                 // Default is not found
754                 boolean IsFound = false;
755
756                 // Get iterator
757                 Iterator<Contact> iterator = this.contactController.allContacts().iterator();
758
759                 // Loop through all
760                 while (iterator.hasNext()) {
761                         // Get next contact
762                         Contact next = iterator.next();
763
764                         // Is the same?
765                         if (ContactUtils.isSameContact(contact, next)) {
766                                 // Yes, then abort loop
767                                 IsFound = false;
768                                 break;
769                         }
770                 }
771
772                 // Return status
773                 return IsFound;
774         }
775
776         /**
777          * Updates all data in contact instance.
778          * <p>
779          * @param contact Contact instance
780          */
781         private void updateContactData (final Contact contact) {
782                 // Contact instance should be valid
783                 if (null == contact) {
784                         // Throw NPE
785                         throw new NullPointerException("contact is null"); //NOI18N
786                 } else if (contact.getContactId() == null) {
787                         // Throw NPE again
788                         throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
789                 } else if (contact.getContactId() < 1) {
790                         // Invalid id
791                         throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
792                 }
793
794                 // Update all fields
795                 contact.setContactGender(this.getGender());
796                 contact.setContactFirstName(this.getFirstName());
797                 contact.setContactFamilyName(this.getFamilyName());
798                 contact.setContactStreet(this.getStreet());
799                 contact.setContactHouseNumber(this.getHouseNumber());
800                 contact.setContactZipCode(this.getZipCode());
801                 contact.setContactCity(this.getCity());
802                 contact.setContactCountry(this.getCountry());
803
804                 // Update contact's cellphone number
805                 this.isCellphoneUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getCellphoneCarrier(), this.getCellphoneNumber());
806
807                 // Update contact's land-line number
808                 this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
809
810                 // Update contact's fax number
811                 this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
812         }
813
814 }