throw new IllegalStateException("User does already exist."); //NOI18N
}
- // Check if user is registered
- if (this.registerBean.isUserNameRegistered(user)) {
- // Abort here
- throw new UserNameAlreadyRegisteredException(user);
- } else if (this.registerBean.isEmailAddressRegistered(user)) {
- // Abort here
- throw new EmailAddressAlreadyRegisteredException(user);
- }
-
- // Set created timestamp
- user.setUserCreated(new GregorianCalendar());
-
- // Try to find the contact instance
+ // Try to find the contact
Contact foundContact = this.getEntityManager().find(user.getUserContact().getClass(), user.getUserContact().getContactId());
- // Try to merge it
+ // Merge the contact to get a detached object back
Contact detachedContact = this.getEntityManager().merge(foundContact);
- // Set it in user
+ // Set detached object in rexcruiter instance
user.setUserContact(detachedContact);
- // Persist user
+ // Set timestamp
+ user.setUserCreated(new GregorianCalendar());
+
+ // Perist it
this.getEntityManager().persist(user);
- // Flush it to get id
+ // Flush it to get updated instance back
this.getEntityManager().flush();
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("linkUser: user.userId={0} - EXIT!", user.getUserId())); //NOI18N
+ // Log trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("linkUser: user={0} - EXIT!", user)); //NOI18N
// Return updated instanc
return user;