* Login controller
*/
@Inject
- private AddressbookUserLoginWebSessionController loginController;
+ private AddressbookUserLoginWebSessionController userLoginController;
/**
* A list of all user's address books
@Override
public String addAddressbook () {
// Is this name already used?
- if (!this.loginController.isUserLoggedIn()) {
+ if (!this.userLoginController.isUserLoggedIn()) {
// Not logged in
throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
} else if (this.getAddressbookName() == null) {
}
// Create address book instance with name
- Addressbook book = new UserAddressbook(this.getAddressbookName(), this.loginController.getLoggedInUser());
+ Addressbook book = new UserAddressbook(this.getAddressbookName(), this.userLoginController.getLoggedInUser());
try {
// Register this address book
} else if (event.getLoggedInUser()== null) {
// user is null
throw new NullPointerException("event.user is null"); //NOI18N
- } else if (!event.getLoggedInUser().equals(this.loginController.getLoggedInUser())) {
+ } else if (!event.getLoggedInUser().equals(this.userLoginController.getLoggedInUser())) {
// Not matching
- throw new IllegalStateException("event.user and loginController.loggedInUser don't match."); //NOI18N
- } else if (!this.loginController.isUserLoggedIn()) {
+ throw new IllegalStateException("event.user and userLoginController.loggedInUser don't match."); //NOI18N
+ } else if (!this.userLoginController.isUserLoggedIn()) {
// Not logged in
throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
}
@Override
public List<Addressbook> allAddressbooks () {
// Is the user logged in?
- if (!this.loginController.isUserLoggedIn()) {
+ if (!this.userLoginController.isUserLoggedIn()) {
// Not logged in
throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
}
@Override
public List<AddressbookEntry> allEntries (final Addressbook addressbook) {
// Is the user logged in?
- if (!this.loginController.isUserLoggedIn()) {
+ if (!this.userLoginController.isUserLoggedIn()) {
// Not logged in
throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
}
@Override
public List<User> allUsersNotSharing () {
// Is the user logged in?
- if (!this.loginController.isUserLoggedIn()) {
+ if (!this.userLoginController.isUserLoggedIn()) {
// Not logged in
throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
}
// Call EJB
- return this.addressbookBean.allUsersNotSharing(this.loginController.getLoggedInUser(), this.getAddressbook());
+ return this.addressbookBean.allUsersNotSharing(this.userLoginController.getLoggedInUser(), this.getAddressbook());
}
@Override
@Override
public boolean hasCreatedAddressbooks () {
// Is the user logged in?
- if (!this.loginController.isUserLoggedIn()) {
+ if (!this.userLoginController.isUserLoggedIn()) {
// Not logged in
throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
}
this.usersAddressbooks = new LinkedList<>();
// Is the user logged-in?
- if (this.loginController.isUserLoggedIn()) {
+ if (this.userLoginController.isUserLoggedIn()) {
// Initialize list
this.initAddressbookList();
}
@Override
public boolean isOwnAddressbook () {
// Is the user logged in?
- if (!this.loginController.isUserLoggedIn()) {
+ if (!this.userLoginController.isUserLoggedIn()) {
// No, then no own address book
throw new IllegalStateException("isOwnAddressbook() has been invoked for a guest account"); //NOI18N
}
// Is same user?
- return Objects.equals(this.getAddressbookUser(), this.loginController.getLoggedInUser());
+ return Objects.equals(this.getAddressbookUser(), this.userLoginController.getLoggedInUser());
}
@Override
*/
private void initAddressbookList () {
// Get user instance
- User user = this.loginController.getLoggedInUser();
+ User user = this.userLoginController.getLoggedInUser();
// Fill list with entries
this.usersAddressbooks = this.addressbookBean.getUsersAddressbookList(user);
Contact contact = this.userLoginController.getLoggedInUser().getUserContact();
// It should be there, so run some tests on it
- assert (contact instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; //NOI18N
- assert (contact.getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N
- assert (contact.getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N
+ assert (contact instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N
+ assert (contact.getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N
+ assert (contact.getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N
// Update all fields
contact.setContactGender(this.getGender());
User user = this.userLoginController.getLoggedInUser();
// It should be there, so run some tests on it
- assert (user instanceof User) : "Instance loginController.loggedInUser is null"; //NOI18N
- assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null"; //NOI18N
- assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N
- assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; //NOI18N
- assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N
- assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N
+ assert (user instanceof User) : "Instance userLoginController.loggedInUser is null"; //NOI18N
+ assert (user.getUserId() instanceof Long) : "Instance userLoginController.loggedInUser.userId is null"; //NOI18N
+ assert (user.getUserId() > 0) : MessageFormat.format("userLoginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N
+ assert (user.getUserContact() instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N
+ assert (user.getUserContact().getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N
+ assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N
// Check if the email address is already enqueued
if (this.isEmailAddressQueued(this.getEmailAddress())) {
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
-@Named ("loginController")
+@Named ("userLoginController")
@SessionScoped
public class AddressbookUserLoginWebSessionBean extends BaseAddressbookController implements AddressbookUserLoginWebSessionController {
* Login controller
*/
@Inject
- private AddressbookUserLoginWebSessionController loginController;
+ private AddressbookUserLoginWebSessionController userLoginController;
/**
* User controller
// Check all conditions (except for admin)
return ((profileMode.equals(ProfileMode.PUBLIC)) ||
- (this.loginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS)));
+ (this.userLoginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS)));
}
}
* Login controller injection
*/
@Inject
- private AddressbookUserLoginWebSessionController loginController;
+ private AddressbookUserLoginWebSessionController userLoginController;
/**
* Share instance
@Override
public List<ShareableAddressbook> allShares () {
// Is the user logged in?
- if (!this.loginController.isUserLoggedIn()) {
+ if (!this.userLoginController.isUserLoggedIn()) {
// Not logged in
throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
}
@Override
public boolean isSharingAddressbooks () {
// Only to be called for logged-in users
- if (!this.loginController.isUserLoggedIn()) {
+ if (!this.userLoginController.isUserLoggedIn()) {
// Not logged in
throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
} else if (this.isUserSharing instanceof Boolean) {
}
// Call the proper bean
- this.isUserSharing = this.shareBean.isUserSharingAddressbooks(this.loginController.getLoggedInUser());
+ this.isUserSharing = this.shareBean.isUserSharingAddressbooks(this.userLoginController.getLoggedInUser());
// Return it
return this.isUserSharing;
@Override
public String startSharing (final User user, final Addressbook addressbook) {
// Check conditions
- if (!this.loginController.isUserLoggedIn()) {
+ if (!this.userLoginController.isUserLoggedIn()) {
// No, then throw exception
throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
} else if (null == user) {
} else if (user.getUserId() < 1) {
// Invalid id number
throw new IllegalStateException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
- } else if (Objects.equals(user, this.loginController.getLoggedInUser())) {
+ } else if (Objects.equals(user, this.userLoginController.getLoggedInUser())) {
// Sharing with yourself!
throw new IllegalStateException("User tries to share with himself."); //NOI18N
} else if (null == addressbook) {
} else if (addressbook.getAddressbookId() < 1) {
// Invalid id number
throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId())); //NOI18N
- } else if (!Objects.equals(addressbook.getAddressbookUser(), this.loginController.getLoggedInUser())) {
+ } else if (!Objects.equals(addressbook.getAddressbookUser(), this.userLoginController.getLoggedInUser())) {
// Not the same user!
- throw new IllegalStateException(MessageFormat.format("Address book id {0} owner id {1} mismatching logged-in user id {2}", addressbook.getAddressbookId(), addressbook.getAddressbookUser().getUserId(), this.loginController.getLoggedInUser().getUserId())); //NOI18N
- } else if (this.loginController.getLoggedInUser().getUserProfileMode() == ProfileMode.INVISIBLE) {
+ throw new IllegalStateException(MessageFormat.format("Address book id {0} owner id {1} mismatching logged-in user id {2}", addressbook.getAddressbookId(), addressbook.getAddressbookUser().getUserId(), this.userLoginController.getLoggedInUser().getUserId())); //NOI18N
+ } else if (this.userLoginController.getLoggedInUser().getUserProfileMode() == ProfileMode.INVISIBLE) {
// User is invisible
- throw new FaceletException(MessageFormat.format("user {0} is invisible and cannot start sharing address books.", this.loginController.getLoggedInUser().getUserId())); //NOI18N
+ throw new FaceletException(MessageFormat.format("user {0} is invisible and cannot start sharing address books.", this.userLoginController.getLoggedInUser().getUserId())); //NOI18N
} else if (user.getUserProfileMode() == ProfileMode.INVISIBLE) {
// User is invisible
throw new FaceletException(MessageFormat.format("user {0} is invisible and cannot be selected for sharing.", user.getUserId())); //NOI18N
this.contactController.updateContactDataFromController(user.getUserContact());
// It should be there, so run some tests on it
- assert (user instanceof User) : "Instance loginController.loggedInUser is null";
- assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null";
- assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId());
- assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null";
- assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null";
- assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId());
+ assert (user instanceof User) : "Instance userLoginController.loggedInUser is null";
+ assert (user.getUserId() instanceof Long) : "Instance userLoginController.loggedInUser.userId is null";
+ assert (user.getUserId() > 0) : MessageFormat.format("userLoginController.loggedInUser.userId={0} is invalid", user.getUserId());
+ assert (user.getUserContact() instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null";
+ assert (user.getUserContact().getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null";
+ assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId());
// Update all fields
user.setUserProfileMode(this.getUserProfileMode());
* User login controller
*/
@Inject
- private AddressbookUserLoginWebSessionController loginController;
+ private AddressbookUserLoginWebSessionController userLoginController;
@Override
public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
super.preValidate(context, component, value, requiredFields, false);
// value is known to be an entered password, so instance login container
- LoginContainer container = new UserLoginContainer(this.loginController.getLoggedInUser(), (String) value);
+ LoginContainer container = new UserLoginContainer(this.userLoginController.getLoggedInUser(), (String) value);
// Test it here
- if (!UserUtils.ifPasswordMatches(container, this.loginController.getLoggedInUser())) {
+ if (!UserUtils.ifPasswordMatches(container, this.userLoginController.getLoggedInUser())) {
// Password mismatches
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Password mismatching.", "The password the user has entered does not match the stored password.")); //NOI18N
}