From 1e7a9cdf3848df9cd33f7c4ab09f17e397e7f7d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 21 Apr 2017 22:17:19 +0200 Subject: [PATCH] Please cherry-pick: - let's move EJB-lookup into post-construct method and out of constructors as this seems to tricker a bug in Glassfish: https://github.com/payara/Payara/issues/1035 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../PizzaConfirmationLinkWebRequestBean.java | 44 +- .../PizzaAdminContactWebRequestBean.java | 114 ++--- ...PizzaAdminContactWebRequestController.java | 12 +- .../contact/PizzaContactWebSessionBean.java | 415 ++++++------------ .../PizzaContactWebSessionController.java | 30 +- .../PizzaAdminContactPhoneWebRequestBean.java | 20 +- .../PizzaAdminCountryWebRequestBean.java | 32 +- .../PizzaCountryWebApplicationBean.java | 25 +- .../PizzaEmailChangeWebSessionBean.java | 42 +- .../PizzaFeatureWebApplicationBean.java | 14 + .../gender/PizzaGenderWebApplicationBean.java | 8 + .../PizzaLocalizationSessionBean.java | 6 + .../login/PizzaUserLoginWebSessionBean.java | 54 ++- ...izzaAdminMobileProviderWebRequestBean.java | 30 +- .../PizzaMobileProviderWebRequestBean.java | 29 +- .../phone/PizzaAdminPhoneWebRequestBean.java | 43 +- .../PizzaAdminPhoneWebRequestController.java | 18 +- .../phone/PizzaPhoneWebApplicationBean.java | 2 +- .../PizzaUserProfileWebRequestBean.java | 14 + .../PizzaProfileModeWebApplicationBean.java | 8 + .../PizzaUserRegisterWebSessionBean.java | 30 +- .../PizzaResendLinkWebSessionBean.java | 36 +- .../user/PizzaAdminUserWebRequestBean.java | 36 +- .../beans/user/PizzaUserWebSessionBean.java | 25 +- .../PizzaUserPasswordWebRequestBean.java | 35 +- ...PizzaUserPasswordWebRequestController.java | 11 +- 26 files changed, 558 insertions(+), 575 deletions(-) diff --git a/src/java/org/mxchange/pizzaapplication/beans/confirmlink/PizzaConfirmationLinkWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/confirmlink/PizzaConfirmationLinkWebRequestBean.java index 00bd6614..9a80c2cc 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/confirmlink/PizzaConfirmationLinkWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/confirmlink/PizzaConfirmationLinkWebRequestBean.java @@ -20,6 +20,7 @@ import java.text.MessageFormat; 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; @@ -30,6 +31,7 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcoreee.utils.FacesUtils; +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; @@ -37,9 +39,8 @@ 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.pizzaapplication.beans.BasePizzaController; -import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; -import org.mxchange.jusercore.events.confirmation.ObservableUserConfirmedAccountEvent; import org.mxchange.pizzaapplication.beans.helper.PizzaWebRequestHelperController; +import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; /** * A web request bean for confirmation link handling @@ -69,25 +70,42 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp /** * Remote user bean */ - private final UserSessionBeanRemote userBean; + private UserSessionBeanRemote userBean; /** - * User controller + * Event being fired when a user has confirmed the account */ @Inject - private PizzaUserWebSessionController userController; + @Any + private Event userConfirmedEvent; /** - * Event being fired when a user has confirmed the account + * User controller */ @Inject - @Any - private Event userConfirmedEvent; + private PizzaUserWebSessionController userController; /** * Default constructor */ public PizzaConfirmationLinkWebRequestBean () { + } + + @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 @@ -101,16 +119,6 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp } } - @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? diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java index 49dd1660..9925c2c3 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java @@ -37,7 +37,9 @@ import org.mxchange.jcontacts.contact.UserContact; 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.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.jphone.phonenumbers.DialableNumber; @@ -49,8 +51,6 @@ import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.phonenumbers.mobile.MobileNumber; import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.pizzaapplication.beans.BasePizzaController; -import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; -import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; import org.mxchange.pizzaapplication.beans.helper.PizzaWebRequestHelperController; /** @@ -93,17 +93,17 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme /** * Cellphone number's carrier */ - private MobileProvider cellphoneCarrier; + private MobileProvider mobileCarrier; /** * Cellphone id number */ - private Long cellphoneId; + private Long mobileId; /** * Cellphone number */ - private Long cellphoneNumber; + private Long mobileNumber; /** * City @@ -118,7 +118,7 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme /** * Remote contact bean */ - private final ContactSessionBeanRemote contactBean; + private ContactSessionBeanRemote contactBean; /** * General contact controller @@ -247,20 +247,6 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme * Default constructor */ public PizzaAdminContactWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/pizzaservice-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 @@ -350,9 +336,9 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme // Is the cell phone set? if (contact.getContactMobileNumber() instanceof DialableMobileNumber) { // ... cellphone data - this.setCellphoneId(contact.getContactMobileNumber().getPhoneId()); - this.setCellphoneCarrier(contact.getContactMobileNumber().getMobileProvider()); - this.setCellphoneNumber(contact.getContactMobileNumber().getPhoneNumber()); + this.setMobileId(contact.getContactMobileNumber().getPhoneId()); + this.setMobileCarrier(contact.getContactMobileNumber().getMobileProvider()); + this.setMobileNumber(contact.getContactMobileNumber().getPhoneNumber()); } // Is the fax set? @@ -398,9 +384,9 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme } // Generate phone number - DialableLandLineNumber landLineNumber = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber()); - DialableMobileNumber mobileNumber = new MobileNumber(this.getCellphoneCarrier(), this.getCellphoneNumber()); - DialableFaxNumber faxNumber = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); + DialableLandLineNumber landLine = 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 instance Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName()); @@ -420,60 +406,60 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme contact.setContactOwnContact(Boolean.TRUE); // Don't set null or wrong references - if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) { + if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) { // Now the number must be given - if (landLineNumber.getPhoneAreaCode() == null) { + if (landLine.getPhoneAreaCode() == null) { // Is null throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N - } else if (landLineNumber.getPhoneAreaCode() < 1) { + } else if (landLine.getPhoneAreaCode() < 1) { // Abort here throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N - } else if (landLineNumber.getPhoneNumber() == null) { + } else if (landLine.getPhoneNumber() == null) { // Is null throw new NullPointerException("phone.phoneNumber is null"); //NOI18N - } else if (landLineNumber.getPhoneNumber() < 1) { + } else if (landLine.getPhoneNumber() < 1) { // Abort here throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N } // Set phone number - contact.setContactLandLineNumber(landLineNumber); + contact.setContactLandLineNumber(landLine); } // Don't set null or wrong references - if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) { + if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) { // Now the number must be given - if (faxNumber.getPhoneAreaCode() == null) { + if (fax.getPhoneAreaCode() == null) { // Is null throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N - } else if (faxNumber.getPhoneAreaCode() < 1) { + } else if (fax.getPhoneAreaCode() < 1) { // Abort here throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N - } else if (faxNumber.getPhoneNumber() == null) { + } else if (fax.getPhoneNumber() == null) { // Is null throw new NullPointerException("fax.phoneNumber is null"); //NOI18N - } else if (faxNumber.getPhoneNumber() < 1) { + } else if (fax.getPhoneNumber() < 1) { // Abort here throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N } // Set fax number - contact.setContactFaxNumber(faxNumber); + contact.setContactFaxNumber(fax); } // Is the provider set? - if ((mobileNumber instanceof DialableMobileNumber) && (this.getCellphoneCarrier() instanceof MobileProvider) && (this.getCellphoneNumber() != null) && (this.getCellphoneNumber() > 0)) { + if ((mobile instanceof DialableMobileNumber) && (this.getMobileCarrier() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) { // Is the number set? - if (mobileNumber.getPhoneNumber() == null) { + if (mobile.getPhoneNumber() == null) { // Is null throw new NullPointerException("cellphone.phoneNumber is null"); //NOI18N - } else if (mobileNumber.getPhoneNumber() < 1) { + } else if (mobile.getPhoneNumber() < 1) { // Abort here throw new IllegalArgumentException("cellphone.phoneNumber is zero or below."); //NOI18N } // Set cellphone number - contact.setContactMobileNumber(mobileNumber); + contact.setContactMobileNumber(mobile); } // Return it @@ -566,33 +552,33 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme } @Override - public MobileProvider getCellphoneCarrier () { - return this.cellphoneCarrier; + public MobileProvider getMobileCarrier () { + return this.mobileCarrier; } @Override - public void setCellphoneCarrier (final MobileProvider cellphoneCarrier) { - this.cellphoneCarrier = cellphoneCarrier; + public void setMobileCarrier (final MobileProvider mobileCarrier) { + this.mobileCarrier = mobileCarrier; } @Override - public Long getCellphoneId () { - return this.cellphoneId; + public Long getMobileId () { + return this.mobileId; } @Override - public void setCellphoneId (final Long cellphoneId) { - this.cellphoneId = cellphoneId; + public void setMobileId (final Long mobileId) { + this.mobileId = mobileId; } @Override - public Long getCellphoneNumber () { - return this.cellphoneNumber; + public Long getMobileNumber () { + return this.mobileNumber; } @Override - public void setCellphoneNumber (Long cellphoneNumber) { - this.cellphoneNumber = cellphoneNumber; + public void setMobileNumber (Long mobileNumber) { + this.mobileNumber = mobileNumber; } @Override @@ -821,6 +807,20 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme */ @PostConstruct public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N + + // Try to lookup (administative) + this.adminContactBean = (AdminContactSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/adminContact!org.mxchange.jcontacts.contact.AdminContactSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw again + throw new FaceletException(e); + } } @Override @@ -856,8 +856,8 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme this.setPhoneCountry(null); this.setPhoneAreaCode(null); this.setPhoneNumber(null); - this.setCellphoneCarrier(null); - this.setCellphoneNumber(null); + this.setMobileCarrier(null); + this.setMobileNumber(null); this.setFaxCountry(null); this.setFaxAreaCode(null); this.setFaxNumber(null); @@ -929,7 +929,7 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme contact.setContactCountry(this.getCountry()); // Update contact's cellphone number - this.isCellphoneUnlinked = ContactUtils.updateMobileNumber(contact, this.getCellphoneCarrier(), this.getCellphoneNumber()); + this.isCellphoneUnlinked = ContactUtils.updateMobileNumber(contact, this.getMobileCarrier(), this.getMobileNumber()); // Update contact's land-line number this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber()); diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestController.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestController.java index 9ac63908..18238811 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestController.java @@ -68,14 +68,14 @@ public interface PizzaAdminContactWebRequestController extends Serializable { *

* @return Cellphone id */ - Long getCellphoneId (); + Long getMobileId (); /** * Setter for cellphone id *

* @param cellphoneId Cellphone id */ - void setCellphoneId (final Long cellphoneId); + void setMobileId (final Long cellphoneId); /** * Getter for fax id @@ -124,28 +124,28 @@ public interface PizzaAdminContactWebRequestController extends Serializable { *

* @return Cellphone number's carrier */ - MobileProvider getCellphoneCarrier (); + MobileProvider getMobileCarrier (); /** * Setter for cellphone number's carrier prefix *

* @param cellphoneCarrier Cellphone number's carrier prefix */ - void setCellphoneCarrier (final MobileProvider cellphoneCarrier); + void setMobileCarrier (final MobileProvider cellphoneCarrier); /** * Getter for ellphone number *

* @return Cellphone number */ - Long getCellphoneNumber (); + Long getMobileNumber (); /** * Setter for ellphone number *

* @param cellphoneNumber Cellphone number */ - void setCellphoneNumber (final Long cellphoneNumber); + void setMobileNumber (final Long cellphoneNumber); /** * City diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java index e225c437..fee0808b 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java @@ -38,12 +38,9 @@ import org.mxchange.jcontacts.contact.UserContact; 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.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; @@ -56,6 +53,7 @@ import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent; 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; import org.mxchange.pizzaapplication.beans.BasePizzaController; import org.mxchange.pizzaapplication.beans.login.PizzaUserLoginWebSessionController; @@ -93,12 +91,12 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P /** * Remote contact bean */ - private final ContactSessionBeanRemote contactBean; + private ContactSessionBeanRemote contactBean; /** * Contact list */ - private final List contacts; + private final List contactList; /** * Country instance @@ -111,14 +109,14 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P private String emailAddress; /** - * Email address repeated + * Email address list */ - private String emailAddressRepeat; + private final List emailAddressList; /** - * Email address list + * Email address repeated */ - private final List emailAddresses; + private String emailAddressRepeat; /** * Family name @@ -176,29 +174,29 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P 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 @@ -222,7 +220,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P private PizzaUserWebSessionController userController; /** - * Login controller (bean) + * Login bean (controller) */ @Inject private PizzaUserLoginWebSessionController userLoginController; @@ -236,21 +234,9 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P * Default constructor */ public PizzaContactWebSessionBean () { - // 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<>(); } /** @@ -272,7 +258,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P 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 @@ -310,35 +296,6 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.clear(); } - /** - * Event observer for deleted contact instance by administrator - *

- * @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. @@ -389,76 +346,14 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P 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 - *

- * @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 - *

- * @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()); - - // Clear all data - this.clear(); + this.emailAddressList.add(event.getUpdatedContact().getContactEmailAddress()); } /** @@ -511,11 +406,48 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.copyContact(event.getLoggedInUser().getUserContact()); } + /** + * Event observer for new user registrations + *

+ * @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 allContacts () { // Return un-modified list - return this.contacts; + return this.contactList; } @Override @@ -526,9 +458,12 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P 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 @@ -544,7 +479,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P 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 @@ -586,14 +521,14 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P } // 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 @@ -615,7 +550,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P 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 } @@ -639,10 +574,10 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P 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()); @@ -651,7 +586,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.contactBean.updateContactData(contact, this.isMobileUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked); // All fine - return "user_contact_data_saved"; //NOI18N + return "contact_data_saved"; //NOI18N } @Override @@ -808,53 +743,53 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P } @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 @@ -888,18 +823,30 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P } /** - * 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/pizzaservice-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 allContacts = this.contactBean.getAllContacts(); // Get full contact list - this.contacts.addAll(allContacts); + this.contactList.addAll(allContacts); // Get all users List allUsers = this.userController.allUsers(); @@ -948,7 +895,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P } // Determine it - return ((this.emailAddresses instanceof List) && (this.emailAddresses.contains(contact.getContactEmailAddress()))); + return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(contact.getContactEmailAddress()))); } @Override @@ -989,7 +936,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.clear(); // Try to lookup it in visible user list - for (final Iterator iterator = this.contacts.iterator(); iterator.hasNext();) { + for (final Iterator iterator = this.contactList.iterator(); iterator.hasNext();) { // Get next user Contact next = iterator.next(); @@ -1014,34 +961,6 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P return localContact; } - /** - * Event observer when a list with unused mobile numbers is being created - *

- * @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 selectableContacts () { return Collections.unmodifiableList(this.selectableContacts); @@ -1072,13 +991,13 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P */ 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()); } /** @@ -1101,10 +1020,10 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P // - 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); @@ -1156,13 +1075,13 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P // - 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()); } @@ -1192,97 +1111,13 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P } // 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 - *

- * @param faxNumber Fax number to remove - */ - private void removeFromContacts (final DialableFaxNumber faxNumber) { - // 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) { - // Is the number set? - if (Objects.equals(contact.getContactFaxNumber(), faxNumber)) { - // Found it - contact.setContactFaxNumber(null); - } - } - } - - /** - * Removes given land-line number from all contacts - *

- * @param landLineNumber Land-line number to remove - */ - private void removeFromContacts (final DialableLandLineNumber landLineNumber) { - // 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) { - // Is the number set? - if (Objects.equals(contact.getContactLandLineNumber(), landLineNumber)) { - // Found it - contact.setContactLandLineNumber(null); - } - } - } - - /** - * Removes given mobile number from all contacts - *

- * @param mobileNumber Mobile number to remove - */ - private void removeFromContacts (final DialableMobileNumber mobileNumber) { - // 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) { - // Is the number set? - if (Objects.equals(contact.getContactMobileNumber(), mobileNumber)) { - // Unset it - contact.setContactMobileNumber(null); - } - } + this.emailAddressList.remove(contact.getContactEmailAddress()); } /** @@ -1305,7 +1140,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P } // Get iterator from list - Iterator iterator = this.contacts.iterator(); + Iterator iterator = this.contactList.iterator(); // "Walk" through all entries while (iterator.hasNext()) { @@ -1321,7 +1156,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P } // Add contact to list - this.contacts.add(contact); + this.contactList.add(contact); } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java index 02642faf..e8556108 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java @@ -34,6 +34,11 @@ import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; @Local public interface PizzaContactWebSessionController extends Serializable { + /** + * Minimum password length + */ + public static final Integer MINIMUM_PASSWORD_LENGTH = 5; + /** * Returns a list of all found contacts *

@@ -82,18 +87,18 @@ public interface PizzaContactWebSessionController extends Serializable { void setBirthday (final Date birthday); /** - * Getter for mobile provider + * Getter for mobile number's carrier *

- * @return Mobile provider + * @return Mobile number's carrier */ - MobileProvider getMobileProvider (); + MobileProvider getMobileCarrier (); /** - * Setter for mobile provider + * Setter for mobile number's carrier prefix *

- * @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 @@ -297,42 +302,42 @@ public interface PizzaContactWebSessionController extends Serializable { *

* @return Phone number's area code */ - Integer getLandLineAreaCode (); + Integer getPhoneAreaCode (); /** * Setter for phone number's area code *

* @param phoneAreaCode Phone number's area code */ - void setLandLineAreaCode (final Integer phoneAreaCode); + void setPhoneAreaCode (final Integer phoneAreaCode); /** * Getter for phone number's country instance *

* @return Phone number's country instance */ - Country getLandLineCountry (); + Country getPhoneCountry (); /** * Setter for phone number's country instance *

* @param phoneCountry Phone number's country instance */ - void setLandLineCountry (final Country phoneCountry); + void setPhoneCountry (final Country phoneCountry); /** * Getter for phone number *

* @return Phone number */ - Long getLandLineNumber (); + Long getPhoneNumber (); /** * Setter for phone number *

* @param phoneNumber Phone number */ - void setLandLineNumber (final Long phoneNumber); + void setPhoneNumber (final Long phoneNumber); /** * Street @@ -387,7 +392,6 @@ public interface PizzaContactWebSessionController extends Serializable { * Setter for controller type *

* @param controllerType Controller type - * * @deprecated Don't use this method. */ @Deprecated diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaAdminContactPhoneWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaAdminContactPhoneWebRequestBean.java index 9bd5bb24..1305fed7 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaAdminContactPhoneWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaAdminContactPhoneWebRequestBean.java @@ -149,7 +149,7 @@ public class PizzaAdminContactPhoneWebRequestBean extends BasePizzaController im Context context = new InitialContext(); // Try to lookup the beans - this.adminPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/jjobs-ejb/adminContactPhone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N + this.adminPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/adminContactPhone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N } catch (final NamingException e) { // Throw again throw new FaceletException(e); @@ -244,10 +244,10 @@ public class PizzaAdminContactPhoneWebRequestBean extends BasePizzaController im } 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))) { @@ -266,7 +266,7 @@ public class PizzaAdminContactPhoneWebRequestBean extends BasePizzaController im // Init instances Contact updatedContact; - DialableFaxNumber faxNumber = this.adminPhoneController.getChoosenFaxNumber(); + DialableFaxNumber faxNumber = this.adminPhoneController.getFaxNumber(); // Try it again try { @@ -306,10 +306,10 @@ public class PizzaAdminContactPhoneWebRequestBean extends BasePizzaController im } 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))) { @@ -328,7 +328,7 @@ public class PizzaAdminContactPhoneWebRequestBean extends BasePizzaController im // Init instance Contact updatedContact; - DialableLandLineNumber landLineNumber = this.adminPhoneController.getChoosenLandLineNumber(); + DialableLandLineNumber landLineNumber = this.adminPhoneController.getLandLineNumber(); // Try it again try { @@ -368,10 +368,10 @@ public class PizzaAdminContactPhoneWebRequestBean extends BasePizzaController im } 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)) { @@ -386,7 +386,7 @@ public class PizzaAdminContactPhoneWebRequestBean extends BasePizzaController im // Init instance Contact updatedContact; - DialableMobileNumber mobileNumber = this.adminPhoneController.getChoosenMobileNumber(); + DialableMobileNumber mobileNumber = this.adminPhoneController.getMobileNumber(); // Try it again try { diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebRequestBean.java index f1c33d3d..4fc4d27c 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebRequestBean.java @@ -19,6 +19,7 @@ package org.mxchange.pizzaapplication.beans.country; 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; @@ -32,9 +33,9 @@ import org.mxchange.jcountry.data.Country; 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.pizzaapplication.beans.BasePizzaController; -import org.mxchange.jcountry.events.ObservableAdminAddedCountryEvent; /** * An administrative country bean @@ -102,17 +103,6 @@ public class PizzaAdminCountryWebRequestBean extends BasePizzaController impleme * Default constructor */ public PizzaAdminCountryWebRequestBean () { - // Try this - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the bean - this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/pizzaservice-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N - } catch (final NamingException ex) { - // Continue to throw - throw new FaceletException(ex); - } } @Override @@ -226,6 +216,24 @@ public class PizzaAdminCountryWebRequestBean extends BasePizzaController impleme 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/pizzaservice-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. diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java index c95c39c3..123bdbee 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java @@ -59,17 +59,6 @@ public class PizzaCountryWebApplicationBean extends BasePizzaController implemen * Default constructor */ public PizzaCountryWebApplicationBean () { - // Try this - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the bean - this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/pizzaservice-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N - } catch (final NamingException ex) { - // Continue to throw - throw new FaceletException(ex); - } } /** @@ -106,10 +95,22 @@ public class PizzaCountryWebApplicationBean extends BasePizzaController implemen } /** - * 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/pizzaservice-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(); } diff --git a/src/java/org/mxchange/pizzaapplication/beans/email_address/PizzaEmailChangeWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/email_address/PizzaEmailChangeWebSessionBean.java index d0d4bfc4..c2337c5f 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/email_address/PizzaEmailChangeWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/email_address/PizzaEmailChangeWebSessionBean.java @@ -19,6 +19,7 @@ package org.mxchange.pizzaapplication.beans.email_address; import java.text.MessageFormat; import java.util.List; import java.util.Objects; +import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; @@ -69,7 +70,7 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen /** * Remote email change bean */ - private final UserEmailChangeSessionBeanRemote emailBean; + private UserEmailChangeSessionBeanRemote emailChangeBean; /** * Features controller @@ -87,20 +88,6 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen * Default constructor */ public PizzaEmailChangeWebSessionBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.emailBean = (UserEmailChangeSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/email-change!org.mxchange.jusercore.model.email_address.EmailChangeSessionBeanRemote"); //NOI18N - - // Init list - this.emailAddresses = this.emailBean.allQueuedAddresses(); - } catch (final NamingException e) { - // Throw again - throw new FaceletException(e); - } } @Override @@ -148,7 +135,7 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen String baseUrl = FacesUtils.generateBaseUrl(); // Call EJB - this.emailBean.enqueueEmailAddressForChange(emailChange, baseUrl); + this.emailChangeBean.enqueueEmailAddressForChange(emailChange, baseUrl); // Unset all so the user is forced to re-enter it this.clear(); @@ -177,6 +164,27 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen this.emailAddressRepeat = emailAddressRepeat; } + /** + * Post-construction + */ + @PostConstruct + public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.emailChangeBean = (UserEmailChangeSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/email-change!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(); + } + @Override public boolean isRequiredChangeEmailAddressSet () { return ((this.getEmailAddress() != null) && @@ -213,7 +221,7 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen } // Check EJB - boolean isQueued = this.emailBean.isEmailAddressEnqueued(emailAddress); + boolean isQueued = this.emailChangeBean.isEmailAddressEnqueued(emailAddress); // Is it there? if (isQueued) { diff --git a/src/java/org/mxchange/pizzaapplication/beans/features/PizzaFeatureWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/features/PizzaFeatureWebApplicationBean.java index e3364c39..b6fd1807 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/features/PizzaFeatureWebApplicationBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/features/PizzaFeatureWebApplicationBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.pizzaapplication.beans.features; +import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; import org.mxchange.pizzaapplication.beans.BasePizzaController; @@ -34,6 +35,19 @@ public class PizzaFeatureWebApplicationBean extends BasePizzaController implemen */ private static final long serialVersionUID = 64_237_512_690_168_674L; + /** + * Default constructor + */ + public PizzaFeatureWebApplicationBean () { + } + + /** + * Post-construction method + */ + @PostConstruct + public void init () { + } + @Override public boolean isFeatureEnabled (final String feature) { // The parameter must be set diff --git a/src/java/org/mxchange/pizzaapplication/beans/gender/PizzaGenderWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/gender/PizzaGenderWebApplicationBean.java index 081dcfbb..a1d65d20 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/gender/PizzaGenderWebApplicationBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/gender/PizzaGenderWebApplicationBean.java @@ -17,6 +17,7 @@ package org.mxchange.pizzaapplication.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; @@ -58,4 +59,11 @@ public class PizzaGenderWebApplicationBean extends BasePizzaController implement return genders; } + /** + * Post-construction method + */ + @PostConstruct + public void init () { + } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/localization/PizzaLocalizationSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/localization/PizzaLocalizationSessionBean.java index 0daa95fc..5fdb2b8e 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/localization/PizzaLocalizationSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/localization/PizzaLocalizationSessionBean.java @@ -49,6 +49,12 @@ public class PizzaLocalizationSessionBean extends BasePizzaController implements */ private Locale locale; + /** + * Default constructor + */ + public PizzaLocalizationSessionBean () { + } + /** * Event observer for logged-in user *

diff --git a/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionBean.java index 87151350..909eeb24 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionBean.java @@ -20,6 +20,7 @@ import java.text.MessageFormat; 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; @@ -87,11 +88,6 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements */ private User loggedInUser; - /** - * Remote register session bean - */ - private UserLoginSessionBeanRemote loginBean; - /** * Event fired when user has logged in */ @@ -115,6 +111,11 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements */ private boolean userLoggedIn; + /** + * Remote register session bean + */ + private UserLoginSessionBeanRemote userLoginBean; + /** * Event fired when user has logged in */ @@ -143,22 +144,8 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements * Default constructor */ public PizzaUserLoginWebSessionBean () { - 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; } /** @@ -215,7 +202,7 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements 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); @@ -337,6 +324,29 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements 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/pizzaservice-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N + + // Also find this + this.userPasswordHistoryBean = (UserPasswordHistorySessionBeanRemote) context.lookup("java:global/pizzaservice-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 diff --git a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java index 99209e8c..f2fd5eec 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java @@ -19,6 +19,7 @@ package org.mxchange.pizzaapplication.beans.mobileprovider; 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; @@ -93,17 +94,6 @@ public class PizzaAdminMobileProviderWebRequestBean extends BasePizzaController * Default constructor */ public PizzaAdminMobileProviderWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the beans - this.adminRemoteBean = (AdminMobileProviderSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/adminMobileProvider!org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw it again - throw new FaceletException(e); - } } @Override @@ -179,6 +169,24 @@ public class PizzaAdminMobileProviderWebRequestBean extends BasePizzaController 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/pizzaservice-ejb/adminMobileProvider!org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw it again + throw new FaceletException(e); + } + } + /** * Clears this bean */ diff --git a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java index 0b222f1d..8ec2a31a 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java @@ -59,17 +59,6 @@ public class PizzaMobileProviderWebRequestBean extends BasePizzaController imple * Default constructor */ public PizzaMobileProviderWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the beans - this.mobileRemoteBean = (MobileProviderSingletonBeanRemote) context.lookup("java:global/pizzaservice-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw it again - throw new FaceletException(e); - } } /** @@ -83,10 +72,10 @@ public class PizzaMobileProviderWebRequestBean extends BasePizzaController imple 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) { @@ -105,10 +94,22 @@ public class PizzaMobileProviderWebRequestBean extends BasePizzaController imple } /** - * 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/pizzaservice-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(); } diff --git a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestBean.java index 6d22e7bd..8cdec597 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestBean.java @@ -19,6 +19,7 @@ package org.mxchange.pizzaapplication.beans.phone; 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; @@ -86,17 +87,17 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement private PizzaWebRequestHelperController 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; @@ -197,18 +198,6 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement public PizzaAdminPhoneWebRequestBean () { // 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 @@ -561,7 +550,7 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement } @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; @@ -575,7 +564,7 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement } @Override - public DialableLandLineNumber getChoosenLandLineNumber () { + public DialableLandLineNumber getLandLineNumber () { return this.choosenLandLineNumber; } @@ -585,7 +574,7 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement } @Override - public DialableMobileNumber getChoosenMobileNumber () { + public DialableMobileNumber getMobileNumber () { return this.choosenMobileNumber; } @@ -634,4 +623,22 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement 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/pizzaservice-ejb/adminPhone!org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw it again + throw new FaceletException(e); + } + } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestController.java b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestController.java index adbd7420..7d05d52f 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestController.java @@ -126,42 +126,42 @@ public interface PizzaAdminPhoneWebRequestController extends Serializable { /** * Getter for choosen fax number *

- * @return Choosen fax number + * @return fax number */ - DialableFaxNumber getChoosenFaxNumber (); + DialableFaxNumber getFaxNumber (); /** * Setter for choosen fax number *

- * @param choosenFaxNumber Choosen fax number + * @param choosenFaxNumber fax number */ void setFaxNumber (final DialableFaxNumber choosenFaxNumber); /** * Getter for choosen land-line number *

- * @return Choosen land-line number + * @return land-line number */ - DialableLandLineNumber getChoosenLandLineNumber (); + DialableLandLineNumber getLandLineNumber (); /** * Setter for choosen land-line number *

- * @param choosenLandLineNumber Choosen land-line number + * @param choosenLandLineNumber land-line number */ void setLandLineNumber (final DialableLandLineNumber choosenLandLineNumber); /** * Getter for choosen mobile number *

- * @return Choosen mobile number + * @return mobile number */ - DialableMobileNumber getChoosenMobileNumber (); + DialableMobileNumber getMobileNumber (); /** * Setter for choosen mobile number *

- * @param choosenMobileNumber Choosen mobile number + * @param choosenMobileNumber mobile number */ void setMobileNumber (final DialableMobileNumber choosenMobileNumber); diff --git a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebApplicationBean.java index 76d9e8e9..045d4125 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebApplicationBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebApplicationBean.java @@ -91,7 +91,7 @@ public class PizzaPhoneWebApplicationBean extends BasePizzaController implements Context context = new InitialContext(); // Try to lookup the beans - this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/jjobs-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N + this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N } catch (final NamingException e) { // Throw it again throw new FaceletException(e); diff --git a/src/java/org/mxchange/pizzaapplication/beans/profile/PizzaUserProfileWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/profile/PizzaUserProfileWebRequestBean.java index 196ebd3f..308ff3d6 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/profile/PizzaUserProfileWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/profile/PizzaUserProfileWebRequestBean.java @@ -17,6 +17,7 @@ package org.mxchange.pizzaapplication.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; @@ -54,6 +55,19 @@ public class PizzaUserProfileWebRequestBean extends BasePizzaController implemen @Inject private PizzaUserLoginWebSessionController userLoginController; + /** + * Default constructor + */ + public PizzaUserProfileWebRequestBean () { + } + + /** + * Post-construction method + */ + @PostConstruct + public void init () { + } + @Override public boolean isProfileLinkVisibleById (final Long userId) { // Init user instance diff --git a/src/java/org/mxchange/pizzaapplication/beans/profilemode/PizzaProfileModeWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/profilemode/PizzaProfileModeWebApplicationBean.java index a44c32fd..e2008ecd 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/profilemode/PizzaProfileModeWebApplicationBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/profilemode/PizzaProfileModeWebApplicationBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.pizzaapplication.beans.profilemode; +import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; @@ -47,4 +48,11 @@ public class PizzaProfileModeWebApplicationBean extends BasePizzaController impl return ProfileMode.values(); } + /** + * Post-construction method + */ + @PostConstruct + public void init () { + } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/register/PizzaUserRegisterWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/register/PizzaUserRegisterWebSessionBean.java index a37036b5..e6041be4 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/register/PizzaUserRegisterWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/register/PizzaUserRegisterWebSessionBean.java @@ -17,6 +17,7 @@ package org.mxchange.pizzaapplication.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; @@ -29,6 +30,7 @@ import javax.naming.NamingException; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.UserContact; import org.mxchange.jcoreee.utils.FacesUtils; +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; @@ -42,7 +44,6 @@ import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebSessionControl import org.mxchange.pizzaapplication.beans.features.PizzaFeaturesWebApplicationController; import org.mxchange.pizzaapplication.beans.user.PizzaAdminUserWebRequestController; import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; -import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent; /** * A web bean for user registration @@ -98,16 +99,6 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme * Default constructor */ public PizzaUserRegisterWebSessionBean () { - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.registerBean = (UserRegistrationSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/register!org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote"); //NOI18N - } catch (final NamingException ex) { - // Continue to throw - throw new FaceletException(ex); - } } @Override @@ -224,4 +215,21 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme 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/pizzaservice-ejb/register!org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw + throw new FaceletException(ex); + } + } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/resendlink/PizzaResendLinkWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/resendlink/PizzaResendLinkWebSessionBean.java index 8218cc15..ec8e6ab5 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/resendlink/PizzaResendLinkWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/resendlink/PizzaResendLinkWebSessionBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.pizzaapplication.beans.resendlink; +import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Event; import javax.enterprise.inject.Any; @@ -26,6 +27,7 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcoreee.utils.FacesUtils; +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; @@ -36,7 +38,6 @@ import org.mxchange.jusercore.model.user.status.UserAccountStatus; import org.mxchange.pizzaapplication.beans.BasePizzaController; import org.mxchange.pizzaapplication.beans.localization.PizzaLocalizationSessionController; import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; -import org.mxchange.jusercore.events.resendlink.ObservableUserResendLinkAccountEvent; /** * A web session bean for resending confirmation link @@ -60,7 +61,7 @@ public class PizzaResendLinkWebSessionBean extends BasePizzaController implement /** * EJB for resending confirmation link */ - private ResendLinkSessionBeanRemote emailBean; + private ResendLinkSessionBeanRemote resendLinkBean; /** * Localization controller @@ -85,17 +86,6 @@ public class PizzaResendLinkWebSessionBean extends BasePizzaController implement * Default constructor */ public PizzaResendLinkWebSessionBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.emailBean = (ResendLinkSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/resendLink!org.mxchange.pizzaapplication.beans.resendlink.ResendLinkSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw again - throw new FaceletException(e); - } } @Override @@ -146,7 +136,7 @@ public class PizzaResendLinkWebSessionBean extends BasePizzaController implement 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 @@ -177,6 +167,24 @@ public class PizzaResendLinkWebSessionBean extends BasePizzaController implement 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/pizzaservice-ejb/resendLink!org.mxchange.pizzaapplication.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 */ diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java index ecea11a9..48fa242f 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java @@ -18,6 +18,7 @@ package org.mxchange.pizzaapplication.beans.user; 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; @@ -95,7 +96,7 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements /** * Administrative user EJB */ - private final AdminUserSessionBeanRemote adminUserBean; + private AdminUserSessionBeanRemote adminUserBean; /** * Bean helper @@ -132,7 +133,7 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements /** * General user EJB */ - private final UserSessionBeanRemote userBean; + private UserSessionBeanRemote userBean; /** * Regular user controller @@ -196,18 +197,6 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements * Default constructor */ public PizzaAdminUserWebRequestBean () { - // 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 @@ -531,6 +520,25 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements 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/pizzaservice-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N + this.adminUserBean = (AdminUserSessionBeanRemote) context.lookup("java:global/pizzaservice-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? diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java index 2d0cd6f3..0f076e7e 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java @@ -94,7 +94,7 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz /** * Remote user bean */ - private final UserSessionBeanRemote userBean; + private UserSessionBeanRemote userBean; /** * User id @@ -149,17 +149,6 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz * Default constructor */ public PizzaUserWebSessionBean () { - // 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); - } } /** @@ -677,6 +666,18 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz */ @PostConstruct public void init () { + // 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); + } + // Initialize user list this.userList = this.userBean.allUsers(); diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/password/PizzaUserPasswordWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/password/PizzaUserPasswordWebRequestBean.java index 619b91b5..044468e3 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/password/PizzaUserPasswordWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/password/PizzaUserPasswordWebRequestBean.java @@ -17,6 +17,7 @@ package org.mxchange.pizzaapplication.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; @@ -27,6 +28,7 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcoreee.utils.FacesUtils; +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; @@ -39,7 +41,6 @@ import org.mxchange.jusercore.model.user.password_history.PasswordHistory; import org.mxchange.pizzaapplication.beans.BasePizzaController; import org.mxchange.pizzaapplication.beans.features.PizzaFeaturesWebApplicationController; import org.mxchange.pizzaapplication.beans.login.PizzaUserLoginWebSessionController; -import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent; /** * A user password (change) bean (controller) @@ -64,7 +65,7 @@ public class PizzaUserPasswordWebRequestBean extends BasePizzaController impleme /** * Remote user bean */ - private final UserSessionBeanRemote userBean; + private UserSessionBeanRemote userBean; /** * Current password (for confirmation of password change) @@ -98,17 +99,6 @@ public class PizzaUserPasswordWebRequestBean extends BasePizzaController impleme * Default constructor */ public PizzaUserPasswordWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.userBean = (UserSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw again - throw new FaceletException(e); - } } @Override @@ -227,6 +217,25 @@ public class PizzaUserPasswordWebRequestBean extends BasePizzaController impleme 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/pizzaservice-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.getUserCurrentPassword() != null) && diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/password/PizzaUserPasswordWebRequestController.java b/src/java/org/mxchange/pizzaapplication/beans/user/password/PizzaUserPasswordWebRequestController.java index b6e1feb8..219b23b4 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/password/PizzaUserPasswordWebRequestController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/password/PizzaUserPasswordWebRequestController.java @@ -70,10 +70,19 @@ public interface PizzaUserPasswordWebRequestController extends Serializable { void setUserPasswordRepeat (final String userPasswordRepeat); /** - * Changes logged-in user's password. It must not match with current password and should not appear in password history list for X (configurable) entries. + * Changes logged-in user's password. It must not match with current + * password and should not appear in password history list for X + * (configurable) entries. *

* @return Redirect outcome */ String doChangePassword (); + /** + * Checks if all 3 passwords are set: old password, 2x new password + *

+ * @return Whether all passwords are set + */ + boolean isRequiredChangePasswordSet (); + } -- 2.39.5