From: Roland Häder Date: Tue, 20 Mar 2018 23:49:37 +0000 (+0100) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1cc9e668ddaf54c50eb896e7aabde28319edafbd;p=jjobs-war.git Please cherry-pick: - added ServletContextListener implementation for (later) pre-initialize JS107 cache before any page is served - added validators for basic company data, headquarter data and branch office's email addresses - rewrote converters which have allowEmptyValue flag to handle it correctly (need that validators.jsf.taglib.xml for this to work) - renamed company name validator as this is for basic company data ... ;-) - updated/changed copyright year to Free Software Foundation Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java b/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java index 4f41c2b4..a35c4594 100644 --- a/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 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 6d72217f..9f216c71 100644 --- a/src/java/org/mxchange/jjobs/converter/business/branchoffice/JobsBranchOfficeConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/branchoffice/JobsBranchOfficeConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 diff --git a/src/java/org/mxchange/jjobs/converter/business/department/JobsCompanyDepartmentConverter.java b/src/java/org/mxchange/jjobs/converter/business/department/JobsCompanyDepartmentConverter.java index b480e600..60bc536b 100644 --- a/src/java/org/mxchange/jjobs/converter/business/department/JobsCompanyDepartmentConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/department/JobsCompanyDepartmentConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 diff --git a/src/java/org/mxchange/jjobs/converter/business/employee/JobsEmployeeConverter.java b/src/java/org/mxchange/jjobs/converter/business/employee/JobsEmployeeConverter.java index 646af467..5df4a7ba 100644 --- a/src/java/org/mxchange/jjobs/converter/business/employee/JobsEmployeeConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/employee/JobsEmployeeConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 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 0ee2ea4c..0f35d756 100644 --- a/src/java/org/mxchange/jjobs/converter/business/headquarter/JobsHeadquarterConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/headquarter/JobsHeadquarterConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 diff --git a/src/java/org/mxchange/jjobs/converter/business/opening_time/JobsCompanyOpeningTimeConverter.java b/src/java/org/mxchange/jjobs/converter/business/opening_time/JobsCompanyOpeningTimeConverter.java index 1d88fc83..dc9c6c0a 100644 --- a/src/java/org/mxchange/jjobs/converter/business/opening_time/JobsCompanyOpeningTimeConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/opening_time/JobsCompanyOpeningTimeConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 diff --git a/src/java/org/mxchange/jjobs/converter/contact/JobsContactConverter.java b/src/java/org/mxchange/jjobs/converter/contact/JobsContactConverter.java index b57562bf..562d623b 100644 --- a/src/java/org/mxchange/jjobs/converter/contact/JobsContactConverter.java +++ b/src/java/org/mxchange/jjobs/converter/contact/JobsContactConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 diff --git a/src/java/org/mxchange/jjobs/converter/country/JobsCountryConverter.java b/src/java/org/mxchange/jjobs/converter/country/JobsCountryConverter.java index bf0f5461..fd5d83ae 100644 --- a/src/java/org/mxchange/jjobs/converter/country/JobsCountryConverter.java +++ b/src/java/org/mxchange/jjobs/converter/country/JobsCountryConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 diff --git a/src/java/org/mxchange/jjobs/converter/dayofweek/JobsDayOfTheWeekConverter.java b/src/java/org/mxchange/jjobs/converter/dayofweek/JobsDayOfTheWeekConverter.java index 7a85b105..eedf3b6a 100644 --- a/src/java/org/mxchange/jjobs/converter/dayofweek/JobsDayOfTheWeekConverter.java +++ b/src/java/org/mxchange/jjobs/converter/dayofweek/JobsDayOfTheWeekConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Roland Häder + * Copyright (C) 2017, 2018 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 @@ -33,6 +33,7 @@ public class JobsDayOfTheWeekConverter extends EnumConverter { * enumeration as class type. */ public JobsDayOfTheWeekConverter () { + // Call other constructor with class type super(DayOfTheWeek.class); } diff --git a/src/java/org/mxchange/jjobs/converter/fax/JobsFaxNumberConverter.java b/src/java/org/mxchange/jjobs/converter/fax/JobsFaxNumberConverter.java index c97b4542..23090a38 100644 --- a/src/java/org/mxchange/jjobs/converter/fax/JobsFaxNumberConverter.java +++ b/src/java/org/mxchange/jjobs/converter/fax/JobsFaxNumberConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2017, 2018 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 diff --git a/src/java/org/mxchange/jjobs/converter/landline/JobsLandLineNumberConverter.java b/src/java/org/mxchange/jjobs/converter/landline/JobsLandLineNumberConverter.java index c18992f4..6f90c040 100644 --- a/src/java/org/mxchange/jjobs/converter/landline/JobsLandLineNumberConverter.java +++ b/src/java/org/mxchange/jjobs/converter/landline/JobsLandLineNumberConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2017, 2018 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 diff --git a/src/java/org/mxchange/jjobs/converter/mobile/JobsMobileNumberConverter.java b/src/java/org/mxchange/jjobs/converter/mobile/JobsMobileNumberConverter.java index b35e80d4..d68cc0a4 100644 --- a/src/java/org/mxchange/jjobs/converter/mobile/JobsMobileNumberConverter.java +++ b/src/java/org/mxchange/jjobs/converter/mobile/JobsMobileNumberConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 diff --git a/src/java/org/mxchange/jjobs/converter/mobileprovider/JobsMobileProviderConverter.java b/src/java/org/mxchange/jjobs/converter/mobileprovider/JobsMobileProviderConverter.java index 8f60aecb..d0248e45 100644 --- a/src/java/org/mxchange/jjobs/converter/mobileprovider/JobsMobileProviderConverter.java +++ b/src/java/org/mxchange/jjobs/converter/mobileprovider/JobsMobileProviderConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 diff --git a/src/java/org/mxchange/jjobs/converter/personal_title/JobsPersonalTitleConverter.java b/src/java/org/mxchange/jjobs/converter/personal_title/JobsPersonalTitleConverter.java index 00cdc695..4447884f 100644 --- a/src/java/org/mxchange/jjobs/converter/personal_title/JobsPersonalTitleConverter.java +++ b/src/java/org/mxchange/jjobs/converter/personal_title/JobsPersonalTitleConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Roland Häder + * Copyright (C) 2017, 2018 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 diff --git a/src/java/org/mxchange/jjobs/converter/profile_mode/JobsProfileModeConverter.java b/src/java/org/mxchange/jjobs/converter/profile_mode/JobsProfileModeConverter.java index 3e9d4150..11e6cbf5 100644 --- a/src/java/org/mxchange/jjobs/converter/profile_mode/JobsProfileModeConverter.java +++ b/src/java/org/mxchange/jjobs/converter/profile_mode/JobsProfileModeConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Roland Häder + * Copyright (C) 2017, 2018 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 diff --git a/src/java/org/mxchange/jjobs/converter/user/JobsUserConverter.java b/src/java/org/mxchange/jjobs/converter/user/JobsUserConverter.java index 579faef2..97c06c48 100644 --- a/src/java/org/mxchange/jjobs/converter/user/JobsUserConverter.java +++ b/src/java/org/mxchange/jjobs/converter/user/JobsUserConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 diff --git a/src/java/org/mxchange/jjobs/converter/user_account_status/JobsUserAccountStatusConverter.java b/src/java/org/mxchange/jjobs/converter/user_account_status/JobsUserAccountStatusConverter.java index 371aa53b..0dc94896 100644 --- a/src/java/org/mxchange/jjobs/converter/user_account_status/JobsUserAccountStatusConverter.java +++ b/src/java/org/mxchange/jjobs/converter/user_account_status/JobsUserAccountStatusConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Roland Häder + * Copyright (C) 2017, 2018 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 diff --git a/src/java/org/mxchange/jjobs/listener/JobsWebApplicationListener.java b/src/java/org/mxchange/jjobs/listener/JobsWebApplicationListener.java new file mode 100644 index 00000000..fc866ea4 --- /dev/null +++ b/src/java/org/mxchange/jjobs/listener/JobsWebApplicationListener.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2017, 2018 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.listener; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.annotation.WebListener; +import org.mxchange.jcoreee.bean.faces.BaseFacesBean; + +/** + * A web-application listener for de-/initialization stuff + *

+ * @author Roland Haeder + */ +@WebListener +public class JobsWebApplicationListener implements ServletContextListener { + + @Override + public void contextDestroyed (final ServletContextEvent sce) { + // Remove all bundles + BaseFacesBean.removeBundles(); + } + + @Override + public void contextInitialized (final ServletContextEvent sce) { + } + +} diff --git a/src/java/org/mxchange/jjobs/validator/birthday/JobsBirthdayValidator.java b/src/java/org/mxchange/jjobs/validator/birthday/JobsBirthdayValidator.java index d50c1ddd..bb5fd332 100644 --- a/src/java/org/mxchange/jjobs/validator/birthday/JobsBirthdayValidator.java +++ b/src/java/org/mxchange/jjobs/validator/birthday/JobsBirthdayValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 Free Software Foundation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/java/org/mxchange/jjobs/validator/business/basicdata/JobsBasicDataCompanyNameValidator.java b/src/java/org/mxchange/jjobs/validator/business/basicdata/JobsBasicDataCompanyNameValidator.java new file mode 100644 index 00000000..c4c7ced7 --- /dev/null +++ b/src/java/org/mxchange/jjobs/validator/business/basicdata/JobsBasicDataCompanyNameValidator.java @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2017, 2018 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.validator.business.basicdata; + +import java.text.MessageFormat; +import javax.enterprise.inject.spi.CDI; +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.FacesValidator; +import javax.faces.validator.ValidatorException; +import org.mxchange.jcoreee.validator.string.BaseStringValidator; +import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestBean; +import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestController; + +/** + * A validator for basic data company names + *

+ * @author Roland Häder + */ +@FacesValidator (value = "BasicDataCompanyNameValidator") +public class JobsBasicDataCompanyNameValidator extends BaseStringValidator { + + /** + * Business basic data backing bean + */ + private static JobsBasicDataWebRequestController BASIC_DATA_CONTROLLER; + + /** + * Serial number + */ + private static final long serialVersionUID = 57_283_657_476_561L; + + @Override + public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { + // Is the instance there? + if (null == BASIC_DATA_CONTROLLER) { + // Get bean from CDI directly + BASIC_DATA_CONTROLLER = CDI.current().select(JobsBasicDataWebRequestBean.class).get(); + } + + // All accepted, required fields + final String[] requiredFields = {"companyName"}; //NOI18N + + // Pre-validation (example: not null, not a string, empty string ...) + super.preValidate(context, component, value, requiredFields, false); + + // Convert name to string (now securely checked in BaseStringValidator) + final String companyName = (String) value; + + // Default is to check on existing names + Boolean checkExisting = Boolean.TRUE; + + // Is attribute "allowEmptyRequiredData" set? + if (component.getAttributes().containsKey("checkExisting")) { //NOI18N + // Get attribute + final Object attribute = component.getAttributes().get("checkExisting"); //NOI18N + + // Make sure, it is Boolean as no String is accepted anymore + if (!(attribute instanceof String)) { + // Not valid attribute, please use "true" or "false" (default) + throw new IllegalArgumentException("checkExisting must be of type String. Please use \"true\" or \"false\" for f:attribute value."); //NOI18N + } + + // Securely cast it + checkExisting = Boolean.parseBoolean((String) attribute); + } + + // Check if name is already used + final Boolean nameExists = BASIC_DATA_CONTROLLER.isCompanyNameUsed(companyName); + + // Is the user id valid? + if ((!nameExists) && (checkExisting)) { + // Format message + final String message = MessageFormat.format("No basic data found with comany name {0}.", companyName); + + // Name does not exist + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_WARN, message, message)); //NOI18N + } else if ((nameExists) && (!checkExisting)) { + // Format message + final String message = MessageFormat.format("Found basic data with comany name {0}.", companyName); + + // Name already exists + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_WARN, message, message)); //NOI18N + } + } + +} diff --git a/src/java/org/mxchange/jjobs/validator/business/basicdata/JobsCompanyNameValidator.java b/src/java/org/mxchange/jjobs/validator/business/basicdata/JobsCompanyNameValidator.java deleted file mode 100644 index 3cc67c6f..00000000 --- a/src/java/org/mxchange/jjobs/validator/business/basicdata/JobsCompanyNameValidator.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jjobs.validator.business.basicdata; - -import java.text.MessageFormat; -import javax.enterprise.inject.spi.CDI; -import javax.faces.application.FacesMessage; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.validator.FacesValidator; -import javax.faces.validator.ValidatorException; -import org.mxchange.jcoreee.validator.string.BaseStringValidator; -import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestBean; -import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestController; - -/** - * A validator for company names - *

- * @author Roland Häder - */ -@FacesValidator ("CompanyNameValidator") -public class JobsCompanyNameValidator extends BaseStringValidator { - - /** - * Business basic data backing bean - */ - private static JobsBasicDataWebRequestController BASIC_DATA_CONTROLLER; - - /** - * Serial number - */ - private static final long serialVersionUID = 57_283_657_476_561L; - - @Override - public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { - // Is the instance there? - if (null == BASIC_DATA_CONTROLLER) { - // Get bean from CDI directly - BASIC_DATA_CONTROLLER = CDI.current().select(JobsBasicDataWebRequestBean.class).get(); - } - - // All accepted, required fields - final String[] requiredFields = {"companyName"}; //NOI18N - - // Pre-validation (example: not null, not a string, empty string ...) - super.preValidate(context, component, value, requiredFields, false); - - // Convert name to string (now securely checked in BaseStringValidator) - final String companyName = (String) value; - - // Default is to check on existing names - Boolean checkExisting = Boolean.TRUE; - - // Is attribute "allowEmptyValue" set? - if (component.getAttributes().containsKey("checkExisting")) { //NOI18N - // Get attribute - final Object attribute = component.getAttributes().get("checkExisting"); //NOI18N - - // Make sure, it is Boolean as no String is accepted anymore - if (!(attribute instanceof String)) { - // Not valid attribute, please use "true" or "false" (default) - throw new IllegalArgumentException("checkExisting must be of type String. Please use \"true\" or \"false\" for f:attribute value."); //NOI18N - } - - // Securely cast it - checkExisting = Boolean.parseBoolean((String) attribute); - } - - // Check if name is already used - final Boolean nameExists = BASIC_DATA_CONTROLLER.isCompanyNameUsed(companyName); - - // Is the user id valid? - if ((!nameExists) && (checkExisting)) { - // Format message - final String message = MessageFormat.format("No basic data found with comany name {0}.", companyName); - - // Name does not exist - throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_WARN, message, message)); //NOI18N - } else if ((nameExists) && (!checkExisting)) { - // Format message - final String message = MessageFormat.format("Found basic data with comany name {0}.", companyName); - - // Name already exists - throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_WARN, message, message)); //NOI18N - } - } - -} diff --git a/src/java/org/mxchange/jjobs/validator/business/headquarter/JobsHeadquarterCompanyNameValidator.java b/src/java/org/mxchange/jjobs/validator/business/headquarter/JobsHeadquarterCompanyNameValidator.java new file mode 100644 index 00000000..eafd8920 --- /dev/null +++ b/src/java/org/mxchange/jjobs/validator/business/headquarter/JobsHeadquarterCompanyNameValidator.java @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2017, 2018 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.validator.business.headquarter; + +import java.text.MessageFormat; +import javax.enterprise.inject.spi.CDI; +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.FacesValidator; +import javax.faces.validator.ValidatorException; +import org.mxchange.jcoreee.validator.string.BaseStringValidator; +import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestBean; +import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestController; + +/** + * A validator for headquarter company names + *

+ * @author Roland Häder + */ +@FacesValidator (value = "HeadquarterCompanyNameValidator") +public class JobsHeadquarterCompanyNameValidator extends BaseStringValidator { + + /** + * Headquarter backing bean + */ + private static JobsHeadquarterWebRequestController HEADQUARTER_CONTROLLER; + + /** + * Serial number + */ + private static final long serialVersionUID = 57_283_657_476_561L; + + @Override + public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { + // Is the instance there? + if (null == HEADQUARTER_CONTROLLER) { + // Get bean from CDI directly + HEADQUARTER_CONTROLLER = CDI.current().select(JobsHeadquarterWebRequestBean.class).get(); + } + + // All accepted, required fields + final String[] requiredFields = {"companyName"}; //NOI18N + + // Pre-validation (example: not null, not a string, empty string ...) + super.preValidate(context, component, value, requiredFields, false); + + // Convert name to string (now securely checked in BaseStringValidator) + final String companyName = (String) value; + + // Default is to check on existing names + Boolean checkExisting = Boolean.TRUE; + + // Is attribute "allowEmptyRequiredData" set? + if (component.getAttributes().containsKey("checkExisting")) { //NOI18N + // Get attribute + final Object attribute = component.getAttributes().get("checkExisting"); //NOI18N + + // Make sure, it is Boolean as no String is accepted anymore + if (!(attribute instanceof String)) { + // Not valid attribute, please use "true" or "false" (default) + throw new IllegalArgumentException("checkExisting must be of type String. Please use \"true\" or \"false\" for f:attribute value."); //NOI18N + } + + // Securely cast it + checkExisting = Boolean.parseBoolean((String) attribute); + } + + // Check if name is already used + final Boolean nameExists = HEADQUARTER_CONTROLLER.isCompanyNameUsed(companyName); + + // Is the user id valid? + if ((!nameExists) && (checkExisting)) { + // Format message + final String message = MessageFormat.format("No basic data found with comany name {0}.", companyName); + + // Name does not exist + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_WARN, message, message)); //NOI18N + } else if ((nameExists) && (!checkExisting)) { + // Format message + final String message = MessageFormat.format("Found basic data with comany name {0}.", companyName); + + // Name already exists + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_WARN, message, message)); //NOI18N + } + } + +} diff --git a/src/java/org/mxchange/jjobs/validator/emailaddress/JobsEmailAddressValidator.java b/src/java/org/mxchange/jjobs/validator/emailaddress/JobsEmailAddressValidator.java index 24d96d79..9ca91373 100644 --- a/src/java/org/mxchange/jjobs/validator/emailaddress/JobsEmailAddressValidator.java +++ b/src/java/org/mxchange/jjobs/validator/emailaddress/JobsEmailAddressValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 @@ -56,34 +56,37 @@ public class JobsEmailAddressValidator extends BaseStringValidator { */ private static final long serialVersionUID = 187_536_745_607_192L; + /** + * Whether empty data is allowed + */ + private Boolean allowEmptyRequiredData; + + /** + * Default constructor + */ + public JobsEmailAddressValidator () { + this.allowEmptyRequiredData = Boolean.FALSE; + } + + /** + * Setter for allowEmptyRequiredData flag + *

+ * @param allowEmptyRequiredData Whether empty values are allowed + */ + public void setAllowEmptyRequiredData (final Boolean allowEmptyRequiredData) { + this.allowEmptyRequiredData = allowEmptyRequiredData; + } + @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { // The required field final String[] requiredFields = {"emailAddress", "emailAddressRepeat", "resendEmailAddress"}; //NOI18N - // Default is to reject empty email address fields - Boolean allowEmptyValue = Boolean.FALSE; - - // Is attribute "allowEmptyValue" set? - if (component.getAttributes().containsKey("allowEmptyValue")) { //NOI18N - // Get attribute - final Object attribute = component.getAttributes().get("allowEmptyValue"); //NOI18N - - // Make sure, it is Boolean as no String is accepted anymore - if (!(attribute instanceof String)) { - // Not valid attribute, please use "true" or "false" (default) - throw new IllegalArgumentException("allowEmptyValue must be of type String. Please use \"true\" or \"false\" for f:attribute value."); //NOI18N - } - - // Securely cast it - allowEmptyValue = Boolean.parseBoolean((String) attribute); - } - // Pre-validation (example: not null, not a string, empty string ...) - super.preValidate(context, component, value, requiredFields, allowEmptyValue); + super.preValidate(context, component, value, requiredFields, this.allowEmptyRequiredData); // Is the email address empty and allowed? - if (null == value && allowEmptyValue) { + if (null == value && this.allowEmptyRequiredData) { // Then accept this here return; } else if (null == value) { diff --git a/src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java b/src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java index 3a6b076f..f2ccf3d4 100644 --- a/src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java +++ b/src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 @@ -56,34 +56,37 @@ public class JobsBasicDataEmailAddressValidator extends BaseStringValidator { */ private static final long serialVersionUID = 187_536_745_607_195L; + /** + * Whether empty data is allowed + */ + private Boolean allowEmptyRequiredData; + + /** + * Default constructor + */ + public JobsBasicDataEmailAddressValidator () { + this.allowEmptyRequiredData = Boolean.FALSE; + } + + /** + * Setter for allowEmptyRequiredData flag + *

+ * @param allowEmptyRequiredData Whether empty values are allowed + */ + public void setAllowEmptyRequiredData (final Boolean allowEmptyRequiredData) { + this.allowEmptyRequiredData = allowEmptyRequiredData; + } + @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { // The required field final String[] requiredFields = {"emailAddress", "emailAddressRepeat", "resendEmailAddress"}; //NOI18N - // Default is to reject empty email address fields - Boolean allowEmptyValue = Boolean.FALSE; - - // Is attribute "allowEmptyValue" set? - if (component.getAttributes().containsKey("allowEmptyValue")) { //NOI18N - // Get attribute - final Object attribute = component.getAttributes().get("allowEmptyValue"); //NOI18N - - // Make sure, it is Boolean as no String is accepted anymore - if (!(attribute instanceof String)) { - // Not valid attribute, please use "true" or "false" (default) - throw new IllegalArgumentException("allowEmptyValue must be of type String. Please use \"true\" or \"false\" for f:attribute value."); //NOI18N - } - - // Securely cast it - allowEmptyValue = Boolean.parseBoolean((String) attribute); - } - // Pre-validation (example: not null, not a string, empty string ...) - super.preValidate(context, component, value, requiredFields, allowEmptyValue); + super.preValidate(context, component, value, requiredFields, this.allowEmptyRequiredData); // Is the email address empty and allowed? - if (null == value && allowEmptyValue) { + if (null == value && this.allowEmptyRequiredData) { // Then accept this here return; } else if (null == value) { diff --git a/src/java/org/mxchange/jjobs/validator/emailaddress/branchoffice/JobsBranchOfficeEmailAddressValidator.java b/src/java/org/mxchange/jjobs/validator/emailaddress/branchoffice/JobsBranchOfficeEmailAddressValidator.java index acc93b90..9f70ba0a 100644 --- a/src/java/org/mxchange/jjobs/validator/emailaddress/branchoffice/JobsBranchOfficeEmailAddressValidator.java +++ b/src/java/org/mxchange/jjobs/validator/emailaddress/branchoffice/JobsBranchOfficeEmailAddressValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 @@ -56,34 +56,37 @@ public class JobsBranchOfficeEmailAddressValidator extends BaseStringValidator { */ private static final long serialVersionUID = 187_536_745_607_195L; + /** + * Whether empty data is allowed + */ + private Boolean allowEmptyRequiredData; + + /** + * Default constructor + */ + public JobsBranchOfficeEmailAddressValidator () { + this.allowEmptyRequiredData = Boolean.FALSE; + } + + /** + * Setter for allowEmptyRequiredData flag + *

+ * @param allowEmptyRequiredData Whether empty values are allowed + */ + public void setAllowEmptyRequiredData (final Boolean allowEmptyRequiredData) { + this.allowEmptyRequiredData = allowEmptyRequiredData; + } + @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { // The required field final String[] requiredFields = {"emailAddress", "emailAddressRepeat", "resendEmailAddress"}; //NOI18N - // Default is to reject empty email address fields - Boolean allowEmptyValue = Boolean.FALSE; - - // Is attribute "allowEmptyValue" set? - if (component.getAttributes().containsKey("allowEmptyValue")) { //NOI18N - // Get attribute - final Object attribute = component.getAttributes().get("allowEmptyValue"); //NOI18N - - // Make sure, it is Boolean as no String is accepted anymore - if (!(attribute instanceof String)) { - // Not valid attribute, please use "true" or "false" (default) - throw new IllegalArgumentException("allowEmptyValue must be of type String. Please use \"true\" or \"false\" for f:attribute value."); //NOI18N - } - - // Securely cast it - allowEmptyValue = Boolean.parseBoolean((String) attribute); - } - // Pre-validation (example: not null, not a string, empty string ...) - super.preValidate(context, component, value, requiredFields, allowEmptyValue); + super.preValidate(context, component, value, requiredFields, this.allowEmptyRequiredData); // Is the email address empty and allowed? - if (null == value && allowEmptyValue) { + if (null == value && this.allowEmptyRequiredData) { // Then accept this here return; } else if (null == value) { diff --git a/src/java/org/mxchange/jjobs/validator/emailaddress/employee/JobsEmployeeEmailAddressValidator.java b/src/java/org/mxchange/jjobs/validator/emailaddress/employee/JobsEmployeeEmailAddressValidator.java new file mode 100644 index 00000000..15aabfd0 --- /dev/null +++ b/src/java/org/mxchange/jjobs/validator/emailaddress/employee/JobsEmployeeEmailAddressValidator.java @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2016 - 2018 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.validator.emailaddress.employee; + +import java.text.MessageFormat; +import java.util.regex.Pattern; +import javax.enterprise.inject.spi.CDI; +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.FacesValidator; +import javax.faces.validator.ValidatorException; +import org.mxchange.jcoreee.validator.string.BaseStringValidator; +import org.mxchange.jjobs.beans.business.employee.JobsEmployeeWebRequestBean; +import org.mxchange.jjobs.beans.business.employee.JobsEmployeeWebRequestController; + +/** + * A validator for employee email address validation + *

+ * @author Roland Häder + */ +@FacesValidator (value = "EmployeeEmailAddressValidator") +public class JobsEmployeeEmailAddressValidator extends BaseStringValidator { + + /** + * Email pattern + */ + private static final String EMAIL_REGEX = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"; //NOI18N + + /** + * Employee backing bean + */ + private static JobsEmployeeWebRequestController EMPLOYEE_CONTROLLER; + + /** + * Pattern matcher + */ + private static final Pattern PATTERN_MATCHER = Pattern.compile(JobsEmployeeEmailAddressValidator.EMAIL_REGEX); + + /** + * Serial number + */ + private static final long serialVersionUID = 187_536_745_607_196L; + + /** + * Whether empty data is allowed + */ + private Boolean allowEmptyRequiredData; + + /** + * Default constructor + */ + public JobsEmployeeEmailAddressValidator () { + this.allowEmptyRequiredData = Boolean.FALSE; + } + + /** + * Setter for allowEmptyRequiredData flag + *

+ * @param allowEmptyRequiredData Whether empty values are allowed + */ + public void setAllowEmptyRequiredData (final Boolean allowEmptyRequiredData) { + this.allowEmptyRequiredData = allowEmptyRequiredData; + } + + @Override + public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { + // The required field + final String[] requiredFields = {"employeeEmailAddress"}; //NOI18N + + // Pre-validation (example: not null, not a string, empty string ...) + super.preValidate(context, component, value, requiredFields, this.allowEmptyRequiredData); + + // Is the email address empty and allowed? + if (null == value && this.allowEmptyRequiredData) { + // Then accept this here + return; + } else if (null == value) { + // Abort here + throw new ValidatorException(new FacesMessage("No empty email address allowed.")); //NOI18N + } + + // Get string from object ... ;-) + // @TODO Add IDN support (GNU lib?) Search for emailAddressRepeat + final String emailAddress = String.valueOf(value).trim(); + + // Checks if the email address matches a regex ("low-level" check) + // @TODO Should also be done by ) + final boolean matches = PATTERN_MATCHER.matcher(emailAddress).matches(); //NOI18N + + // Is the email address valid? + if (!matches) { + // Generate message + String message = MessageFormat.format("Email address {0} does not match regular expression.", emailAddress); //NOI18N + + // Not matching + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_WARN, message, message)); + } + + // Get client id (aka form id) + final String clientId = component.getClientId(); + + // Is the instance there? + if (null == EMPLOYEE_CONTROLLER) { + // Get bean from CDI directly + EMPLOYEE_CONTROLLER = CDI.current().select(JobsEmployeeWebRequestBean.class).get(); + } + + // Is it registered? + final Boolean isRegistered = EMPLOYEE_CONTROLLER.isEmailAddressRegistered(emailAddress); + + // Is the email address already registered? + if ((!clientId.endsWith("resendEmailAddress")) && (isRegistered)) { //NOI18N + // Generate message + final String message = MessageFormat.format("Email address {0} is already registered.", emailAddress); //NOI18N + + // No, then abort here + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, message, message)); + } else if ((clientId.endsWith("resendEmailAddress")) && (!isRegistered)) { //NOI18N + // Generate message + final String message = MessageFormat.format("Email address {0} is not registered.", emailAddress); //NOI18N + + // No, then abort here + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, message, message)); + } + } + +} diff --git a/src/java/org/mxchange/jjobs/validator/emailaddress/headquarter/JobsHeadquarterEmailAddressValidator.java b/src/java/org/mxchange/jjobs/validator/emailaddress/headquarter/JobsHeadquarterEmailAddressValidator.java index aa566f7a..698366c4 100644 --- a/src/java/org/mxchange/jjobs/validator/emailaddress/headquarter/JobsHeadquarterEmailAddressValidator.java +++ b/src/java/org/mxchange/jjobs/validator/emailaddress/headquarter/JobsHeadquarterEmailAddressValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 @@ -56,34 +56,37 @@ public class JobsHeadquarterEmailAddressValidator extends BaseStringValidator { */ private static final long serialVersionUID = 187_536_745_607_194L; + /** + * Whether empty data is allowed + */ + private Boolean allowEmptyRequiredData; + + /** + * Default constructor + */ + public JobsHeadquarterEmailAddressValidator () { + this.allowEmptyRequiredData = Boolean.FALSE; + } + + /** + * Setter for allowEmptyRequiredData flag + *

+ * @param allowEmptyRequiredData Whether empty values are allowed + */ + public void setAllowEmptyRequiredData (final Boolean allowEmptyRequiredData) { + this.allowEmptyRequiredData = allowEmptyRequiredData; + } + @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { // The required field final String[] requiredFields = {"emailAddress", "emailAddressRepeat", "resendEmailAddress"}; //NOI18N - // Default is to reject empty email address fields - Boolean allowEmptyValue = Boolean.FALSE; - - // Is attribute "allowEmptyValue" set? - if (component.getAttributes().containsKey("allowEmptyValue")) { //NOI18N - // Get attribute - final Object attribute = component.getAttributes().get("allowEmptyValue"); //NOI18N - - // Make sure, it is Boolean as no String is accepted anymore - if (!(attribute instanceof String)) { - // Not valid attribute, please use "true" or "false" (default) - throw new IllegalArgumentException("allowEmptyValue must be of type String. Please use \"true\" or \"false\" for f:attribute value."); //NOI18N - } - - // Securely cast it - allowEmptyValue = Boolean.parseBoolean((String) attribute); - } - // Pre-validation (example: not null, not a string, empty string ...) - super.preValidate(context, component, value, requiredFields, allowEmptyValue); + super.preValidate(context, component, value, requiredFields, this.allowEmptyRequiredData); // Is the email address empty and allowed? - if (null == value && allowEmptyValue) { + if (null == value && this.allowEmptyRequiredData) { // Then accept this here return; } else if (null == value) { diff --git a/src/java/org/mxchange/jjobs/validator/names/JobsNameValidator.java b/src/java/org/mxchange/jjobs/validator/names/JobsNameValidator.java index 3482a4db..ae57c578 100644 --- a/src/java/org/mxchange/jjobs/validator/names/JobsNameValidator.java +++ b/src/java/org/mxchange/jjobs/validator/names/JobsNameValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 Free Software Foundation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/java/org/mxchange/jjobs/validator/password/JobsUserPasswordValidator.java b/src/java/org/mxchange/jjobs/validator/password/JobsUserPasswordValidator.java index f2bce2ba..8430d9c6 100644 --- a/src/java/org/mxchange/jjobs/validator/password/JobsUserPasswordValidator.java +++ b/src/java/org/mxchange/jjobs/validator/password/JobsUserPasswordValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 diff --git a/src/java/org/mxchange/jjobs/validator/phone/abroad/JobsAbroadDialValidator.java b/src/java/org/mxchange/jjobs/validator/phone/abroad/JobsAbroadDialValidator.java index 40b31102..fa4083bf 100644 --- a/src/java/org/mxchange/jjobs/validator/phone/abroad/JobsAbroadDialValidator.java +++ b/src/java/org/mxchange/jjobs/validator/phone/abroad/JobsAbroadDialValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 Free Software Foundation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/java/org/mxchange/jjobs/validator/phone/number/JobsPhoneNumberValidator.java b/src/java/org/mxchange/jjobs/validator/phone/number/JobsPhoneNumberValidator.java index ca3c8447..7a3edc51 100644 --- a/src/java/org/mxchange/jjobs/validator/phone/number/JobsPhoneNumberValidator.java +++ b/src/java/org/mxchange/jjobs/validator/phone/number/JobsPhoneNumberValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 Free Software Foundation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/java/org/mxchange/jjobs/validator/privacy_terms/JobsPrivacyTermsCheckboxValidator.java b/src/java/org/mxchange/jjobs/validator/privacy_terms/JobsPrivacyTermsCheckboxValidator.java index 489e75bf..5473a500 100644 --- a/src/java/org/mxchange/jjobs/validator/privacy_terms/JobsPrivacyTermsCheckboxValidator.java +++ b/src/java/org/mxchange/jjobs/validator/privacy_terms/JobsPrivacyTermsCheckboxValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 Free Software Foundation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/java/org/mxchange/jjobs/validator/url/JobsUrlValidator.java b/src/java/org/mxchange/jjobs/validator/url/JobsUrlValidator.java index 44139747..ff956ce5 100644 --- a/src/java/org/mxchange/jjobs/validator/url/JobsUrlValidator.java +++ b/src/java/org/mxchange/jjobs/validator/url/JobsUrlValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 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 @@ -49,34 +49,37 @@ public class JobsUrlValidator extends BaseStringValidator { */ private static final long serialVersionUID = 187_536_745_607_193L; + /** + * Whether empty data is allowed + */ + private Boolean allowEmptyRequiredData; + + /** + * Default constructor + */ + public JobsUrlValidator () { + this.allowEmptyRequiredData = Boolean.FALSE; + } + + /** + * Setter for allowEmptyRequiredData flag + *

+ * @param allowEmptyRequiredData Whether empty values are allowed + */ + public void setAllowEmptyRequiredData (final Boolean allowEmptyRequiredData) { + this.allowEmptyRequiredData = allowEmptyRequiredData; + } + @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { // The required field final String[] requiredFields = {"companyWebsiteUrl"}; //NOI18N - // Default is to reject empty email address fields - Boolean allowEmptyValue = Boolean.FALSE; - - // Is attribute "allowEmptyValue" set? - if (component.getAttributes().containsKey("allowEmptyValue")) { //NOI18N - // Get attribute - Object attribute = component.getAttributes().get("allowEmptyValue"); //NOI18N - - // Make sure, it is Boolean as no String is accepted anymore - if (!(attribute instanceof String)) { - // Not valid attribute, please use "true" or "false" (default) - throw new IllegalArgumentException("allowEmptyValue must be of type String. Please use \"true\" or \"false\" for f:attribute value."); //NOI18N - } - - // Securely cast it - allowEmptyValue = Boolean.parseBoolean((String) attribute); - } - // Pre-validation (example: not null, not a string, empty string ...) - super.preValidate(context, component, value, requiredFields, allowEmptyValue); + super.preValidate(context, component, value, requiredFields, this.allowEmptyRequiredData); // Is the email address empty and allowed? - if (null == value && allowEmptyValue) { + if (null == value && this.allowEmptyRequiredData) { // Then accept this here return; } else if (null == value) { diff --git a/src/java/org/mxchange/jjobs/validator/user/JobsUserIdValidator.java b/src/java/org/mxchange/jjobs/validator/user/JobsUserIdValidator.java index d3bc56a9..267a071f 100644 --- a/src/java/org/mxchange/jjobs/validator/user/JobsUserIdValidator.java +++ b/src/java/org/mxchange/jjobs/validator/user/JobsUserIdValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 Roland Häder + * Copyright (C) 2016 - 2018 Free Software Foundation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by