+ @Override
+ public Contact addContact (final Contact contact) throws ContactAlreadyAddedException {
+ // Log trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("addContact: contact={0} - CALLED!", contact)); //NOI18N
+
+ // The contact instance must be valid
+ if (null == contact) {
+ // Throw NPE again
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() instanceof Long) {
+ // Throw NPE again
+ throw new NullPointerException("contact.contactId is not null"); //NOI18N //NOI18N
+ } else if (this.lookupContact(contact) instanceof Contact) {
+ // Already found
+ throw new ContactAlreadyAddedException(contact);
+ }
+
+ // Set created timestamp
+ contact.setContactCreated(new GregorianCalendar());
+
+ // Set all created timestamps in cellphone, land-line and fax number(s)
+ this.setAllContactPhoneEntriesCreated(contact);
+
+ // Persist it
+ this.getEntityManager().persist(contact);
+
+ // Flush it
+ this.getEntityManager().flush();
+
+ // Return updated instance
+ return contact;
+ }
+