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;
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;
@Any
private Event<AdminAddedContactEvent> addedContactEvent;
+ /**
+ * Administrative contact EJB
+ */
+ private AdminContactSessionBeanRemote adminContactBean;
+
/**
* Admin helper instance
*/
// 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
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();
// 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);
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());
}
}
// 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());
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
// 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()
);
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;
private Date birthday;
/**
- * Cellphone number's carrier
+ * Mobile number's carrier
*/
private MobileProvider cellphoneCarrier;
/**
- * Cellphone number
+ * Mobile number
*/
private Long cellphoneNumber;
/**
* Whether a cellphone entry has been unlinked
*/
- private boolean isCellphoneUnlinked;
+ private boolean isMobileUnlinked;
/**
* Whether a fax entry has been unlinked
}
// 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());
//* 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
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());
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
}
@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;
}
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);
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)) {
void setBirthday (final Date birthday);
/**
- * Getter for ellphone number's carrier
+ * Getter for mobile number's provider
* <p>
- * @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
* <p>
- * @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
* <p>
- * @return Cellphone number
+ * @return Mobile number
*/
- Long getCellphoneNumber ();
+ Long getMobileNumber ();
/**
- * Setter for ellphone number
+ * Setter for mobile number
* <p>
- * @param cellphoneNumber Cellphone number
+ * @param mobileNumber Mobile number
*/
- void setCellphoneNumber (final Long cellphoneNumber);
+ void setMobileNumber (final Long mobileNumber);
/**
* City
* Setter for controller type
* <p>
* @param controllerType Controller type
+ *
* @deprecated Don't use this method.
*/
@Deprecated
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;
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;
@Inject
private PizzaAdminPhoneWebRequestController adminPhoneController;
- /**
- * All cell phone numbers
- */
- private final List<DialableMobileNumber> cellphoneNumbers;
-
/**
* General contact controller
*/
}
// Init lists/maps
- this.cellphoneNumbers = new LinkedList<>();
this.contacts = new HashMap<>(10);
}
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();
}
@Override
public List<Contact> allMobileContacts () {
// Get id
- Long phoneId = this.adminPhoneController.getCellphone().getPhoneId();
+ Long phoneId = this.adminPhoneController.getMobileNumber().getPhoneId();
// Is cache there?
if (this.contacts.containsKey(phoneId)) {
// "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);
}
}
}
- /**
- * Post-initialization of this class
- */
- @PostConstruct
- public void init () {
- // All phone numbers
- this.cellphoneNumbers.addAll(this.adminPhoneBean.allCellphoneNumbers());
- }
-
/**
* Clears this bean
*/
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;
/**
* Remote email change bean
*/
- private final EmailChangeSessionBeanRemote emailBean;
+ private final UserEmailChangeSessionBeanRemote emailBean;
/**
* Features controller
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();
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;
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;
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;
/**
*/
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;
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;
@Inject
private PizzaUserWebSessionController userController;
+ /**
+ * Event being fired after confirmation link is being sent
+ */
+ @Inject
+ @Any
+ private Event<UserResendLinkAccountEvent> userResendLinkEvent;
+
/**
* Default constructor
*/
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?
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
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;
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));
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.converter.cellphone;
-
-import java.text.MessageFormat;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
-import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
-import org.mxchange.jphone.phonenumbers.DialableNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote;
-
-/**
- * Converter for cellphone id <-> valid cellphone instance
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@FacesConverter (value = "CellphoneConverter")
-public class PizzaCellphoneConverter implements Converter {
-
- /**
- * Logger instance
- */
- @Log
- private LoggerBeanLocal loggerBeanLocal;
-
- /**
- * Phone EJB
- */
- private PhoneSessionBeanRemote phoneBean;
-
- /**
- * Initialization of this converter
- */
- public PizzaCellphoneConverter () {
- // Try to get it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Lookup logger
- this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
-
- // ... and user controller
- this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw it
- throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
- }
- }
-
- @Override
- public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
- // Trace message
- // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
-
- // Is the value null or empty?
- if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
- // Warning message
- this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
- // Return null
- return null;
- }
-
- // Init instance
- DialableMobileNumber cellphone = null;
-
- try {
- // Try to parse the value as long
- Long cellphoneId = 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);
-
- // Debug message
- // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: cellphone={0}", cellphone)); //NOI18N
- } catch (final NumberFormatException ex) {
- // Throw again
- throw new ConverterException(ex);
- } catch (final PhoneEntityNotFoundException ex) {
- // Debug message
- this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N
- }
-
- // Trace message
- // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: cellphone={0} - EXIT!", cellphone)); //NOI18N
-
- // Return it
- return cellphone;
- }
-
- @Override
- public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
- // Is the object null?
- if ((null == value) || ((String.valueOf(value)).isEmpty())) {
- // Is null
- return ""; //NOI18N
- } else if (!(value instanceof DialableNumber)) {
- // Not same interface
- throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement DialableNumber.", value)); //NOI18N
- }
-
- // Return category id
- return String.valueOf(((DialableNumber) value).getPhoneId());
- }
-
-}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.converter.mobile;
+
+import java.text.MessageFormat;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.convert.FacesConverter;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
+import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
+import org.mxchange.jphone.phonenumbers.DialableNumber;
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote;
+
+/**
+ * Converter for mobile id <-> valid mobile instance
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@FacesConverter (value = "CellphoneConverter")
+public class PizzaMobileConverter implements Converter {
+
+ /**
+ * Logger instance
+ */
+ @Log
+ private LoggerBeanLocal loggerBeanLocal;
+
+ /**
+ * Phone EJB
+ */
+ private PhoneSessionBeanRemote phoneBean;
+
+ /**
+ * Initialization of this converter
+ */
+ public PizzaMobileConverter () {
+ // Try to get it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Lookup logger
+ this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
+
+ // ... and user controller
+ this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw it
+ throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
+ }
+ }
+
+ @Override
+ public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+ // Trace message
+ // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
+
+ // Is the value null or empty?
+ if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
+ // Warning message
+ this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
+
+ // Return null
+ return null;
+ }
+
+ // Init instance
+ DialableMobileNumber mobile = null;
+
+ try {
+ // Try to parse the value as long
+ Long mobileId = Long.valueOf(submittedValue);
+
+ // Debug message
+ // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: userId{0}", userId)); //NOI18N
+
+ // Try to get mobile instance from it
+ mobile = this.phoneBean.findMobileNumberById(mobileId);
+
+ // Debug message
+ // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: mobile={0}", mobile)); //NOI18N
+ } catch (final NumberFormatException ex) {
+ // Throw again
+ throw new ConverterException(ex);
+ } catch (final PhoneEntityNotFoundException ex) {
+ // Debug message
+ this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N
+ }
+
+ // Trace message
+ // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: mobile={0} - EXIT!", mobile)); //NOI18N
+
+ // Return it
+ return mobile;
+ }
+
+ @Override
+ public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
+ // Is the object null?
+ if ((null == value) || ((String.valueOf(value)).isEmpty())) {
+ // Is null
+ return ""; //NOI18N
+ } else if (!(value instanceof DialableNumber)) {
+ // Not same interface
+ throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement DialableNumber.", value)); //NOI18N
+ }
+
+ // Return category id
+ return String.valueOf(((DialableNumber) value).getPhoneId());
+ }
+
+}