import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
import org.mxchange.jcontacts.contact.Contact;
import org.mxchange.jcontacts.contact.UserContact;
import org.mxchange.jcontacts.contact.gender.Gender;
import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
-import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
import org.mxchange.jusercore.events.login.UserLoggedInEvent;
import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
/**
* A user bean (controller)
/**
* Cellphone number's carrier
*/
- private SmsProvider cellphoneCarrier;
+ private MobileProvider cellphoneCarrier;
/**
* Cellphone number
*/
private String street;
+ /**
+ * User instance
+ */
+ private User user;
+
/**
* Remote user bean
*/
this.addUserNameEmailAddress(registeredUser);
// Clear all data
- this.clearData();
+ this.clear();
// Set user id again
this.setUserId(registeredUser.getUserId());
}
// Is the provider set?
- if ((cellphone instanceof DialableCellphoneNumber) && (this.getCellphoneCarrier() instanceof SmsProvider) && (this.getCellphoneNumber() != null) && (this.getCellphoneNumber() > 0)) {
+ if ((cellphone instanceof DialableCellphoneNumber) && (this.getCellphoneCarrier() instanceof MobileProvider) && (this.getCellphoneNumber() != null) && (this.getCellphoneNumber() > 0)) {
// Is the number set?
if (cellphone.getPhoneNumber() == null) {
// Is null
// Trace message
//this.getLogger().logTrace(MessageFormat.format("createUserInstance: user={0} - EXIT!", user));
-
// Return it
return user;
}
}
@Override
- public SmsProvider getCellphoneCarrier () {
+ public MobileProvider getCellphoneCarrier () {
return this.cellphoneCarrier;
}
@Override
- public void setCellphoneCarrier (final SmsProvider cellphoneCarrier) {
+ public void setCellphoneCarrier (final MobileProvider cellphoneCarrier) {
this.cellphoneCarrier = cellphoneCarrier;
}
this.street = street;
}
+ @Override
+ public User getUser () {
+ return this.user;
+ }
+
+ @Override
+ public void setUser (final User user) {
+ this.user = user;
+ }
+
@Override
public Long getUserId () {
return this.userId;
@Override
public User lookupUserById (final Long userId) throws UserNotFoundException {
// Init variable
- User user = null;
+ User localUser = null;
+
+ // Clear this bean
+ this.clear();
// Try to lookup it in visible user list
for (final Iterator<User> iterator = this.visibleUserList.iterator(); iterator.hasNext();) {
// Is the user id found?
if (Objects.equals(next.getUserId(), userId)) {
// Copy to other variable
- user = next;
+ localUser = next;
break;
}
}
// Is it still null?
- if (null == user) {
+ if (null == localUser) {
// Not visible for the current user
throw new UserNotFoundException(userId);
}
+ // Copy all data to this bean
+ this.copyUser(localUser);
+
// Return it
- return user;
+ return localUser;
}
/**
}
/**
- * Clears all data in this bean
+ * Clears this bean
*/
- private void clearData () {
+ private void clear () {
// Clear all data
// - personal data
this.setUserId(null);
this.setUserName(null);
this.setUserPassword(null);
this.setUserPasswordRepeat(null);
+
+ // - user instance
+ this.setUser(null);
}
/**
this.setPhoneAreaCode(phone.getPhoneAreaCode());
this.setPhoneNumber(phone.getPhoneNumber());
}
- if ((cellphone instanceof DialableCellphoneNumber) && (cellphone.getCellphoneProvider() instanceof SmsProvider)) {
+ if ((cellphone instanceof DialableCellphoneNumber) && (cellphone.getCellphoneProvider() instanceof MobileProvider)) {
this.setCellphoneCarrier(cellphone.getCellphoneProvider());
this.setCellphoneNumber(cellphone.getPhoneNumber());
}