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