From: Roland Häder Date: Wed, 10 Jun 2020 18:21:14 +0000 (+0200) Subject: Don't cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=dee04814d8f638d9255fc313770eea783873429d;p=jjobs-war.git Don't cherry-pick: - fixed bugs of previous cherry-picking season ... Signed-off-by: Roland Häder --- diff --git a/nbproject/project.properties b/nbproject/project.properties index bdb0bd79..dab8378d 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -72,8 +72,6 @@ javac.classpath=\ ${file.reference.jcontacts-lib.jar}:\ ${file.reference.jcontacts-business-core.jar}:\ ${file.reference.jcontacts-business-lib.jar}:\ - ${file.reference.jcustomer-core.jar}:\ - ${file.reference.jcustomer-lib.jar}:\ ${file.reference.jphone-core.jar}:\ ${file.reference.jphone-lib.jar}:\ ${file.reference.juser-core.jar}:\ @@ -122,8 +120,6 @@ javadoc.reference.jcontacts-lib.jar=https://docs.mxchange.org/javadoc/jcontacts- javadoc.reference.jcoreee.jar=https://docs.mxchange.org/javadoc/jcoreee/ javadoc.reference.jcountry-core.jar=https://docs.mxchange.org/javadoc/jcountry-core/ javadoc.reference.jcountry-lib.jar=https://docs.mxchange.org/javadoc/jcountry-lib/ -javadoc.reference.jcustomer-core.jar=https://docs.mxchange.org/javadoc/jcustomer-core/ -javadoc.reference.jcustomer-lib.jar=https://docs.mxchange.org/javadoc/jcustomer-lib/ javadoc.reference.jphone-core.jar=https://docs.mxchange.org/javadoc/jphone-core/ javadoc.reference.jphone-lib.jar=https://docs.mxchange.org/javadoc/jphone-lib/ javadoc.reference.juser-activity-core.jar=https://docs.mxchange.org/javadoc/juser-activity-core/ diff --git a/nbproject/project.xml b/nbproject/project.xml index 596e47ec..46cb1053 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -27,12 +27,6 @@ ${file.reference.jcontacts-business-lib.jar} - - ${file.reference.jcustomer-core.jar} - - - ${file.reference.jcustomer-lib.jar} - ${file.reference.jphone-core.jar} @@ -49,16 +43,13 @@ ${file.reference.juser-activity-core.jar} - ${file.reference.juser-login-core.jar} - - - ${file.reference.juser-login-lib.jar} + ${file.reference.juser-activity-lib.jar} - ${file.reference.juser-activity-lib.jar} + ${file.reference.juser-login-core.jar} - ${file.reference.jcontacts-business-lib.jar} + ${file.reference.juser-login-lib.jar} ${reference.jjobs-core.jar} diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java index 248a06b6..85e5bd1b 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java @@ -105,13 +105,6 @@ public class JobsContactWebRequestBean extends BaseJobsBean implements JobsConta @Inject private Event contactUpdatedEvent; - /** - * Event being fired when a user has updated his contact data - */ - @Any - @Inject - private Event contactUpdatedEvent; - /** * Country instance */ diff --git a/src/java/org/mxchange/jjobs/beans/user/action/JobsUserActionWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/action/JobsUserActionWebRequestBean.java new file mode 100644 index 00000000..3b60d240 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/user/action/JobsUserActionWebRequestBean.java @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2016 - 2020 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.beans.user.action; + +import java.text.MessageFormat; +import javax.ejb.EJB; +import javax.enterprise.context.RequestScoped; +import javax.enterprise.event.Event; +import javax.enterprise.inject.Any; +import javax.faces.FacesException; +import javax.inject.Inject; +import javax.inject.Named; +import org.mxchange.jcontacts.model.contact.Contact; +import org.mxchange.jjobs.beans.BaseJobsBean; +import org.mxchange.jjobs.beans.contact.JobsContactWebRequestController; +import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController; +import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController; +import org.mxchange.jusercore.events.user.update.post.ObservablePostUserPersonalDataUpdatedEvent; +import org.mxchange.jusercore.events.user.update.post.PostUserPersonalDataUpdatedEvent; +import org.mxchange.jusercore.events.user.update.pre.ObservablePreUserPersonalDataUpdatedEvent; +import org.mxchange.jusercore.events.user.update.pre.PreUserPersonalDataUpdatedEvent; +import org.mxchange.jusercore.model.user.User; +import org.mxchange.jusercore.model.user.UserSessionBeanRemote; +import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException; + +/** + * A user action bean (controller) + *

+ * @author Roland Häder + */ +@Named ("userActionController") +@RequestScoped +public class JobsUserActionWebRequestBean extends BaseJobsBean implements JobsUserActionWebRequestController { + + /** + * Serial number + */ + private static final long serialVersionUID = 542_145_347_920L; + + /** + * General contact controller + */ + @Inject + private JobsContactWebRequestController contactController; + + /** + * Features controller + */ + @Inject + private JobsFeaturesWebApplicationController featureController; + + /** + * Event being fired when user updated personal data + */ + @Inject + @Any + private Event postUpdatedPersonalDataEvent; + + /** + * Event being fired when user updated personal data + */ + @Inject + @Any + private Event preUpdatedPersonalDataEvent; + + /** + * Remote user bean + */ + @EJB (lookup = "java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote") + private UserSessionBeanRemote userBean; + + /** + * Login controller (bean) + */ + @Inject + private JobsUserLoginWebSessionController userLoginController; + + /** + * Default constructor + */ + public JobsUserActionWebRequestBean () { + // Call super constructor + super(); + } + + @Override + public String doChangePersonalData () { + // This method shall only be called if the user is logged-in + if (!this.userLoginController.isUserLoggedIn()) { + // Not logged-in + throw new IllegalStateException("User is not logged-in"); //NOI18N + } else if (!this.contactController.isRequiredChangePersonalDataSet()) { + // Not all required fields are set + throw new FacesException("Not all required fields are set."); //NOI18N + } else if (!this.userLoginController.ifCurrentPasswordMatches()) { + // Password not matching + throw new FacesException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser())); + } else if (!this.featureController.isFeatureEnabled("change_user_personal_data")) { //NOI18N + // Editing is not allowed + throw new IllegalStateException("User tried to edit personal data."); //NOI18N + } + + // Get user instance + final User user = this.userLoginController.getLoggedInUser(); + + // Fire pre-update event + this.preUpdatedPersonalDataEvent.fire(new PreUserPersonalDataUpdatedEvent(user)); + + // It should be there, so run some tests on it + assert (user instanceof User) : "Instance userLoginController.loggedInUser is null"; //NOI18N + assert (user.getUserId() instanceof Long) : "Instance userLoginController.loggedInUser.userId is null"; //NOI18N + assert (user.getUserId() > 0) : MessageFormat.format("userLoginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N + assert (user.getUserContact() instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N + assert (user.getUserContact().getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N + assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N + + // Send it to the EJB + final User updatedUser = this.userBean.updateUserPersonalData(user); + + // Fire post-update event + this.postUpdatedPersonalDataEvent.fire(new PostUserPersonalDataUpdatedEvent(updatedUser)); + + // All fine + return "user_contact_data_saved"; //NOI18N + } + +} diff --git a/src/java/org/mxchange/jjobs/beans/user/action/JobssUserActionWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/action/JobssUserActionWebRequestBean.java deleted file mode 100644 index faace205..00000000 --- a/src/java/org/mxchange/jjobs/beans/user/action/JobssUserActionWebRequestBean.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) 2016 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jjobs.beans.user.action; - -import java.text.MessageFormat; -import javax.ejb.EJB; -import javax.enterprise.context.RequestScoped; -import javax.enterprise.event.Event; -import javax.enterprise.inject.Any; -import javax.faces.FacesException; -import javax.inject.Inject; -import javax.inject.Named; -import org.mxchange.jcontacts.model.contact.Contact; -import org.mxchange.jjobs.beans.BaseJobsBean; -import org.mxchange.jjobs.beans.contact.JobsContactWebRequestController; -import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController; -import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController; -import org.mxchange.jusercore.events.user.update.post.ObservablePostUserPersonalDataUpdatedEvent; -import org.mxchange.jusercore.events.user.update.post.PostUserPersonalDataUpdatedEvent; -import org.mxchange.jusercore.events.user.update.pre.ObservablePreUserPersonalDataUpdatedEvent; -import org.mxchange.jusercore.events.user.update.pre.PreUserPersonalDataUpdatedEvent; -import org.mxchange.jusercore.model.user.User; -import org.mxchange.jusercore.model.user.UserSessionBeanRemote; -import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException; - -/** - * A user action bean (controller) - *

- * @author Roland Häder - */ -@Named ("userActionController") -@RequestScoped -public class JobssUserActionWebRequestBean extends BaseJobsBean implements JobsUserActionWebRequestController { - - /** - * Serial number - */ - private static final long serialVersionUID = 542_145_347_920L; - - /** - * General contact controller - */ - @Inject - private JobsContactWebRequestController contactController; - - /** - * Features controller - */ - @Inject - private JobsFeaturesWebApplicationController featureController; - - /** - * Event being fired when user updated personal data - */ - @Inject - @Any - private Event postUpdatedPersonalDataEvent; - - /** - * Event being fired when user updated personal data - */ - @Inject - @Any - private Event preUpdatedPersonalDataEvent; - - /** - * Remote user bean - */ - @EJB (lookup = "java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote") - private UserSessionBeanRemote userBean; - - /** - * Login controller (bean) - */ - @Inject - private JobsUserLoginWebSessionController userLoginController; - - /** - * Default constructor - */ - public JobssUserActionWebRequestBean () { - // Call super constructor - super(); - } - - @Override - public String doChangePersonalData () { - // This method shall only be called if the user is logged-in - if (!this.userLoginController.isUserLoggedIn()) { - // Not logged-in - throw new IllegalStateException("User is not logged-in"); //NOI18N - } else if (!this.contactController.isRequiredChangePersonalDataSet()) { - // Not all required fields are set - throw new FacesException("Not all required fields are set."); //NOI18N - } else if (!this.userLoginController.ifCurrentPasswordMatches()) { - // Password not matching - throw new FacesException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser())); - } else if (!this.featureController.isFeatureEnabled("change_user_personal_data")) { //NOI18N - // Editing is not allowed - throw new IllegalStateException("User tried to edit personal data."); //NOI18N - } - - // Get user instance - final User user = this.userLoginController.getLoggedInUser(); - - // Fire pre-update event - this.preUpdatedPersonalDataEvent.fire(new PreUserPersonalDataUpdatedEvent(user)); - - // It should be there, so run some tests on it - assert (user instanceof User) : "Instance userLoginController.loggedInUser is null"; //NOI18N - assert (user.getUserId() instanceof Long) : "Instance userLoginController.loggedInUser.userId is null"; //NOI18N - assert (user.getUserId() > 0) : MessageFormat.format("userLoginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N - assert (user.getUserContact() instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N - assert (user.getUserContact().getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N - assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N - - // Send it to the EJB - final User updatedUser = this.userBean.updateUserPersonalData(user); - - // Fire post-update event - this.postUpdatedPersonalDataEvent.fire(new PostUserPersonalDataUpdatedEvent(updatedUser)); - - // All fine - return "user_contact_data_saved"; //NOI18N - } - -} diff --git a/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBasicCompanyDataConverter.java b/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBasicCompanyDataConverter.java index 304d9b47..09ebf9f6 100644 --- a/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBasicCompanyDataConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBasicCompanyDataConverter.java @@ -54,7 +54,7 @@ public class JobsBasicCompanyDataConverter implements Converter { // Is the instance there? if (null == BASIC_DATA_LIST_CONTROLLER) { // Get bean from CDI directly - BASIC_DATA_LIST_CONTROLLER = CDI.current().select(JobssBasicDataListWebViewBean.class).get(); + BASIC_DATA_LIST_CONTROLLER = CDI.current().select(JobsBasicDataListWebViewBean.class).get(); } try { diff --git a/src/java/org/mxchange/jjobs/converter/business/branchoffice/JobsBranchOfficeConverter.java b/src/java/org/mxchange/jjobs/converter/business/branchoffice/JobsBranchOfficeConverter.java index 6aa69961..25f56b6c 100644 --- a/src/java/org/mxchange/jjobs/converter/business/branchoffice/JobsBranchOfficeConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/branchoffice/JobsBranchOfficeConverter.java @@ -54,7 +54,7 @@ public class JobsBranchOfficeConverter implements Converter { // Is the instance there? if (null == BRANCH_OFFICE_LIST_CONTROLLER) { // Get bean from CDI directly - BRANCH_OFFICE_LIST_CONTROLLER = CDI.current().select(JobssBranchOfficeListWebViewBean.class).get(); + BRANCH_OFFICE_LIST_CONTROLLER = CDI.current().select(JobsBranchOfficeListWebViewBean.class).get(); } try { diff --git a/src/java/org/mxchange/jjobs/converter/business/company_employee/JobsEmployeeConverter.java b/src/java/org/mxchange/jjobs/converter/business/company_employee/JobsEmployeeConverter.java index 4fb4f03d..6f39ab5d 100644 --- a/src/java/org/mxchange/jjobs/converter/business/company_employee/JobsEmployeeConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/company_employee/JobsEmployeeConverter.java @@ -54,7 +54,7 @@ public class JobsEmployeeConverter implements Converter { // Is the instance there? if (null == EMPLOYEE_LIST_CONTROLLER) { // Get bean from CDI directly - EMPLOYEE_LIST_CONTROLLER = CDI.current().select(JobssEmployeeListWebViewBean.class).get(); + EMPLOYEE_LIST_CONTROLLER = CDI.current().select(JobsEmployeeListWebViewBean.class).get(); } try { diff --git a/src/java/org/mxchange/jjobs/converter/business/department/JobsDepartmentConverter.java b/src/java/org/mxchange/jjobs/converter/business/department/JobsDepartmentConverter.java index 7b72dd59..7af9ee43 100644 --- a/src/java/org/mxchange/jjobs/converter/business/department/JobsDepartmentConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/department/JobsDepartmentConverter.java @@ -54,7 +54,7 @@ public class JobsDepartmentConverter implements Converter { // Is the instance there? if (null == DEPARTMENT_LIST_CONTROLLER) { // Get bean from CDI directly - DEPARTMENT_LIST_CONTROLLER = CDI.current().select(JobssDepartmentListWebViewBean.class).get(); + DEPARTMENT_LIST_CONTROLLER = CDI.current().select(JobsDepartmentListWebViewBean.class).get(); } try { diff --git a/src/java/org/mxchange/jjobs/converter/business/headquarter/JobsHeadquarterConverter.java b/src/java/org/mxchange/jjobs/converter/business/headquarter/JobsHeadquarterConverter.java index 392ddd67..20de7a51 100644 --- a/src/java/org/mxchange/jjobs/converter/business/headquarter/JobsHeadquarterConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/headquarter/JobsHeadquarterConverter.java @@ -54,7 +54,7 @@ public class JobsHeadquarterConverter implements Converter { // Is the instance there? if (null == HEADQUARTER_LIST_CONTROLLER) { // Set it now - HEADQUARTER_LIST_CONTROLLER = CDI.current().select(JobssHeadquarterListWebViewBean.class).get(); + HEADQUARTER_LIST_CONTROLLER = CDI.current().select(JobsHeadquarterListWebViewBean.class).get(); } try { diff --git a/src/java/org/mxchange/jjobs/converter/contact/JobsContactConverter.java b/src/java/org/mxchange/jjobs/converter/contact/JobsContactConverter.java index 1dc91db5..647654a1 100644 --- a/src/java/org/mxchange/jjobs/converter/contact/JobsContactConverter.java +++ b/src/java/org/mxchange/jjobs/converter/contact/JobsContactConverter.java @@ -54,7 +54,7 @@ public class JobsContactConverter implements Converter { // Is the instance there? if (null == CONTACT_LIST_CONTROLLER) { // Get bean from CDI directly - CONTACT_LIST_CONTROLLER = CDI.current().select(JobssContactListWebViewBean.class).get(); + CONTACT_LIST_CONTROLLER = CDI.current().select(JobsContactListWebViewBean.class).get(); } try { diff --git a/src/java/org/mxchange/jjobs/converter/country/JobsCountryConverter.java b/src/java/org/mxchange/jjobs/converter/country/JobsCountryConverter.java index 283367fe..6507d87c 100644 --- a/src/java/org/mxchange/jjobs/converter/country/JobsCountryConverter.java +++ b/src/java/org/mxchange/jjobs/converter/country/JobsCountryConverter.java @@ -54,7 +54,7 @@ public class JobsCountryConverter implements Converter { // Is the instance there? if (null == COUNTRY_LIST_CONTROLLER) { // Get bean from CDI directly - COUNTRY_LIST_CONTROLLER = CDI.current().select(JobssCountryListWebViewBean.class).get(); + COUNTRY_LIST_CONTROLLER = CDI.current().select(JobsCountryListWebViewBean.class).get(); } // Try this better diff --git a/src/java/org/mxchange/jjobs/converter/fax/JobsFaxNumberConverter.java b/src/java/org/mxchange/jjobs/converter/fax/JobsFaxNumberConverter.java index c37cf3fd..a3ce26bb 100644 --- a/src/java/org/mxchange/jjobs/converter/fax/JobsFaxNumberConverter.java +++ b/src/java/org/mxchange/jjobs/converter/fax/JobsFaxNumberConverter.java @@ -54,7 +54,7 @@ public class JobsFaxNumberConverter implements Converter { // Is the instance there? if (null == PHONE_LIST_CONTROLLER) { // Get bean from CDI directly - PHONE_LIST_CONTROLLER = CDI.current().select(JobssPhoneListWebViewBean.class).get(); + PHONE_LIST_CONTROLLER = CDI.current().select(JobsPhoneListWebViewBean.class).get(); } try { diff --git a/src/java/org/mxchange/jjobs/converter/landline/JobsLandLineNumberConverter.java b/src/java/org/mxchange/jjobs/converter/landline/JobsLandLineNumberConverter.java index 8c5a5777..534a6da6 100644 --- a/src/java/org/mxchange/jjobs/converter/landline/JobsLandLineNumberConverter.java +++ b/src/java/org/mxchange/jjobs/converter/landline/JobsLandLineNumberConverter.java @@ -54,7 +54,7 @@ public class JobsLandLineNumberConverter implements Converter { // Is the instance there? if (null == MOBILE_PROVIDER_LIST_CONTROLLER) { // Get bean from CDI directly - MOBILE_PROVIDER_LIST_CONTROLLER = CDI.current().select(JobssMobileProviderListWebViewBean.class).get(); + MOBILE_PROVIDER_LIST_CONTROLLER = CDI.current().select(JobsMobileProviderListWebViewBean.class).get(); } // Try this better diff --git a/src/java/org/mxchange/jjobs/converter/user/JobsUserConverter.java b/src/java/org/mxchange/jjobs/converter/user/JobsUserConverter.java index c1589801..b55a40d0 100644 --- a/src/java/org/mxchange/jjobs/converter/user/JobsUserConverter.java +++ b/src/java/org/mxchange/jjobs/converter/user/JobsUserConverter.java @@ -57,7 +57,7 @@ public class JobsUserConverter implements Converter { // Is the instance there? if (null == USER_LIST_CONTROLLER) { // Get bean from CDI directly - USER_LIST_CONTROLLER = CDI.current().select(JobssUserListWebViewBean.class).get(); + USER_LIST_CONTROLLER = CDI.current().select(JobsUserListWebViewBean.class).get(); } try {