From 02ba7497808d06dc98611d8e40525ef6aa1cf953 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 5 Aug 2017 19:56:41 +0200 Subject: [PATCH] updated jar(s) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- lib/jphone-core.jar | Bin 66086 -> 66026 bytes .../jjobs/beans/BaseJobsController.java | 2 +- .../JobsAdminContactWebRequestBean.java | 8 +- .../JobsAdminContactPhoneWebRequestBean.java | 611 +++++++++++------- .../phone/JobsContactPhoneWebSessionBean.java | 180 +++++- .../JobsCountryWebApplicationBean.java | 134 +--- .../helper/JobsWebRequestHelperBean.java | 40 +- ...JobsAdminMobileProviderWebRequestBean.java | 135 +--- .../phone/JobsAdminPhoneWebRequestBean.java | 14 +- .../phone/JobsPhoneWebApplicationBean.java | 134 +--- .../JobsProfileModeWebApplicationBean.java | 135 +--- .../user/JobsAdminUserWebRequestBean.java | 198 +++--- .../beans/user/JobsUserWebSessionBean.java | 4 +- .../JobsUserActivityWebApplicationBean.java | 66 +- .../JobsConfirmationLinkWebRequestBean.java | 16 +- .../localization/bundle_de_DE.properties | 4 +- .../localization/bundle_en_US.properties | 4 +- web/admin/user/admin_user_activity_log.xhtml | 4 +- 18 files changed, 784 insertions(+), 905 deletions(-) diff --git a/lib/jphone-core.jar b/lib/jphone-core.jar index c26881aca177c269466cbbe99109ae447c9db073..e02fe6449c20b81d3ab78ce994272454a410dfb6 100644 GIT binary patch delta 2162 zcmZuydrVVT7{B-SL0gN+L$Kshx-noDML-adry^J=SQryGqfAZ6bisimadXB+m^yGe zfiGw_7m?XCb6c1TOWXsQE@s&uMy6()Lq$*?N_nct1c9CJYj3rSP0szD^ZWh2@0{=4 zb8c;W<^3PZwRvWlT*GlHjx*b8wey8+TW!1*pEnKooIwVRd=$cZJ|3Z-Pef=GqT!rI z1+xT=G(6p_(Mai>jzfZvLrq8M719t|WJ{n(Mgn#>-gOIWk(ngZo>&#MJM!nrQ;@BZ zXF4DjqL!!P^2Kn`q6WKy);X@oK~sj3il|g3!qEdT@N3?tHCoK1BB0j{oPLBMUfUCqG z)H(R1AcyaQK9h89NT8s~wkgbkBMX0quDB?+9V)QT4~F4UC8R9THCsbtD8scd8AaSQ zP7waHXp*N$?GDc^&=D2|dt$@uSkOf;OLJ9BJ}u*VTodn&=`VFXG`7k(4x0(Ocs=AL zdqL-zp3R|#h~RXHU-~B;EDV4>S)LG;pkmrQC`@>l4`MwX3?|IsSHS4<7hT$-)VXk3 zJr~NB8Q}Cw9?&=D-Q2V+$T3~ZwzSG4JjY>s#W|hMX$zn!(~>UC3b$-7FMemorp+bA zG)ZK#^8YDeQEEK2CWlg`J{{cx%;ZKw*^1ESl#~od{b&1Y<3P-gWG5oDxg)iT3g41` zo^~n1bdPq=Kf8)z%r;opoxto+-%U5>?{2z*>K-Cj_7J(hXBAr7ddvvhdqr5diK(0d3iL*--} zCa?|f!coY``v?sqMEZ>qRF6`C?0zL`AKl-LpnO2E@4-GCX&>%IsC!7H_t@^|T#tsa zM0OsH2D~_KCz*TtvsRo;gztnPc8{ck9YO(kNaNVC$Cmrl&si%@B|8H=@BqUHkLVNV zIW7uWsV;>bV(3U!!jo|=uCt1%3({R`L*@eT8lgDNzoIa_%B8$viiYV26!S4t+Ou4W z-r@Ohk#ih2lbcx!CnnZnv5zN2A$lD&PP_nz*NgD`Bo(@4 zQWR_(oU8&)6e~erB*LXhD)t6bBa2c^n$__6v;kAJPK(0AW6!X&>(}zWs6@<&!nH=&WHr|P=qIh=7$fIe8JUC? z&`uU*eYJW_!Ex9U-Ddl>-oR(GRP`miD9mYv#sJI@!;i$Ae=r{_^M$6+(Nxsu!2i}#0ycK@Su1YWE8 LA&BF|ZnXRd8&4L) delta 2320 zcmZ`)drVVj6uB|WuAs2gX($Q&8mY5HvGM>#oq~JAcl=aC}tB7n%E?S6Wn6> zMWuvyIF-k(?pCQh<=l#TE=Y`~BXn~{gv*k6D3MSAhp|0AX_qBg9#QpDC3J}OEz(qE z8>E>cENx6vPU&6|hMd+=D^Ef1nmkR+)WhIh z4Hy+9H7QmhJ1o;ftZO#7WJ+`&D&hsOhbj9ch;sEK7SZXykFYYJnRs1rqZIjzq3y&U z2p9R}2vK)^b|%Hux|y8vW|b^==HSAgp=(*Jup3Hn&WnVr&*YFAA8xlr#ZiSn^%Bas zA2UjL@7*z$GSxf%KZFPRSg2ka4Q+#R_&p%sUKdwDef+honGMAHC+ce}?n)R2%?w@a zY&c&ihn56Cd6u=T!ny+tDPi``glLw{fjfRP8dqqh1Ry8zGlgza2yMf*v?HXw6#$#+6Z2@o0qFJ})&!+`=op2bV!#_M*nLD0{P^ zj&^Q&`Ze0;vDHs$|GTrhh`*J0l>Dvv=Lka!CWsF!(#i0Nr>w6e|H6iS3iMZ4AIT9T z%OZ(4mT#rJvlZci$ls_bp}4-TmiROK>xoZ1e42R2i6jnnb8KgW5pQ2K5zn`zlWueC zF{;b8XV84v9i4vME#cBS5(PO}9dzZschD8SCz2tLiCpt|HA;>>&P7P;=0Vv_S3Iq| z(8FBtFgz%pP|*0qg2CfGJTyN^_6(Ih-eIX{xE6z>J!XW0ULHPpy23MT5r?Bsi$rFP zC-7@8X;^15G8>)L+Bs()dSlK4kL;s9lAY>%4;j|ULzs)!wBD78%t_ZagrNS<5f1cM zl5Bur=fE!Xh6cVsC?6!!A;P+6l+gaH7Gv)}-;HorgrcFn=>0vk2ch%@#kyYX{*U`r z{xWIu(Bl!7!bd|QY{W=)CGt2cjy=Ttdf zwqayBR{Bj~U3p%%&E)NZR@=NidMrh_;b?`Ei)Cyz_4$-k{m&{AMz1s9Xb|2_XuiUv z0(bQ|SUwy?;`UP+WmlyPgO=q}HMvL-hk~V41-sYi;J_Fy=*lS1ZC>w=1i+T!P&hqG zkp*KscXxw3GT);=F0dt5H#-B&TZ252>92V%y$tTibmzAt3ARtVYA@TSHO=D(pH3~zX@x5mv*Utq~)xe$r?r;K$A_kFWX zE7U~G^r@RuM~ys;iiBzYzmzcyT9QxU z=NAQGeA6rz3pT~FJZEfy?X7W5)vS(E>qGwF4Z;~fTji6ww^a~kdgu5Nf;$~T<7gQ^ tLVdd+G#>htrAZEb%?h)8+#x(o4U~6iG?rYMkisxI!uNUv! * @author Roland Häder */ -public abstract class BaseJobsController extends BaseFacesBean { +public class BaseJobsController extends BaseFacesBean { /** * Serial number diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java index 3edd3bdc..208c9002 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java @@ -39,7 +39,7 @@ import org.mxchange.jcontacts.contact.UserContact; import org.mxchange.jcontacts.contact.title.PersonalTitle; import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; -import org.mxchange.jcontacts.events.contact.helper.created.ObservableHelperCreatedContactEvent; +import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent; import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent; import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException; @@ -315,9 +315,9 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement *

* @param event Event being fired */ - public void afterHelperCreatedContactEvent (@Observes final ObservableHelperCreatedContactEvent event) { + public void afterCreatedContactEvent (@Observes final ObservableCreatedContactEvent event) { // Log message - //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AdminContactController::afterHelperCreatedContactEvent(): contact={0} - CALLED!", contact)); //NOI18N + //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AdminContactController::afterCreatedContactEvent(): contact={0} - CALLED!", contact)); //NOI18N // The event instance must be valid if (null == event) { @@ -380,7 +380,7 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement } // Log message - //* NOISY-DEBUG: */ System.out.println("AdminContactController::afterHelperCreatedContactEvent(): EXIT!"); //NOI18N + //* NOISY-DEBUG: */ System.out.println("AdminContactController::afterCreatedContactEvent(): EXIT!"); //NOI18N } @Override diff --git a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java index 89084e88..bcb263bd 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java @@ -17,16 +17,12 @@ package org.mxchange.jjobs.beans.contact.phone; import java.text.MessageFormat; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; +import java.util.Calendar; import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Event; import javax.enterprise.event.Observes; import javax.enterprise.inject.Any; -import javax.faces.application.FacesMessage; -import javax.faces.context.FacesContext; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; import javax.inject.Named; @@ -35,6 +31,7 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; +import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent; import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; import org.mxchange.jcontacts.events.fax.linked.AdminLinkedFaxNumberEvent; import org.mxchange.jcontacts.events.fax.linked.ObservableAdminLinkedFaxNumberEvent; @@ -53,6 +50,8 @@ import org.mxchange.jcountry.data.Country; import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController; import org.mxchange.jjobs.beans.phone.JobsAdminPhoneWebRequestController; +import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent; +import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent; import org.mxchange.jphone.exceptions.PhoneNumberAlreadyLinkedException; import org.mxchange.jphone.exceptions.PhoneNumberNotLinkedException; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; @@ -63,6 +62,7 @@ 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.user.add.ObservableAdminAddedUserEvent; +import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent; /** * An administrative contact phone controller (bean) @@ -71,7 +71,7 @@ import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent; */ @Named ("adminContactPhoneController") @RequestScoped -public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsController implements JobsAdminContactPhoneWebRequestController { +public class JobsAdminContactPhoneWebRequestBean extends BaseJobsController implements JobsAdminContactPhoneWebRequestController { /** * Call-stack instance (5 may show BeanELResolver.getValue as caller) @@ -83,6 +83,11 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro */ private static final long serialVersionUID = 542_145_347_916L; + /** + * Administrative EJB for phone number + */ + private AdminContactsPhoneSessionBeanRemote adminContactPhoneBean; + /** * Event being fired when a fax number has been linked */ @@ -104,11 +109,6 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro @Any private Event adminLinkedMobileNumberEvent; - /** - * Administrative EJB for phone number - */ - private AdminContactsPhoneSessionBeanRemote adminPhoneBean; - /** * Administrative phone controller */ @@ -122,25 +122,9 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro private JobsWebRequestHelperController beanHelper; /** - * Event being fired when a fax number has been unlinked + * Contact instance */ - @Inject - @Any - private Event faxNumberUnlinkedEvent; - - /** - * Event being fired when a land-line number has been unlinked - */ - @Inject - @Any - private Event landLineNumberUnlinkedEvent; - - /** - * Event being fired when admin unlinks mobile from contact - */ - @Inject - @Any - private Event mobileNumberUnlinkedEvent; + private Contact contact; /** * Area code (city dial prefix) for fax number @@ -157,6 +141,13 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro */ private Long faxNumber; + /** + * Event being fired when a fax number has been unlinked + */ + @Inject + @Any + private Event faxNumberUnlinkedEvent; + /** * Area code (city dial prefix) for land-line number */ @@ -173,15 +164,44 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro private Long landLineNumber; /** - * Mobile provider + * Event being fired when a land-line number has been unlinked */ - private MobileProvider mobileProvider; + @Inject + @Any + private Event landLineNumberUnlinkedEvent; /** * Mobile number */ private Long mobileNumber; + /** + * Event being fired when administrator unlinks mobile from contact + */ + @Inject + @Any + private Event mobileNumberUnlinkedEvent; + + /** + * Mobile provider + */ + private MobileProvider mobileProvider; + + /** + * When fax number has been created + */ + private Calendar phoneEntryCreated; + + /** + * When fax number has been updated + */ + private Calendar phoneEntryUpdated; + + /** + * Phone id (primary key) + */ + private Long phoneId; + /** * Default constructor */ @@ -269,6 +289,136 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro this.clear(); } + /** + * Observer for events being fired when a bean helper has successfully + * created a contact instance. + *

+ * @param event Event being fired + */ + public void afterCreatedContactEvent (@Observes final ObservableCreatedContactEvent event) { + // Log message + //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AdminContactController::afterCreatedContactEvent(): contact={0} - CALLED!", contact)); //NOI18N + + // The event instance must be valid + if (null == event) { + // Throw NPE again + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getCreatedContact() == null) { + // Throw NPE again + throw new NullPointerException("event.createdContact is null"); //NOI18N //NOI18N + } else if (event.getCreatedContact().getContactId() == null) { + // Throw NPE again + throw new NullPointerException("event.createdContact.contactId is null"); //NOI18N //NOI18N + } else if (event.getCreatedContact().getContactId() < 1) { + // Not valid + throw new IllegalStateException(MessageFormat.format("event.createdContact.contactId={0} is not valid.", event.getCreatedContact().getContactId())); //NOI18N + } + + // Set it here + this.setContact(event.getCreatedContact()); + } + + /** + * Observes events being fired when a bean helper has successfully created a + * fax number instance. + *

+ * @param event Event being fired + */ + public void afterCreatedFaxNumberEvent (@Observes final ObservableCreatedFaxNumberEvent event) { + // The event instance must be valid + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getFaxNumber() == null) { + // Throw NPE again + throw new NullPointerException("event.faxNumber is null"); //NOI18N + } else if (event.getFaxNumber().getPhoneId() == null) { + // Throw NPE yet again + throw new NullPointerException("event.faxNumber.phoneId is null"); //NOI18N + } else if (event.getFaxNumber().getPhoneId() < 1) { + // Throw NPE yet again + throw new NullPointerException(MessageFormat.format("event.faxNumber.phoneId={0} is invalid", event.getFaxNumber().getPhoneId())); //NOI18N + } + + // Get fax number from event + DialableFaxNumber number = event.getFaxNumber(); + + // Copy all data to this bean + this.setPhoneId(number.getPhoneId()); + this.setFaxCountry(number.getPhoneCountry()); + this.setFaxAreaCode(number.getPhoneAreaCode()); + this.setFaxNumber(number.getPhoneNumber()); + this.setPhoneEntryCreated(number.getPhoneEntryCreated()); + this.setPhoneEntryUpdated(number.getPhoneEntryUpdated()); + } + + /** + * Observes events being fired when a bean helper has successfully created a + * land-line number instance. + *

+ * @param event Event being fired + */ + public void afterCreatedLandLineNumberEvent (@Observes final ObservableCreatedLandLineNumberEvent event) { + // The event instance must be valid + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getLandLineNumber() == null) { + // Throw NPE again + throw new NullPointerException("event.landLineNumber is null"); //NOI18N + } else if (event.getLandLineNumber().getPhoneId() == null) { + // Throw NPE yet again + throw new NullPointerException("event.landLineNumber.phoneId is null"); //NOI18N + } else if (event.getLandLineNumber().getPhoneId() < 1) { + // Throw NPE yet again + throw new NullPointerException(MessageFormat.format("event.landLineNumber.phoneId={0} is invalid", event.getLandLineNumber().getPhoneId())); //NOI18N + } + + // Get fax number from event + DialableLandLineNumber number = event.getLandLineNumber(); + + // Copy all data to this bean + this.setPhoneId(number.getPhoneId()); + this.setLandLineCountry(number.getPhoneCountry()); + this.setLandLineAreaCode(number.getPhoneAreaCode()); + this.setLandLineNumber(number.getPhoneNumber()); + this.setPhoneEntryCreated(number.getPhoneEntryCreated()); + this.setPhoneEntryUpdated(number.getPhoneEntryUpdated()); + } + + /** + * Observes events being fired when a bean helper has successfully created a + * mobile number instance. + *

+ * @param event Event being fired + */ + public void afterCreatedMobileNumberEvent (@Observes final ObservableCreatedMobileNumberEvent event) { + // The event instance must be valid + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getMobileNumber() == null) { + // Throw NPE again + throw new NullPointerException("event.mobileNumber is null"); //NOI18N + } else if (event.getMobileNumber().getPhoneId() == null) { + // Throw NPE yet again + throw new NullPointerException("event.mobileNumber.phoneId is null"); //NOI18N + } else if (event.getMobileNumber().getPhoneId() < 1) { + // Throw NPE yet again + throw new NullPointerException(MessageFormat.format("event.mobileNumber.phoneId={0} is invalid", event.getMobileNumber().getPhoneId())); //NOI18N + } + + // Get fax number from event + DialableMobileNumber number = event.getMobileNumber(); + + // Copy all data to this bean + this.setPhoneId(number.getPhoneId()); + this.setMobileProvider(number.getMobileProvider()); + this.setMobileNumber(number.getPhoneNumber()); + this.setPhoneEntryCreated(number.getPhoneEntryCreated()); + this.setPhoneEntryUpdated(number.getPhoneEntryUpdated()); + } + /** * Links fax number to contact from bean helper as "main fax number". *

@@ -276,18 +426,18 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro */ public String doLinkMainFaxNumber () { // Get contact from helper - Contact contact = this.beanHelper.getContact(); + Contact targetContact = this.getContact(); // Is all data properly set? - if (null == contact) { + if (null == targetContact) { // Throw NPE - throw new NullPointerException("contact is null"); //NOI18N - } else if (contact.getContactId() == null) { + throw new NullPointerException("targetContact is null"); //NOI18N + } else if (targetContact.getContactId() == null) { // Throw it again - throw new NullPointerException("contact.contactId is null"); //NOI18N - } else if (contact.getContactId() < 1) { + throw new NullPointerException("targetContact.contactId is null"); //NOI18N + } else if (targetContact.getContactId() < 1) { // Is not valid - throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("targetContact.contactId={0} is not valid", targetContact.getContactId())); //NOI18N } else if (this.getFaxCountry() == null) { // Throw NPE again throw new NullPointerException("this.faxCountry is null"); //NOI18N @@ -318,7 +468,7 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro // Try it again try { // Link it, too - updatedContact = this.adminPhoneBean.linkNewFaxNumberWithContact(contact, number); + updatedContact = this.adminContactPhoneBean.linkNewFaxNumberWithContact(targetContact, number); } catch (final PhoneNumberAlreadyLinkedException ex) { // Throw again as cause this.showFacesMessage("form_add_contact_fax:faxNumber", ex); //NOI18N @@ -340,18 +490,18 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro */ public String doLinkMainLandLineNumber () { // Get contact from helper - Contact contact = this.beanHelper.getContact(); + Contact targetContact = this.getContact(); // Is all data properly set? - if (null == contact) { + if (null == targetContact) { // Throw NPE - throw new NullPointerException("contact is null"); //NOI18N - } else if (contact.getContactId() == null) { + throw new NullPointerException("targetContact is null"); //NOI18N + } else if (targetContact.getContactId() == null) { // Throw it again - throw new NullPointerException("contact.contactId is null"); //NOI18N - } else if (contact.getContactId() < 1) { + throw new NullPointerException("targetContact.contactId is null"); //NOI18N + } else if (targetContact.getContactId() < 1) { // Is not valid - throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("targetContact.contactId={0} is not valid", targetContact.getContactId())); //NOI18N } else if (this.getLandLineCountry() == null) { // Throw NPE again throw new NullPointerException("this.landLineCountry is null"); //NOI18N @@ -382,7 +532,7 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro // Try it again try { // Link it, too - updatedContact = this.adminPhoneBean.linkNewLandLineNumberWithContact(contact, number); + updatedContact = this.adminContactPhoneBean.linkNewLandLineNumberWithContact(targetContact, number); } catch (final PhoneNumberAlreadyLinkedException ex) { // Throw again as cause this.showFacesMessage("form_add_contact_landLine:landLineNumber", ex); //NOI18N @@ -403,18 +553,18 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro */ public String doLinkMainMobileNumber () { // Get contact from helper - Contact contact = this.beanHelper.getContact(); + Contact targetContact = this.getContact(); // Is all data properly set? - if (null == contact) { + if (null == targetContact) { // Throw NPE - throw new NullPointerException("contact is null"); //NOI18N - } else if (contact.getContactId() == null) { + throw new NullPointerException("targetContact is null"); //NOI18N + } else if (targetContact.getContactId() == null) { // Throw it again - throw new NullPointerException("contact.contactId is null"); //NOI18N - } else if (contact.getContactId() < 1) { + throw new NullPointerException("targetContact.contactId is null"); //NOI18N + } else if (targetContact.getContactId() < 1) { // Is not valid - throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("targetContact.contactId={0} is not valid", targetContact.getContactId())); //NOI18N } else if (this.getMobileProvider() == null) { // Throw NPE throw new NullPointerException("this.mobileProvider is null"); //NOI18N @@ -439,7 +589,7 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro // Try it again try { // Link it, too - updatedContact = this.adminPhoneBean.linkNewMobileNumberWithContact(contact, number); + updatedContact = this.adminContactPhoneBean.linkNewMobileNumberWithContact(targetContact, number); } catch (final PhoneNumberAlreadyLinkedException ex) { // Throw again as cause this.showFacesMessage("form_add_contact_mobile:mobileNumber", ex); //NOI18N @@ -453,6 +603,24 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro return "admin_show_contact"; //NOI18N } + /** + * Getter for contact instance + *

+ * @return Contact instance + */ + public Contact getContact () { + return this.contact; + } + + /** + * Setter for contact instance + *

+ * @param contact Contact instance + */ + public void setContact (final Contact contact) { + this.contact = contact; + } + /** * Getter for fax area code *

@@ -561,6 +729,24 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro this.landLineNumber = landLineNumber; } + /** + * Getter for mobile number + *

+ * @return Mobile number + */ + public Long getMobileNumber () { + return this.mobileNumber; + } + + /** + * Setter for mobile number + *

+ * @param mobileNumber Mobile number + */ + public void setMobileNumber (final Long mobileNumber) { + this.mobileNumber = mobileNumber; + } + /** * Getter for mobile provider *

@@ -580,21 +766,21 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro } /** - * Getter for mobile number + * Setter for phone id *

- * @return Mobile number + * @return Phone id */ - public Long getMobileNumber () { - return this.mobileNumber; + public Long getPhoneId () { + return this.phoneId; } /** - * Setter for mobile number + * Getter for phone id *

- * @param mobileNumber Mobile number + * @param phoneId Phone id */ - public void setMobileNumber (final Long mobileNumber) { - this.mobileNumber = mobileNumber; + public void setPhoneId (final Long phoneId) { + this.phoneId = phoneId; } /** @@ -608,7 +794,7 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro 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.adminContactPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/adminContactPhone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N } catch (final NamingException e) { // Throw again throw new FaceletException(e); @@ -621,31 +807,34 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro * @return Redirect outcome */ public String unlinkFaxContactData () { + // Create fax number instance + DialableFaxNumber number = this.createFaxNumber(); + // Is all data set - if (this.beanHelper.getFaxNumber() == null) { + if (number == null) { // Not set, throw NPE - throw new NullPointerException("this.beanHelper.faxNumber is null"); //NOI18N - } else if (this.beanHelper.getFaxNumber().getPhoneId() == null) { + throw new NullPointerException("number is null"); //NOI18N + } else if (number.getPhoneId() == null) { // Throw NPE again - throw new NullPointerException("this.beanHelper.faxNumber.phoneId is null"); //NOI18N - } else if (this.beanHelper.getFaxNumber().getPhoneId() < 1) { + throw new NullPointerException("number.phoneId is null"); //NOI18N + } else if (number.getPhoneId() < 1) { // Invalid number - throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.faxNumber.phoneId={0} is not valid", this.beanHelper.getFaxNumber().getPhoneId())); //NOI18N - } else if (this.beanHelper.getFaxNumber().getPhoneNumber() == null) { + throw new IllegalArgumentException(MessageFormat.format("number.phoneId={0} is not valid", number.getPhoneId())); //NOI18N + } else if (number.getPhoneNumber() == null) { // Throw NPE again - throw new NullPointerException("this.beanHelper.faxNumber.phoneNumber is null"); //NOI18N - } else if (this.beanHelper.getFaxNumber().getPhoneNumber() < 1) { + throw new NullPointerException("number.phoneNumber is null"); //NOI18N + } else if (number.getPhoneNumber() < 1) { // Throw it again ... - throw new NullPointerException(MessageFormat.format("this.beanHelper.faxNumber.phoneNumber={0} is not valid.", this.beanHelper.getFaxNumber().getPhoneNumber())); //NOI18N - } else if (this.beanHelper.getContact() == null) { + throw new NullPointerException(MessageFormat.format("number.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N + } else if (this.getContact() == null) { // ... and throw again - throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N - } else if (this.beanHelper.getContact().getContactId() == null) { + throw new NullPointerException("this.contact is null"); //NOI18N + } else if (this.getContact().getContactId() == null) { // ... and again ... - throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N - } else if (this.beanHelper.getContact().getContactId() < 1) { + throw new NullPointerException("this.contact.contactId is null"); //NOI18N + } else if (this.getContact().getContactId() < 1) { // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("this.contact.contactId={0} is invalid.", this.getContact().getContactId())); //NOI18N } // Init contact instance @@ -653,7 +842,7 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro try { // Unlink it and return contact without fax instance - updatedContact = this.adminPhoneBean.unlinkFaxDataFromContact(this.beanHelper.getContact(), this.beanHelper.getFaxNumber()); + updatedContact = this.adminContactPhoneBean.unlinkFaxDataFromContact(this.getContact(), number); } catch (final PhoneNumberNotLinkedException ex) { // Did not work this.showFacesMessage("form_unlink_contact_fax:faxNumberId", ex); //NOI18N @@ -661,7 +850,7 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro } // Fire event - this.faxNumberUnlinkedEvent.fire(new AdminUnlinkedFaxNumberEvent(updatedContact, this.beanHelper.getFaxNumber())); + this.faxNumberUnlinkedEvent.fire(new AdminUnlinkedFaxNumberEvent(updatedContact, number)); // All fine here return "admin_show_contact"; //NOI18N @@ -673,31 +862,34 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro * @return Redirect outcome */ public String unlinkLandLineContactData () { + // Create fax number instance + DialableLandLineNumber number = this.createLandLineNumber(); + // Is all data set - if (this.beanHelper.getLandLineNumber() == null) { + if (number == null) { // Not set, throw NPE - throw new NullPointerException("this.beanHelper.landLineNumber is null"); //NOI18N - } else if (this.beanHelper.getLandLineNumber().getPhoneId() == null) { + throw new NullPointerException("number is null"); //NOI18N + } else if (number.getPhoneId() == null) { // Throw NPE again - throw new NullPointerException("this.beanHelper.landLineNumber.phoneId is null"); //NOI18N - } else if (this.beanHelper.getLandLineNumber().getPhoneId() < 1) { + throw new NullPointerException("number.phoneId is null"); //NOI18N + } else if (number.getPhoneId() < 1) { // Invalid number - throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.landLineNumber.phoneId={0} is not valid", this.beanHelper.getLandLineNumber().getPhoneId())); //NOI18N - } else if (this.beanHelper.getLandLineNumber().getPhoneNumber() == null) { + throw new IllegalArgumentException(MessageFormat.format("number.phoneId={0} is not valid", number.getPhoneId())); //NOI18N + } else if (number.getPhoneNumber() == null) { // Throw NPE again - throw new NullPointerException("this.beanHelper.landLineNumber.phoneNumber is null"); //NOI18N - } else if (this.beanHelper.getLandLineNumber().getPhoneNumber() < 1) { + throw new NullPointerException("number.phoneNumber is null"); //NOI18N + } else if (number.getPhoneNumber() < 1) { // Throw it again ... - throw new NullPointerException(MessageFormat.format("this.beanHelper.landLineNumber.phoneNumber={0} is not valid.", this.beanHelper.getLandLineNumber().getPhoneNumber())); //NOI18N - } else if (this.beanHelper.getContact() == null) { + throw new NullPointerException(MessageFormat.format("number.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N + } else if (this.getContact() == null) { // ... and throw again - throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N - } else if (this.beanHelper.getContact().getContactId() == null) { + throw new NullPointerException("this.contact is null"); //NOI18N + } else if (this.getContact().getContactId() == null) { // ... and again ... - throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N - } else if (this.beanHelper.getContact().getContactId() < 1) { + throw new NullPointerException("this.contact.contactId is null"); //NOI18N + } else if (this.getContact().getContactId() < 1) { // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("this.contact.contactId={0} is invalid.", this.getContact().getContactId())); //NOI18N } // Init contact instance @@ -705,7 +897,7 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro try { // Unlink it and return contact without landLine instance - updatedContact = this.adminPhoneBean.unlinkLandLineDataFromContact(this.beanHelper.getContact(), this.beanHelper.getLandLineNumber()); + updatedContact = this.adminContactPhoneBean.unlinkLandLineDataFromContact(this.getContact(), number); } catch (final PhoneNumberNotLinkedException ex) { // Did not work this.showFacesMessage("form_unlink_contact_landLine:landLineNumberId", ex); //NOI18N @@ -713,7 +905,7 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro } // Fire event - this.landLineNumberUnlinkedEvent.fire(new AdminUnlinkedLandLineNumberEvent(updatedContact, this.beanHelper.getLandLineNumber())); + this.landLineNumberUnlinkedEvent.fire(new AdminUnlinkedLandLineNumberEvent(updatedContact, number)); // All fine here return "admin_show_contact"; //NOI18N @@ -725,40 +917,43 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro * @return Redirect outcome */ public String unlinkMobileContactData () { + // Create fax number instance + DialableMobileNumber number = this.createMobileNumber(); + // Is all data set - if (this.beanHelper.getMobileNumber() == null) { + if (number == null) { // Not set, throw NPE - throw new NullPointerException("this.beanHelper.mobileNumber is null"); //NOI18N - } else if (this.beanHelper.getMobileNumber().getPhoneId() == null) { + throw new NullPointerException("number is null"); //NOI18N + } else if (number.getPhoneId() == null) { // Throw NPE again - throw new NullPointerException("this.beanHelper.mobileNumber.phoneId is null"); //NOI18N - } else if (this.beanHelper.getMobileNumber().getPhoneId() < 1) { + throw new NullPointerException("number.phoneId is null"); //NOI18N + } else if (number.getPhoneId() < 1) { // Invalid number - throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.mobileNumber.phoneId={0} is not valid", this.beanHelper.getMobileNumber().getPhoneId())); //NOI18N - } else if (this.beanHelper.getMobileNumber().getMobileProvider() == null) { + throw new IllegalArgumentException(MessageFormat.format("number.phoneId={0} is not valid", number.getPhoneId())); //NOI18N + } else if (number.getMobileProvider() == null) { // Throw NPE - throw new NullPointerException("this.beanHelper.mobileNumber.mobileProvider is null"); //NOI18N - } else if (this.beanHelper.getMobileNumber().getMobileProvider().getProviderId() == null) { + throw new NullPointerException("number.mobileProvider is null"); //NOI18N + } else if (number.getMobileProvider().getProviderId() == null) { // ... throw again - throw new NullPointerException("this.beanHelper.mobileNumber.mobileProvider.providerId is null"); //NOI18N - } else if (this.beanHelper.getMobileNumber().getMobileProvider().getProviderId() < 1) { + throw new NullPointerException("number.mobileProvider.providerId is null"); //NOI18N + } else if (number.getMobileProvider().getProviderId() < 1) { // Id not valid - throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.mobileNumber.mobileProvider.providerId={0} is not valid.", this.beanHelper.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N - } else if (this.beanHelper.getMobileNumber().getPhoneNumber() == null) { + throw new IllegalArgumentException(MessageFormat.format("number.mobileProvider.providerId={0} is not valid.", number.getMobileProvider().getProviderId())); //NOI18N + } else if (number.getPhoneNumber() == null) { // Throw NPE again - throw new NullPointerException("this.beanHelper.mobileNumber.phoneNumber is null"); //NOI18N - } else if (this.beanHelper.getMobileNumber().getPhoneNumber() < 1) { + throw new NullPointerException("number.phoneNumber is null"); //NOI18N + } else if (number.getPhoneNumber() < 1) { // Throw it again ... - throw new NullPointerException(MessageFormat.format("this.beanHelper.mobileNumber.phoneNumber={0} is not valid.", this.beanHelper.getMobileNumber().getPhoneNumber())); //NOI18N - } else if (this.beanHelper.getContact() == null) { + throw new NullPointerException(MessageFormat.format("number.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N + } else if (this.getContact() == null) { // ... and throw again - throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N - } else if (this.beanHelper.getContact().getContactId() == null) { + throw new NullPointerException("this.contact is null"); //NOI18N + } else if (this.getContact().getContactId() == null) { // ... and again ... - throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N - } else if (this.beanHelper.getContact().getContactId() < 1) { + throw new NullPointerException("this.contact.contactId is null"); //NOI18N + } else if (this.getContact().getContactId() < 1) { // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("this.contact.contactId={0} is invalid.", this.getContact().getContactId())); //NOI18N } // Init contact instance @@ -766,7 +961,7 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro try { // Unlink it and return contact without mobile instance - updatedContact = this.adminPhoneBean.unlinkMobileDataFromContact(this.beanHelper.getContact(), this.beanHelper.getMobileNumber()); + updatedContact = this.adminContactPhoneBean.unlinkMobileDataFromContact(this.getContact(), number); } catch (final PhoneNumberNotLinkedException ex) { // Did not work this.showFacesMessage("form_unlink_contact_mobile:mobileNumberId", ex); //NOI18N @@ -774,7 +969,7 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro } // Fire event - this.mobileNumberUnlinkedEvent.fire(new AdminUnlinkedMobileNumberEvent(updatedContact, this.beanHelper.getMobileNumber())); + this.mobileNumberUnlinkedEvent.fire(new AdminUnlinkedMobileNumberEvent(updatedContact, number)); // All fine here return "admin_show_contact"; //NOI18N @@ -788,130 +983,114 @@ public abstract class JobsAdminContactPhoneWebRequestBean extends BaseJobsContro } /** - * Returns given property key or throws an exception if not found. - *

- * @param parameterKey Property key - *

- * @return Property value + * Creates an instance of a DialableFaxNumber class *

- * @throws NullPointerException If given key is not found - * @throws NumberFormatException If no number is given in context parameter + * @return DialableFaxNumber class */ - protected int getIntegerContextParameter (final String parameterKey) throws NullPointerException, NumberFormatException { - // Get context parameter - Integer contextValue = Integer.parseInt(this.getStringContextParameter(parameterKey)); + private DialableFaxNumber createFaxNumber () { + // Instanciate it + DialableFaxNumber number = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); + + // Set all other fields + number.setPhoneEntryCreated(this.getPhoneEntryCreated()); + number.setPhoneEntryUpdated(this.getPhoneEntryUpdated()); + + // Is id number there? + if (this.getPhoneId() instanceof Long) { + // Set it + number.setPhoneId(this.getPhoneId()); + } + // Return it - return contextValue; + return number; } /** - * Returns given property key or throws an exception if not found. - *

- * @param parameterKey Property key + * Returns an instance of a DialableLandLineNumber from all fields stored in + * this bean. *

- * @return Property value - *

- * @throws NullPointerException If given key is not found + * @return An instance of a DialableLandLineNumber class */ - protected String getStringContextParameter (final String parameterKey) throws NullPointerException { - // Get context parameter - String contextValue = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(parameterKey); - // Is it null? - if (null == contextValue) { - // Throw NPE - throw new NullPointerException(MessageFormat.format("parameterKey={0} is not set.", parameterKey)); //NOI18N + private DialableLandLineNumber createLandLineNumber () { + // Initialize it + DialableLandLineNumber number = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber()); + + // Add all other data + number.setPhoneEntryCreated(this.getPhoneEntryCreated()); + number.setPhoneEntryUpdated(this.getPhoneEntryUpdated()); + + // Is id number set? + if (this.getPhoneId() instanceof Long) { + // Set it + number.setPhoneId(this.getPhoneId()); } + // Return it - return contextValue; + return number; } /** - * Checks whether debug mode is enabled for given controller - *

- * @param controllerName Name of controller + * Returns an instance of a DialableMobileNumber from all fields stored in + * this bean. *

- * @return Whether debug mode is enabled + * @return An instance of a DialableMobileNumber class */ - protected boolean isDebugModeEnabled (final String controllerName) { - // Parameters should be valid - if (null == controllerName) { - // Throw NPE - throw new NullPointerException("controllerName is null"); //NOI18N - } else if (controllerName.isEmpty()) { - // Is empty - throw new IllegalArgumentException("controllerName is empty"); //NOI18N + private DialableMobileNumber createMobileNumber () { + // Initialize it + DialableMobileNumber number = new MobileNumber(this.getMobileProvider(), this.getMobileNumber()); + + // Add all other data + number.setPhoneEntryCreated(this.getPhoneEntryCreated()); + number.setPhoneEntryUpdated(this.getPhoneEntryUpdated()); + + // Is id number set? + if (this.getPhoneId() instanceof Long) { + // Set it + number.setPhoneId(this.getPhoneId()); } - // Try to get context parameter - String contextParameter = this.getStringContextParameter(String.format("is_debug_%s_enabled", controllerName)); //NOI18N - // Is it set and true? - boolean isEnabled = Boolean.parseBoolean(contextParameter) == Boolean.TRUE; + // Return it - return isEnabled; + return number; } /** - * Loads resource bundle for given locale. This must be implemented per - * project so all projects can still customize their methods. Calling - * ResourceBundleloadBundle() in this class means that also the bundle files - * must be present here. - *

- * @param locale Locale from e.g. FacesContext + * Getter for phone entry created *

- * @return Initialized and loaded resource bundle + * @param faxNumberEntryCreated Phone entry created */ - protected abstract ResourceBundle loadResourceBundle (final Locale locale); + @SuppressWarnings ("ReturnOfDateField") + private Calendar getPhoneEntryCreated () { + return this.phoneEntryCreated; + } /** - * Shows a faces message for given causing exception. The message from the - * exception is being inserted into the message. + * Setter for phone entry created *

- * @param clientId Client id to send message to - * @param cause Causing exception + * @param phoneEntryCreated Phone entry created */ - protected void showFacesMessage (final String clientId, final Throwable cause) { - // Get context and add message - this.showFacesMessage(clientId, cause.getMessage()); + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + private void setPhoneEntryCreated (final Calendar phoneEntryCreated) { + this.phoneEntryCreated = phoneEntryCreated; } /** - * Shows a faces message with given message (i18n) key. + * Getter for phone entry updated *

- * @param clientId Client id to send message to - * @param i18nKey Message key + * @return Phone entry updated + */ + @SuppressWarnings ("ReturnOfDateField") + private Calendar getPhoneEntryUpdated () { + return this.phoneEntryUpdated; + } + + /** + * Setter for phone entry updated *

- * @throws NullPointerException If clientId or i18nKey is null - * @throws IllegalArgumentException If clientId or i18nKey is empty + * @param phoneEntryUpdated Phone entry updated */ - protected void showFacesMessage (final String clientId, final String i18nKey) throws NullPointerException, IllegalArgumentException { - // Both parameter must be valid - if (null == clientId) { - // Throw NPE - throw new NullPointerException("clientId is null"); //NOI18N - } else if (clientId.isEmpty()) { - // Is empty - throw new IllegalArgumentException("clientId is null"); //NOI18N - } else if (null == i18nKey) { - // Throw NPE - throw new NullPointerException("i18nKey is null"); //NOI18N - } else if (i18nKey.isEmpty()) { - // Is empty - throw new IllegalArgumentException("i18nKey is null"); //NOI18N - } - // Get current locale - Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); - // Get bundle bundle - ResourceBundle bundle = this.loadResourceBundle(locale); - // Default is i18nKey - String message = MessageFormat.format("!{0}!", i18nKey); //NOI18N - // Try it - try { - // Get message - message = bundle.getString(i18nKey); - } catch (final MissingResourceException ex) { - // Did not find it, ignored - } - // Get context and add message - FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message)); + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + private void setPhoneEntryUpdated (final Calendar phoneEntryUpdated) { + this.phoneEntryUpdated = phoneEntryUpdated; } } diff --git a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebSessionBean.java index 63dcc3b4..3f9650c9 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebSessionBean.java @@ -35,11 +35,14 @@ import org.mxchange.jcontacts.events.mobile.unlinked.ObservableAdminUnlinkedMobi import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jjobs.beans.contact.JobsContactWebSessionController; import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController; +import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent; +import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent; import org.mxchange.jphone.phonenumbers.DialableNumber; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent; +import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent; /** * A general contact bean (controller) @@ -74,6 +77,21 @@ public class JobsContactPhoneWebSessionBean extends BaseJobsController implement */ private final Map> contacts; + /** + * fax number + */ + private DialableFaxNumber faxNumber; + + /** + * land-line number + */ + private DialableLandLineNumber landLineNumber; + + /** + * Chosen mobile number + */ + private DialableMobileNumber mobileNumber; + /** * Default constructor */ @@ -245,6 +263,84 @@ public class JobsContactPhoneWebSessionBean extends BaseJobsController implement this.clear(); } + /** + * Observes events being fired when a bean helper has successfully created a + * fax number instance. + *

+ * @param event Event being fired + */ + public void afterCreatedFaxNumberEvent (@Observes final ObservableCreatedFaxNumberEvent event) { + // The event instance must be valid + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getFaxNumber() == null) { + // Throw NPE again + throw new NullPointerException("event.faxNumber is null"); //NOI18N + } else if (event.getFaxNumber().getPhoneId() == null) { + // Throw NPE yet again + throw new NullPointerException("event.faxNumber.phoneId is null"); //NOI18N + } else if (event.getFaxNumber().getPhoneId() < 1) { + // Throw NPE yet again + throw new NullPointerException(MessageFormat.format("event.faxNumber.phoneId={0} is invalid", event.getFaxNumber().getPhoneId())); //NOI18N + } + + // Set it here + this.setFaxNumber(event.getFaxNumber()); + } + + /** + * Observes events being fired when a bean helper has successfully created a + * land-line number instance. + *

+ * @param event Event being fired + */ + public void afterCreatedLandLineNumberEvent (@Observes final ObservableCreatedLandLineNumberEvent event) { + // The event instance must be valid + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getLandLineNumber() == null) { + // Throw NPE again + throw new NullPointerException("event.landLineNumber is null"); //NOI18N + } else if (event.getLandLineNumber().getPhoneId() == null) { + // Throw NPE yet again + throw new NullPointerException("event.landLineNumber.phoneId is null"); //NOI18N + } else if (event.getLandLineNumber().getPhoneId() < 1) { + // Throw NPE yet again + throw new NullPointerException(MessageFormat.format("event.landLineNumber.phoneId={0} is invalid", event.getLandLineNumber().getPhoneId())); //NOI18N + } + + // Set it here + this.setLandLineNumber(event.getLandLineNumber()); + } + + /** + * Observes events being fired when a bean helper has successfully created a + * mobile number instance. + *

+ * @param event Event being fired + */ + public void afterCreatedMobileNumberEvent (@Observes final ObservableCreatedMobileNumberEvent event) { + // The event instance must be valid + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getMobileNumber() == null) { + // Throw NPE again + throw new NullPointerException("event.mobileNumber is null"); //NOI18N + } else if (event.getMobileNumber().getPhoneId() == null) { + // Throw NPE yet again + throw new NullPointerException("event.mobileNumber.phoneId is null"); //NOI18N + } else if (event.getMobileNumber().getPhoneId() < 1) { + // Throw NPE yet again + throw new NullPointerException(MessageFormat.format("event.mobileNumber.phoneId={0} is invalid", event.getMobileNumber().getPhoneId())); //NOI18N + } + + // Set it here + this.setMobileNumber(event.getMobileNumber()); + } + /** * Getter for all contacts having current fax number linked *

@@ -252,12 +348,12 @@ public class JobsContactPhoneWebSessionBean extends BaseJobsController implement */ public List allCurrentFaxNumberContacts () { // Get id - DialableFaxNumber faxNumber = this.beanHelper.getFaxNumber(); + DialableFaxNumber number = this.getFaxNumber(); // Is cache there? - if (this.contacts.containsKey(faxNumber)) { + if (this.contacts.containsKey(number)) { // Return cached version - return this.contacts.get(faxNumber); + return this.contacts.get(number); } else { // Ask bean List list = new LinkedList<>(); @@ -265,14 +361,14 @@ public class JobsContactPhoneWebSessionBean extends BaseJobsController implement // "Walk" through all contacts for (final Contact contact : this.contactController.allContacts()) { // Is mobile instance the same? - if (Objects.equals(contact.getContactFaxNumber(), faxNumber)) { + if (Objects.equals(contact.getContactFaxNumber(), number)) { // Found one list.add(contact); } } // Store result in cache - this.contacts.put(faxNumber, list); + this.contacts.put(number, list); // Return now-cached list return list; @@ -286,12 +382,12 @@ public class JobsContactPhoneWebSessionBean extends BaseJobsController implement */ public List allCurrentLandLineNumberContacts () { // Get id - DialableLandLineNumber landLineNumber = this.beanHelper.getLandLineNumber(); + DialableLandLineNumber number = this.getLandLineNumber(); // Is cache there? - if (this.contacts.containsKey(landLineNumber)) { + if (this.contacts.containsKey(number)) { // Return cached version - return this.contacts.get(landLineNumber); + return this.contacts.get(number); } else { // Ask bean List list = new LinkedList<>(); @@ -299,14 +395,14 @@ public class JobsContactPhoneWebSessionBean extends BaseJobsController implement // "Walk" through all contacts for (final Contact contact : this.contactController.allContacts()) { // Is mobile instance the same? - if (Objects.equals(contact.getContactLandLineNumber(), landLineNumber)) { + if (Objects.equals(contact.getContactLandLineNumber(), number)) { // Found one list.add(contact); } } // Store result in cache - this.contacts.put(landLineNumber, list); + this.contacts.put(number, list); // Return now-cached list return list; @@ -320,12 +416,12 @@ public class JobsContactPhoneWebSessionBean extends BaseJobsController implement */ public List allCurrentMobileNumberContacts () { // Get id - DialableMobileNumber mobileNumber = this.beanHelper.getMobileNumber(); + DialableMobileNumber number = this.getMobileNumber(); // Is cache there? - if (this.contacts.containsKey(mobileNumber)) { + if (this.contacts.containsKey(number)) { // Return cached version - return this.contacts.get(mobileNumber); + return this.contacts.get(number); } else { // Ask bean List list = new LinkedList<>(); @@ -333,20 +429,74 @@ public class JobsContactPhoneWebSessionBean extends BaseJobsController implement // "Walk" through all contacts for (final Contact contact : this.contactController.allContacts()) { // Is mobile instance the same? - if (Objects.equals(contact.getContactMobileNumber(), mobileNumber)) { + if (Objects.equals(contact.getContactMobileNumber(), number)) { // Found one list.add(contact); } } // Store result in cache - this.contacts.put(mobileNumber, list); + this.contacts.put(number, list); // Return now-cached list return list; } } + /** + * Getter for chosen fax number + *

+ * @return fax number + */ + public DialableFaxNumber getFaxNumber () { + return this.faxNumber; + } + + /** + * Setter for chosen fax number + *

+ * @param faxNumber fax number + */ + public void setFaxNumber (final DialableFaxNumber faxNumber) { + this.faxNumber = faxNumber; + } + + /** + * Getter for chosen land-line number + *

+ * @return land-line number + */ + public DialableLandLineNumber getLandLineNumber () { + return this.landLineNumber; + } + + /** + * Setter for chosen land-line number + *

+ * @param landLineNumber land-line number + */ + public void setLandLineNumber (final DialableLandLineNumber landLineNumber) { + this.landLineNumber = landLineNumber; + } + + /** + * Getter for chosen mobile number + *

+ * @return mobile number + */ + public DialableMobileNumber getMobileNumber () { + return this.mobileNumber; + } + + /** + * Setter for chosen mobile number + *

+ * @param mobileNumber mobile number + */ + public void setMobileNumber (final DialableMobileNumber mobileNumber) { + this.mobileNumber = mobileNumber; + } + /** * Clears this bean */ diff --git a/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebApplicationBean.java index 8a376d3e..ceffa6bb 100644 --- a/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebApplicationBean.java @@ -18,14 +18,9 @@ package org.mxchange.jjobs.beans.country; import java.text.MessageFormat; import java.util.List; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.event.Observes; -import javax.faces.application.FacesMessage; -import javax.faces.context.FacesContext; import javax.faces.view.facelets.FaceletException; import javax.inject.Named; import javax.naming.Context; @@ -43,7 +38,7 @@ import org.mxchange.jjobs.beans.BaseJobsController; */ @Named ("countryController") @ApplicationScoped -public abstract class JobsCountryWebApplicationBean extends BaseJobsController implements JobsCountryWebApplicationController { +public class JobsCountryWebApplicationBean extends BaseJobsController implements JobsCountryWebApplicationController { /** * Serial number @@ -122,131 +117,4 @@ public abstract class JobsCountryWebApplicationBean extends BaseJobsController i this.countryList = this.countryBean.allCountries(); } - /** - * Returns given property key or throws an exception if not found. - *

- * @param parameterKey Property key - *

- * @return Property value - *

- * @throws NullPointerException If given key is not found - * @throws NumberFormatException If no number is given in context parameter - */ - protected int getIntegerContextParameter (final String parameterKey) throws NullPointerException, NumberFormatException { - // Get context parameter - Integer contextValue = Integer.parseInt(this.getStringContextParameter(parameterKey)); - // Return it - return contextValue; - } - - /** - * Returns given property key or throws an exception if not found. - *

- * @param parameterKey Property key - *

- * @return Property value - *

- * @throws NullPointerException If given key is not found - */ - protected String getStringContextParameter (final String parameterKey) throws NullPointerException { - // Get context parameter - String contextValue = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(parameterKey); - // Is it null? - if (null == contextValue) { - // Throw NPE - throw new NullPointerException(MessageFormat.format("parameterKey={0} is not set.", parameterKey)); //NOI18N - } - // Return it - return contextValue; - } - - /** - * Checks whether debug mode is enabled for given controller - *

- * @param controllerName Name of controller - *

- * @return Whether debug mode is enabled - */ - protected boolean isDebugModeEnabled (final String controllerName) { - // Parameters should be valid - if (null == controllerName) { - // Throw NPE - throw new NullPointerException("controllerName is null"); //NOI18N - } else if (controllerName.isEmpty()) { - // Is empty - throw new IllegalArgumentException("controllerName is empty"); //NOI18N - } - // Try to get context parameter - String contextParameter = this.getStringContextParameter(String.format("is_debug_%s_enabled", controllerName)); //NOI18N - // Is it set and true? - boolean isEnabled = Boolean.parseBoolean(contextParameter) == Boolean.TRUE; - // Return it - return isEnabled; - } - - /** - * Loads resource bundle for given locale. This must be implemented per - * project so all projects can still customize their methods. Calling - * ResourceBundleloadBundle() in this class means that also the bundle files - * must be present here. - *

- * @param locale Locale from e.g. FacesContext - *

- * @return Initialized and loaded resource bundle - */ - protected abstract ResourceBundle loadResourceBundle (final Locale locale); - - /** - * Shows a faces message for given causing exception. The message from the - * exception is being inserted into the message. - *

- * @param clientId Client id to send message to - * @param cause Causing exception - */ - protected void showFacesMessage (final String clientId, final Throwable cause) { - // Get context and add message - this.showFacesMessage(clientId, cause.getMessage()); - } - - /** - * Shows a faces message with given message (i18n) key. - *

- * @param clientId Client id to send message to - * @param i18nKey Message key - *

- * @throws NullPointerException If clientId or i18nKey is null - * @throws IllegalArgumentException If clientId or i18nKey is empty - */ - protected void showFacesMessage (final String clientId, final String i18nKey) throws NullPointerException, IllegalArgumentException { - // Both parameter must be valid - if (null == clientId) { - // Throw NPE - throw new NullPointerException("clientId is null"); //NOI18N - } else if (clientId.isEmpty()) { - // Is empty - throw new IllegalArgumentException("clientId is null"); //NOI18N - } else if (null == i18nKey) { - // Throw NPE - throw new NullPointerException("i18nKey is null"); //NOI18N - } else if (i18nKey.isEmpty()) { - // Is empty - throw new IllegalArgumentException("i18nKey is null"); //NOI18N - } - // Get current locale - Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); - // Get bundle bundle - ResourceBundle bundle = this.loadResourceBundle(locale); - // Default is i18nKey - String message = MessageFormat.format("!{0}!", i18nKey); //NOI18N - // Try it - try { - // Get message - message = bundle.getString(i18nKey); - } catch (final MissingResourceException ex) { - // Did not find it, ignored - } - // Get context and add message - FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message)); - } - } diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java index 52f109d5..34a8014c 100644 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java @@ -23,24 +23,24 @@ import javax.enterprise.inject.Any; import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontacts.contact.Contact; -import org.mxchange.jcontacts.events.contact.helper.created.HelperCreatedContactEvent; -import org.mxchange.jcontacts.events.contact.helper.created.ObservableHelperCreatedContactEvent; +import org.mxchange.jcontacts.events.contact.created.CreatedContactEvent; +import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent; import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jjobs.beans.contact.JobsAdminContactWebRequestController; import org.mxchange.jjobs.beans.phone.JobsAdminPhoneWebRequestController; import org.mxchange.jjobs.beans.user.JobsAdminUserWebRequestController; import org.mxchange.jjobs.beans.user.JobsUserWebSessionController; -import org.mxchange.jphone.events.helper.fax.created.HelperCreatedFaxNumberEvent; -import org.mxchange.jphone.events.helper.fax.created.ObservableHelperCreatedFaxNumberEvent; -import org.mxchange.jphone.events.helper.landline.created.HelperCreatedLandLineNumberEvent; -import org.mxchange.jphone.events.helper.landline.created.ObservableHelperCreatedLandLineNumberEvent; -import org.mxchange.jphone.events.helper.mobile.created.HelperCreatedMobileNumberEvent; -import org.mxchange.jphone.events.helper.mobile.created.ObservableHelperCreatedMobileNumberEvent; +import org.mxchange.jphone.events.fax.created.CreatedFaxNumberEvent; +import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent; +import org.mxchange.jphone.events.landline.created.CreatedLandLineNumberEvent; +import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent; +import org.mxchange.jphone.events.mobile.created.CreatedMobileNumberEvent; +import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; -import org.mxchange.jusercore.events.user.helper.created.HelperCreatedUserEvent; -import org.mxchange.jusercore.events.user.helper.created.ObservableHelperCreatedUserEvent; +import org.mxchange.jusercore.events.user.created.CreatedUserEvent; +import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent; import org.mxchange.jusercore.model.user.User; /** @@ -90,7 +90,7 @@ public class JobsWebRequestHelperBean extends BaseJobsController implements Jobs */ @Any @Inject - private Event contactCreatedEvent; + private Event contactCreatedEvent; /** * Fax number @@ -102,7 +102,7 @@ public class JobsWebRequestHelperBean extends BaseJobsController implements Jobs */ @Any @Inject - private Event faxNumberCreatedEvent; + private Event faxNumberCreatedEvent; /** * Land-line number @@ -114,7 +114,7 @@ public class JobsWebRequestHelperBean extends BaseJobsController implements Jobs */ @Any @Inject - private Event landLineNumberCreatedEvent; + private Event landLineNumberCreatedEvent; /** * Mobile number @@ -126,7 +126,7 @@ public class JobsWebRequestHelperBean extends BaseJobsController implements Jobs */ @Any @Inject - private Event mobileNumberCreatedEvent; + private Event mobileNumberCreatedEvent; /** * User instance @@ -144,7 +144,7 @@ public class JobsWebRequestHelperBean extends BaseJobsController implements Jobs */ @Any @Inject - private Event userCreatedEvent; + private Event userCreatedEvent; /** * Default constructor @@ -180,7 +180,7 @@ public class JobsWebRequestHelperBean extends BaseJobsController implements Jobs this.setPhoneInstances(this.getContact()); // Set all fields: user - this.contactCreatedEvent.fire(new HelperCreatedContactEvent(this.getContact())); + this.contactCreatedEvent.fire(new CreatedContactEvent(this.getContact())); } /** @@ -221,7 +221,7 @@ public class JobsWebRequestHelperBean extends BaseJobsController implements Jobs } // Fire event - this.faxNumberCreatedEvent.fire(new HelperCreatedFaxNumberEvent(this.getFaxNumber())); + this.faxNumberCreatedEvent.fire(new CreatedFaxNumberEvent(this.getFaxNumber())); } /** @@ -262,7 +262,7 @@ public class JobsWebRequestHelperBean extends BaseJobsController implements Jobs } // Fire event - this.landLineNumberCreatedEvent.fire(new HelperCreatedLandLineNumberEvent(this.getLandLineNumber())); + this.landLineNumberCreatedEvent.fire(new CreatedLandLineNumberEvent(this.getLandLineNumber())); } /** @@ -297,7 +297,7 @@ public class JobsWebRequestHelperBean extends BaseJobsController implements Jobs } // Fire event - this.mobileNumberCreatedEvent.fire(new HelperCreatedMobileNumberEvent(this.getMobileNumber())); + this.mobileNumberCreatedEvent.fire(new CreatedMobileNumberEvent(this.getMobileNumber())); } /** @@ -329,7 +329,7 @@ public class JobsWebRequestHelperBean extends BaseJobsController implements Jobs this.setPhoneInstances(userContact); // Fire event - this.userCreatedEvent.fire(new HelperCreatedUserEvent(this.getUser())); + this.userCreatedEvent.fire(new CreatedUserEvent(this.getUser())); } /** diff --git a/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestBean.java index 4dab41b3..2a0e9315 100644 --- a/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestBean.java @@ -16,19 +16,13 @@ */ package org.mxchange.jjobs.beans.mobileprovider; -import java.text.MessageFormat; import java.util.Iterator; import java.util.List; -import java.util.Locale; -import java.util.MissingResourceException; import java.util.Objects; -import java.util.ResourceBundle; import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Event; import javax.enterprise.inject.Any; -import javax.faces.application.FacesMessage; -import javax.faces.context.FacesContext; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; import javax.inject.Named; @@ -51,7 +45,7 @@ import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; */ @Named ("adminMobileProviderController") @RequestScoped -public abstract class JobsAdminMobileProviderWebRequestBean extends BaseJobsController implements JobsAdminMobileProviderWebRequestController { +public class JobsAdminMobileProviderWebRequestBean extends BaseJobsController implements JobsAdminMobileProviderWebRequestController { /** * Serial number @@ -267,131 +261,4 @@ public abstract class JobsAdminMobileProviderWebRequestBean extends BaseJobsCont return isFound; } - /** - * Returns given property key or throws an exception if not found. - *

- * @param parameterKey Property key - *

- * @return Property value - *

- * @throws NullPointerException If given key is not found - * @throws NumberFormatException If no number is given in context parameter - */ - protected int getIntegerContextParameter (final String parameterKey) throws NullPointerException, NumberFormatException { - // Get context parameter - Integer contextValue = Integer.parseInt(this.getStringContextParameter(parameterKey)); - // Return it - return contextValue; - } - - /** - * Returns given property key or throws an exception if not found. - *

- * @param parameterKey Property key - *

- * @return Property value - *

- * @throws NullPointerException If given key is not found - */ - protected String getStringContextParameter (final String parameterKey) throws NullPointerException { - // Get context parameter - String contextValue = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(parameterKey); - // Is it null? - if (null == contextValue) { - // Throw NPE - throw new NullPointerException(MessageFormat.format("parameterKey={0} is not set.", parameterKey)); //NOI18N - } - // Return it - return contextValue; - } - - /** - * Checks whether debug mode is enabled for given controller - *

- * @param controllerName Name of controller - *

- * @return Whether debug mode is enabled - */ - protected boolean isDebugModeEnabled (final String controllerName) { - // Parameters should be valid - if (null == controllerName) { - // Throw NPE - throw new NullPointerException("controllerName is null"); //NOI18N - } else if (controllerName.isEmpty()) { - // Is empty - throw new IllegalArgumentException("controllerName is empty"); //NOI18N - } - // Try to get context parameter - String contextParameter = this.getStringContextParameter(String.format("is_debug_%s_enabled", controllerName)); //NOI18N - // Is it set and true? - boolean isEnabled = Boolean.parseBoolean(contextParameter) == Boolean.TRUE; - // Return it - return isEnabled; - } - - /** - * Loads resource bundle for given locale. This must be implemented per - * project so all projects can still customize their methods. Calling - * ResourceBundleloadBundle() in this class means that also the bundle files - * must be present here. - *

- * @param locale Locale from e.g. FacesContext - *

- * @return Initialized and loaded resource bundle - */ - protected abstract ResourceBundle loadResourceBundle (final Locale locale); - - /** - * Shows a faces message for given causing exception. The message from the - * exception is being inserted into the message. - *

- * @param clientId Client id to send message to - * @param cause Causing exception - */ - protected void showFacesMessage (final String clientId, final Throwable cause) { - // Get context and add message - this.showFacesMessage(clientId, cause.getMessage()); - } - - /** - * Shows a faces message with given message (i18n) key. - *

- * @param clientId Client id to send message to - * @param i18nKey Message key - *

- * @throws NullPointerException If clientId or i18nKey is null - * @throws IllegalArgumentException If clientId or i18nKey is empty - */ - protected void showFacesMessage (final String clientId, final String i18nKey) throws NullPointerException, IllegalArgumentException { - // Both parameter must be valid - if (null == clientId) { - // Throw NPE - throw new NullPointerException("clientId is null"); //NOI18N - } else if (clientId.isEmpty()) { - // Is empty - throw new IllegalArgumentException("clientId is null"); //NOI18N - } else if (null == i18nKey) { - // Throw NPE - throw new NullPointerException("i18nKey is null"); //NOI18N - } else if (i18nKey.isEmpty()) { - // Is empty - throw new IllegalArgumentException("i18nKey is null"); //NOI18N - } - // Get current locale - Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); - // Get bundle bundle - ResourceBundle bundle = this.loadResourceBundle(locale); - // Default is i18nKey - String message = MessageFormat.format("!{0}!", i18nKey); //NOI18N - // Try it - try { - // Get message - message = bundle.getString(i18nKey); - } catch (final MissingResourceException ex) { - // Did not find it, ignored - } - // Get context and add message - FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message)); - } - } diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java index a8493ef5..bb1b0268 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java @@ -34,21 +34,21 @@ import javax.naming.NamingException; import org.mxchange.jcountry.data.Country; import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController; +import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent; import org.mxchange.jphone.events.fax.deleted.AdminDeletedFaxNumberEvent; import org.mxchange.jphone.events.fax.deleted.AdminFaxNumberDeletedEvent; import org.mxchange.jphone.events.fax.removed.AdminFaxNumberRemovedFromListEvent; import org.mxchange.jphone.events.fax.removed.AdminRemoveFaxNumberFromListEvent; import org.mxchange.jphone.events.fax.updated.AdminFaxNumberUpdatedEvent; import org.mxchange.jphone.events.fax.updated.AdminUpdatedFaxNumberEvent; -import org.mxchange.jphone.events.helper.fax.created.ObservableHelperCreatedFaxNumberEvent; -import org.mxchange.jphone.events.helper.landline.created.ObservableHelperCreatedLandLineNumberEvent; -import org.mxchange.jphone.events.helper.mobile.created.ObservableHelperCreatedMobileNumberEvent; +import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent; import org.mxchange.jphone.events.landline.deleted.AdminDeletedLandLineNumberEvent; import org.mxchange.jphone.events.landline.deleted.AdminLandLineNumberDeletedEvent; import org.mxchange.jphone.events.landline.removed.AdminLandLineNumberRemovedFromListEvent; import org.mxchange.jphone.events.landline.removed.AdminRemoveLandLineNumberFromListEvent; import org.mxchange.jphone.events.landline.updated.AdminLandLineNumberUpdatedEvent; import org.mxchange.jphone.events.landline.updated.AdminUpdatedLandLineNumberEvent; +import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent; import org.mxchange.jphone.events.mobile.deleted.AdminDeletedMobileNumberEvent; import org.mxchange.jphone.events.mobile.deleted.AdminMobileNumberDeletedEvent; import org.mxchange.jphone.events.mobile.remove.AdminMobileNumberRemovedFromListEvent; @@ -71,7 +71,7 @@ import org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote; */ @Named ("adminPhoneController") @RequestScoped -public abstract class JobsAdminPhoneWebRequestBean extends BaseJobsController implements JobsAdminPhoneWebRequestController { +public class JobsAdminPhoneWebRequestBean extends BaseJobsController implements JobsAdminPhoneWebRequestController { /** * Call-stack position @@ -232,7 +232,7 @@ public abstract class JobsAdminPhoneWebRequestBean extends BaseJobsController im *

* @param event Event being fired */ - public void afterHelperCreatedFaxNumberEvent (@Observes final ObservableHelperCreatedFaxNumberEvent event) { + public void afterCreatedFaxNumberEvent (@Observes final ObservableCreatedFaxNumberEvent event) { // The event instance must be valid if (null == event) { // Throw NPE @@ -266,7 +266,7 @@ public abstract class JobsAdminPhoneWebRequestBean extends BaseJobsController im *

* @param event Event being fired */ - public void afterHelperCreatedLandLineNumberEvent (@Observes final ObservableHelperCreatedLandLineNumberEvent event) { + public void afterCreatedLandLineNumberEvent (@Observes final ObservableCreatedLandLineNumberEvent event) { // The event instance must be valid if (null == event) { // Throw NPE @@ -300,7 +300,7 @@ public abstract class JobsAdminPhoneWebRequestBean extends BaseJobsController im *

* @param event Event being fired */ - public void afterHelperCreatedMobileNumberEvent (@Observes final ObservableHelperCreatedMobileNumberEvent event) { + public void afterCreatedMobileNumberEvent (@Observes final ObservableCreatedMobileNumberEvent event) { // The event instance must be valid if (null == event) { // Throw NPE diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java index a13129b3..027d49d8 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java @@ -19,15 +19,10 @@ package org.mxchange.jjobs.beans.phone; import java.text.MessageFormat; import java.util.LinkedList; import java.util.List; -import java.util.Locale; -import java.util.MissingResourceException; import java.util.Objects; -import java.util.ResourceBundle; import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.event.Observes; -import javax.faces.application.FacesMessage; -import javax.faces.context.FacesContext; import javax.faces.view.facelets.FaceletException; import javax.inject.Named; import javax.naming.Context; @@ -59,7 +54,7 @@ import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent; */ @Named ("phoneController") @ApplicationScoped -public abstract class JobsPhoneWebApplicationBean extends BaseJobsController implements JobsPhoneWebApplicationController { +public class JobsPhoneWebApplicationBean extends BaseJobsController implements JobsPhoneWebApplicationController { /** * Serial number @@ -674,131 +669,4 @@ public abstract class JobsPhoneWebApplicationBean extends BaseJobsController imp } } - /** - * Returns given property key or throws an exception if not found. - *

- * @param parameterKey Property key - *

- * @return Property value - *

- * @throws NullPointerException If given key is not found - * @throws NumberFormatException If no number is given in context parameter - */ - protected int getIntegerContextParameter (final String parameterKey) throws NullPointerException, NumberFormatException { - // Get context parameter - Integer contextValue = Integer.parseInt(this.getStringContextParameter(parameterKey)); - // Return it - return contextValue; - } - - /** - * Returns given property key or throws an exception if not found. - *

- * @param parameterKey Property key - *

- * @return Property value - *

- * @throws NullPointerException If given key is not found - */ - protected String getStringContextParameter (final String parameterKey) throws NullPointerException { - // Get context parameter - String contextValue = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(parameterKey); - // Is it null? - if (null == contextValue) { - // Throw NPE - throw new NullPointerException(MessageFormat.format("parameterKey={0} is not set.", parameterKey)); //NOI18N - } - // Return it - return contextValue; - } - - /** - * Checks whether debug mode is enabled for given controller - *

- * @param controllerName Name of controller - *

- * @return Whether debug mode is enabled - */ - protected boolean isDebugModeEnabled (final String controllerName) { - // Parameters should be valid - if (null == controllerName) { - // Throw NPE - throw new NullPointerException("controllerName is null"); //NOI18N - } else if (controllerName.isEmpty()) { - // Is empty - throw new IllegalArgumentException("controllerName is empty"); //NOI18N - } - // Try to get context parameter - String contextParameter = this.getStringContextParameter(String.format("is_debug_%s_enabled", controllerName)); //NOI18N - // Is it set and true? - boolean isEnabled = Boolean.parseBoolean(contextParameter) == Boolean.TRUE; - // Return it - return isEnabled; - } - - /** - * Loads resource bundle for given locale. This must be implemented per - * project so all projects can still customize their methods. Calling - * ResourceBundleloadBundle() in this class means that also the bundle files - * must be present here. - *

- * @param locale Locale from e.g. FacesContext - *

- * @return Initialized and loaded resource bundle - */ - protected abstract ResourceBundle loadResourceBundle (final Locale locale); - - /** - * Shows a faces message for given causing exception. The message from the - * exception is being inserted into the message. - *

- * @param clientId Client id to send message to - * @param cause Causing exception - */ - protected void showFacesMessage (final String clientId, final Throwable cause) { - // Get context and add message - this.showFacesMessage(clientId, cause.getMessage()); - } - - /** - * Shows a faces message with given message (i18n) key. - *

- * @param clientId Client id to send message to - * @param i18nKey Message key - *

- * @throws NullPointerException If clientId or i18nKey is null - * @throws IllegalArgumentException If clientId or i18nKey is empty - */ - protected void showFacesMessage (final String clientId, final String i18nKey) throws NullPointerException, IllegalArgumentException { - // Both parameter must be valid - if (null == clientId) { - // Throw NPE - throw new NullPointerException("clientId is null"); //NOI18N - } else if (clientId.isEmpty()) { - // Is empty - throw new IllegalArgumentException("clientId is null"); //NOI18N - } else if (null == i18nKey) { - // Throw NPE - throw new NullPointerException("i18nKey is null"); //NOI18N - } else if (i18nKey.isEmpty()) { - // Is empty - throw new IllegalArgumentException("i18nKey is null"); //NOI18N - } - // Get current locale - Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); - // Get bundle bundle - ResourceBundle bundle = this.loadResourceBundle(locale); - // Default is i18nKey - String message = MessageFormat.format("!{0}!", i18nKey); //NOI18N - // Try it - try { - // Get message - message = bundle.getString(i18nKey); - } catch (final MissingResourceException ex) { - // Did not find it, ignored - } - // Get context and add message - FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message)); - } - } diff --git a/src/java/org/mxchange/jjobs/beans/profilemode/JobsProfileModeWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/profilemode/JobsProfileModeWebApplicationBean.java index befcc5a1..e6b54844 100644 --- a/src/java/org/mxchange/jjobs/beans/profilemode/JobsProfileModeWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/profilemode/JobsProfileModeWebApplicationBean.java @@ -16,14 +16,8 @@ */ package org.mxchange.jjobs.beans.profilemode; -import java.text.MessageFormat; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; -import javax.faces.application.FacesMessage; -import javax.faces.context.FacesContext; import javax.inject.Named; import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; @@ -35,7 +29,7 @@ import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; */ @Named ("profileModeController") @ApplicationScoped -public abstract class JobsProfileModeWebApplicationBean extends BaseJobsController implements JobsProfileModeWebApplicationController { +public class JobsProfileModeWebApplicationBean extends BaseJobsController implements JobsProfileModeWebApplicationController { /** * Serial number @@ -63,131 +57,4 @@ public abstract class JobsProfileModeWebApplicationBean extends BaseJobsControll public void init () { } - /** - * Returns given property key or throws an exception if not found. - *

- * @param parameterKey Property key - *

- * @return Property value - *

- * @throws NullPointerException If given key is not found - * @throws NumberFormatException If no number is given in context parameter - */ - protected int getIntegerContextParameter (final String parameterKey) throws NullPointerException, NumberFormatException { - // Get context parameter - Integer contextValue = Integer.parseInt(this.getStringContextParameter(parameterKey)); - // Return it - return contextValue; - } - - /** - * Returns given property key or throws an exception if not found. - *

- * @param parameterKey Property key - *

- * @return Property value - *

- * @throws NullPointerException If given key is not found - */ - protected String getStringContextParameter (final String parameterKey) throws NullPointerException { - // Get context parameter - String contextValue = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(parameterKey); - // Is it null? - if (null == contextValue) { - // Throw NPE - throw new NullPointerException(MessageFormat.format("parameterKey={0} is not set.", parameterKey)); //NOI18N - } - // Return it - return contextValue; - } - - /** - * Checks whether debug mode is enabled for given controller - *

- * @param controllerName Name of controller - *

- * @return Whether debug mode is enabled - */ - protected boolean isDebugModeEnabled (final String controllerName) { - // Parameters should be valid - if (null == controllerName) { - // Throw NPE - throw new NullPointerException("controllerName is null"); //NOI18N - } else if (controllerName.isEmpty()) { - // Is empty - throw new IllegalArgumentException("controllerName is empty"); //NOI18N - } - // Try to get context parameter - String contextParameter = this.getStringContextParameter(String.format("is_debug_%s_enabled", controllerName)); //NOI18N - // Is it set and true? - boolean isEnabled = Boolean.parseBoolean(contextParameter) == Boolean.TRUE; - // Return it - return isEnabled; - } - - /** - * Loads resource bundle for given locale. This must be implemented per - * project so all projects can still customize their methods. Calling - * ResourceBundleloadBundle() in this class means that also the bundle files - * must be present here. - *

- * @param locale Locale from e.g. FacesContext - *

- * @return Initialized and loaded resource bundle - */ - protected abstract ResourceBundle loadResourceBundle (final Locale locale); - - /** - * Shows a faces message for given causing exception. The message from the - * exception is being inserted into the message. - *

- * @param clientId Client id to send message to - * @param cause Causing exception - */ - protected void showFacesMessage (final String clientId, final Throwable cause) { - // Get context and add message - this.showFacesMessage(clientId, cause.getMessage()); - } - - /** - * Shows a faces message with given message (i18n) key. - *

- * @param clientId Client id to send message to - * @param i18nKey Message key - *

- * @throws NullPointerException If clientId or i18nKey is null - * @throws IllegalArgumentException If clientId or i18nKey is empty - */ - protected void showFacesMessage (final String clientId, final String i18nKey) throws NullPointerException, IllegalArgumentException { - // Both parameter must be valid - if (null == clientId) { - // Throw NPE - throw new NullPointerException("clientId is null"); //NOI18N - } else if (clientId.isEmpty()) { - // Is empty - throw new IllegalArgumentException("clientId is null"); //NOI18N - } else if (null == i18nKey) { - // Throw NPE - throw new NullPointerException("i18nKey is null"); //NOI18N - } else if (i18nKey.isEmpty()) { - // Is empty - throw new IllegalArgumentException("i18nKey is null"); //NOI18N - } - // Get current locale - Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); - // Get bundle bundle - ResourceBundle bundle = this.loadResourceBundle(locale); - // Default is i18nKey - String message = MessageFormat.format("!{0}!", i18nKey); //NOI18N - // Try it - try { - // Get message - message = bundle.getString(i18nKey); - } catch (final MissingResourceException ex) { - // Did not find it, ignored - } - // Get context and add message - FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message)); - } - } diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java index b4773724..882f886d 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java @@ -39,9 +39,9 @@ import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController; import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent; +import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent; import org.mxchange.jusercore.events.user.delete.AdminDeletedUserEvent; import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent; -import org.mxchange.jusercore.events.user.helper.created.ObservableHelperCreatedUserEvent; import org.mxchange.jusercore.events.user.linked.AdminLinkedUserEvent; import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent; import org.mxchange.jusercore.events.user.locked.AdminLockedUserEvent; @@ -105,6 +105,11 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J @Inject private JobsWebRequestHelperController beanHelper; + /** + * Contact instance + */ + private Contact contact; + /** * Regular contact controller */ @@ -131,6 +136,11 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J @Any private Event updatedUserDataEvent; + /** + * User instance + */ + private User user; + /** * General user EJB */ @@ -210,9 +220,6 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J * @return Redirect outcome */ public String addUser () { - // Get contact from bean helper to "cache" it locally - Contact contact = this.beanHelper.getContact(); - // As the form cannot validate the data (required="true"), check it here if (this.getUserName() == null) { // Throw NPE @@ -220,47 +227,47 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J } else if (this.getUserName().isEmpty()) { // Is empty throw new IllegalArgumentException("userName is null"); //NOI18N - } else if (contact == null) { + } else if (this.getContact() == null) { // No contact instance set, so test required fields: gender, first name and family name this.adminContactController.validateContactData(); } // Create new user instance - User user = new LoginUser(); + User newUser = new LoginUser(); // Set user name, CONFIRMED and INVISIBLE - user.setUserName(this.getUserName()); - user.setUserMustChangePassword(this.getUserMustChangePassword()); - user.setUserAccountStatus(UserAccountStatus.CONFIRMED); - user.setUserProfileMode(ProfileMode.INVISIBLE); + newUser.setUserName(this.getUserName()); + newUser.setUserMustChangePassword(this.getUserMustChangePassword()); + newUser.setUserAccountStatus(UserAccountStatus.CONFIRMED); + newUser.setUserProfileMode(ProfileMode.INVISIBLE); // Copy user locale - user.setUserLocale(this.localizationController.getLocale()); + newUser.setUserLocale(this.localizationController.getLocale()); // Init instance Contact userContact; // Is a contact instance in helper set? - if (contact instanceof Contact) { + if (this.getContact() instanceof Contact) { // Then use it for contact linking - userContact = contact; + userContact = this.getContact(); } else { // Create contact instance userContact = this.contactController.createContactInstance(); } // Set contact in user - user.setUserContact(userContact); + newUser.setUserContact(userContact); // Init variable for password String password = null; // Is the user name or email address used already? // @TODO Add password length check - if (this.userController.isUserNameRegistered(user)) { + if (this.userController.isUserNameRegistered(newUser)) { // User name is already used - throw new FaceletException(new UserNameAlreadyRegisteredException(user)); - } else if ((contact == null) && (this.contactController.isEmailAddressRegistered(user.getUserContact()))) { + throw new FaceletException(new UserNameAlreadyRegisteredException(newUser)); + } else if ((this.getContact() == null) && (this.contactController.isEmailAddressRegistered(newUser.getUserContact()))) { // Email address is already used this.showFacesMessage("admin_add_user:emailAddress", "ERROR_EMAIL_ADDRESS_ALREADY_USED"); //NOI18N @@ -275,7 +282,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J password = UserLoginUtils.createRandomPassword(JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH); } else if (!this.isSamePasswordEntered()) { // Both passwords don't match - throw new FaceletException(new UserPasswordRepeatMismatchException(user)); + throw new FaceletException(new UserPasswordRepeatMismatchException(newUser)); } else { // Both match, so get it from this bean password = this.getUserPassword(); @@ -286,19 +293,19 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J assert (password.length() >= JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH) : "Password is not long enough."; //NOI18N // Encrypt password and set it - user.setUserEncryptedPassword(UserLoginUtils.encryptPassword(password)); + newUser.setUserEncryptedPassword(UserLoginUtils.encryptPassword(password)); try { // Now, that all is set, call EJB - if (contact instanceof Contact) { + if (this.getContact() instanceof Contact) { // Link contact with this user - User updatedUser = this.adminUserBean.linkUser(user); + User updatedUser = this.adminUserBean.linkUser(newUser); // Fire event this.userLinkedEvent.fire(new AdminLinkedUserEvent(updatedUser)); } else { // Add new contact - User updatedUser = this.adminUserBean.addUser(user); + User updatedUser = this.adminUserBean.addUser(newUser); // Fire event this.addedUserEvent.fire(new AdminAddedUserEvent(updatedUser)); @@ -309,7 +316,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J } // Clear helper - this.beanHelper.setContact(null); + this.setContact(null); // Clear this bean this.clear(); @@ -325,7 +332,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J *

* @param event User created event */ - public void afterHelperCreatedUserEvent (@Observes final ObservableHelperCreatedUserEvent event) { + public void afterCreatedUserEvent (@Observes final ObservableCreatedUserEvent event) { // Is the instance valid? if (null == event) { // Throw NPE @@ -341,12 +348,8 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J throw new NullPointerException(MessageFormat.format("event.createdUser.userId={0} is not valid", event.getCreatedUser().getUserId())); //NOI18N } - // Get user instance - User user = event.getCreatedUser(); - - // Set all fields here - this.setUserName(user.getUserName()); - this.setUserLockReason(user.getUserLastLockedReason()); + // Set whole user + this.setUser(event.getCreatedUser()); } /** @@ -384,31 +387,28 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J * @return Redirect outcome */ public String deleteUserData () { - // Get user instance into local variable - User user = this.beanHelper.getUser(); - // Is the user instance valid and CONFIRMED? - if (null == user) { + if (this.getUser() == null) { // Throw NPE throw new NullPointerException("user is null"); //NOI18N - } else if (user.getUserId() == null) { + } else if (this.getUser().getUserId() == null) { // Throw again throw new NullPointerException("user.userId is null"); //NOI18N - } else if (user.getUserId() < 1) { + } else if (this.getUser().getUserId() < 1) { // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", this.getUser().getUserId())); //NOI18N } try { // All fine, delete it - this.adminUserBean.deleteUser(user, this.getUserDeleteReason()); + this.adminUserBean.deleteUser(this.getUser(), this.getUserDeleteReason()); } catch (final UserNotFoundException ex) { // Should not happen, so throw again throw new FaceletException(ex); } // Fire event - this.deleteUserEvent.fire(new AdminDeletedUserEvent(user, this.getUserDeleteReason())); + this.deleteUserEvent.fire(new AdminDeletedUserEvent(this.getUser(), this.getUserDeleteReason())); // Redirect return "admin_list_user"; //NOI18N @@ -420,22 +420,19 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J * @return Redirect outcome */ public String editUserData () { - // Get user instance - User user = this.beanHelper.getUser(); - // Null password means not setting it String encryptedPassword = null; // Check if user instance is in helper and valid - if (null == user) { + if (this.getUser() == null) { // Throw NPE throw new NullPointerException("beanHelper.user is null"); //NOI18N - } else if (user.getUserId() == null) { + } else if (this.getUser().getUserId() == null) { // Throw NPE again throw new NullPointerException("beanHelper.user.userId is null"); //NOI18N - } else if (user.getUserId() < 1) { + } else if (this.getUser().getUserId() < 1) { // Invalid id - throw new IllegalStateException(MessageFormat.format("beanHelper.user.userId={0} is invalid", user.getUserId())); //NOI18N + throw new IllegalStateException(MessageFormat.format("beanHelper.user.userId={0} is invalid", this.getUser().getUserId())); //NOI18N } else if (this.getUserName() == null) { // Not all required fields are set throw new NullPointerException("this.userName is null"); //NOI18N @@ -450,7 +447,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J // Not same password entered this.showFacesMessage("form_edit_user:userPassword", "ADMIN_USER_PASSWORD_REPEAT_DIFFERENT"); //NOI18N return ""; //NOI18N - } else if ((!Objects.equals(user.getUserName(), this.getUserName())) && (this.userBean.ifUserNameExists(this.getUserName()))) { + } else if ((!Objects.equals(this.getUser().getUserName(), this.getUserName())) && (this.userBean.ifUserNameExists(this.getUserName()))) { // Clear all fields this.clear(); @@ -459,7 +456,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J return ""; //NOI18N } else if (this.isSamePasswordEntered()) { // Same password entered, create container - if ((Objects.equals(user.getUserMustChangePassword(), this.getUserMustChangePassword())) && (UserLoginUtils.ifPasswordMatches(new UserLoginContainer(user, this.getUserPassword())))) { + if ((Objects.equals(this.getUser().getUserMustChangePassword(), this.getUserMustChangePassword())) && (UserLoginUtils.ifPasswordMatches(new UserLoginContainer(this.getUser(), this.getUserPassword())))) { // Clear password fields this.setUserPassword(null); this.setUserPasswordRepeat(null); @@ -474,17 +471,17 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J } // Set user name and flag - user.setUserName(this.getUserName()); - user.setUserMustChangePassword(this.getUserMustChangePassword()); + this.getUser().setUserName(this.getUserName()); + this.getUser().setUserMustChangePassword(this.getUserMustChangePassword()); // Is a password set? if (encryptedPassword != null) { // Set it as well - user.setUserEncryptedPassword(encryptedPassword); + this.getUser().setUserEncryptedPassword(encryptedPassword); } // Call EJB for updating user data - User updatedUser = this.userBean.updateUserData(user); + User updatedUser = this.userBean.updateUserData(this.getUser()); // Fire event this.updatedUserDataEvent.fire(new AdminUpdatedUserDataEvent(updatedUser)); @@ -493,6 +490,42 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J return "admin_list_user"; //NOI18N } + /** + * Getter for contact instance + *

+ * @return Contact instance + */ + public Contact getContact () { + return this.contact; + } + + /** + * Setter for contact instance + *

+ * @param contact Contact instance + */ + public void setContact (final Contact contact) { + this.contact = contact; + } + + /** + * Getter for user instance + *

+ * @return User instance + */ + public User getUser () { + return this.user; + } + + /** + * Setter for user instance + *

+ * @param user User instance + */ + public void setUser (final User user) { + this.user = user; + } + /** * Getter for user delete reason *

@@ -612,8 +645,8 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J 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 + this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N + this.adminUserBean = (AdminUserSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/adminUser!org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote"); //NOI18N } catch (final NamingException e) { // Throw again throw new FaceletException(e); @@ -627,25 +660,22 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J * @return Redirect outcome */ public String lockUserAccount () { - // Get user instance - User user = this.beanHelper.getUser(); - // Is the user instance valid and CONFIRMED? - if (null == user) { + if (this.getUser() == null) { // Throw NPE - throw new NullPointerException("user is null"); //NOI18N - } else if (user.getUserId() == null) { + throw new NullPointerException("this.user is null"); //NOI18N + } else if (this.getUser().getUserId() == null) { // Throw again - throw new NullPointerException("user.userId is null"); //NOI18N - } else if (user.getUserId() < 1) { + throw new NullPointerException("this.user.userId is null"); //NOI18N + } else if (this.getUser().getUserId() < 1) { // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N - } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) { + throw new IllegalArgumentException(MessageFormat.format("this.user.userId={0} is not valid", this.getUser().getUserId())); //NOI18N + } else if (this.getUser().getUserAccountStatus() == UserAccountStatus.LOCKED) { // User account is locked - throw new FacesException(new UserStatusLockedException(user)); - } else if (user.getUserAccountStatus() == UserAccountStatus.UNCONFIRMED) { + throw new FacesException(new UserStatusLockedException(this.getUser())); + } else if (this.getUser().getUserAccountStatus() == UserAccountStatus.UNCONFIRMED) { // User account is locked - throw new FaceletException(new UserStatusUnconfirmedException(user)); + throw new FaceletException(new UserStatusUnconfirmedException(this.getUser())); } else if (this.getUserLockReason() == null) { // Throw NPE again throw new NullPointerException("this.userLockReason is null"); //NOI18N @@ -662,7 +692,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J String baseUrl = FacesUtils.generateBaseUrl(); // Call EJB to lock account - updatedUser = this.adminUserBean.lockUserAccount(user, this.getUserLockReason(), baseUrl); + updatedUser = this.adminUserBean.lockUserAccount(this.getUser(), this.getUserLockReason(), baseUrl); } catch (final UserStatusLockedException | UserStatusUnconfirmedException | UserNotFoundException ex) { // Throw again throw new FaceletException(ex); @@ -685,25 +715,22 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J * @return Redirect outcome */ public String unlockUserAccount () { - // Get user instance - User user = this.beanHelper.getUser(); - // Is the user instance valid and CONFIRMED? - if (null == user) { + if (this.getUser() == null) { // Throw NPE - throw new NullPointerException("user is null"); //NOI18N - } else if (user.getUserId() == null) { + throw new NullPointerException("this.user is null"); //NOI18N + } else if (this.getUser().getUserId() == null) { // Throw again - throw new NullPointerException("user.userId is null"); //NOI18N - } else if (user.getUserId() < 1) { + throw new NullPointerException("this.user.userId is null"); //NOI18N + } else if (this.getUser().getUserId() < 1) { // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N - } else if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) { + throw new IllegalArgumentException(MessageFormat.format("this.user.userId={0} is not valid", this.getUser().getUserId())); //NOI18N + } else if (this.getUser().getUserAccountStatus() == UserAccountStatus.CONFIRMED) { // User account is locked - throw new FacesException(new UserStatusConfirmedException(user)); - } else if (user.getUserAccountStatus() == UserAccountStatus.UNCONFIRMED) { + throw new FacesException(new UserStatusConfirmedException(this.getUser())); + } else if (this.getUser().getUserAccountStatus() == UserAccountStatus.UNCONFIRMED) { // User account is locked - throw new FaceletException(new UserStatusUnconfirmedException(user)); + throw new FaceletException(new UserStatusUnconfirmedException(this.getUser())); } // Init updated user instance @@ -714,7 +741,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J String baseUrl = FacesUtils.generateBaseUrl(); // Call EJB to unlock account - updatedUser = this.adminUserBean.unlockUserAccount(user, baseUrl); + updatedUser = this.adminUserBean.unlockUserAccount(this.getUser(), baseUrl); } catch (final UserStatusConfirmedException | UserStatusUnconfirmedException | UserNotFoundException ex) { // Throw again throw new FaceletException(ex); @@ -735,11 +762,10 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J */ private void clear () { // Clear all data - // - other data - this.setUserName(null); - this.setUserPassword(null); - this.setUserPasswordRepeat(null); + this.setContact(null); + this.setUserLockReason(null); this.setUserMustChangePassword(null); + this.setUserName(null); } /** diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java index a09df30f..36f826ca 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java @@ -41,6 +41,7 @@ import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController; import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent; import org.mxchange.jusercore.events.user.clear.password.ObservableClearUserPasswordEvent; import org.mxchange.jusercore.events.user.clear.username.ObservableClearUserNameEvent; +import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent; import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent; import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent; import org.mxchange.jusercore.events.user.locked.ObservableAdminLockedUserEvent; @@ -60,7 +61,6 @@ import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredE import org.mxchange.juserlogincore.events.user.password_change.ObservableUpdatedUserPasswordEvent; import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException; import org.mxchange.juserlogincore.login.UserLoginUtils; -import org.mxchange.jusercore.events.user.helper.created.ObservableHelperCreatedContactEvent; /** * A user controller (bean) @@ -338,7 +338,7 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs *

* @param event User created event */ - public void afterHelperCreatedUserEvent (@Observes final ObservableHelperCreatedContactEvent event) { + public void afterCreatedUserEvent (@Observes final ObservableCreatedUserEvent event) { // Is the instance valid? if (null == event) { // Throw NPE diff --git a/src/java/org/mxchange/jjobs/beans/user/activity/JobsUserActivityWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/user/activity/JobsUserActivityWebApplicationBean.java index 0adf5d0c..b4b5bec4 100644 --- a/src/java/org/mxchange/jjobs/beans/user/activity/JobsUserActivityWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/activity/JobsUserActivityWebApplicationBean.java @@ -35,6 +35,7 @@ import javax.naming.NamingException; import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController; import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent; +import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent; import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent; import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent; import org.mxchange.jusercore.events.user.locked.ObservableAdminLockedUserEvent; @@ -73,6 +74,11 @@ public class JobsUserActivityWebApplicationBean extends BaseJobsController imple @Inject private JobsWebRequestHelperController beanHelper; + /** + * User instance + */ + private User user; + /** * EJB for user activity log */ @@ -320,6 +326,33 @@ public class JobsUserActivityWebApplicationBean extends BaseJobsController imple this.addUserActivity(event.getUpdatedUser(), "ADMIN_UPDATED_USER_PERSONAL_DATA"); //NOI18N } + /** + * Event observer for when a bean helper has successfully created a user + * instance, means the user exists. If the user does not exist, this event + * should not fire but instead a proper exception must be thrown. + *

+ * @param event User created event + */ + public void afterCreatedUserEvent (@Observes final ObservableCreatedUserEvent event) { + // Is the instance valid? + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getCreatedUser() == null) { + // Throw NPE again + throw new NullPointerException("event.createdUser is null"); //NOI18N + } else if (event.getCreatedUser().getUserId() == null) { + // Throw NPE again + throw new NullPointerException("event.createdUser.userId is null"); //NOI18N + } else if (event.getCreatedUser().getUserId() < 1) { + // Throw NPE again + throw new NullPointerException(MessageFormat.format("event.createdUser.userId={0} is not valid", event.getCreatedUser().getUserId())); //NOI18N + } + + // Set whole user + this.setUser(event.getCreatedUser()); + } + /** * Event observer when user confirmed account. *

@@ -528,28 +561,25 @@ public class JobsUserActivityWebApplicationBean extends BaseJobsController imple @Override public List fetchCurrentUsersActivityLog () { - // Get user - User user = this.beanHelper.getUser(); - // beanHelper.user should be set and valid - if (null == user) { + if (this.getUser() == null) { // Is not set throw new NullPointerException("this.beanHelper.user is null"); //NOI18N - } else if (user.getUserId() == null) { + } else if (this.getUser().getUserId() == null) { // Throw NPE again throw new NullPointerException("this.beanHelper.user.userId is null"); //NOI18N - } else if (user.getUserId() < 1) { + } else if (this.getUser().getUserId() < 1) { // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.user.userId={0} is not valid", user.getUserId())); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.user.userId={0} is not valid", this.getUser().getUserId())); //NOI18N } // Init list List list = new LinkedList<>(); // Is the user set? - if (this.usersActivity.containsKey(user)) { + if (this.usersActivity.containsKey(this.getUser())) { // Return it - list.addAll(this.usersActivity.get(user)); + list.addAll(this.usersActivity.get(this.getUser())); // Sort list and reverse it Collections.sort(list, new UserActivityLogTimestampComparator()); @@ -560,6 +590,24 @@ public class JobsUserActivityWebApplicationBean extends BaseJobsController imple return list; } + /** + * Getter for user instance + *

+ * @return User instance + */ + public User getUser () { + return this.user; + } + + /** + * Setter for user instance + *

+ * @param user User instance + */ + public void setUser (final User user) { + this.user = user; + } + /** * Post-constructor method */ diff --git a/src/java/org/mxchange/jjobs/beans/user/confirmlink/JobsConfirmationLinkWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/confirmlink/JobsConfirmationLinkWebRequestBean.java index 1d8021e4..d6bac806 100644 --- a/src/java/org/mxchange/jjobs/beans/user/confirmlink/JobsConfirmationLinkWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/confirmlink/JobsConfirmationLinkWebRequestBean.java @@ -36,6 +36,8 @@ import org.mxchange.jcoreee.utils.FacesUtils; import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController; import org.mxchange.jjobs.beans.user.JobsUserWebSessionController; +import org.mxchange.jusercore.events.user.created.CreatedUserEvent; +import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent; import org.mxchange.jusercore.exceptions.UserStatusConfirmedException; import org.mxchange.jusercore.exceptions.UserStatusLockedException; import org.mxchange.jusercore.model.user.User; @@ -94,6 +96,13 @@ public class JobsConfirmationLinkWebRequestBean extends BaseJobsController imple @Inject private JobsUserWebSessionController userController; + /** + * Event for when a user instance was created + */ + @Any + @Inject + private Event userCreatedEvent; + /** * Default constructor */ @@ -250,11 +259,8 @@ public class JobsConfirmationLinkWebRequestBean extends BaseJobsController imple // Debug message System.out.println(MessageFormat.format("{0}.confirmUserAccount: updatedUser={1}", this.getClass().getSimpleName(), updatedUser)); //NOI18N - // Set it again in helper - this.beanHelper.setUser(updatedUser); - - // ... and copy it to the controller - this.beanHelper.copyUserToController(); + // Fire event + this.userCreatedEvent.fire(new CreatedUserEvent(updatedUser)); // Trace message System.out.println(MessageFormat.format("{0}.confirmUserAccount: EXIT!", this.getClass().getSimpleName())); //NOI18N diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index c782214d..a3d7f44d 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -737,8 +737,8 @@ TABLE_SUMMARY_ADMIN_LIST_USER_ACTIVITY_LOG=Diese Tabelle enth\u00e4lt die Aktivi ADMIN_LINK_SHOW_USER_ACTIVITY_LOG=Aktivit\u00e4ten des Benutzers auflisten PAGE_TITLE_ADMIN_USER_ACTIVITY_LOG=Logbuch Benutzeraktivit\u00e4ten CONTENT_TITLE_ADMIN_USER_ACTIVITY_LOG=Logbuch Benutzeraktivit\u00e4ten: -ADMIN_LIST_USER_ACTIVIRY_LOG_MESSAGE=Nachricht an Benutzer: -ADMIN_LIST_USER_ACTIVIRY_LOG_TYPE=Aktivit\u00e4t: +ADMIN_LIST_USER_ACTIVITY_LOG_MESSAGE=Nachricht an Benutzer: +ADMIN_LIST_USER_ACTIVITY_LOG_TYPE=Aktivit\u00e4t: ADMIN_LIST_USER_ACTIVITY_LOG_TIMESTAMP=Zeitmarke: ADMIN_ACTIVITY_ADMIN_LINKED_USER_ACCOUNT=Kontaktdaten mit Benutzeraccount verlinkt. USER_ACTIVITY_ADMIN_LINKED_USER_ACCOUNT=Ihr Account wurde aus bestehenden Kontaktdaten erstellt. diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index e2a4dc83..0f41a55e 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -737,8 +737,8 @@ TABLE_SUMMARY_ADMIN_LIST_USER_ACTIVITY_LOG=This table shows chosen user's activi ADMIN_LINK_SHOW_USER_ACTIVITY_LOG=List user's actitivy log PAGE_TITLE_ADMIN_USER_ACTIVITY_LOG=Logfile of user activity CONTENT_TITLE_ADMIN_USER_ACTIVITY_LOG=Logfile of user activity: -ADMIN_LIST_USER_ACTIVIRY_LOG_MESSAGE=Message to user: -ADMIN_LIST_USER_ACTIVIRY_LOG_TYPE=Activity: +ADMIN_LIST_USER_ACTIVITY_LOG_MESSAGE=Message to user: +ADMIN_LIST_USER_ACTIVITY_LOG_TYPE=Activity: ADMIN_LIST_USER_ACTIVITY_LOG_TIMESTAMP=Timestamp: ADMIN_ACTIVITY_ADMIN_LINKED_USER_ACCOUNT=Contact data linked with user account. USER_ACTIVITY_ADMIN_LINKED_USER_ACCOUNT=Your account has been created with existing contact data. diff --git a/web/admin/user/admin_user_activity_log.xhtml b/web/admin/user/admin_user_activity_log.xhtml index 686c0e7d..f935d0fe 100644 --- a/web/admin/user/admin_user_activity_log.xhtml +++ b/web/admin/user/admin_user_activity_log.xhtml @@ -83,7 +83,7 @@ - + @@ -91,7 +91,7 @@ - + -- 2.39.5