]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java
Continued with contact:
[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                 // Clear this bean
275                 this.clear();
276
277                 // Return outcome
278                 return "admin_list_contact"; //NOI18N
279         }
280
281         @Override
282         public List<Contact> allContacts () {
283                 return this.contactController.allContacts();
284         }
285
286         @Override
287         public String changeContactData () {
288                 // Get contact instance
289                 Contact contact = this.adminHelper.getContact();
290
291                 // Check if contact instance is in helper and valid
292                 if (null == contact) {
293                         // Throw NPE
294                         throw new NullPointerException("adminHelper.contact is null"); //NOI18N
295                 } else if (contact.getContactId() == null) {
296                         // Throw NPE again
297                         throw new NullPointerException("adminHelper.contact.contactId is null"); //NOI18N //NOI18N
298                 } else if (contact.getContactId() < 1) {
299                         // Invalid id
300                         throw new IllegalStateException(MessageFormat.format("adminHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
301                 }
302
303                 // Update all data in contact
304                 this.updateContactData(contact);
305
306                 // Call EJB for updating contact data
307                 Contact updatedContact = this.contactBean.updateContactData(contact, this.isCellphoneUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
308
309                 // Fire event
310                 this.updatedContactEvent.fire(new AdminContactUpdatedEvent(updatedContact));
311
312                 // Return to contact list (for now)
313                 return "admin_list_contact"; //NOI18N
314         }
315
316         @Override
317         public void copyContactToController (final Contact contact) {
318                 // Log message
319                 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AdminContactController::copyContactToController(): contact={0} - CALLED!", contact)); //NOI18N
320
321                 // The contact instance must be valid
322                 if (null == contact) {
323                         // Throw NPE again
324                         throw new NullPointerException("contact is null"); //NOI18N
325                 } else if (contact.getContactId() == null) {
326                         // Throw NPE again
327                         throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
328                 } else if (contact.getContactId() < 1) {
329                         // Not valid
330                         throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
331                 }
332
333                 // Set all fields: contact
334                 this.setContactId(contact.getContactId());
335                 this.setBirthday(contact.getContactBirthday());
336                 this.setCity(contact.getContactCity());
337                 this.setComment(contact.getContactComment());
338                 this.setCountry(contact.getContactCountry());
339                 this.setEmailAddress(contact.getContactEmailAddress());
340                 this.setFamilyName(contact.getContactFamilyName());
341                 this.setFirstName(contact.getContactFirstName());
342                 this.setGender(contact.getContactGender());
343                 this.setHouseNumber(contact.getContactHouseNumber());
344                 this.setStreet(contact.getContactStreet());
345                 this.setZipCode(contact.getContactZipCode());
346
347                 // Is the cell phone set?
348                 if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) {
349                         // ... cellphone data
350                         this.setCellphoneId(contact.getContactCellphoneNumber().getPhoneId());
351                         this.setCellphoneCarrier(contact.getContactCellphoneNumber().getCellphoneProvider());
352                         this.setCellphoneNumber(contact.getContactCellphoneNumber().getPhoneNumber());
353                 }
354
355                 // Is the fax set?
356                 if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
357                         // ... fax data
358                         this.setFaxId(contact.getContactFaxNumber().getPhoneId());
359                         this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode());
360                         this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry());
361                         this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber());
362                 }
363
364                 // Is the land-line number set?
365                 if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
366                         // .. land-line data
367                         this.setLandLineId(contact.getContactLandLineNumber().getPhoneId());
368                         this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode());
369                         this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry());
370                         this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber());
371                 }
372
373                 // Log message
374                 //* NOISY-DEBUG: */ System.out.println("AdminContactController::copyContactToController(): EXIT!"); //NOI18N
375         }
376
377         @Override
378         public Contact createContactInstance () {
379                 // Are all minimum fields set?
380                 if (this.getGender() == null) {
381                         // Throw NPE
382                         throw new NullPointerException("gender is null"); //NOI18N
383                 } else if (this.getFirstName() == null) {
384                         // Throw NPE
385                         throw new NullPointerException("firstName is null"); //NOI18N
386                 } else if (this.getFirstName().isEmpty()) {
387                         // Empty string
388                         throw new IllegalStateException("firstName is empty"); //NOI18N
389                 } else if (this.getFamilyName() == null) {
390                         // Throw NPE
391                         throw new NullPointerException("familyName is null"); //NOI18N
392                 } else if (this.getFamilyName().isEmpty()) {
393                         // Empty string
394                         throw new IllegalStateException("familyName is empty"); //NOI18N
395                 }
396
397                 // Generate phone number
398                 DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
399                 DialableCellphoneNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber());
400                 DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
401
402                 // Create new instance
403                 Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
404
405                 // Add all others
406                 contact.setContactBirthday(this.getBirthday());
407                 contact.setContactStreet(this.getStreet());
408                 contact.setContactHouseNumber(this.getHouseNumber());
409                 contact.setContactZipCode(this.getZipCode());
410                 contact.setContactCity(this.getCity());
411                 contact.setContactCountry(this.getCountry());
412                 contact.setContactEmailAddress(this.getEmailAddress());
413                 contact.setContactBirthday(this.getBirthday());
414                 contact.setContactComment(this.getComment());
415
416                 // Set ownContact
417                 contact.setContactOwnContact(Boolean.TRUE);
418
419                 // Don't set null or wrong references
420                 if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) {
421                         // Now the number must be given
422                         if (phone.getPhoneAreaCode() == null) {
423                                 // Is null
424                                 throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
425                         } else if (phone.getPhoneAreaCode() < 1) {
426                                 // Abort here
427                                 throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
428                         } else if (phone.getPhoneNumber() == null) {
429                                 // Is null
430                                 throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
431                         } else if (phone.getPhoneNumber() < 1) {
432                                 // Abort here
433                                 throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
434                         }
435
436                         // Set phone number
437                         contact.setContactLandLineNumber(phone);
438                 }
439
440                 // Don't set null or wrong references
441                 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
442                         // Now the number must be given
443                         if (fax.getPhoneAreaCode() == null) {
444                                 // Is null
445                                 throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
446                         } else if (fax.getPhoneAreaCode() < 1) {
447                                 // Abort here
448                                 throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
449                         } else if (fax.getPhoneNumber() == null) {
450                                 // Is null
451                                 throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
452                         } else if (fax.getPhoneNumber() < 1) {
453                                 // Abort here
454                                 throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
455                         }
456
457                         // Set fax number
458                         contact.setContactFaxNumber(fax);
459                 }
460
461                 // Is the provider set?
462                 if ((cellphone instanceof DialableCellphoneNumber) && (this.getCellphoneCarrier() instanceof MobileProvider) && (this.getCellphoneNumber() != null) && (this.getCellphoneNumber() > 0)) {
463                         // Is the number set?
464                         if (cellphone.getPhoneNumber() == null) {
465                                 // Is null
466                                 throw new NullPointerException("cellphone.phoneNumber is null"); //NOI18N
467                         } else if (cellphone.getPhoneNumber() < 1) {
468                                 // Abort here
469                                 throw new IllegalArgumentException("cellphone.phoneNumber is zero or below."); //NOI18N
470                         }
471
472                         // Set cellphone number
473                         contact.setContactCellphoneNumber(cellphone);
474                 }
475
476                 // Return it
477                 return contact;
478         }
479
480         @Override
481         public Date getBirthday () {
482                 return this.birthday;
483         }
484
485         @Override
486         public void setBirthday (final Date birthday) {
487                 this.birthday = birthday;
488         }
489
490         @Override
491         public MobileProvider getCellphoneCarrier () {
492                 return this.cellphoneCarrier;
493         }
494
495         @Override
496         public void setCellphoneCarrier (final MobileProvider cellphoneCarrier) {
497                 this.cellphoneCarrier = cellphoneCarrier;
498         }
499
500         @Override
501         public Long getCellphoneId () {
502                 return this.cellphoneId;
503         }
504
505         @Override
506         public void setCellphoneId (final Long cellphoneId) {
507                 this.cellphoneId = cellphoneId;
508         }
509
510         @Override
511         public Long getCellphoneNumber () {
512                 return this.cellphoneNumber;
513         }
514
515         @Override
516         public void setCellphoneNumber (Long cellphoneNumber) {
517                 this.cellphoneNumber = cellphoneNumber;
518         }
519
520         @Override
521         public String getCity () {
522                 return this.city;
523         }
524
525         @Override
526         public void setCity (final String city) {
527                 this.city = city;
528         }
529
530         @Override
531         public String getComment () {
532                 return this.comment;
533         }
534
535         @Override
536         public void setComment (final String comment) {
537                 this.comment = comment;
538         }
539
540         @Override
541         public Long getContactId () {
542                 return this.contactId;
543         }
544
545         @Override
546         public void setContactId (final Long contactId) {
547                 this.contactId = contactId;
548         }
549
550         @Override
551         public Country getCountry () {
552                 return this.country;
553         }
554
555         @Override
556         public void setCountry (final Country country) {
557                 this.country = country;
558         }
559
560         @Override
561         public String getEmailAddress () {
562                 return this.emailAddress;
563         }
564
565         @Override
566         public void setEmailAddress (final String emailAddress) {
567                 this.emailAddress = emailAddress;
568         }
569
570         @Override
571         public String getFamilyName () {
572                 return this.familyName;
573         }
574
575         @Override
576         public void setFamilyName (final String familyName) {
577                 this.familyName = familyName;
578         }
579
580         @Override
581         public Integer getFaxAreaCode () {
582                 return this.faxAreaCode;
583         }
584
585         @Override
586         public void setFaxAreaCode (final Integer faxAreaCode) {
587                 this.faxAreaCode = faxAreaCode;
588         }
589
590         @Override
591         public Country getFaxCountry () {
592                 return this.faxCountry;
593         }
594
595         @Override
596         public void setFaxCountry (final Country faxCountry) {
597                 this.faxCountry = faxCountry;
598         }
599
600         @Override
601         public Long getFaxId () {
602                 return this.faxId;
603         }
604
605         @Override
606         public void setFaxId (final Long faxId) {
607                 this.faxId = faxId;
608         }
609
610         @Override
611         public Long getFaxNumber () {
612                 return this.faxNumber;
613         }
614
615         @Override
616         public void setFaxNumber (final Long faxNumber) {
617                 this.faxNumber = faxNumber;
618         }
619
620         @Override
621         public String getFirstName () {
622                 return this.firstName;
623         }
624
625         @Override
626         public void setFirstName (final String firstName) {
627                 this.firstName = firstName;
628         }
629
630         @Override
631         public Gender getGender () {
632                 return this.gender;
633         }
634
635         @Override
636         public void setGender (final Gender gender) {
637                 this.gender = gender;
638         }
639
640         @Override
641         public Short getHouseNumber () {
642                 return this.houseNumber;
643         }
644
645         @Override
646         public void setHouseNumber (final Short houseNumber) {
647                 this.houseNumber = houseNumber;
648         }
649
650         @Override
651         public Long getLandLineId () {
652                 return this.landLineId;
653         }
654
655         @Override
656         public void setLandLineId (final Long landLineId) {
657                 this.landLineId = landLineId;
658         }
659
660         @Override
661         public Integer getPhoneAreaCode () {
662                 return this.phoneAreaCode;
663         }
664
665         @Override
666         public void setPhoneAreaCode (final Integer phoneAreaCode) {
667                 this.phoneAreaCode = phoneAreaCode;
668         }
669
670         @Override
671         public Country getPhoneCountry () {
672                 return this.phoneCountry;
673         }
674
675         @Override
676         public void setPhoneCountry (final Country phoneCountry) {
677                 this.phoneCountry = phoneCountry;
678         }
679
680         @Override
681         public Long getPhoneNumber () {
682                 return this.phoneNumber;
683         }
684
685         @Override
686         public void setPhoneNumber (final Long phoneNumber) {
687                 this.phoneNumber = phoneNumber;
688         }
689
690         @Override
691         public String getStreet () {
692                 return this.street;
693         }
694
695         @Override
696         public void setStreet (final String street) {
697                 this.street = street;
698         }
699
700         @Override
701         public Integer getZipCode () {
702                 return this.zipCode;
703         }
704
705         @Override
706         public void setZipCode (final Integer zipCode) {
707                 this.zipCode = zipCode;
708         }
709
710         @Override
711         public boolean hasContacts () {
712                 return (!this.allContacts().isEmpty());
713         }
714
715         /**
716          * Post-initialization of this class
717          */
718         @PostConstruct
719         public void init () {
720         }
721
722         /**
723          * Clears this bean
724          */
725         private void clear () {
726                 // Clear all data
727                 // - personal data
728                 this.setGender(Gender.UNKNOWN);
729                 this.setFirstName(null);
730                 this.setFamilyName(null);
731                 this.setStreet(null);
732                 this.setHouseNumber(null);
733                 this.setZipCode(null);
734                 this.setCity(null);
735                 this.setCountry(null);
736
737                 // - contact data
738                 this.setEmailAddress(null);
739                 this.setPhoneCountry(null);
740                 this.setPhoneAreaCode(null);
741                 this.setPhoneNumber(null);
742                 this.setCellphoneCarrier(null);
743                 this.setCellphoneNumber(null);
744                 this.setFaxCountry(null);
745                 this.setFaxAreaCode(null);
746                 this.setFaxNumber(null);
747
748                 // - other data
749                 this.setBirthday(null);
750                 this.setComment(null);
751         }
752
753         /**
754          * Checks whether the given contact is found
755          * <p>
756          * @param contact Contact inastance
757          *
758          * @return Wether contact has been found
759          */
760         private boolean isSameContactFound (final Contact contact) {
761                 // Default is not found
762                 boolean IsFound = false;
763
764                 // Get iterator
765                 Iterator<Contact> iterator = this.allContacts().iterator();
766
767                 // Loop through all
768                 while (iterator.hasNext()) {
769                         // Get next contact
770                         Contact next = iterator.next();
771
772                         // Is the same?
773                         if (ContactUtils.isSameContact(contact, next)) {
774                                 // Yes, then abort loop
775                                 IsFound = false;
776                                 break;
777                         }
778                 }
779
780                 // Return status
781                 return IsFound;
782         }
783
784         /**
785          * Updates all data in contact instance.
786          * <p>
787          * @param contact Contact instance
788          */
789         private void updateContactData (final Contact contact) {
790                 // Contact instance should be valid
791                 if (null == contact) {
792                         // Throw NPE
793                         throw new NullPointerException("contact is null"); //NOI18N
794                 } else if (contact.getContactId() == null) {
795                         // Throw NPE again
796                         throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
797                 } else if (contact.getContactId() < 1) {
798                         // Invalid id
799                         throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
800                 }
801
802                 // Update all fields
803                 contact.setContactGender(this.getGender());
804                 contact.setContactFirstName(this.getFirstName());
805                 contact.setContactFamilyName(this.getFamilyName());
806                 contact.setContactStreet(this.getStreet());
807                 contact.setContactHouseNumber(this.getHouseNumber());
808                 contact.setContactZipCode(this.getZipCode());
809                 contact.setContactCity(this.getCity());
810                 contact.setContactCountry(this.getCountry());
811
812                 // Update contact's cellphone number
813                 this.isCellphoneUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getCellphoneCarrier(), this.getCellphoneNumber());
814
815                 // Update contact's land-line number
816                 this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
817
818                 // Update contact's fax number
819                 this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
820         }
821
822 }