2 * Copyright (C) 2016, 2017 Roland Häder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
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 General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jfinancials.database;
19 import java.text.MessageFormat;
20 import java.util.GregorianCalendar;
21 import java.util.Objects;
22 import java.util.Properties;
23 import javax.ejb.EJBException;
24 import javax.faces.FacesException;
25 import javax.jms.Connection;
26 import javax.jms.JMSException;
27 import javax.jms.MessageProducer;
28 import javax.jms.ObjectMessage;
29 import javax.jms.Queue;
30 import javax.jms.QueueConnectionFactory;
31 import javax.jms.Session;
32 import javax.mail.Address;
33 import javax.naming.Context;
34 import javax.naming.InitialContext;
35 import javax.naming.NamingException;
36 import org.mxchange.jcontacts.contact.Contact;
37 import org.mxchange.jcoreee.database.BaseDatabaseBean;
38 import org.mxchange.jmailee.model.delivery.wrapper.EmailDeliveryWrapper;
39 import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery;
40 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
41 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
42 import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
43 import org.mxchange.jphone.utils.PhoneUtils;
44 import org.mxchange.jusercore.model.user.LoginUser;
45 import org.mxchange.jusercore.model.user.User;
46 import org.mxchange.jusercore.model.user.UserUtils;
49 * A helper class for beans that access the database.
51 * @author Roland Häder<roland@mxchange.org>
53 public abstract class BaseFinancialsDatabaseBean extends BaseDatabaseBean {
58 private static final long serialVersionUID = 12_895_410_275_811_963L;
63 private Connection connection;
68 private MessageProducer messageProducer;
71 * Mailer message queue
78 private Session session;
81 * Protected constructor
83 protected BaseFinancialsDatabaseBean () {
84 // Call super constructor
88 // Get initial context
89 Context context = new InitialContext();
91 // Get factory from JMS resource
92 QueueConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup("jms/jfinancials-queue-factory"); //NOI18N
95 this.queue = (Queue) context.lookup("jms/jfinancials-email-queue"); //NOI18N
98 this.connection = connectionFactory.createConnection();
100 // Init session instance
101 this.session = this.connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
103 // And message producer
104 this.messageProducer = this.session.createProducer(this.queue);
105 } catch (final NamingException | JMSException e) {
106 // Continued to throw
107 throw new FacesException(e);
112 * Updates all contact's phone entry's created timestamps
114 * @param contact Contact instance to update
116 protected void setAllContactPhoneEntriesCreated (final Contact contact) {
118 this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllContactPhoneEntriesCreated: contact={0} - CALLED!", contact)); //NOI18N
120 // The contact instance must be valid
121 if (null == contact) {
123 throw new NullPointerException("contact is null"); //NOI18N
126 // Get all phone instances
127 DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
128 DialableFaxNumber faxNumber = contact.getContactFaxNumber();
129 DialableMobileNumber mobileNumber = contact.getContactMobileNumber();
132 this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntriesCreated: landLineNumber={0},faxNumber={1},mobileNumber={2}", landLineNumber, faxNumber, mobileNumber)); //NOI18N
134 // Is a phone number instance set?
135 if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() == null)) {
137 this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesCreated: Setting created timestamp for land-line number ..."); //NOI18N
139 // Set updated timestamp
140 landLineNumber.setPhoneEntryCreated(new GregorianCalendar());
143 // Is a fax number instance set?
144 if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() == null)) {
146 this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesCreated: Setting created timestamp for fax number ..."); //NOI18N
148 // Set updated timestamp
149 faxNumber.setPhoneEntryCreated(new GregorianCalendar());
152 // Is a mobile number instance set?
153 if ((mobileNumber instanceof DialableMobileNumber) && (mobileNumber.getPhoneId() == null)) {
155 this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesCreated: Setting created timestamp for mobile number ..."); //NOI18N
157 // Set updated timestamp
158 mobileNumber.setPhoneEntryCreated(new GregorianCalendar());
162 this.getLoggerBeanLocal().logTrace("setAllContactPhoneEntriesCreated: EXIT!"); //NOI18N
166 * Returns a detached instance from given mobile instance
168 * @param mobileNumber Mobile instance
169 * @param fetchedNumber Found mobile number in database
171 * @return Detached instance
173 protected DialableMobileNumber getDetached (final DialableMobileNumber mobileNumber, final DialableMobileNumber fetchedNumber) {
175 this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: mobileNumber={0},fetchedNumber={1} - CALLED!", mobileNumber, fetchedNumber)); //NOI18N
178 if (null == mobileNumber) {
180 throw new NullPointerException("mobileNumber is null"); //NOI18N
181 } else if (fetchedNumber.getPhoneId() == null) {
183 throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
187 this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
189 // Init query instance
190 DialableMobileNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
193 this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
196 DialableMobileNumber detachedNumber = null;
198 // Is there a difference?
199 if (!PhoneUtils.isSameMobileNumber(mobileNumber, fetchedNumber)) {
201 detachedNumber = this.getEntityManager().merge(foundNumber);
207 this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
210 return detachedNumber;
214 * Returns a detached instance from given land-line instance
216 * @param landLineNumber Land-line instance
217 * @param fetchedNumber Found land-line number in database
219 * @return Detached instance
221 protected DialableLandLineNumber getDetached (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber fetchedNumber) {
223 this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: landLineNumber={0},fetchedNumber={1} - CALLED!", landLineNumber, fetchedNumber)); //NOI18N
226 if (null == landLineNumber) {
228 throw new NullPointerException("landLineNumber is null"); //NOI18N
229 } else if (fetchedNumber.getPhoneId() == null) {
231 throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
235 this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
237 // Init query instance
238 DialableLandLineNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
241 this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
244 DialableLandLineNumber detachedNumber = null;
246 // Is there a difference?
247 if (!PhoneUtils.isSameLandLineNumber(landLineNumber, fetchedNumber)) {
249 detachedNumber = this.getEntityManager().merge(foundNumber);
253 this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
256 return detachedNumber;
260 * Returns a detached instance from given fax instance
262 * @param faxNumber Fax instance
263 * @param fetchedNumber Found fax number in database
265 * @return Detached instance
267 protected DialableFaxNumber getDetached (final DialableFaxNumber faxNumber, final DialableFaxNumber fetchedNumber) {
269 this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: faxNumber={0},fetchedNumber={1} - CALLED!", faxNumber, fetchedNumber)); //NOI18N
272 if (null == faxNumber) {
274 throw new NullPointerException("faxNumber is null"); //NOI18N
275 } else if (fetchedNumber.getPhoneId() == null) {
277 throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
281 this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
283 // Init query instance
284 DialableFaxNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
287 this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
290 DialableFaxNumber detachedNumber = null;
292 // Is there a difference?
293 if (!PhoneUtils.isSameFaxNumber(faxNumber, fetchedNumber)) {
295 detachedNumber = this.getEntityManager().merge(foundNumber);
299 this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
302 return detachedNumber;
306 * Get back a managed instance from given user
308 * @param user Unmanaged/detached user instance
310 * @return Managed user instance
312 protected User getManagedUser (final User user) {
314 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getManaged: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
316 // user should not be null
319 throw new NullPointerException("user is null"); //NOI18N
320 } else if (user.getUserId() == null) {
322 throw new NullPointerException("user.userId is null"); //NOI18N
323 } else if (user.getUserId() < 1) {
325 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is null", user.getUserId())); //NOI18N
326 } else if (user.getUserContact() == null) {
328 throw new NullPointerException("user.userContact is null"); //NOI18N
329 } else if (user.getUserContact().getContactId() == null) {
331 throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
332 } else if (user.getUserContact().getContactId() < 1) {
333 // Not valid id number
334 throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is not valid", user.getUserContact().getContactId())); //NOI18N#
337 // Try to find it (should be there)
338 User managedUser = this.getEntityManager().find(LoginUser.class, user.getUserId());
341 assert (managedUser instanceof User) : "managedUser is null"; //NOI18N
344 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getManaged: managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
351 * Merges given contact's data
353 * @param contact Contact instance to merge
355 * @return Detached contact instance
357 protected Contact mergeContactData (final Contact contact) {
359 this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: contact={0} - CALLED!", contact)); //NOI18N
361 // The contact instance must be valid
362 if (null == contact) {
364 throw new NullPointerException("contact is null"); //NOI18N
365 } else if (contact.getContactId() == null) {
367 throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
368 } else if (contact.getContactId() < 1) {
370 throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
373 // Set updated timestamp
374 contact.setContactUpdated(new GregorianCalendar());
376 // Get contact from it and find it
377 Contact foundContact = this.getEntityManager().find(contact.getClass(), contact.getContactId());
380 assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", contact.getContactId()); //NOI18N
383 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: foundContact.contactId={0}", foundContact.getContactId())); //NOI18N
385 // Merge contact instance
386 Contact detachedContact = this.getEntityManager().merge(foundContact);
389 detachedContact.copyAll(contact);
392 this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: detachedContact={0} - EXIT!", detachedContact)); //NOI18N
394 // Return detached contact
395 return detachedContact;
399 * Merges given (detached) contact's mobile, land-line and fax numbers
401 * @param detachedContact Detached contact instance
403 protected void mergeContactsMobileLandLineFaxNumbers (final Contact detachedContact) {
405 this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactsMobileLandLineFaxNumbers: detachedContact={0} - CALLED!", detachedContact)); //NOI18N
407 // The contact instance must be valid
408 if (null == detachedContact) {
410 throw new NullPointerException("detachedContact is null"); //NOI18N
411 } else if (detachedContact.getContactId() == null) {
413 throw new NullPointerException("detachedContact.contactId is null"); //NOI18N //NOI18N
414 } else if (detachedContact.getContactId() < 1) {
416 throw new IllegalStateException(MessageFormat.format("detachedContact.contactId={0} is not valid.", detachedContact.getContactId())); //NOI18N
420 DialableMobileNumber mobile = detachedContact.getContactMobileNumber();
421 DialableLandLineNumber landLine = detachedContact.getContactLandLineNumber();
422 DialableFaxNumber fax = detachedContact.getContactFaxNumber();
424 // Is there a mobile instance set?
425 if (mobile instanceof DialableMobileNumber) {
427 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: mobile.phoneId={0} is being updated ...", mobile.getPhoneId())); //NOI18N
430 DialableMobileNumber foundMobile = this.getEntityManager().find(mobile.getClass(), mobile.getPhoneId());
433 assert (foundMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", foundMobile.getPhoneId()); //NOI18N
435 // Then merge it, too
436 DialableMobileNumber detachedMobile = this.getEntityManager().merge(foundMobile);
439 assert (detachedMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", detachedMobile.getPhoneId()); //NOI18N
442 detachedMobile.copyAll(detachedContact.getContactMobileNumber());
445 detachedContact.setContactMobileNumber(detachedMobile);
448 // Is there a fax instance set?
449 if (fax instanceof DialableFaxNumber) {
451 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: fax.phoneId={0} is being updated ...", fax.getPhoneId())); //NOI18N
454 DialableFaxNumber foundFax = this.getEntityManager().find(fax.getClass(), fax.getPhoneId());
457 assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N
459 // Then merge it, too
460 DialableFaxNumber detachedFax = this.getEntityManager().merge(foundFax);
463 assert (detachedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", detachedFax.getPhoneId()); //NOI18N
466 detachedFax.copyAll(detachedContact.getContactFaxNumber());
469 detachedContact.setContactFaxNumber(detachedFax);
472 // Is there a fax instance set?
473 if (landLine instanceof DialableLandLineNumber) {
475 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLine.phoneId={0} is being updated ...", landLine.getPhoneId())); //NOI18N
478 DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLine.getClass(), landLine.getPhoneId());
481 assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId()); //NOI18N
483 // Then merge it, too
484 DialableLandLineNumber detachedLandLine = this.getEntityManager().merge(foundLandLine);
487 assert (detachedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", detachedLandLine.getPhoneId()); //NOI18N
490 detachedLandLine.copyAll(detachedContact.getContactLandLineNumber());
493 detachedContact.setContactLandLineNumber(detachedLandLine);
497 this.getLoggerBeanLocal().logTrace("mergeContactsMobileLandLineFaxNumbers: EXIT!"); //NOI18N
501 * Sends an email with given subject line, template name to given recipient
504 * @param subjectLine Subject line
505 * @param templateName Template name
506 * @param emailAddress Recipient's email address
507 * @param user User instance
508 * @param baseUrl Base URL
510 protected void sendEmail (final String subjectLine, final String templateName, final Address emailAddress, final User user, final String baseUrl) {
512 this.getLoggerBeanLocal().logTrace(MessageFormat.format("sendEmail: subjectLine={0},templateName={1},emailAddress={2},user={3},baseUrl={4} - CALLED!", subjectLine, templateName, emailAddress, user, baseUrl)); //NOI18N
515 if (null == subjectLine) {
517 throw new NullPointerException("subjectLine is null"); //NOI18N
518 } else if (subjectLine.isEmpty()) {
520 throw new IllegalArgumentException("subjectLine is empty"); //NOI18N
521 } else if (null == templateName) {
523 throw new NullPointerException("templateName is null"); //NOI18N
524 } else if (templateName.isEmpty()) {
526 throw new IllegalArgumentException("templateName is empty"); //NOI18N
527 } else if (null == emailAddress) {
529 throw new NullPointerException("emailAddress is null"); //NOI18N
532 // Prepare mail wrapper
533 WrapableEmailDelivery emailWrapper = new EmailDeliveryWrapper();
536 Properties variables = UserUtils.getAllUserFields(user);
539 variables.put("baseUrl", baseUrl); //NOI18N
542 // @TODO Language from message bundle
543 emailWrapper.setRecipient(emailAddress);
544 emailWrapper.setLocale(user.getUserLocale());
545 emailWrapper.setSubjectLine(subjectLine);
546 emailWrapper.setTemplateName(templateName);
547 emailWrapper.setTemplateVariables(variables);
550 // Send out email change
551 ObjectMessage message = this.session.createObjectMessage();
552 message.setObject(emailWrapper);
555 this.sendMessage(message, this.messageProducer);
556 } catch (final JMSException ex) {
558 throw new EJBException(ex);
562 this.getLoggerBeanLocal().logTrace("sendEmail: EXIT!"); //NOI18N
566 * Updates all contact's phone instances from other contact, both contacts
567 * should be the same.
569 * @param contact Contact to set instances
570 * @param other Other contact to get instances from
572 protected void setAllContactPhoneEntries (final Contact contact, final Contact other) {
574 this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllContactPhoneEntries: contact={0},other={1} - CALLED!", contact, other)); //NOI18N
576 // Both must be the same and not null
577 if (null == contact) {
579 throw new NullPointerException("contact is null"); //NOI18N
580 } else if (null == other) {
582 throw new NullPointerException("other is null"); //NOI18N
583 } else if (!Objects.equals(contact, other)) {
584 // Not same instances
585 throw new IllegalArgumentException(MessageFormat.format("contact={0} and other={1} are not equal!", contact, other)); //NOI18N
589 this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntries: other.contactMobileNumber={0}", other.getContactMobileNumber())); //NOI18N
591 // Is other mobile not set?
592 if ((other.getContactMobileNumber() == null) || (PhoneUtils.isSameMobileNumber(contact.getContactMobileNumber(), other.getContactMobileNumber()))) {
594 this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntries: Copying mobile entry ..."); //NOI18N
596 // Is the fax number set?
597 if (other.getContactMobileNumber() instanceof DialableMobileNumber) {
598 // Copy mobile number
599 contact.setContactMobileNumber(this.getDetached(other.getContactMobileNumber(), contact.getContactMobileNumber()));
602 contact.setContactMobileNumber(null);
607 this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntries: other.contactLandLineNumber={0}", other.getContactLandLineNumber())); //NOI18N
609 // Is other mobile not set?
610 if ((other.getContactLandLineNumber() == null) || (PhoneUtils.isSameLandLineNumber(contact.getContactLandLineNumber(), other.getContactLandLineNumber()))) {
612 this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntries: Copying land-line entry ..."); //NOI18N
614 // Is the land-line number set?
615 if (other.getContactLandLineNumber() instanceof DialableLandLineNumber) {
616 // Copy land-line number
617 contact.setContactLandLineNumber(this.getDetached(other.getContactLandLineNumber(), contact.getContactLandLineNumber()));
620 contact.setContactLandLineNumber(null);
625 this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntries: other.contactFaxNumber={0}", other.getContactFaxNumber())); //NOI18N
627 // Is other mobile not set?
628 if ((other.getContactFaxNumber() == null) || (PhoneUtils.isSameFaxNumber(contact.getContactFaxNumber(), other.getContactFaxNumber()))) {
630 this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntries: Copying fax entry ..."); //NOI18N
632 // Is the fax number set?
633 if (other.getContactFaxNumber() instanceof DialableFaxNumber) {
635 contact.setContactFaxNumber(this.getDetached(other.getContactFaxNumber(), contact.getContactFaxNumber()));
638 contact.setContactFaxNumber(null);
643 this.getLoggerBeanLocal().logTrace("setAllContactPhoneEntries: EXIT!"); //NOI18N
647 * Updates all contact's phone entry's updated timestamps
649 * @param contact Contact instance to update
650 * @param isMobileUnlinked Whether a mobile entry has been unlinked in
652 * @param isLandlineUnlinked Whether a land-line entry has been unlinked in
654 * @param isFaxUnlinked Whether a fax entry has been unlinked in contact
657 protected void setAllContactPhoneEntriesUpdated (final Contact contact, final boolean isMobileUnlinked, final boolean isLandlineUnlinked, final boolean isFaxUnlinked) {
659 this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllContactPhoneEntriesUpdated: contact={0},isMobileUnlinked={1},isLandlineUnlinked={2},isFaxUnlinked={3} - CALLED", contact, isMobileUnlinked, isLandlineUnlinked, isFaxUnlinked)); //NOI18N
661 // The contact instance must be valid
662 if (null == contact) {
664 throw new NullPointerException("contact is null"); //NOI18N
665 } else if (contact.getContactId() == null) {
667 throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
668 } else if (contact.getContactId() < 1) {
670 throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
673 // Get all phone instances
674 DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
675 DialableFaxNumber faxNumber = contact.getContactFaxNumber();
676 DialableMobileNumber mobileNumber = contact.getContactMobileNumber();
678 // Flags and instances must be constistent
679 if (isMobileUnlinked && mobileNumber instanceof DialableMobileNumber) {
681 throw new IllegalStateException("isCellPhoneUnlinked is TRUE, but mobileNumber is set."); //NOI18N
682 } else if (isLandlineUnlinked && landLineNumber instanceof DialableLandLineNumber) {
684 throw new IllegalStateException("isLandlineUnlinked is TRUE, but landLineNumber is set."); //NOI18N
685 } else if (isFaxUnlinked && faxNumber instanceof DialableFaxNumber) {
687 throw new IllegalStateException("isFaxUnlinked is TRUE, but faxNumber is set."); //NOI18N
690 // Is a phone number instance set?
691 if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() instanceof Long) && (landLineNumber.getPhoneId() > 0)) {
693 this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesUpdated: Setting updated timestamp for land-line number ..."); //NOI18N
695 // Set updated timestamp
696 landLineNumber.setPhoneEntryUpdated(new GregorianCalendar());
699 // Is a fax number instance set?
700 if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() instanceof Long) && (faxNumber.getPhoneId() > 0)) {
702 this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesUpdated: Setting updated timestamp for fax number ..."); //NOI18N
704 // Set updated timestamp
705 faxNumber.setPhoneEntryUpdated(new GregorianCalendar());
708 // Is a mobile number instance set?
709 if ((mobileNumber instanceof DialableMobileNumber) && (mobileNumber.getPhoneId() instanceof Long) && (mobileNumber.getPhoneId() > 0)) {
711 this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesUpdated: Setting updated timestamp for mobile number ..."); //NOI18N
713 // Set updated timestamp
714 mobileNumber.setPhoneEntryUpdated(new GregorianCalendar());
718 this.getLoggerBeanLocal().logTrace("setAllContactPhoneEntriesUpdated: EXIT!"); //NOI18N