import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote;
import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
return foundUser;
}
+ @Override
+ public User findUserById (final Long userId) throws UserNotFoundException {
+ // Is the parameter valid?
+ if (null == userId) {
+ // Throw NPE
+ throw new NullPointerException("userId is null"); //NOI18N
+ } else if (userId < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("userId={0} is not valid.", userId)); //NOI18N
+ } else if (!this.ifUserIdExists(userId)) {
+ // Does not exist
+ throw new UserNotFoundException(userId);
+ }
+
+ // Create query instance
+ Query query = this.getEntityManager().createNamedQuery("SearchUserId", LoginUser.class); //NOI18N
+
+ // Set user id
+ query.setParameter("id", userId); //NOI18N
+
+ // Fetch the result, it should be there by now
+ User user = (User) query.getSingleResult();
+
+ // Should be there
+ assert(user instanceof User) : "user is null"; //NOI18N
+
+ // Return found user
+ return user;
+ }
+
@Override
@SuppressWarnings ("unchecked")
public List<String> getEmailAddressList () {
@Override
public void updateUserPersonalData (final User user) {
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("updateUserPersonalData: user={0} - CALLED!", user));
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("updateUserPersonalData: user={0} - CALLED!", user)); //NOI18N
// user should not be null
if (null == user) {
assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", user.getUserContact().getContactId()); //NOI18N
// Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: contact.contactId={0}", foundContact.getContactId()));
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: contact.contactId={0}", foundContact.getContactId())); //NOI18N
// Merge contact instance
Contact detachedContact = this.getEntityManager().merge(foundContact);
// Is there a cellphone instance set?
if (cellphone instanceof DialableCellphoneNumber) {
// Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: cellphone.phoneId={0} is being updated ...", cellphone.getPhoneId()));
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: cellphone.phoneId={0} is being updated ...", cellphone.getPhoneId())); //NOI18N
// Then find it, too
DialableCellphoneNumber foundCellphone = this.getEntityManager().find(cellphone.getClass(), cellphone.getPhoneId());
// Should be there
- assert (foundCellphone instanceof DialableCellphoneNumber) : MessageFormat.format("Cellphone number with id {0} not found but should be.", foundCellphone.getPhoneId());
+ assert (foundCellphone instanceof DialableCellphoneNumber) : MessageFormat.format("Cellphone number with id {0} not found but should be.", foundCellphone.getPhoneId()); //NOI18N
// Then merge it, too
DialableCellphoneNumber detachedCellphone = this.getEntityManager().merge(foundCellphone);
// Should be there
- assert (detachedCellphone instanceof DialableCellphoneNumber) : MessageFormat.format("Cellphone number with id {0} not found but should be.", detachedCellphone.getPhoneId());
+ assert (detachedCellphone instanceof DialableCellphoneNumber) : MessageFormat.format("Cellphone number with id {0} not found but should be.", detachedCellphone.getPhoneId()); //NOI18N
// Copy all
detachedCellphone.copyAll(user.getUserContact().getContactCellphoneNumber());
// Is there a fax instance set?
if (fax instanceof DialableFaxNumber) {
// Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: fax.phoneId={0} is being updated ...", fax.getPhoneId()));
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: fax.phoneId={0} is being updated ...", fax.getPhoneId())); //NOI18N
// Then find it, too
DialableFaxNumber foundFax = this.getEntityManager().find(fax.getClass(), fax.getPhoneId());
// Should be there
- assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId());
+ assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N
// Then merge it, too
DialableFaxNumber detachedFax = this.getEntityManager().merge(foundFax);
// Should be there
- assert (detachedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", detachedFax.getPhoneId());
+ assert (detachedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", detachedFax.getPhoneId()); //NOI18N
// Copy all
detachedFax.copyAll(user.getUserContact().getContactFaxNumber());
// Is there a fax instance set?
if (landLine instanceof DialableLandLineNumber) {
// Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLine.phoneId={0} is being updated ...", landLine.getPhoneId()));
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLine.phoneId={0} is being updated ...", landLine.getPhoneId())); //NOI18N
// Then find it, too
DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLine.getClass(), landLine.getPhoneId());
// Should be there
- assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId());
+ assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId()); //NOI18N
// Then merge it, too
DialableLandLineNumber detachedLandLine = this.getEntityManager().merge(foundLandLine);
// Should be there
- assert (detachedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", detachedLandLine.getPhoneId());
+ assert (detachedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", detachedLandLine.getPhoneId()); //NOI18N
// Copy all
detachedLandLine.copyAll(user.getUserContact().getContactLandLineNumber());