From 77d1ab13b25a612a1588f1ed40e072408f67c900 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 11 Apr 2017 12:47:54 +0200 Subject: [PATCH] API has changed: no more cellphone, now is mobile --- .../PizzaAdminContactWebRequestBean.java | 77 +++++++++++++------ .../contact/PizzaContactWebSessionBean.java | 72 ++++++++--------- .../PizzaContactWebSessionController.java | 25 +++--- .../PizzaContactPhoneWebSessionBean.java | 30 +------- .../PizzaEmailChangeWebSessionBean.java | 6 +- ...izzaAdminMobileProviderWebRequestBean.java | 4 +- .../PizzaMobileProviderWebRequestBean.java | 2 +- ...zzaMobileProviderWebRequestController.java | 2 +- .../PizzaResendLinkWebSessionBean.java | 43 ++++++++--- .../PizzaUserPasswordWebRequestBean.java | 6 +- .../PizzaMobileConverter.java} | 22 +++--- 11 files changed, 160 insertions(+), 129 deletions(-) rename src/java/org/mxchange/pizzaapplication/converter/{cellphone/PizzaCellphoneConverter.java => mobile/PizzaMobileConverter.java} (88%) diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java index 9c0d356c..2c9f1e54 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java @@ -30,6 +30,7 @@ import javax.inject.Named; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; +import org.mxchange.jcontacts.contact.AdminContactSessionBeanRemote; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.ContactSessionBeanRemote; import org.mxchange.jcontacts.contact.UserContact; @@ -42,12 +43,12 @@ import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent; import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException; import org.mxchange.jcountry.data.Country; import org.mxchange.jphone.phonenumbers.DialableNumber; -import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber; -import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.phonenumbers.landline.LandLineNumber; +import org.mxchange.jphone.phonenumbers.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.pizzaapplication.beans.helper.PizzaWebRequestController; @@ -73,6 +74,11 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme @Any private Event addedContactEvent; + /** + * Administrative contact EJB + */ + private AdminContactSessionBeanRemote adminContactBean; + /** * Admin helper instance */ @@ -248,6 +254,9 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme // 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); @@ -256,6 +265,24 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme @Override public String addContact () { + // Are all minimum fields set? + if (this.getGender() == null) { + // Throw NPE + throw new NullPointerException("gender is null"); //NOI18N + } else if (this.getFirstName() == null) { + // Throw NPE + throw new NullPointerException("firstName is null"); //NOI18N + } else if (this.getFirstName().isEmpty()) { + // Empty string + throw new IllegalStateException("firstName is empty"); //NOI18N + } else if (this.getFamilyName() == null) { + // Throw NPE + throw new NullPointerException("familyName is null"); //NOI18N + } else if (this.getFamilyName().isEmpty()) { + // Empty string + throw new IllegalStateException("familyName is empty"); //NOI18N + } + // Create new contact instance Contact contact = this.createContactInstance(); @@ -271,7 +298,7 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme // Try to call EJB try { // Call EJB - updatedContact = this.contactBean.addContact(contact); + updatedContact = this.adminContactBean.addContact(contact); } catch (final ContactAlreadyAddedException ex) { // Throw again throw new FaceletException(ex); @@ -324,7 +351,7 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme if (contact.getContactMobileNumber() instanceof DialableMobileNumber) { // ... cellphone data this.setCellphoneId(contact.getContactMobileNumber().getPhoneId()); - this.setCellphoneCarrier(contact.getContactMobileNumber().getCellphoneProvider()); + this.setCellphoneCarrier(contact.getContactMobileNumber().getMobileProvider()); this.setCellphoneNumber(contact.getContactMobileNumber().getPhoneNumber()); } @@ -371,9 +398,9 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme } // Generate phone number - DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber()); - DialableMobileNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber()); - DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); + 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()); // Create new instance Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName()); @@ -393,60 +420,60 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme contact.setContactOwnContact(Boolean.TRUE); // Don't set null or wrong references - if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) { + if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.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) { + if (landLineNumber.getPhoneAreaCode() == null) { // Is null throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N - } else if (phone.getPhoneAreaCode() < 1) { + } else if (landLineNumber.getPhoneAreaCode() < 1) { // Abort here throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N - } else if (phone.getPhoneNumber() == null) { + } else if (landLineNumber.getPhoneNumber() == null) { // Is null throw new NullPointerException("phone.phoneNumber is null"); //NOI18N - } else if (phone.getPhoneNumber() < 1) { + } else if (landLineNumber.getPhoneNumber() < 1) { // Abort here throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N } // Set phone number - contact.setContactLandLineNumber(phone); + contact.setContactLandLineNumber(landLineNumber); } // Don't set null or wrong references - if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) { + if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) { // Now the number must be given - if (fax.getPhoneAreaCode() == null) { + if (faxNumber.getPhoneAreaCode() == null) { // Is null throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N - } else if (fax.getPhoneAreaCode() < 1) { + } else if (faxNumber.getPhoneAreaCode() < 1) { // Abort here throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N - } else if (fax.getPhoneNumber() == null) { + } else if (faxNumber.getPhoneNumber() == null) { // Is null throw new NullPointerException("fax.phoneNumber is null"); //NOI18N - } else if (fax.getPhoneNumber() < 1) { + } else if (faxNumber.getPhoneNumber() < 1) { // Abort here throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N } // Set fax number - contact.setContactFaxNumber(fax); + contact.setContactFaxNumber(faxNumber); } // Is the provider set? - if ((cellphone instanceof DialableMobileNumber) && (this.getCellphoneCarrier() instanceof MobileProvider) && (this.getCellphoneNumber() != null) && (this.getCellphoneNumber() > 0)) { + if ((mobileNumber instanceof DialableMobileNumber) && (this.getCellphoneCarrier() instanceof MobileProvider) && (this.getCellphoneNumber() != null) && (this.getCellphoneNumber() > 0)) { // Is the number set? - if (cellphone.getPhoneNumber() == null) { + if (mobileNumber.getPhoneNumber() == null) { // Is null throw new NullPointerException("cellphone.phoneNumber is null"); //NOI18N - } else if (cellphone.getPhoneNumber() < 1) { + } else if (mobileNumber.getPhoneNumber() < 1) { // Abort here throw new IllegalArgumentException("cellphone.phoneNumber is zero or below."); //NOI18N } // Set cellphone number - contact.setContactCellphoneNumber(cellphone); + contact.setContactMobileNumber(mobileNumber); } // Return it @@ -497,8 +524,8 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme // Get all data String number = String.format( "%s%d%d", //NOI18N - cellphoneNumber.getCellphoneProvider().getProviderCountry().getCountryExternalDialPrefix(), - cellphoneNumber.getCellphoneProvider().getProviderDialPrefix(), + cellphoneNumber.getMobileProvider().getProviderCountry().getCountryExternalDialPrefix(), + cellphoneNumber.getMobileProvider().getProviderDialPrefix(), cellphoneNumber.getPhoneNumber() ); diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java index 2ccf5834..ae17941e 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java @@ -41,12 +41,12 @@ import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent; import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcountry.data.Country; -import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber; -import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.phonenumbers.landline.LandLineNumber; +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; +import org.mxchange.jphone.phonenumbers.mobile.MobileNumber; import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent; import org.mxchange.jusercore.events.login.UserLoggedInEvent; @@ -79,12 +79,12 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P private Date birthday; /** - * Cellphone number's carrier + * Mobile number's carrier */ private MobileProvider cellphoneCarrier; /** - * Cellphone number + * Mobile number */ private Long cellphoneNumber; @@ -171,7 +171,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P /** * Whether a cellphone entry has been unlinked */ - private boolean isCellphoneUnlinked; + private boolean isMobileUnlinked; /** * Whether a fax entry has been unlinked @@ -450,9 +450,9 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P } // Generate phone number - DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber()); - DialableMobileNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber()); - DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); + DialableLandLineNumber landLineNumber = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber()); + DialableMobileNumber mobileNumber = new MobileNumber(this.getMobileProvider(), this.getMobileNumber()); + DialableFaxNumber faxNumber = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); // Create new contact Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName()); @@ -470,60 +470,60 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createContactInstance: this.emailAddress={1}", this.getClass().getSimpleName(), this.getEmailAddress())); // Don't set null or wrong references - if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) { + if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.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) { + if (landLineNumber.getPhoneAreaCode() == null) { // Is null throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N - } else if (phone.getPhoneAreaCode() < 1) { + } else if (landLineNumber.getPhoneAreaCode() < 1) { // Abort here throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N - } else if (phone.getPhoneNumber() == null) { + } else if (landLineNumber.getPhoneNumber() == null) { // Is null throw new NullPointerException("phone.phoneNumber is null"); //NOI18N - } else if (phone.getPhoneNumber() < 1) { + } else if (landLineNumber.getPhoneNumber() < 1) { // Abort here throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N } // Set phone number - contact.setContactLandLineNumber(phone); + contact.setContactLandLineNumber(landLineNumber); } // Don't set null or wrong references - if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) { + if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) { // Now the number must be given - if (fax.getPhoneAreaCode() == null) { + if (faxNumber.getPhoneAreaCode() == null) { // Is null throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N - } else if (fax.getPhoneAreaCode() < 1) { + } else if (faxNumber.getPhoneAreaCode() < 1) { // Abort here throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N - } else if (fax.getPhoneNumber() == null) { + } else if (faxNumber.getPhoneNumber() == null) { // Is null throw new NullPointerException("fax.phoneNumber is null"); //NOI18N - } else if (fax.getPhoneNumber() < 1) { + } else if (faxNumber.getPhoneNumber() < 1) { // Abort here throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N } // Set fax number - contact.setContactFaxNumber(fax); + contact.setContactFaxNumber(faxNumber); } // Is the provider set? - if ((cellphone instanceof DialableMobileNumber) && (this.getCellphoneCarrier() instanceof MobileProvider) && (this.getCellphoneNumber() != null) && (this.getCellphoneNumber() > 0)) { + if ((mobileNumber instanceof DialableMobileNumber) && (this.getMobileProvider() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) { // Is the number set? - if (cellphone.getPhoneNumber() == null) { + if (mobileNumber.getPhoneNumber() == null) { // Is null throw new NullPointerException("cellphone.phoneNumber is null"); //NOI18N - } else if (cellphone.getPhoneNumber() < 1) { + } else if (mobileNumber.getPhoneNumber() < 1) { // Abort here throw new IllegalArgumentException("cellphone.phoneNumber is zero or below."); //NOI18N } // Set cellphone number - contact.setContactCellphoneNumber(cellphone); + contact.setContactMobileNumber(mobileNumber); } // Trace message @@ -568,7 +568,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P contact.setContactCountry(this.getCountry()); // Update contact's cellphone number - this.isCellphoneUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getCellphoneCarrier(), this.getCellphoneNumber()); + this.isMobileUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getMobileProvider(), this.getMobileNumber()); // Update contact's land-line number this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber()); @@ -577,7 +577,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); // Send it to the EJB - this.contactBean.updateContactData(contact, this.isCellphoneUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked); + this.contactBean.updateContactData(contact, this.isMobileUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked); // All fine return "contact_data_saved"; //NOI18N @@ -596,22 +596,22 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P } @Override - public MobileProvider getCellphoneCarrier () { + public MobileProvider getMobileProvider () { return this.cellphoneCarrier; } @Override - public void setCellphoneCarrier (final MobileProvider cellphoneCarrier) { - this.cellphoneCarrier = cellphoneCarrier; + public void setMobileProvider (final MobileProvider mobileProvider) { + this.cellphoneCarrier = mobileProvider; } @Override - public Long getCellphoneNumber () { + public Long getMobileNumber () { return this.cellphoneNumber; } @Override - public void setCellphoneNumber (Long cellphoneNumber) { + public void setMobileNumber (Long cellphoneNumber) { this.cellphoneNumber = cellphoneNumber; } @@ -1005,8 +1005,8 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.setPhoneAreaCode(null); this.setPhoneCountry(null); this.setPhoneNumber(null); - this.setCellphoneCarrier(null); - this.setCellphoneNumber(null); + this.setMobileProvider(null); + this.setMobileNumber(null); this.setFaxAreaCode(null); this.setFaxCountry(null); this.setFaxNumber(null); @@ -1062,9 +1062,9 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.setPhoneNumber(phone.getPhoneNumber()); } - if ((cellphone instanceof DialableMobileNumber) && (cellphone.getCellphoneProvider() instanceof MobileProvider)) { - this.setCellphoneCarrier(cellphone.getCellphoneProvider()); - this.setCellphoneNumber(cellphone.getPhoneNumber()); + if ((cellphone instanceof DialableMobileNumber) && (cellphone.getMobileProvider() instanceof MobileProvider)) { + this.setMobileProvider(cellphone.getMobileProvider()); + this.setMobileNumber(cellphone.getPhoneNumber()); } if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) { diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java index bbf548c4..02aae246 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java @@ -145,32 +145,32 @@ public interface PizzaContactWebSessionController extends Serializable { void setBirthday (final Date birthday); /** - * Getter for ellphone number's carrier + * Getter for mobile number's provider *

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

- * @param cellphoneCarrier Cellphone number's carrier prefix + * @param mobileProvider Mobile number's provider */ - void setCellphoneCarrier (final MobileProvider cellphoneCarrier); + void setMobileProvider (final MobileProvider mobileProvider); /** - * Getter for ellphone number + * Getter for mobile number *

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

- * @param cellphoneNumber Cellphone number + * @param mobileNumber Mobile number */ - void setCellphoneNumber (final Long cellphoneNumber); + void setMobileNumber (final Long mobileNumber); /** * City @@ -450,6 +450,7 @@ 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/PizzaContactPhoneWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebSessionBean.java index a6fb36bf..159d7cbe 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebSessionBean.java @@ -22,7 +22,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; -import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Observes; import javax.faces.view.facelets.FaceletException; @@ -34,7 +33,6 @@ import javax.naming.NamingException; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent; -import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; import org.mxchange.pizzaapplication.beans.BasePizzaController; @@ -66,11 +64,6 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme @Inject private PizzaAdminPhoneWebRequestController adminPhoneController; - /** - * All cell phone numbers - */ - private final List cellphoneNumbers; - /** * General contact controller */ @@ -100,7 +93,6 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme } // Init lists/maps - this.cellphoneNumbers = new LinkedList<>(); this.contacts = new HashMap<>(10); } @@ -121,15 +113,6 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N } - // Get contact - Contact contact = event.getAddedContact(); - - // Is cellphone set? - if (contact.getContactMobileNumber() instanceof DialableMobileNumber) { - // Unique-add it - this.uniqueAddCellphoneNumber(contact.getContactMobileNumber()); - } - // Clear this bean this.clear(); } @@ -176,7 +159,7 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme @Override public List allMobileContacts () { // Get id - Long phoneId = this.adminPhoneController.getCellphone().getPhoneId(); + Long phoneId = this.adminPhoneController.getMobileNumber().getPhoneId(); // Is cache there? if (this.contacts.containsKey(phoneId)) { @@ -189,7 +172,7 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme // "Walk" through all contacts for (final Contact contact : this.contactController.allContacts()) { // Is cellphone instance the same? - if (Objects.equals(contact.getContactMobileNumber(), this.adminPhoneController.getCellphone())) { + if (Objects.equals(contact.getContactMobileNumber(), this.adminPhoneController.getMobileNumber())) { // Found one list.add(contact); } @@ -203,15 +186,6 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme } } - /** - * Post-initialization of this class - */ - @PostConstruct - public void init () { - // All phone numbers - this.cellphoneNumbers.addAll(this.adminPhoneBean.allCellphoneNumbers()); - } - /** * Clears this bean */ 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 9eb6ac19..3c82045a 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/email_address/PizzaEmailChangeWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/email_address/PizzaEmailChangeWebSessionBean.java @@ -31,7 +31,7 @@ import org.mxchange.jcoreee.utils.FacesUtils; import org.mxchange.jusercore.exceptions.UserPasswordMismatchException; import org.mxchange.jusercore.model.email_address.ChangeableEmailAddress; import org.mxchange.jusercore.model.email_address.EmailAddressChange; -import org.mxchange.jusercore.model.email_address.EmailChangeSessionBeanRemote; +import org.mxchange.jusercore.model.email_address.UserEmailChangeSessionBeanRemote; import org.mxchange.jusercore.model.user.User; import org.mxchange.pizzaapplication.beans.BasePizzaController; import org.mxchange.pizzaapplication.beans.features.PizzaFeaturesWebApplicationController; @@ -69,7 +69,7 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen /** * Remote email change bean */ - private final EmailChangeSessionBeanRemote emailBean; + private final UserEmailChangeSessionBeanRemote emailBean; /** * Features controller @@ -93,7 +93,7 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen Context context = new InitialContext(); // Try to lookup - this.emailBean = (EmailChangeSessionBeanRemote) context.lookup("java:global/addressbook-ejb/email-change!org.mxchange.jusercore.model.email_address.EmailChangeSessionBeanRemote"); //NOI18N + 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(); diff --git a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java index 52f7edbc..65fbcf3c 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java @@ -29,8 +29,8 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcountry.data.Country; -import org.mxchange.jphone.events.AdminAddedMobileProviderEvent; -import org.mxchange.jphone.events.AdminMobileProviderAddedEvent; +import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent; +import org.mxchange.jphone.events.mobileprovider.added.AdminMobileProviderAddedEvent; import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException; import org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote; import org.mxchange.jphone.phonenumbers.mobileprovider.CellphoneProvider; diff --git a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java index 609ac53f..a678b272 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java @@ -27,7 +27,7 @@ import javax.inject.Named; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.mxchange.jphone.events.AdminAddedMobileProviderEvent; +import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent; import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote; import org.mxchange.pizzaapplication.beans.BasePizzaController; diff --git a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java index 0baad433..8b4fa3fa 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java @@ -18,7 +18,7 @@ package org.mxchange.pizzaapplication.beans.mobileprovider; import java.io.Serializable; import java.util.List; -import org.mxchange.jphone.events.AdminAddedMobileProviderEvent; +import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent; import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; /** diff --git a/src/java/org/mxchange/pizzaapplication/beans/resendlink/PizzaResendLinkWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/resendlink/PizzaResendLinkWebSessionBean.java index 63475b7c..f775f8a8 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/resendlink/PizzaResendLinkWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/resendlink/PizzaResendLinkWebSessionBean.java @@ -16,8 +16,9 @@ */ package org.mxchange.pizzaapplication.beans.resendlink; -import java.text.MessageFormat; import javax.enterprise.context.SessionScoped; +import javax.enterprise.event.Event; +import javax.enterprise.inject.Any; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; import javax.inject.Named; @@ -25,7 +26,10 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcoreee.utils.FacesUtils; +import org.mxchange.jusercore.events.resendlink.ResendLinkUserAccountEvent; +import org.mxchange.jusercore.events.resendlink.UserResendLinkAccountEvent; import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException; +import org.mxchange.jusercore.exceptions.UserNotFoundException; import org.mxchange.jusercore.exceptions.UserStatusConfirmedException; import org.mxchange.jusercore.exceptions.UserStatusLockedException; import org.mxchange.jusercore.model.user.User; @@ -70,6 +74,13 @@ public class PizzaResendLinkWebSessionBean extends BasePizzaController implement @Inject private PizzaUserWebSessionController userController; + /** + * Event being fired after confirmation link is being sent + */ + @Inject + @Any + private Event userResendLinkEvent; + /** * Default constructor */ @@ -106,7 +117,8 @@ public class PizzaResendLinkWebSessionBean extends BasePizzaController implement this.clear(); // Not found, should not happen as the registered validator should find it - throw new FaceletException(MessageFormat.format("this.emailAddress={0} should be resolveable into User instance.", this.getEmailAddress()), ex); //NOI18N + this.showFacesMessage("form_resend_link:", "ERROR_USER_EMAIL_ADDRESS_NOT_FOUND"); //NOI18N + return ""; //NOI18N } // Is the user account already confirmed? @@ -115,31 +127,44 @@ public class PizzaResendLinkWebSessionBean extends BasePizzaController implement this.clear(); // Then abort here - this.showFacesMessage("form_resend_link:resendEmailAddress", new UserStatusConfirmedException(user)); //NOI18N + this.showFacesMessage("form_resend_link:resendEmailAddress", "ERROR_USER_STATUS_ALREADY_CONFIRMED"); //NOI18N return ""; //NOI18N } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) { // Always clear bean this.clear(); // User account is locked - this.showFacesMessage("form_resend_link:resendEmailAddress", new UserStatusLockedException(user)); //NOI18N + this.showFacesMessage("form_resend_link:resendEmailAddress", "ERROR_USER_STATUS_LOCKED"); //NOI18N return ""; //NOI18N } else if (user.getUserConfirmKey() == null) { // Status is UNCONFIRMED but confirmation key is NULL throw new NullPointerException("user.userConfirmKey is null"); //NOI18N } - // Get base URL - String baseUrl = FacesUtils.generateBaseUrl(); + try { + // Get base URL + String baseUrl = FacesUtils.generateBaseUrl(); + + // Call EJB and return redirect target + this.emailBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl); + } catch (final UserNotFoundException ex) { + // User not found + this.showFacesMessage("form_resend_link:resendEmailAddress", "ERROR_USER_NOT_FOUND"); //NOI18N + return ""; //NOI18N + } catch (final UserStatusLockedException | UserStatusConfirmedException ex) { + // Output message, this should not happen as the confirmation key is being removed + this.showFacesMessage("form_resend_link:resendEmailAddress", ex); //NOI18N + return ""; //NOI18N + } - // Call EJB and return redirect target - this.emailBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl); + // Fire event + this.userResendLinkEvent.fire(new ResendLinkUserAccountEvent(user)); // Clear this bean this.clear(); // Return redirect target - return "resend_done"; //NOI18N + return "user_resend_done"; //NOI18N } @Override 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 ae4b484a..0dee5e18 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/password/PizzaUserPasswordWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/password/PizzaUserPasswordWebRequestBean.java @@ -26,6 +26,7 @@ import javax.inject.Named; 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.UpdatedUserPasswordEvent; import org.mxchange.jusercore.events.user.password_change.UserUpdatedPasswordEvent; import org.mxchange.jusercore.exceptions.UserNotFoundException; @@ -173,8 +174,11 @@ public class PizzaUserPasswordWebRequestBean extends BasePizzaController impleme user.setUserEncryptedPassword(encryptedPassword); try { + // Get base URL + String baseUrl = FacesUtils.generateBaseUrl(); + // All is set, then update password - PasswordHistory passwordHistory = this.userBean.updateUserPassword(user); + PasswordHistory passwordHistory = this.userBean.updateUserPassword(user, baseUrl); // Fire event this.userUpdatedPasswordEvent.fire(new UserUpdatedPasswordEvent(passwordHistory)); diff --git a/src/java/org/mxchange/pizzaapplication/converter/cellphone/PizzaCellphoneConverter.java b/src/java/org/mxchange/pizzaapplication/converter/mobile/PizzaMobileConverter.java similarity index 88% rename from src/java/org/mxchange/pizzaapplication/converter/cellphone/PizzaCellphoneConverter.java rename to src/java/org/mxchange/pizzaapplication/converter/mobile/PizzaMobileConverter.java index c15af38c..a01af819 100644 --- a/src/java/org/mxchange/pizzaapplication/converter/cellphone/PizzaCellphoneConverter.java +++ b/src/java/org/mxchange/pizzaapplication/converter/mobile/PizzaMobileConverter.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package org.mxchange.pizzaapplication.converter.cellphone; +package org.mxchange.pizzaapplication.converter.mobile; import java.text.MessageFormat; import javax.faces.component.UIComponent; @@ -33,12 +33,12 @@ import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote; /** - * Converter for cellphone id <-> valid cellphone instance + * Converter for mobile id <-> valid mobile instance *

* @author Roland Häder */ @FacesConverter (value = "CellphoneConverter") -public class PizzaCellphoneConverter implements Converter { +public class PizzaMobileConverter implements Converter { /** * Logger instance @@ -54,7 +54,7 @@ public class PizzaCellphoneConverter implements Converter { /** * Initialization of this converter */ - public PizzaCellphoneConverter () { + public PizzaMobileConverter () { // Try to get it try { // Get initial context @@ -86,20 +86,20 @@ public class PizzaCellphoneConverter implements Converter { } // Init instance - DialableMobileNumber cellphone = null; + DialableMobileNumber mobile = null; try { // Try to parse the value as long - Long cellphoneId = Long.valueOf(submittedValue); + Long mobileId = Long.valueOf(submittedValue); // Debug message // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: userId{0}", userId)); //NOI18N - // Try to get cellphone instance from it - cellphone = this.phoneBean.findCellphoneById(cellphoneId); + // Try to get mobile instance from it + mobile = this.phoneBean.findMobileNumberById(mobileId); // Debug message - // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: cellphone={0}", cellphone)); //NOI18N + // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: mobile={0}", mobile)); //NOI18N } catch (final NumberFormatException ex) { // Throw again throw new ConverterException(ex); @@ -109,10 +109,10 @@ public class PizzaCellphoneConverter implements Converter { } // Trace message - // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: cellphone={0} - EXIT!", cellphone)); //NOI18N + // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: mobile={0} - EXIT!", mobile)); //NOI18N // Return it - return cellphone; + return mobile; } @Override -- 2.39.5