}
@Override
- public boolean isContactFound (final Contact contact) {
+ public Contact lookupContact (final Contact contact) {
// Log trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("isContactFound: contact={0} - CALLED!", contact)); //NOI18N
} else if ((contact.getContactId() instanceof Long) && (contact.getContactId() > 0)) {
try {
// Id set, ask other method
- return (this.findContactById(contact.getContactId()) instanceof Contact);
+ return this.findContactById(contact.getContactId());
} catch (final ContactNotFoundException ex) {
// Not found, should not happen
throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is set, but not found.", contact.getContactId()), ex); //NOI18N
}
// Default is not found
- boolean isFound = false;
+ Contact foundContact = null;
// Get whole list
List<Contact> contacts = this.getAllContacts();
if (contacts.isEmpty()) {
// Then abort here
this.getLoggerBeanLocal().logTrace("isContactFound: No contacts registered, returning 'false' ..."); //NOI18N
- return false;
+ return null;
}
// Get iterator
// Debug message
this.getLoggerBeanLocal().logDebug(MessageFormat.format("isContactFound: Found same contact, id={0}", next.getContactId())); //NOI18N
- // Set contact id
- contact.setContactId(next.getContactId());
-
- // Update also other ids
- this.setAllContactPhoneEntries(contact, next);
-
// Found it
- isFound = true;
+ foundContact = next;
break;
}
}
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("isContactFound: isFound={0} - EXIT!", isFound)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("isContactFound: foundContact={0} - EXIT!", foundContact)); //NOI18N
// Return status
- return isFound;
+ return foundContact;
}
@Override
// Get contact instance
Contact contact = customer.getCustomerContact();
- Contact updatedContact = null;
+ Contact updatedContact = this.contactBean.lookupContact(contact);
// Is a customer found?
- if (this.contactBean.isContactFound(contact)) {
+ if (updatedContact instanceof Contact) {
// Yes, then get updated version
updatedContact = this.contactBean.updateContactData(contact);