import java.util.Iterator;
import java.util.List;
import java.util.Objects;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
import javax.naming.NamingException;
import org.mxchange.jcoreee.utils.FacesUtils;
import org.mxchange.jjobs.beans.BaseJobsController;
+import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController;
import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
+import org.mxchange.jusercore.events.confirmation.ObservableUserConfirmedAccountEvent;
import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
import org.mxchange.jusercore.exceptions.UserStatusLockedException;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
-import org.mxchange.jusercore.events.confirmation.ObservableUserConfirmedAccountEvent;
-import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController;
/**
* A web request bean for confirmation link handling
/**
* Remote user bean
*/
- private final UserSessionBeanRemote userBean;
+ private UserSessionBeanRemote userBean;
/**
* Event being fired when a user has confirmed the account
* Default constructor
*/
public JobsConfirmationLinkWebRequestBean () {
+ }
+
+ @Override
+ public String getConfirmationKey () {
+ return this.confirmationKey;
+ }
+
+ @Override
+ public void setConfirmationKey (final String confirmationKey) {
+ this.confirmationKey = confirmationKey;
+ }
+
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void init () {
// Try it
try {
// Get initial context
}
}
- @Override
- public String getConfirmationKey () {
- return this.confirmationKey;
- }
-
- @Override
- public void setConfirmationKey (final String confirmationKey) {
- this.confirmationKey = confirmationKey;
- }
-
@Override
public void maybeConfirmUserAccount () {
// Is the confirmation key set?
import org.mxchange.jcontacts.contact.gender.Gender;
import org.mxchange.jcontacts.contact.utils.ContactUtils;
import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
import org.mxchange.jcontacts.events.contact.deleted.AdminDeletedContactEvent;
+import org.mxchange.jcontacts.events.contact.deleted.ObservableAdminDeletedContactEvent;
import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
import org.mxchange.jcountry.data.Country;
import org.mxchange.jjobs.beans.BaseJobsController;
+import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController;
import org.mxchange.jphone.phonenumbers.DialableNumber;
import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
-import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
-import org.mxchange.jcontacts.events.contact.deleted.ObservableAdminDeletedContactEvent;
-import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
-import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController;
/**
* An administrative user controller (bean)
/**
* General contact EJB
*/
- private final ContactSessionBeanRemote contactBean;
+ private ContactSessionBeanRemote contactBean;
/**
* General contact controller
* Default constructor
*/
public JobsAdminContactWebRequestBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup (general)
- this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jjobs-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
-
- // Try to lookup (administative)
- this.adminContactBean = (AdminContactSessionBeanRemote) context.lookup("java:global/jjobs-ejb/adminContact!org.mxchange.jcontacts.contact.AdminContactSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
}
@Override
*/
@PostConstruct
public void init () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup (general)
+ this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jjobs-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
+
+ // Try to lookup (administative)
+ this.adminContactBean = (AdminContactSessionBeanRemote) context.lookup("java:global/jjobs-ejb/adminContact!org.mxchange.jcontacts.contact.AdminContactSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
}
/**
import org.mxchange.jcontacts.contact.gender.Gender;
import org.mxchange.jcontacts.contact.utils.ContactUtils;
import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
-import org.mxchange.jcontacts.events.contact.deleted.ObservableAdminDeletedContactEvent;
import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
-import org.mxchange.jcontacts.events.mobile.unlinked.ObservableAdminUnlinkedMobileNumberEvent;
import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
import org.mxchange.jcountry.data.Country;
import org.mxchange.jjobs.beans.BaseJobsController;
import org.mxchange.jjobs.beans.login.JobsUserLoginWebSessionController;
import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
-import org.mxchange.jphone.events.mobile.remove.AdminRemoveMobileNumberFromListEvent;
import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
+import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
import org.mxchange.jusercore.model.user.User;
/**
/**
* Remote contact bean
*/
- private final ContactSessionBeanRemote contactBean;
+ private ContactSessionBeanRemote contactBean;
/**
* Contact list
*/
- private final List<Contact> contacts;
+ private final List<Contact> contactList;
/**
* Country instance
private String emailAddress;
/**
- * Email address repeated
+ * Email address list
*/
- private String emailAddressRepeat;
+ private final List<String> emailAddressList;
/**
- * Email address list
+ * Email address repeated
*/
- private final List<String> emailAddresses;
+ private String emailAddressRepeat;
/**
* Family name
private boolean isMobileUnlinked;
/**
- * Land-line number area code
+ * Mobile number's carrier
*/
- private Integer landLineAreaCode;
+ private MobileProvider mobileCarrier;
/**
- * Country instance for land-line number
+ * Mobile number
*/
- private Country landLineCountry;
+ private Long mobileNumber;
/**
- * Land-line number
+ * Phone number area code
*/
- private Long landLineNumber;
+ private Integer phoneAreaCode;
/**
- * Mobile number
+ * Country instance for phone number
*/
- private Long mobileNumber;
+ private Country phoneCountry;
/**
- * Mobile provider
+ * Phone number
*/
- private MobileProvider mobileProvider;
+ private Long phoneNumber;
/**
* A list of all selectable contacts
private JobsUserWebSessionController userController;
/**
- * Login controller (bean)
+ * Login bean (controller)
*/
@Inject
private JobsUserLoginWebSessionController userLoginController;
* Default constructor
*/
public JobsContactWebSessionBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jjobs-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
-
// Init lists/maps
- this.contacts = new LinkedList<>();
- this.emailAddresses = new LinkedList<>();
+ this.contactList = new LinkedList<>();
+ this.emailAddressList = new LinkedList<>();
}
/**
throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
} else if (event.getAddedContact().getContactId() < 1) {
// Not valid
- throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
+ throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
}
// Clear this bean
* @param event Event being fired
*/
public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("contactController.afterAdminAddedUserEvent(): event={0} - CALLED!", event)); //NOI18N
+
// event should not be null
if (null == event) {
// Throw NPE
this.clear();
}
- /**
- * Event observer for deleted contact instance by administrator
- * <p>
- * @param event Event being fired
- */
- public void afterAdminDeletedContactEvent (@Observes final ObservableAdminDeletedContactEvent event) {
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getDeletedContact() == null) {
- // Throw NPE again
- throw new NullPointerException("event.deletedContact is null"); //NOI18N
- } else if (event.getDeletedContact().getContactId() == null) {
- // userId is null
- throw new NullPointerException("event.deletedContact.contactId is null"); //NOI18N
- } else if (event.getDeletedContact().getContactId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getDeletedContact(), event.getDeletedContact().getContactId())); //NOI18N
- }
-
- // Remove from both lists
- this.contacts.remove(event.getDeletedContact());
- this.selectableContacts.remove(event.getDeletedContact());
-
- // Clear all data
- this.clear();
- }
-
/**
* Observes events being fired when an administrator has linked a new user
* with existing contact data.
throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
} else if (event.getUpdatedContact().getContactId() < 1) {
// Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
}
// Add contact instance only once
this.uniqueAddContact(event.getUpdatedContact());
// Add email address to list
- this.emailAddresses.add(event.getUpdatedContact().getContactEmailAddress());
- }
-
- /**
- * Event observer for new user registrations
- * <p>
- * @param event User registration event
- */
- public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) {
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getRegisteredUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.registeredUser is null"); //NOI18N
- } else if (event.getRegisteredUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
- } else if (event.getRegisteredUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
- }
-
- // Get user instance
- Contact registeredContact = event.getRegisteredUser().getUserContact();
-
- // Copy all data from registered->user
- this.copyContact(registeredContact);
-
- // Add user name and email address
- this.addUserNameEmailAddress(registeredContact);
-
- // Clear all data
- this.clear();
- }
-
- /**
- * Event observer for unlinked mobile contact by administrators
- * <p>
- * @param event Unlinked mobile contact event
- */
- public void afterAdminUnlinkedMobileContactDataEvent (@Observes final ObservableAdminUnlinkedMobileNumberEvent event) {
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getUnlinkedMobileNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.unlinkedMobileNumber is null"); //NOI18N
- } else if (event.getUnlinkedMobileNumber().getPhoneId() == null) {
- // userId is null
- throw new NullPointerException("event.unlinkedMobileNumber.contactId is null"); //NOI18N
- } else if (event.getUnlinkedMobileNumber().getPhoneId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUnlinkedMobileNumber(), event.getUnlinkedMobileNumber().getPhoneId())); //NOI18N
- }
-
- // Remove it from list
- this.removeFromContacts(event.getUnlinkedMobileNumber());
+ this.emailAddressList.add(event.getUpdatedContact().getContactEmailAddress());
- // Clear all data
- this.clear();
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println("contactController.afterAdminUpdatedContactDataEvent(): EXIT!"); //NOI18N
}
/**
this.copyContact(event.getLoggedInUser().getUserContact());
}
+ /**
+ * Event observer for new user registrations
+ * <p>
+ * @param event User registration event
+ */
+ public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getRegisteredUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.registeredUser is null"); //NOI18N
+ } else if (event.getRegisteredUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
+ } else if (event.getRegisteredUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
+ }
+
+ // Get user instance
+ Contact registeredContact = event.getRegisteredUser().getUserContact();
+
+ // Copy all data from registered->user
+ this.copyContact(registeredContact);
+
+ // Add contact instance only once
+ this.uniqueAddContact(registeredContact);
+
+ // Add user name and email address
+ this.addUserNameEmailAddress(registeredContact);
+
+ // Clear all data
+ this.clear();
+ }
+
@Override
@SuppressWarnings ("ReturnOfCollectionOrArrayField")
public List<Contact> allContacts () {
// Return un-modified list
- return this.contacts;
+ return this.contactList;
}
@Override
throw new FaceletException(new IllegalArgumentException("Not all personal data is set, but createContactInstance() is called.")); //NOI18N
}
+ // Required personal data must be set
+ assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
+
// Generate phone number
- DialableLandLineNumber phone = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
- DialableMobileNumber mobile = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
+ DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
+ DialableMobileNumber mobile = new MobileNumber(this.getMobileCarrier(), this.getMobileNumber());
DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
// Create new contact
contact.setContactComment(this.getComment());
// Don't set null or wrong references
- if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) {
+ if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) {
// Now the number must be given
if (phone.getPhoneAreaCode() == null) {
// Is null
}
// Is the provider set?
- if ((mobile instanceof DialableMobileNumber) && (this.getMobileProvider() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) {
+ if ((mobile instanceof DialableMobileNumber) && (this.getMobileCarrier() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) {
// Is the number set?
if (mobile.getPhoneNumber() == null) {
// Is null
- throw new NullPointerException("mobileNumber.phoneNumber is null"); //NOI18N
+ throw new NullPointerException("mobile.phoneNumber is null"); //NOI18N
} else if (mobile.getPhoneNumber() < 1) {
// Abort here
- throw new IllegalArgumentException("mobileNumber.phoneNumber is zero or below."); //NOI18N
+ throw new IllegalArgumentException("mobile.phoneNumber is zero or below."); //NOI18N
}
// Set mobile number
throw new FaceletException("Not all required fields are set."); //NOI18N
} else if (!this.userLoginController.ifCurrentPasswordMatches()) {
// Password not matching
- this.showFacesMessage("form_login_change_personal:currentPassword", "ERROR_USER_CURRENT_PASSWORD_MISMATCHING"); //NOI18N
+ this.showFacesMessage("form_login_change_personal:currentPassword", new UserPasswordMismatchException(this.userLoginController.getLoggedInUser())); //NOI18N
return ""; //NOI18N
}
contact.setContactCountry(this.getCountry());
// Update contact's mobile number
- this.isMobileUnlinked = ContactUtils.updateMobileNumber(contact, this.getMobileProvider(), this.getMobileNumber());
+ this.isMobileUnlinked = ContactUtils.updateMobileNumber(contact, this.getMobileCarrier(), this.getMobileNumber());
// Update contact's land-line number
- this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
+ this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
// Update contact's fax number
this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
this.contactBean.updateContactData(contact, this.isMobileUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
// All fine
- return "user_contact_data_saved"; //NOI18N
+ return "contact_data_saved"; //NOI18N
}
@Override
}
@Override
- public Integer getLandLineAreaCode () {
- return this.landLineAreaCode;
+ public MobileProvider getMobileCarrier () {
+ return this.mobileCarrier;
}
@Override
- public void setLandLineAreaCode (final Integer landLineAreaCode) {
- this.landLineAreaCode = landLineAreaCode;
+ public void setMobileCarrier (final MobileProvider mobileCarrier) {
+ this.mobileCarrier = mobileCarrier;
}
@Override
- public Country getLandLineCountry () {
- return this.landLineCountry;
+ public Long getMobileNumber () {
+ return this.mobileNumber;
}
@Override
- public void setLandLineCountry (final Country landLineCountry) {
- this.landLineCountry = landLineCountry;
+ public void setMobileNumber (final Long mobileNumber) {
+ this.mobileNumber = mobileNumber;
}
@Override
- public Long getLandLineNumber () {
- return this.landLineNumber;
+ public Integer getPhoneAreaCode () {
+ return this.phoneAreaCode;
}
@Override
- public void setLandLineNumber (final Long landLineNumber) {
- this.landLineNumber = landLineNumber;
+ public void setPhoneAreaCode (final Integer phoneAreaCode) {
+ this.phoneAreaCode = phoneAreaCode;
}
@Override
- public Long getMobileNumber () {
- return this.mobileNumber;
+ public Country getPhoneCountry () {
+ return this.phoneCountry;
}
@Override
- public void setMobileNumber (Long mobileNumber) {
- this.mobileNumber = mobileNumber;
+ public void setPhoneCountry (final Country phoneCountry) {
+ this.phoneCountry = phoneCountry;
}
@Override
- public MobileProvider getMobileProvider () {
- return this.mobileProvider;
+ public Long getPhoneNumber () {
+ return this.phoneNumber;
}
@Override
- public void setMobileProvider (final MobileProvider mobileProvider) {
- this.mobileProvider = mobileProvider;
+ public void setPhoneNumber (final Long phoneNumber) {
+ this.phoneNumber = phoneNumber;
}
@Override
}
/**
- * Post-initialization of this class
+ * Post-construction method
*/
@PostConstruct
public void init () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/addressbook-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+
// Get full email address list for reducing EJB calls
- this.emailAddresses.addAll(this.contactBean.getEmailAddressList());
+ this.emailAddressList.addAll(this.contactBean.getEmailAddressList());
// Get all contacts
List<Contact> allContacts = this.contactBean.getAllContacts();
// Get full contact list
- this.contacts.addAll(allContacts);
+ this.contactList.addAll(allContacts);
// Get all users
List<User> allUsers = this.userController.allUsers();
}
// Determine it
- return ((this.emailAddresses instanceof List) && (this.emailAddresses.contains(contact.getContactEmailAddress())));
+ return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(contact.getContactEmailAddress())));
}
@Override
this.clear();
// Try to lookup it in visible user list
- for (final Iterator<Contact> iterator = this.contacts.iterator(); iterator.hasNext();) {
+ for (final Iterator<Contact> iterator = this.contactList.iterator(); iterator.hasNext();) {
// Get next user
Contact next = iterator.next();
return localContact;
}
- /**
- * Event observer when a list with unused mobile numbers is being created
- * <p>
- * @param event Event being fired
- */
- public void removeMobileNumberFromListEvent (@Observes final AdminRemoveMobileNumberFromListEvent event) {
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getMobileNumberList() == null) {
- // Throw NPE again
- throw new NullPointerException("event.mobileList is null"); //NOI18N
- } else if (event.getMobileNumberList().isEmpty()) {
- // List is empty, no need to check
- return;
- }
-
- // Check all entries
- for (final Contact contact : this.contacts) {
- // Is the mobile instance set and in list?
- if ((contact.getContactMobileNumber() instanceof DialableMobileNumber) && (event.getMobileNumberList().contains(contact.getContactMobileNumber()))) {
- // Found it, so remvoe it from list
- event.getMobileNumberList().remove(contact.getContactMobileNumber());
- }
- }
- }
-
@Override
public List<Contact> selectableContacts () {
return Collections.unmodifiableList(this.selectableContacts);
*/
private void addUserNameEmailAddress (final Contact contact) {
// Make sure the entry is not added yet
- if (this.emailAddresses.contains(contact.getContactEmailAddress())) {
+ if (this.emailAddressList.contains(contact.getContactEmailAddress())) {
// Already added
throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", contact.getContactEmailAddress())); //NOI18N
}
// Add email addres
- this.emailAddresses.add(contact.getContactEmailAddress());
+ this.emailAddressList.add(contact.getContactEmailAddress());
}
/**
// - contact data
this.setEmailAddress(null);
this.setEmailAddressRepeat(null);
- this.setLandLineAreaCode(null);
- this.setLandLineCountry(null);
- this.setLandLineNumber(null);
- this.setMobileProvider(null);
+ this.setPhoneAreaCode(null);
+ this.setPhoneCountry(null);
+ this.setPhoneNumber(null);
+ this.setMobileCarrier(null);
this.setMobileNumber(null);
this.setFaxAreaCode(null);
this.setFaxCountry(null);
// - contact data
if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneAreaCode() > 0)) {
- this.setLandLineCountry(phone.getPhoneCountry());
- this.setLandLineAreaCode(phone.getPhoneAreaCode());
- this.setLandLineNumber(phone.getPhoneNumber());
+ this.setPhoneCountry(phone.getPhoneCountry());
+ this.setPhoneAreaCode(phone.getPhoneAreaCode());
+ this.setPhoneNumber(phone.getPhoneNumber());
}
if ((mobile instanceof DialableMobileNumber) && (mobile.getMobileProvider() instanceof MobileProvider)) {
- this.setMobileProvider(mobile.getMobileProvider());
+ this.setMobileCarrier(mobile.getMobileProvider());
this.setMobileNumber(mobile.getPhoneNumber());
}
}
// Remove from general list
- if (!this.contacts.remove(contact)) {
+ if (!this.contactList.remove(contact)) {
// Did not remove contact
throw new IllegalStateException(MessageFormat.format("contact {0} was not removed.", contact.getContactId())); //NOI18N
}
// Remove from other lists
- this.emailAddresses.remove(contact.getContactEmailAddress());
- }
-
- /**
- * Removes given fax number from all contacts
- * <p>
- * @param faxNumber Fax number to remove
- */
- private void removeFromContacts (final DialableFaxNumber faxNumber) {
- // Log message
- System.out.println(MessageFormat.format("{0}.removeFromContacts: faxNumber={1} - CALLED!", this.getClass().getSimpleName(), faxNumber)); //NOI18N
-
- // Is it valid?
- if (null == faxNumber) {
- // Throw NPE
- throw new NullPointerException("faxNumber is null"); //NOI18N
- } else if (faxNumber.getPhoneId() == null) {
- // Throw NPE again
- throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
- } else if (faxNumber.getPhoneId() < 1) {
- // Throw NPE again
- throw new NullPointerException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N
- }
-
- // Loop through all contacts
- for (final Contact contact : this.contacts) {
- // Log message
- System.out.println(MessageFormat.format("{0}.removeFromContacts: contact={1},contact.contactFaxNumber={2}", this.getClass().getSimpleName(), contact, contact.getContactFaxNumber())); //NOI18N
-
- // Is the number set?
- if (Objects.equals(contact.getContactFaxNumber(), faxNumber)) {
- // Log message
- System.out.println(MessageFormat.format("{0}.removeFromContacts: Unsetting faxNumber={1} ...", this.getClass().getSimpleName(), faxNumber)); //NOI18N
-
- // Found it
- contact.setContactFaxNumber(null);
- }
- }
- }
-
- /**
- * Removes given land-line number from all contacts
- * <p>
- * @param landLineNumber Land-line number to remove
- */
- private void removeFromContacts (final DialableLandLineNumber landLineNumber) {
- // Log message
- System.out.println(MessageFormat.format("{0}.removeFromContacts: landLineNumber={1} - CALLED!", this.getClass().getSimpleName(), landLineNumber)); //NOI18N
-
- // Is it valid?
- if (null == landLineNumber) {
- // Throw NPE
- throw new NullPointerException("landLineNumber is null"); //NOI18N
- } else if (landLineNumber.getPhoneId() == null) {
- // Throw NPE again
- throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
- } else if (landLineNumber.getPhoneId() < 1) {
- // Throw NPE again
- throw new NullPointerException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N
- }
-
- // Loop through all contacts
- for (final Contact contact : this.contacts) {
- // Log message
- System.out.println(MessageFormat.format("{0}.removeFromContacts: contact={1},contact.contactLandLineNumber={2}", this.getClass().getSimpleName(), contact, contact.getContactLandLineNumber())); //NOI18N
-
- // Is the number set?
- if (Objects.equals(contact.getContactLandLineNumber(), landLineNumber)) {
- // Log message
- System.out.println(MessageFormat.format("{0}.removeFromContacts: Unsetting landLineNumber={1} ...", this.getClass().getSimpleName(), landLineNumber)); //NOI18N
-
- // Found it
- contact.setContactLandLineNumber(null);
- }
- }
- }
-
- /**
- * Removes given mobile number from all contacts
- * <p>
- * @param mobileNumber Mobile number to remove
- */
- private void removeFromContacts (final DialableMobileNumber mobileNumber) {
- // Log message
- System.out.println(MessageFormat.format("{0}.removeFromContacts: mobileNumber={1} - CALLED!", this.getClass().getSimpleName(), mobileNumber)); //NOI18N
-
- // Is it valid?
- if (null == mobileNumber) {
- // Throw NPE
- throw new NullPointerException("mobileNumber is null"); //NOI18N
- } else if (mobileNumber.getPhoneId() == null) {
- // Throw NPE again
- throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N
- } else if (mobileNumber.getPhoneId() < 1) {
- // Throw NPE again
- throw new NullPointerException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); //NOI18N
- }
-
- // Loop through all contacts
- for (final Contact contact : this.contacts) {
- // Log message
- System.out.println(MessageFormat.format("{0}.removeFromContacts: contact={1},contact.contactMobileNumber={2}", this.getClass().getSimpleName(), contact, contact.getContactMobileNumber())); //NOI18N
-
- // Is the number set?
- if (Objects.equals(contact.getContactMobileNumber(), mobileNumber)) {
- // Log message
- System.out.println(MessageFormat.format("{0}.removeFromContacts: Unsetting mobileNumber={1} ...", this.getClass().getSimpleName(), mobileNumber)); //NOI18N
-
- // Unset it
- contact.setContactMobileNumber(null);
- }
- }
+ this.emailAddressList.remove(contact.getContactEmailAddress());
}
/**
}
// Get iterator from list
- Iterator<Contact> iterator = this.contacts.iterator();
+ Iterator<Contact> iterator = this.contactList.iterator();
// "Walk" through all entries
while (iterator.hasNext()) {
}
// Add contact to list
- this.contacts.add(contact);
+ this.contactList.add(contact);
}
}
@Local
public interface JobsContactWebSessionController extends Serializable {
+ /**
+ * Minimum password length
+ */
+ public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
+
/**
* Returns a list of all found contacts
* <p>
void setBirthday (final Date birthday);
/**
- * Getter for mobile provider
+ * Getter for mobile number's carrier
* <p>
- * @return Mobile provider
+ * @return Mobile number's carrier
*/
- MobileProvider getMobileProvider ();
+ MobileProvider getMobileCarrier ();
/**
- * Setter for mobile provider
+ * Setter for mobile number's carrier prefix
* <p>
- * @param mobileProvider Mobile provider
+ * @param mobileCarrier Mobile number's carrier prefix
*/
- void setMobileProvider (final MobileProvider mobileProvider);
+ void setMobileCarrier (final MobileProvider mobileCarrier);
/**
* Getter for mobile number
* <p>
* @return Phone number's area code
*/
- Integer getLandLineAreaCode ();
+ Integer getPhoneAreaCode ();
/**
* Setter for phone number's area code
* <p>
* @param phoneAreaCode Phone number's area code
*/
- void setLandLineAreaCode (final Integer phoneAreaCode);
+ void setPhoneAreaCode (final Integer phoneAreaCode);
/**
* Getter for phone number's country instance
* <p>
* @return Phone number's country instance
*/
- Country getLandLineCountry ();
+ Country getPhoneCountry ();
/**
* Setter for phone number's country instance
* <p>
* @param phoneCountry Phone number's country instance
*/
- void setLandLineCountry (final Country phoneCountry);
+ void setPhoneCountry (final Country phoneCountry);
/**
* Getter for phone number
* <p>
* @return Phone number
*/
- Long getLandLineNumber ();
+ Long getPhoneNumber ();
/**
* Setter for phone number
* <p>
* @param phoneNumber Phone number
*/
- void setLandLineNumber (final Long phoneNumber);
+ void setPhoneNumber (final Long phoneNumber);
/**
* Street
* Setter for controller type
* <p>
* @param controllerType Controller type
- *
* @deprecated Don't use this method.
*/
@Deprecated
} else if (contact.getContactId() < 1) {
// Is not valid
throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
- } else if ((this.adminPhoneController.getChoosenFaxNumber() == null) && (this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1))) {
+ } else if ((this.adminPhoneController.getFaxNumber() == null) && (this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1))) {
// All fields are empty
throw new NullPointerException("choosenFaxNumber, mobileProvider and phoneNumer are null"); //NOI18N
- } else if ((this.adminPhoneController.getChoosenFaxNumber() instanceof DialableFaxNumber) && (this.adminPhoneController.getPhoneCountry() instanceof Country) && (this.adminPhoneController.getPhoneAreaCode() instanceof Integer) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
+ } else if ((this.adminPhoneController.getFaxNumber() instanceof DialableFaxNumber) && (this.adminPhoneController.getPhoneCountry() instanceof Country) && (this.adminPhoneController.getPhoneAreaCode() instanceof Integer) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
// All fields are set
throw new IllegalStateException("choosenFaxNumber, mobileProvider and phoneNumer are all set"); //NOI18N
} else if ((this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() instanceof Integer) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
// Init instances
Contact updatedContact;
- DialableFaxNumber faxNumber = this.adminPhoneController.getChoosenFaxNumber();
+ DialableFaxNumber faxNumber = this.adminPhoneController.getFaxNumber();
// Try it again
try {
} else if (contact.getContactId() < 1) {
// Is not valid
throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
- } else if ((this.adminPhoneController.getChoosenLandLineNumber() == null) && (this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1))) {
+ } else if ((this.adminPhoneController.getLandLineNumber() == null) && (this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1))) {
// All fields are empty
throw new NullPointerException("choosenLandLineNumber, mobileProvider and phoneNumer are null"); //NOI18N
- } else if ((this.adminPhoneController.getChoosenLandLineNumber() instanceof DialableLandLineNumber) && (this.adminPhoneController.getPhoneCountry() instanceof Country) && (this.adminPhoneController.getPhoneAreaCode() instanceof Integer) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
+ } else if ((this.adminPhoneController.getLandLineNumber() instanceof DialableLandLineNumber) && (this.adminPhoneController.getPhoneCountry() instanceof Country) && (this.adminPhoneController.getPhoneAreaCode() instanceof Integer) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
// All fields are set
throw new IllegalStateException("choosenLandLineNumber, mobileProvider and phoneNumer are all set"); //NOI18N
} else if ((this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() instanceof Integer) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
// Init instance
Contact updatedContact;
- DialableLandLineNumber landLineNumber = this.adminPhoneController.getChoosenLandLineNumber();
+ DialableLandLineNumber landLineNumber = this.adminPhoneController.getLandLineNumber();
// Try it again
try {
} else if (contact.getContactId() < 1) {
// Is not valid
throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
- } else if ((this.adminPhoneController.getChoosenMobileNumber() == null) && (this.adminPhoneController.getMobileProvider() == null) && ((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1))) {
+ } else if ((this.adminPhoneController.getMobileNumber() == null) && (this.adminPhoneController.getMobileProvider() == null) && ((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1))) {
// All fields are empty
throw new NullPointerException("choosenMobileNumber, mobileProvider and phoneNumer are null"); //NOI18N
- } else if ((this.adminPhoneController.getChoosenMobileNumber() instanceof DialableMobileNumber) && (this.adminPhoneController.getMobileProvider() instanceof MobileProvider) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
+ } else if ((this.adminPhoneController.getMobileNumber() instanceof DialableMobileNumber) && (this.adminPhoneController.getMobileProvider() instanceof MobileProvider) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
// All fields are set
throw new IllegalStateException("choosenMobileNumber, mobileProvider and phoneNumer are all set"); //NOI18N
} else if ((this.adminPhoneController.getMobileProvider() == null) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
// Init instance
Contact updatedContact;
- DialableMobileNumber mobileNumber = this.adminPhoneController.getChoosenMobileNumber();
+ DialableMobileNumber mobileNumber = this.adminPhoneController.getMobileNumber();
// Try it again
try {
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
import org.mxchange.jcountry.data.CountryData;
import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
import org.mxchange.jcountry.events.AdminAddedCountryEvent;
+import org.mxchange.jcountry.events.ObservableAdminAddedCountryEvent;
import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
import org.mxchange.jjobs.beans.BaseJobsController;
-import org.mxchange.jcountry.events.ObservableAdminAddedCountryEvent;
/**
* An administrative country bean
* Default constructor
*/
public JobsAdminCountryWebRequestBean () {
- // Try this
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup the bean
- this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/jjobs-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw
- throw new FaceletException(ex);
- }
}
@Override
return (!this.allCountries().isEmpty());
}
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void init () {
+ // Try this
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the bean
+ this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/jjobs-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw
+ throw new FaceletException(ex);
+ }
+ }
+
/**
* Clears this bean's data. This should be called after a form has been
* submitted and the processing of the form was successful.
* Default constructor
*/
public JobsCountryWebApplicationBean () {
- // Try this
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup the bean
- this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/jjobs-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw
- throw new FaceletException(ex);
- }
}
/**
}
/**
- * Post-initialization of this class
+ * Post-construction method
*/
@PostConstruct
public void init () {
+ // Try this
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the bean
+ this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/jjobs-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw
+ throw new FaceletException(ex);
+ }
+
// "Cache" country list as this will not change so often.
this.countryList = this.countryBean.allCountries();
}
/**
* Remote email change bean
*/
- private final UserEmailChangeSessionBeanRemote emailChangeBean;
+ private UserEmailChangeSessionBeanRemote emailChangeBean;
/**
* Features controller
* Default constructor
*/
public JobsEmailChangeWebSessionBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.emailChangeBean = (UserEmailChangeSessionBeanRemote) context.lookup("java:global/jjobs-ejb/userEmailChange!org.mxchange.jusercore.model.email_address.EmailChangeSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
}
@Override
*/
@PostConstruct
public void init () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.emailChangeBean = (UserEmailChangeSessionBeanRemote) context.lookup("java:global/jjobs-ejb/userEmailChange!org.mxchange.jusercore.model.email_address.EmailChangeSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+
// Init list
this.emailAddresses = this.emailChangeBean.allQueuedAddresses();
}
*/
package org.mxchange.jjobs.beans.features;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
import org.mxchange.jjobs.beans.BaseJobsController;
*/
private static final long serialVersionUID = 64_237_512_690_168_674L;
+ /**
+ * Default constructor
+ */
+ public JobsFeatureWebApplicationBean () {
+ }
+
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void init () {
+ }
+
@Override
public boolean isFeatureEnabled (final String feature) {
// The parameter must be set
package org.mxchange.jjobs.beans.gender;
import java.util.List;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
import org.mxchange.jcontacts.contact.gender.Gender;
return genders;
}
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void init () {
+ }
+
}
// Validate user instance
if (this.getUser() == null) {
// Throw NPE
- throw new NullPointerException("this.user is null");
+ throw new NullPointerException("this.user is null"); //NOI18N
} else if (this.getUser().getUserId() == null) {
// Throw NPE again
- throw new NullPointerException("this.user.userId is null");
+ throw new NullPointerException("this.user.userId is null"); //NOI18N
} else if (this.getUser().getUserId() < 1) {
// Not valid
- throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId()));
+ throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N
}
// Get contact
// Default key is "unused"
String messageKey = "CONTACT_IS_UNUSED"; //NOI18N
- // Check user
+ // Check user/recruiter
boolean isUserContact = this.userController.isContactFound(contact);
// Check user first
*/
private Locale locale;
+ /**
+ * Default constructor
+ */
+ public JobsLocalizationSessionBean () {
+ }
+
/**
* Event observer for logged-in user
* <p>
import java.util.Collections;
import java.util.List;
import java.util.Objects;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Event;
import javax.enterprise.event.Observes;
*/
private User loggedInUser;
- /**
- * Remote register session bean
- */
- private UserLoginSessionBeanRemote loginBean;
-
/**
* Event fired when user has logged in
*/
*/
private boolean userLoggedIn;
+ /**
+ * Remote register session bean
+ */
+ private UserLoginSessionBeanRemote userLoginBean;
+
/**
* Event fired when user has logged in
*/
* Default constructor
*/
public JobsUserLoginWebSessionBean () {
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.loginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/jjobs-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N
-
- // Also find this
- this.userPasswordHistoryBean = (UserPasswordHistorySessionBeanRemote) context.lookup("java:global/jjobs-ejb/userPasswordHistory!org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote"); //NOI18N
-
- // Defaul template is guest
- this.baseTemplatePathName = GUEST_BASE_TEMPLATE_NAME;
- } catch (final NamingException ex) {
- // Continue to throw
- throw new FaceletException(ex);
- }
+ // Defaul template is guest
+ this.baseTemplatePathName = GUEST_BASE_TEMPLATE_NAME;
}
/**
try {
// Call bean
- User confirmedUser = this.loginBean.validateUserAccountStatus(container);
+ User confirmedUser = this.userLoginBean.validateUserAccountStatus(container);
// All fine here so set it here
this.setLoggedInUser(confirmedUser);
return ((this.isUserLoggedIn()) && (Objects.equals(this.getLoggedInUser().getUserMustChangePassword(), Boolean.TRUE)));
}
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void init () {
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.userLoginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/jjobs-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N
+
+ // Also find this
+ this.userPasswordHistoryBean = (UserPasswordHistorySessionBeanRemote) context.lookup("java:global/jjobs-ejb/userPasswordHistory!org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote"); //NOI18N
+
+ // Defaul template is guest
+ this.baseTemplatePathName = GUEST_BASE_TEMPLATE_NAME;
+ } catch (final NamingException ex) {
+ // Continue to throw
+ throw new FaceletException(ex);
+ }
+ }
+
@Override
public boolean isInvisible () {
// Check on login
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
* Default constructor
*/
public JobsAdminMobileProviderWebRequestBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup the beans
- this.adminRemoteBean = (AdminMobileProviderSessionBeanRemote) context.lookup("java:global/jjobs-ejb/adminMobileProvider!org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw it again
- throw new FaceletException(e);
- }
}
@Override
this.providerName = providerName;
}
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void init () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the beans
+ this.adminRemoteBean = (AdminMobileProviderSessionBeanRemote) context.lookup("java:global/jjobs-ejb/adminMobileProvider!org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw it again
+ throw new FaceletException(e);
+ }
+ }
+
/**
* Checks whether if the given mobile provider is already created by
* checking both dial prefix and country.
* Default constructor
*/
public JobsMobileProviderWebRequestBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup the beans
- this.mobileRemoteBean = (MobileProviderSingletonBeanRemote) context.lookup("java:global/jjobs-ejb/mobileProvider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw it again
- throw new FaceletException(e);
- }
}
/**
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getAddedMobileProvider()== null) {
+ } else if (event.getAddedMobileProvider() == null) {
// Throw again ...
throw new NullPointerException("event.addedMobileProvider is null"); //NOI18N
- } else if (event.getAddedMobileProvider().getProviderId()== null) {
+ } else if (event.getAddedMobileProvider().getProviderId() == null) {
// And again ...
throw new NullPointerException("event.addedMobileProvider.providerId is null"); //NOI18N
} else if (event.getAddedMobileProvider().getProviderId() < 1) {
}
/**
- * Initializer method
+ * Post-construction method
*/
@PostConstruct
public void init () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the beans
+ this.mobileRemoteBean = (MobileProviderSingletonBeanRemote) context.lookup("java:global/jjobs-ejb/mobileProvider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw it again
+ throw new FaceletException(e);
+ }
+
// Init list of mobile providers
this.mobileProviders = this.mobileRemoteBean.allMobileProvider();
}
import java.text.MessageFormat;
import java.util.List;
import java.util.Objects;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
private JobsWebRequestHelperController beanHelper;
/**
- * Choosen fax number
+ * fax number
*/
private DialableFaxNumber choosenFaxNumber;
/**
- * Choosen land-line number
+ * land-line number
*/
private DialableLandLineNumber choosenLandLineNumber;
/**
- * Choosen mobile number
+ * mobile number
*/
private DialableMobileNumber choosenMobileNumber;
@Any
private Event<AdminDeletedFaxNumberEvent> faxNumberDeletedEvent;
-
/**
* Event being fired when an administrator has updated fax number
*/
@Inject
@Any
private Event<AdminUpdatedFaxNumberEvent> faxNumberUpdatedEvent;
+
/**
* Event being fired when an administrator has deleted land-line number
*/
@Inject
@Any
private Event<AdminUpdatedLandLineNumberEvent> landLineNumberUpdatedEvent;
+
/**
* Event being fired when an administrator has deleted mobile number
*/
public JobsAdminPhoneWebRequestBean () {
// String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[3].getClassName(), Thread.currentThread().getStackTrace()[3].getMethodName());
// System.out.println(MessageFormat.format("{0}: Constructed, caller: {1}", this.getClass().getSimpleName(), caller));
-
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup the beans
- this.adminPhoneBean = (AdminPhoneSessionBeanRemote) context.lookup("java:global/jjobs-ejb/adminPhone!org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw it again
- throw new FaceletException(e);
- }
}
@Override
}
@Override
- public DialableFaxNumber getChoosenFaxNumber () {
+ public DialableFaxNumber getFaxNumber () {
// String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());
// System.out.println(MessageFormat.format("{0}: Returning this.choosenFaxNumber={1}, caller: {2}", this.getClass().getSimpleName(), this.choosenFaxNumber, caller));
return this.choosenFaxNumber;
}
@Override
- public void setChoosenFaxNumber (final DialableFaxNumber choosenFaxNumber) {
+ public void setFaxNumber (final DialableFaxNumber choosenFaxNumber) {
// String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());
// System.out.println(MessageFormat.format("{0}: Settin choosenFaxNumber={1}, previous: this.choosenFaxNumber={2}, caller: {3}", this.getClass().getSimpleName(), choosenFaxNumber, this.choosenFaxNumber, caller));
this.choosenFaxNumber = choosenFaxNumber;
}
@Override
- public DialableLandLineNumber getChoosenLandLineNumber () {
+ public DialableLandLineNumber getLandLineNumber () {
return this.choosenLandLineNumber;
}
@Override
- public void setChoosenLandLineNumber (final DialableLandLineNumber choosenLandLineNumber) {
+ public void setLandLineNumber (final DialableLandLineNumber choosenLandLineNumber) {
this.choosenLandLineNumber = choosenLandLineNumber;
}
@Override
- public DialableMobileNumber getChoosenMobileNumber () {
+ public DialableMobileNumber getMobileNumber () {
return this.choosenMobileNumber;
}
@Override
- public void setChoosenMobileNumber (final DialableMobileNumber choosenMobileNumber) {
+ public void setMobileNumber (final DialableMobileNumber choosenMobileNumber) {
this.choosenMobileNumber = choosenMobileNumber;
}
this.phoneNumber = phoneNumber;
}
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void init () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the beans
+ this.adminPhoneBean = (AdminPhoneSessionBeanRemote) context.lookup("java:global/jjobs-ejb/adminPhone!org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw it again
+ throw new FaceletException(e);
+ }
+ }
+
}
/**
* Getter for choosen fax number
* <p>
- * @return Choosen fax number
+ * @return fax number
*/
- DialableFaxNumber getChoosenFaxNumber ();
+ DialableFaxNumber getFaxNumber ();
/**
* Setter for choosen fax number
* <p>
- * @param choosenFaxNumber Choosen fax number
+ * @param choosenFaxNumber fax number
*/
- void setChoosenFaxNumber (final DialableFaxNumber choosenFaxNumber);
+ void setFaxNumber (final DialableFaxNumber choosenFaxNumber);
/**
* Getter for choosen land-line number
* <p>
- * @return Choosen land-line number
+ * @return land-line number
*/
- DialableLandLineNumber getChoosenLandLineNumber ();
+ DialableLandLineNumber getLandLineNumber ();
/**
* Setter for choosen land-line number
* <p>
- * @param choosenLandLineNumber Choosen land-line number
+ * @param choosenLandLineNumber land-line number
*/
- void setChoosenLandLineNumber (final DialableLandLineNumber choosenLandLineNumber);
+ void setLandLineNumber (final DialableLandLineNumber choosenLandLineNumber);
/**
* Getter for choosen mobile number
* <p>
- * @return Choosen mobile number
+ * @return mobile number
*/
- DialableMobileNumber getChoosenMobileNumber ();
+ DialableMobileNumber getMobileNumber ();
/**
* Setter for choosen mobile number
* <p>
- * @param choosenMobileNumber Choosen mobile number
+ * @param choosenMobileNumber mobile number
*/
- void setChoosenMobileNumber (final DialableMobileNumber choosenMobileNumber);
+ void setMobileNumber (final DialableMobileNumber choosenMobileNumber);
/**
* Getter for phone area code
package org.mxchange.jjobs.beans.profile;
import java.text.MessageFormat;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.faces.view.facelets.FaceletException;
import javax.inject.Inject;
@Inject
private JobsUserLoginWebSessionController userLoginController;
+ /**
+ * Default constructor
+ */
+ public JobsUserProfileWebRequestBean () {
+ }
+
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void init () {
+ }
+
@Override
public boolean isProfileLinkVisibleById (final Long userId) {
// Init user instance
*/
package org.mxchange.jjobs.beans.profilemode;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
import org.mxchange.jjobs.beans.BaseJobsController;
// Return it
return ProfileMode.values();
}
+
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void init () {
+ }
+
}
package org.mxchange.jjobs.beans.register;
import java.text.MessageFormat;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController;
import org.mxchange.jjobs.beans.user.JobsAdminUserWebRequestController;
import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
+import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent;
import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
import org.mxchange.jusercore.exceptions.DataRepeatMismatchException;
import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.UserUtils;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
-import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent;
/**
* A web bean for user registration
* Default constructor
*/
public JobsUserRegisterWebSessionBean () {
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.registerBean = (UserRegistrationSessionBeanRemote) context.lookup("java:global/jjobs-ejb/register!org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw
- throw new FaceletException(ex);
- }
}
@Override
return "user_register_page2"; //NOI18N
}
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void init () {
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.registerBean = (UserRegistrationSessionBeanRemote) context.lookup("java:global/jjobs-ejb/register!org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw
+ throw new FaceletException(ex);
+ }
+ }
+
}
*/
package org.mxchange.jjobs.beans.resendlink;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
import org.mxchange.jjobs.beans.BaseJobsController;
import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController;
import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
+import org.mxchange.jusercore.events.resendlink.ObservableUserResendLinkAccountEvent;
import org.mxchange.jusercore.events.resendlink.UserResendLinkAccountEvent;
import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.exceptions.UserStatusLockedException;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
-import org.mxchange.jusercore.events.resendlink.ObservableUserResendLinkAccountEvent;
/**
* A web session bean for resending confirmation link
/**
* EJB for resending confirmation link
*/
- private ResendLinkSessionBeanRemote emailBean;
+ private ResendLinkSessionBeanRemote resendLinkBean;
/**
* Localization controller
* Default constructor
*/
public JobsResendLinkWebSessionBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.emailBean = (ResendLinkSessionBeanRemote) context.lookup("java:global/jjobs-ejb/resendLink!org.mxchange.jjobs.beans.resendlink.ResendLinkSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
}
@Override
String baseUrl = FacesUtils.generateBaseUrl();
// Call EJB and return redirect target
- this.emailBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl);
+ this.resendLinkBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl);
} catch (final UserNotFoundException ex) {
// User not found
this.showFacesMessage("form_resend_link:resendEmailAddress", "ERROR_USER_NOT_FOUND"); //NOI18N
this.emailAddress = emailAddress;
}
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void init () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.resendLinkBean = (ResendLinkSessionBeanRemote) context.lookup("java:global/jjobs-ejb/resendLink!org.mxchange.jjobs.beans.resendlink.ResendLinkSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+ }
+
/**
* Clears email address fields so the user has to re-enter them
*/
import java.text.MessageFormat;
import java.util.Objects;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.enterprise.event.Observes;
/**
* Administrative user EJB
*/
- private final AdminUserSessionBeanRemote adminUserBean;
+ private AdminUserSessionBeanRemote adminUserBean;
/**
* Bean helper
/**
* General user EJB
*/
- private final UserSessionBeanRemote userBean;
+ private UserSessionBeanRemote userBean;
/**
* Regular user controller
* Default constructor
*/
public JobsAdminUserWebRequestBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
- this.adminUserBean = (AdminUserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/adminUser!org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
}
@Override
this.userPasswordRepeat = userPasswordRepeat;
}
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void init () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+ this.adminUserBean = (AdminUserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/adminUser!org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+ }
+
@Override
public String lockUserAccount (final User user) {
// Is the user instance valid and CONFIRMED?
/**
* Remote user bean
*/
- private final UserSessionBeanRemote userBean;
+ private UserSessionBeanRemote userBean;
/**
* User id
* Default constructor
*/
public JobsUserWebSessionBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jrecruiter-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
}
/**
*/
@PostConstruct
public void init () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+
// Initialize user list
this.userList = this.userBean.allUsers();
package org.mxchange.jjobs.beans.user.password;
import java.util.Objects;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
import org.mxchange.jjobs.beans.BaseJobsController;
import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController;
import org.mxchange.jjobs.beans.login.JobsUserLoginWebSessionController;
+import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
+import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
import org.mxchange.jusercore.exceptions.UserStatusLockedException;
import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
import org.mxchange.jusercore.model.user.UserUtils;
import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
-import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
/**
* A user password (change) controller (bean)
/**
* Remote user bean
*/
- private final UserSessionBeanRemote userBean;
+ private UserSessionBeanRemote userBean;
+
+ /**
+ * Current password (for confirmation of password change)
+ */
+ private String userCurrentPassword;
/**
- * Login controller (bean)
+ * Login bean (controller)
*/
@Inject
private JobsUserLoginWebSessionController userLoginController;
* Default constructor
*/
public JobsUserPasswordWebRequestBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
}
@Override
// Not all required fields are set
throw new FaceletException("Not all required fields are set."); //NOI18N
} else if (!this.userLoginController.ifCurrentPasswordMatches()) {
+ // Password not matching
+ throw new FaceletException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
+ } else if (!this.featureController.isFeatureEnabled("change_user_password")) { //NOI18N
+ // Editing is not allowed
+ throw new IllegalStateException("User tried to change password."); //NOI18N
+ } else if (!UserUtils.ifPasswordMatches(this.getUserCurrentPassword(), this.userLoginController.getLoggedInUser())) {
// Password mismatches
- this.showFacesMessage("form_user_change_password:userCurrentPassword", "ERROR_USER_CURRENT_PASSWORD_MISMATCHING"); //NOI18N
+ this.showFacesMessage("form_user_change_password:userCurrentPassword", "Entered current password does not matched stored password."); //NOI18N
// Clear bean
- this.userLoginController.setUserCurrentPassword(null);
this.clear();
// No redirect
return ""; //NOI18N
- } else if (!this.featureController.isFeatureEnabled("change_user_password")) { //NOI18N
- // Editing is not allowed
- throw new IllegalStateException("User tried to change password."); //NOI18N
} else if (!Objects.equals(this.getUserPassword(), this.getUserPasswordRepeat())) {
// Both entered passwords don't match
- this.showFacesMessage("form_user_change_password:userPasswordRepeat", "ERROR_USER_NEW_PASSWORDS_MISMATCH"); //NOI18N
+ this.showFacesMessage("form_user_change_password:userPasswordRepeat", "Entered new passwords mismatch."); //NOI18N
// Clear bean
- this.userLoginController.setUserCurrentPassword(null);
this.clear();
// No redirect
return ""; //NOI18N
- } else if (Objects.equals(this.userLoginController.getUserCurrentPassword(), this.getUserPassword())) {
+ } else if (Objects.equals(this.getUserCurrentPassword(), this.getUserPassword())) {
// New password matches current
- this.showFacesMessage("form_user_change_password:userPassword", "ERROR_USER_NEW_PASSWORD_SAME_AS_CURRENT"); //NOI18N
+ this.showFacesMessage("form_user_change_password:userPassword", "Entered new password is same as current password."); //NOI18N
// Clear bean
- this.userLoginController.setUserCurrentPassword(null);
this.clear();
// No redirect
return ""; //NOI18N
} else if (this.userLoginController.isPasswordInHistory(this.getUserPassword())) {
// Is already in list (to old passwords are ignored)
- this.showFacesMessage("form_user_change_password:userPassword", "ERROR_USER_NEW_PASSWORD_ALREADY_ENTERED"); //NOI18N
+ this.showFacesMessage("form_user_change_password:userPassword", "Entered new password is has already been used some time ago."); //NOI18N
// Clear bean
- this.userLoginController.setUserCurrentPassword(null);
this.clear();
// No redirect
return ""; //NOI18N
- } else if (this.isWeakPassword(this.getUserPassword())) {
- // Password is to weak
- this.showFacesMessage("form_user_change_password:userPassword", "ERROR_USER_PASSWORD_TO_WEAK"); //NOI18N
-
- // Clear bean
- this.userLoginController.setUserCurrentPassword(null);
- this.clear();
-
- // Skip it
- return ""; //NOI18N
}
// Get user instance
String encryptedPassword = UserUtils.encryptPassword(this.getUserPassword());
// Set it in user
- user.setUserMustChangePassword(Boolean.FALSE);
user.setUserEncryptedPassword(encryptedPassword);
try {
this.userUpdatedPasswordEvent.fire(new UpdatedUserPasswordEvent(passwordHistory));
} catch (final UserNotFoundException | UserStatusUnconfirmedException | UserStatusLockedException ex) {
// Clear bean
- this.userLoginController.setUserCurrentPassword(null);
this.clear();
// Throw again
this.clear();
// Return outcome
- return "user_data_saved"; //NOI18N
+ return "login_data_saved"; //NOI18N
+ }
+
+ @Override
+ public String getUserCurrentPassword () {
+ return this.userCurrentPassword;
+ }
+
+ @Override
+ public void setUserCurrentPassword (final String userCurrentPassword) {
+ this.userCurrentPassword = userCurrentPassword;
}
@Override
this.userPasswordRepeat = userPasswordRepeat;
}
+ /**
+ * Post-initialization of this class
+ */
+ @PostConstruct
+ public void init () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+ }
+
@Override
public boolean isRequiredChangePasswordSet () {
// Is all data set?
- return ((this.userLoginController.getUserCurrentPassword() != null) &&
- (!this.userLoginController.getUserCurrentPassword().isEmpty()) &&
+ return ((this.getUserCurrentPassword() != null) &&
+ (!this.getUserCurrentPassword().isEmpty()) &&
(this.getUserPassword() != null) &&
(!this.getUserPassword().isEmpty()) &&
(this.getUserPasswordRepeat() != null) &&
*/
void setUserPassword (final String userPassword);
+ /**
+ * Getter for current clear-text user password
+ * <p>
+ * @return Current clear-text user password
+ */
+ String getUserCurrentPassword ();
+
+ /**
+ * Setter for current clear-text user password
+ * <p>
+ * @param userCurrentPassword Current clear-text user password
+ */
+ void setUserCurrentPassword (final String userCurrentPassword);
+
/**
* Getter for clear-text user password repeated
* <p>
*/
void setUserPasswordRepeat (final String userPasswordRepeat);
- /**
- * Checks whether all required "password-change fields" are set.
- * <p>
- * @return Whether the required fields are set
- */
- boolean isRequiredChangePasswordSet ();
-
/**
* Changes logged-in user's password. It must not match with current
* password and should not appear in password history list for X
*/
String doChangePassword ();
+ /**
+ * Checks if all 3 passwords are set: old password, 2x new password
+ * <p>
+ * @return Whether all passwords are set
+ */
+ boolean isRequiredChangePasswordSet ();
+
}