]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java
Continued:
[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 java.util.List;
23 import javax.annotation.PostConstruct;
24 import javax.enterprise.context.RequestScoped;
25 import javax.enterprise.event.Event;
26 import javax.enterprise.inject.Any;
27 import javax.faces.view.facelets.FaceletException;
28 import javax.inject.Inject;
29 import javax.inject.Named;
30 import javax.naming.Context;
31 import javax.naming.InitialContext;
32 import javax.naming.NamingException;
33 import org.mxchange.jcontacts.contact.Contact;
34 import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
35 import org.mxchange.jcontacts.contact.UserContact;
36 import org.mxchange.jcontacts.contact.gender.Gender;
37 import org.mxchange.jcontacts.contact.utils.ContactUtils;
38 import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
39 import org.mxchange.jcontacts.events.contact.add.AdminContactAddedEvent;
40 import org.mxchange.jcontacts.events.contact.update.AdminContactUpdatedEvent;
41 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
42 import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
43 import org.mxchange.jcountry.data.Country;
44 import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber;
45 import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
46 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
47 import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
48 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
49 import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
50 import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
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 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                 // Set gender to UNKNOWN
233                 this.gender = Gender.UNKNOWN;
234
235                 // Try it
236                 try {
237                         // Get initial context
238                         Context context = new InitialContext();
239
240                         // Try to lookup
241                         this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/PizzaService-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
242                 } catch (final NamingException e) {
243                         // Throw again
244                         throw new FaceletException(e);
245                 }
246         }
247
248         @Override
249         public String addContact () {
250                 // Create new contact instance
251                 Contact contact = this.createContactInstance();
252
253                 // Default is not same contact
254                 if (this.isSameContactFound(contact)) {
255                         // Already registered
256                         throw new FaceletException(new ContactAlreadyAddedException(contact));
257                 }
258
259                 // Init contact
260                 Contact updatedContact;
261
262                 // Try to call EJB
263                 try {
264                         // Call EJB
265                         updatedContact = this.contactBean.addContact(contact);
266                 } catch (final ContactAlreadyAddedException ex) {
267                         // Throw again
268                         throw new FaceletException(ex);
269                 }
270
271                 // Fire event
272                 this.addedContactEvent.fire(new AdminContactAddedEvent(updatedContact));
273
274                 // Return outcome
275                 return "admin_list_contact"; //NOI18N
276         }
277
278         @Override
279         public List<Contact> allContacts () {
280                 return this.contactController.allContacts();
281         }
282
283         @Override
284         public String changeContactData () {
285                 // Get contact instance
286                 Contact contact = this.adminHelper.getContact();
287
288                 // Check if contact instance is in helper and valid
289                 if (null == contact) {
290                         // Throw NPE
291                         throw new NullPointerException("adminHelper.contact is null"); //NOI18N
292                 } else if (contact.getContactId() == null) {
293                         // Throw NPE again
294                         throw new NullPointerException("adminHelper.contact.contactId is null"); //NOI18N //NOI18N
295                 } else if (contact.getContactId() < 1) {
296                         // Invalid id
297                         throw new IllegalStateException(MessageFormat.format("adminHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
298                 }
299
300                 // Update all data in contact
301                 this.updateContactData(contact);
302
303                 // Call EJB for updating contact data
304                 Contact updatedContact = this.contactBean.updateContactData(contact, this.isCellphoneUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
305
306                 // Fire event
307                 this.updatedContactEvent.fire(new AdminContactUpdatedEvent(updatedContact));
308
309                 // Return to contact list (for now)
310                 return "admin_list_contact"; //NOI18N
311         }
312
313         @Override
314         public void copyContactToController (final Contact contact) {
315                 // Log message
316                 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AdminContactController::copyContactToController(): contact={0} - CALLED!", contact)); //NOI18N
317
318                 // The contact instance must be valid
319                 if (null == contact) {
320                         // Throw NPE again
321                         throw new NullPointerException("contact is null"); //NOI18N
322                 } else if (contact.getContactId() == null) {
323                         // Throw NPE again
324                         throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
325                 } else if (contact.getContactId() < 1) {
326                         // Not valid
327                         throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
328                 }
329
330                 // Set all fields: contact
331                 this.setContactId(contact.getContactId());
332                 this.setBirthday(contact.getContactBirthday());
333                 this.setCity(contact.getContactCity());
334                 this.setComment(contact.getContactComment());
335                 this.setCountry(contact.getContactCountry());
336                 this.setEmailAddress(contact.getContactEmailAddress());
337                 this.setFamilyName(contact.getContactFamilyName());
338                 this.setFirstName(contact.getContactFirstName());
339                 this.setGender(contact.getContactGender());
340                 this.setHouseNumber(contact.getContactHouseNumber());
341                 this.setStreet(contact.getContactStreet());
342                 this.setZipCode(contact.getContactZipCode());
343
344                 // Is the cell phone set?
345                 if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) {
346                         // ... cellphone data
347                         this.setCellphoneId(contact.getContactCellphoneNumber().getPhoneId());
348                         this.setCellphoneCarrier(contact.getContactCellphoneNumber().getCellphoneProvider());
349                         this.setCellphoneNumber(contact.getContactCellphoneNumber().getPhoneNumber());
350                 }
351
352                 // Is the fax set?
353                 if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
354                         // ... fax data
355                         this.setFaxId(contact.getContactFaxNumber().getPhoneId());
356                         this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode());
357                         this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry());
358                         this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber());
359                 }
360
361                 // Is the land-line number set?
362                 if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
363                         // .. land-line data
364                         this.setLandLineId(contact.getContactLandLineNumber().getPhoneId());
365                         this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode());
366                         this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry());
367                         this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber());
368                 }
369
370                 // Log message
371                 //* NOISY-DEBUG: */ System.out.println("AdminContactController::copyContactToController(): EXIT!"); //NOI18N
372         }
373
374         @Override
375         public Contact createContactInstance () {
376                 // Are all minimum fields set?
377                 if (this.getGender() == null) {
378                         // Throw NPE
379                         throw new NullPointerException("gender is null"); //NOI18N
380                 } else if (this.getFirstName() == null) {
381                         // Throw NPE
382                         throw new NullPointerException("firstName is null"); //NOI18N
383                 } else if (this.getFirstName().isEmpty()) {
384                         // Empty string
385                         throw new IllegalStateException("firstName is empty"); //NOI18N
386                 } else if (this.getFamilyName() == null) {
387                         // Throw NPE
388                         throw new NullPointerException("familyName is null"); //NOI18N
389                 } else if (this.getFamilyName().isEmpty()) {
390                         // Empty string
391                         throw new IllegalStateException("familyName is empty"); //NOI18N
392                 }
393
394                 // Generate phone number
395                 DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
396                 DialableCellphoneNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber());
397                 DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
398
399                 // Create new instance
400                 Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
401
402                 // Add all others
403                 contact.setContactBirthday(this.getBirthday());
404                 contact.setContactStreet(this.getStreet());
405                 contact.setContactHouseNumber(this.getHouseNumber());
406                 contact.setContactZipCode(this.getZipCode());
407                 contact.setContactCity(this.getCity());
408                 contact.setContactCountry(this.getCountry());
409                 contact.setContactEmailAddress(this.getEmailAddress());
410                 contact.setContactBirthday(this.getBirthday());
411                 contact.setContactComment(this.getComment());
412
413                 // Set ownContact
414                 contact.setContactOwnContact(Boolean.TRUE);
415
416                 // Don't set null or wrong references
417                 if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) {
418                         // Now the number must be given
419                         if (phone.getPhoneAreaCode() == null) {
420                                 // Is null
421                                 throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
422                         } else if (phone.getPhoneAreaCode() < 1) {
423                                 // Abort here
424                                 throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
425                         } else if (phone.getPhoneNumber() == null) {
426                                 // Is null
427                                 throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
428                         } else if (phone.getPhoneNumber() < 1) {
429                                 // Abort here
430                                 throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
431                         }
432
433                         // Set phone number
434                         contact.setContactLandLineNumber(phone);
435                 }
436
437                 // Don't set null or wrong references
438                 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
439                         // Now the number must be given
440                         if (fax.getPhoneAreaCode() == null) {
441                                 // Is null
442                                 throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
443                         } else if (fax.getPhoneAreaCode() < 1) {
444                                 // Abort here
445                                 throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
446                         } else if (fax.getPhoneNumber() == null) {
447                                 // Is null
448                                 throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
449                         } else if (fax.getPhoneNumber() < 1) {
450                                 // Abort here
451                                 throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
452                         }
453
454                         // Set fax number
455                         contact.setContactFaxNumber(fax);
456                 }
457
458                 // Is the provider set?
459                 if ((cellphone instanceof DialableCellphoneNumber) && (this.getCellphoneCarrier() instanceof MobileProvider) && (this.getCellphoneNumber() != null) && (this.getCellphoneNumber() > 0)) {
460                         // Is the number set?
461                         if (cellphone.getPhoneNumber() == null) {
462                                 // Is null
463                                 throw new NullPointerException("cellphone.phoneNumber is null"); //NOI18N
464                         } else if (cellphone.getPhoneNumber() < 1) {
465                                 // Abort here
466                                 throw new IllegalArgumentException("cellphone.phoneNumber is zero or below."); //NOI18N
467                         }
468
469                         // Set cellphone number
470                         contact.setContactCellphoneNumber(cellphone);
471                 }
472
473                 // Return it
474                 return contact;
475         }
476
477         @Override
478         public Date getBirthday () {
479                 return this.birthday;
480         }
481
482         @Override
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         @Override
708         public boolean hasContacts () {
709                 return (!this.allContacts().isEmpty());
710         }
711
712         /**
713          * Post-initialization of this class
714          */
715         @PostConstruct
716         public void init () {
717         }
718
719         /**
720          * Clears this bean
721          */
722         private void clear () {
723                 // Clear all data
724                 // - personal data
725                 this.setGender(Gender.UNKNOWN);
726                 this.setFirstName(null);
727                 this.setFamilyName(null);
728                 this.setStreet(null);
729                 this.setHouseNumber(null);
730                 this.setZipCode(null);
731                 this.setCity(null);
732                 this.setCountry(null);
733
734                 // - contact data
735                 this.setEmailAddress(null);
736                 this.setPhoneCountry(null);
737                 this.setPhoneAreaCode(null);
738                 this.setPhoneNumber(null);
739                 this.setCellphoneCarrier(null);
740                 this.setCellphoneNumber(null);
741                 this.setFaxCountry(null);
742                 this.setFaxAreaCode(null);
743                 this.setFaxNumber(null);
744
745                 // - other data
746                 this.setBirthday(null);
747                 this.setComment(null);
748         }
749
750         /**
751          * Checks whether the given contact is found
752          * <p>
753          * @param contact Contact inastance
754          *
755          * @return Wether contact has been found
756          */
757         private boolean isSameContactFound (final Contact contact) {
758                 // Default is not found
759                 boolean IsFound = false;
760
761                 // Get iterator
762                 Iterator<Contact> iterator = this.allContacts().iterator();
763
764                 // Loop through all
765                 while (iterator.hasNext()) {
766                         // Get next contact
767                         Contact next = iterator.next();
768
769                         // Is the same?
770                         if (ContactUtils.isSameContact(contact, next)) {
771                                 // Yes, then abort loop
772                                 IsFound = false;
773                                 break;
774                         }
775                 }
776
777                 // Return status
778                 return IsFound;
779         }
780
781         /**
782          * Updates all data in contact instance.
783          * <p>
784          * @param contact Contact instance
785          */
786         private void updateContactData (final Contact contact) {
787                 // Contact instance should be valid
788                 if (null == contact) {
789                         // Throw NPE
790                         throw new NullPointerException("contact is null"); //NOI18N
791                 } else if (contact.getContactId() == null) {
792                         // Throw NPE again
793                         throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
794                 } else if (contact.getContactId() < 1) {
795                         // Invalid id
796                         throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
797                 }
798
799                 // Update all fields
800                 contact.setContactGender(this.getGender());
801                 contact.setContactFirstName(this.getFirstName());
802                 contact.setContactFamilyName(this.getFamilyName());
803                 contact.setContactStreet(this.getStreet());
804                 contact.setContactHouseNumber(this.getHouseNumber());
805                 contact.setContactZipCode(this.getZipCode());
806                 contact.setContactCity(this.getCity());
807                 contact.setContactCountry(this.getCountry());
808
809                 // Update contact's cellphone number
810                 this.isCellphoneUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getCellphoneCarrier(), this.getCellphoneNumber());
811
812                 // Update contact's land-line number
813                 this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
814
815                 // Update contact's fax number
816                 this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
817         }
818
819 }