From: Roland Häder Date: Sat, 24 Mar 2018 16:09:34 +0000 (+0100) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0d640905c074d28fea9428655b47e8476e3b6762;p=jjobs-war.git Please cherry-pick: - isEmailAddressRegistered() should always, like other public methods, validate their parameter - introduced isCompanyNameUsed() which is similar to isEmailAddressRegistered() which will be used to check in JS107 cache if company name is already used - make sure only non-null email addresses are added to emailAddressCache - updated/changed copyright to Free Software Foundation - added TODO to get rid of generateRandomUserName() business method is which deprecated anyway - removed isPublicUserProfileEnabled() - AdminBranchOfficeWebRequestBean is surely a request-scoped backing bean - added to same bean properties for last house number and extension of branch office - renamed bean field employeePersonalContact -> employeePersonalData - fixed some leftovers from duplication of branch office controller for employees - same with department bean - used more MessageFormat.format() which prevents more String objects polluting both heaps - injected feature backing bean into admin user bean - added missing bean property for user's profile mode to same bean - introduced private method createUserInstance() to same bean - null-ed more fields in same bean in clear() method - fixed imports of ContactUtils -> Contacts - AdminHeadquarterWebRequestBean is surely a request-scoped backing bean - added to same bean properties for last house number and extension of headquarter - fixed some leftovers from duplication of branch office controller for headquarter Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/beans/BaseJobsBean.java b/src/java/org/mxchange/jjobs/beans/BaseJobsBean.java index 6c863e2d..68dd4091 100644 --- a/src/java/org/mxchange/jjobs/beans/BaseJobsBean.java +++ b/src/java/org/mxchange/jjobs/beans/BaseJobsBean.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/beans/business/basicdata/JobsAdminBasicDataWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestBean.java index ee1912d4..db6428ed 100644 --- a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestBean.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/beans/business/basicdata/JobsAdminBasicDataWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestController.java index 371c0f87..c3a9784a 100644 --- a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestController.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/beans/business/basicdata/JobsBasicDataWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestBean.java index e2097dda..124244d9 100644 --- a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestBean.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 @@ -461,6 +461,15 @@ public class JobsBasicDataWebRequestBean extends BaseJobsBean implements JobsBas @Override public Boolean isEmailAddressRegistered (final String emailAddress) { + // Validate parameter + if (null == emailAddress) { + // Throw NPE + throw new NullPointerException("emailAddress is null"); //NOI18N + } else if (emailAddress.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("emailAddress is empty"); //NOI18N + } + // Default is not found boolean isFound = false; diff --git a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestController.java index 056dc969..c801fbdd 100644 --- a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestController.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/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestBean.java index c28d15c7..f37c725b 100644 --- a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestBean.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 @@ -21,7 +21,7 @@ import java.util.Date; import java.util.List; import java.util.Objects; import javax.ejb.EJB; -import javax.enterprise.context.SessionScoped; +import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Event; import javax.enterprise.inject.Any; import javax.inject.Inject; @@ -52,7 +52,7 @@ import org.mxchange.jusercore.model.user.User; * @author Roland Häder */ @Named ("adminBranchOfficeController") -@SessionScoped +@RequestScoped public class JobsAdminBranchOfficeWebRequestBean extends BaseJobsBean implements JobsAdminBranchOfficeWebRequestController { /** @@ -101,6 +101,16 @@ public class JobsAdminBranchOfficeWebRequestBean extends BaseJobsBean implements */ private Short branchHouseNumber; + /** + * House number's extension (a,b,c,...) + */ + private String branchHouseNumberExtension; + + /** + * Last house number + */ + private Short branchLastHouseNumber; + /** * Number of branch office */ @@ -119,6 +129,11 @@ public class JobsAdminBranchOfficeWebRequestBean extends BaseJobsBean implements @Inject private JobsBranchOfficeWebRequestController branchOfficeController; + /** + * Owner/leader of branch office + */ + private Employable branchOwner; + /** * Store */ @@ -393,6 +408,42 @@ public class JobsAdminBranchOfficeWebRequestBean extends BaseJobsBean implements this.branchHouseNumber = branchHouseNumber; } + /** + * Getter for house number's extension + *

+ * @return House number's extension + */ + public String getBranchHouseNumberExtension () { + return this.branchHouseNumberExtension; + } + + /** + * Setter for house number's extension + *

+ * @param branchHouseNumberExtension House number's extension + */ + public void setBranchHouseNumberExtension (final String branchHouseNumberExtension) { + this.branchHouseNumberExtension = branchHouseNumberExtension; + } + + /** + * Getter for last house number + *

+ * @return Last house number + */ + public Short getBranchLastHouseNumber () { + return this.branchLastHouseNumber; + } + + /** + * Setter for last house number + *

+ * @param branchLastHouseNumber Last house number + */ + public void setBranchLastHouseNumber (final Short branchLastHouseNumber) { + this.branchLastHouseNumber = branchLastHouseNumber; + } + /** * Getter for branch office number *

@@ -431,6 +482,24 @@ public class JobsAdminBranchOfficeWebRequestBean extends BaseJobsBean implements JobsAdminBranchOfficeWebRequestBean.branchOpeningTimes = branchOpeningTimes; } + /** + * Getter for branch office contact person + *

+ * @return Branch office contact person + */ + public Employable getBranchOwner () { + return this.branchOwner; + } + + /** + * Setter for branch office contact person + *

+ * @param branchOwner Branch office contact person + */ + public void setBranchOwner (final Employable branchOwner) { + this.branchOwner = branchOwner; + } + /** * Getter for store *

@@ -716,13 +785,26 @@ public class JobsAdminBranchOfficeWebRequestBean extends BaseJobsBean implements this.setBranchCountry(null); this.setBranchEmailAddress(null); this.setBranchHouseNumber(null); + this.setBranchHouseNumberExtension(null); + this.setBranchLastHouseNumber(null); this.setBranchNumber(null); + this.setBranchOwner(null); this.setBranchStore(null); this.setBranchStreet(null); this.setBranchSuiteNumber(null); this.setBranchUserOwner(null); this.setBranchZipCode(null); - this.setBranchOpeningTimes(null); + + // Opening times list + this.setBranchOpeningTimes(new ArrayList(1)); + + // Fax and land-line number + this.setFaxAreaCode(null); + this.setFaxCountry(null); + this.setFaxNumber(null); + this.setLandLineAreaCode(null); + this.setLandLineCountry(null); + this.setLandLineNumber(null); // Extra-clear opening time this.clearOpeningTime(); @@ -753,7 +835,10 @@ public class JobsAdminBranchOfficeWebRequestBean extends BaseJobsBean implements // Add all other fields, too branchOffice.setBranchContactEmployee(this.getBranchContactEmployee()); branchOffice.setBranchEmailAddress(this.getBranchEmailAddress()); + branchOffice.setBranchHouseNumberExtension(this.getBranchHouseNumberExtension()); + branchOffice.setBranchLastHouseNumber(this.getBranchLastHouseNumber()); branchOffice.setBranchNumber(this.getBranchNumber()); + branchOffice.setBranchOwnerEmployee(this.getBranchOwner()); branchOffice.setBranchStore(this.getBranchStore()); branchOffice.setBranchSuiteNumber(this.getBranchSuiteNumber()); branchOffice.setBranchUserOwner(this.getBranchUserOwner()); diff --git a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestController.java index 43766350..c817db44 100644 --- a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestController.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/beans/business/branchoffice/JobsBranchOfficeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestBean.java index 26ec02e4..f7fa0ea9 100644 --- a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestBean.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 @@ -204,6 +204,15 @@ public class JobsBranchOfficeWebRequestBean extends BaseJobsBean implements Jobs @Override public Boolean isEmailAddressRegistered (final String emailAddress) { + // Validate parameter + if (null == emailAddress) { + // Throw NPE + throw new NullPointerException("emailAddress is null"); //NOI18N + } else if (emailAddress.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("emailAddress is empty"); //NOI18N + } + // Default is not found boolean isFound = false; diff --git a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestController.java index ad50bac0..2a60ccef 100644 --- a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestController.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/beans/business/department/JobsAdminDepartmentWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestBean.java index cc8c41e7..1431e179 100644 --- a/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestBean.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 @@ -122,7 +122,7 @@ public class JobsAdminDepartmentWebRequestBean extends BaseJobsBean implements J // Is the department not created yet? if (this.isDepartmentCreatedByRequiredData(department)) { // Then show proper faces message - this.showFacesMessage("form-admin-add-department:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N + this.showFacesMessage("form-admin-add-department:branchStreet", "ADMIN_DEPARTMENT_ALREADY_CREATED"); //NOI18N return ""; //NOI18N } diff --git a/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestController.java index 5e9fe091..62458c8a 100644 --- a/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestController.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/beans/business/department/JobsDepartmentWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/department/JobsDepartmentWebRequestBean.java index 196b6142..e57dac3b 100644 --- a/src/java/org/mxchange/jjobs/beans/business/department/JobsDepartmentWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/department/JobsDepartmentWebRequestBean.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/beans/business/department/JobsDepartmentWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/department/JobsDepartmentWebRequestController.java index 896f2864..8f68a8e2 100644 --- a/src/java/org/mxchange/jjobs/beans/business/department/JobsDepartmentWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/business/department/JobsDepartmentWebRequestController.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/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java index 931c1166..38464448 100644 --- a/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 RRoland 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 @@ -107,7 +107,7 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job /** * Assigned personal data of the employee */ - private Contact employeePersonalContact; + private Contact employeePersonalData; /** * Employee's phone extension (on top of a "main number") @@ -163,7 +163,7 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job updatedOffice = this.adminEmployeeBean.addEmployee(employee); } catch (final EmployeeAlreadyAddedException ex) { // Output message - this.showFacesMessage("form-admin-add-branch-office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N + this.showFacesMessage("form-admin-add-employee:employeeNumber", "ADMIN_EMPLOYEE_ALREADY_CREATED"); //NOI18N return ""; //NOI18N } @@ -290,17 +290,17 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job *

* @return Employee's personal contact data */ - public Contact getEmployeePersonalContact () { - return this.employeePersonalContact; + public Contact getEmployeePersonalData () { + return this.employeePersonalData; } /** * Setter for employee's personal contact data *

- * @param employeePersonalContact Employee's personal contact data + * @param employeePersonalData Employee's personal contact data */ - public void setEmployeePersonalContact (final Contact employeePersonalContact) { - this.employeePersonalContact = employeePersonalContact; + public void setEmployeePersonalData (final Contact employeePersonalData) { + this.employeePersonalData = employeePersonalData; } /** @@ -385,7 +385,7 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job this.setEmployeeDepartment(null); this.setEmployeeEmailAddress(null); this.setEmployeeHeadquarter(null); - this.setEmployeePersonalContact(null); + this.setEmployeePersonalData(null); this.setEmployeePhoneExtension(null); this.setEmployeeNumber(null); this.setEmployeeUserOwner(null); @@ -398,7 +398,7 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job */ private Employable createEmployee () { // Init instance - final Employable employee = new BusinessEmployee(this.getEmployeeCompany(), this.getEmployeeNumber(), this.getEmployeePersonalContact()); + final Employable employee = new BusinessEmployee(this.getEmployeeCompany(), this.getEmployeeNumber(), this.getEmployeePersonalData()); // Set all othewr data employee.setEmployeeBranchOffice(this.getEmployeeBranchOffice()); diff --git a/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestController.java index c8f55a7b..00a5932a 100644 --- a/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestController.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/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java index ef3409b6..36e056ae 100644 --- a/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 RRoland 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 @@ -22,6 +22,7 @@ import java.util.Comparator; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Objects; import javax.annotation.PostConstruct; import javax.cache.Cache; import javax.ejb.EJB; @@ -123,7 +124,7 @@ public class JobsEmployeeWebRequestBean extends BaseJobsBean implements JobsEmpl throw new NullPointerException("employeeId is null"); //NOI18N } else if (employeeId < 1) { // Throw IAE - throw new IllegalArgumentException("employeeId=" + employeeId + " is invalid"); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("employeeId={0} is invalid", employeeId)); //NOI18N } else if (!this.employeeCache.containsKey(employeeId)) { // Not found throw new EmployeeNotFoundException(employeeId); @@ -142,7 +143,7 @@ public class JobsEmployeeWebRequestBean extends BaseJobsBean implements JobsEmpl * @return Filtered list of employees */ @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List getFilteredEmployees () { //NOI18N + public List getFilteredEmployees () { return this.filteredEmployees; } @@ -152,7 +153,7 @@ public class JobsEmployeeWebRequestBean extends BaseJobsBean implements JobsEmpl * @param filteredEmployees Filtered list of employees */ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") - public void setFilteredEmployees (final List filteredEmployees) { //NOI18N + public void setFilteredEmployees (final List filteredEmployees) { this.filteredEmployees = filteredEmployees; } @@ -197,4 +198,32 @@ public class JobsEmployeeWebRequestBean extends BaseJobsBean implements JobsEmpl } } + @Override + public Boolean isEmailAddressRegistered (final String emailAddress) { + // Validate parameter + if (null == emailAddress) { + // Throw NPE + throw new NullPointerException("emailAddress is null"); //NOI18N + } else if (emailAddress.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("emailAddress is empty"); //NOI18N + } + + // Default is not found + boolean isFound = false; + + // Check all entries + for (final Employable basicData : this.allEmployees()) { + // Is email address used? + if (Objects.equals(basicData.getEmployeeEmailAddress(), emailAddress)) { + // Found it + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + } diff --git a/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebSessionController.java b/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebSessionController.java index 1e8d42b3..a11f0bd4 100644 --- a/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebSessionController.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 @@ -28,6 +28,15 @@ import org.mxchange.jcontactsbusiness.model.employee.Employable; */ public interface JobsEmployeeWebRequestController extends Serializable { + /** + * Validates if given email address is already in use by an employee + *

+ * @param emailAddress Email address to be validated + *

+ * @return Whether the email address is already used + */ + Boolean isEmailAddressRegistered (final String emailAddress); + /** * Returns a list of all company employees *

diff --git a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java index 2d55dd32..5ccf6e31 100644 --- a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.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 @@ -21,7 +21,7 @@ import java.util.Date; import java.util.List; import java.util.Objects; import javax.ejb.EJB; -import javax.enterprise.context.SessionScoped; +import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Event; import javax.enterprise.inject.Any; import javax.inject.Inject; @@ -51,7 +51,7 @@ import org.mxchange.jusercore.model.user.User; * @author Roland Häder */ @Named ("adminHeadquarterController") -@SessionScoped +@RequestScoped public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements JobsAdminHeadquarterWebRequestController { /** @@ -97,6 +97,11 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements */ private String headquarterCity; + /** + * Headquarter's company name + */ + private String headquarterCompanyName; + /** * Contact person in headquarter */ @@ -123,6 +128,16 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements */ private Short headquarterHouseNumber; + /** + * House number's extension + */ + private String headquarterHouseNumberExtension; + + /** + * Last house number + */ + private Short headquarterLastHouseNumber; + /** * Store */ @@ -211,7 +226,7 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements // Is the headquarter not created yet? if (this.isHeadquarterCreatedByRequiredData(headquarter)) { // Then show proper faces message - this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N + this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_HEADQUARTER_ALREADY_CREATED"); //NOI18N return ""; //NOI18N } @@ -223,7 +238,7 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements updatedHeadquarter = this.adminHeadquarterBean.addHeadquarter(headquarter); } catch (final HeadquarterAlreadyAddedException ex) { // Output message - this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N + this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_HEADQUARTER_ALREADY_CREATED"); //NOI18N return ""; //NOI18N } @@ -234,7 +249,7 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements this.clear(); // Redirect to list - return "admin_list_headquarter_office"; //NOI18N + return "admin_list_headquarter"; //NOI18N } /** @@ -346,6 +361,24 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements this.headquarterCity = headquarterCity; } + /** + * Getter for headquarter's company name + *

+ * @return Headquarter's company name + */ + public String getHeadquarterCompanyName () { + return this.headquarterCompanyName; + } + + /** + * Setter for headquarter's company name + *

+ * @param headquarterCompanyName Headquarter's company name + */ + public void setHeadquarterCompanyName (final String headquarterCompanyName) { + this.headquarterCompanyName = headquarterCompanyName; + } + /** * Getter for headquarter contact person *

@@ -418,6 +451,42 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements this.headquarterHouseNumber = headquarterHouseNumber; } + /** + * Getter for house number's extension + *

+ * @return House number's extension + */ + public String getHeadquarterHouseNumberExtension () { + return this.headquarterHouseNumberExtension; + } + + /** + * Setter for house number's extension + *

+ * @param headquarterHouseNumberExtension House number's extension + */ + public void setHeadquarterHouseNumberExtension (final String headquarterHouseNumberExtension) { + this.headquarterHouseNumberExtension = headquarterHouseNumberExtension; + } + + /** + * Getter for last house number + *

+ * @return Last house number + */ + public Short getHeadquarterLastHouseNumber () { + return this.headquarterLastHouseNumber; + } + + /** + * Setter for last house number + *

+ * @param headquarterLastHouseNumber Last house number + */ + public void setHeadquarterLastHouseNumber (final Short headquarterLastHouseNumber) { + this.headquarterLastHouseNumber = headquarterLastHouseNumber; + } + /** * Getter for opening times of this headquarter *

@@ -664,10 +733,13 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements private void clear () { // Clear all headquarter data this.setHeadquarterCity(null); + this.setHeadquarterCompanyName(null); this.setHeadquarterContactEmployee(null); this.setHeadquarterCountry(null); this.setHeadquarterEmailAddress(null); this.setHeadquarterHouseNumber(null); + this.setHeadquarterHouseNumberExtension(null); + this.setHeadquarterLastHouseNumber(null); this.setHeadquarterStore(null); this.setHeadquarterStreet(null); this.setHeadquarterSuiteNumber(null); @@ -699,11 +771,13 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements */ private Headquarter createHeadquarter () { // Create new headquarter instance - final Headquarter headquarter = new BusinessHeadquarter(this.getHeadquarterCity(), this.getHeadquarterCountry(), this.getHeadquarterStreet(), this.getHeadquarterZipCode(), this.getHeadquarterHouseNumber()); + final Headquarter headquarter = new BusinessHeadquarter(this.getHeadquarterCompanyName(), this.getHeadquarterCity(), this.getHeadquarterCountry(), this.getHeadquarterStreet(), this.getHeadquarterZipCode(), this.getHeadquarterHouseNumber()); // Add all other fields, too headquarter.setHeadquarterContactEmployee(this.getHeadquarterContactEmployee()); headquarter.setHeadquarterEmailAddress(this.getHeadquarterEmailAddress()); + headquarter.setHeadquarterHouseNumberExtension(this.getHeadquarterHouseNumberExtension()); + headquarter.setHeadquarterLastHouseNumber(this.getHeadquarterLastHouseNumber()); headquarter.setHeadquarterStore(this.getHeadquarterStore()); headquarter.setHeadquarterSuiteNumber(this.getHeadquarterSuiteNumber()); headquarter.setHeadquarterUserOwner(this.getHeadquarterUserOwner()); diff --git a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestController.java index f4e91336..b918af26 100644 --- a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestController.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/beans/business/headquarter/JobsHeadquarterWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestBean.java index 892c951e..ac6abea7 100644 --- a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestBean.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 @@ -202,8 +202,45 @@ public class JobsHeadquarterWebRequestBean extends BaseJobsBean implements JobsH } } + @Override + public Boolean isCompanyNameUsed (final String companyName) { + // Validate parameter + if (null == companyName) { + // Throw NPE + throw new NullPointerException("companyName is null"); //NOI18N + } else if (companyName.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("companyName is empty"); //NOI18N + } + + // Default is not found + boolean isFound = false; + + // Check all entries + for (final Headquarter headquarter : this.allHeadquarter()) { + // Is same company name? + if (Objects.equals(headquarter.getHeadquarterCompanyName(), companyName)) { + // Found it + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + @Override public Boolean isEmailAddressRegistered (final String emailAddress) { + // Validate parameter + if (null == emailAddress) { + // Throw NPE + throw new NullPointerException("emailAddress is null"); //NOI18N + } else if (emailAddress.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("emailAddress is empty"); //NOI18N + } + // Default is not found boolean isFound = false; diff --git a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestController.java index 9d65fbad..ae7afd7d 100644 --- a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestController.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 @@ -28,6 +28,15 @@ import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; */ public interface JobsHeadquarterWebRequestController extends Serializable { + /** + * Checks whether given company name already exists + *

+ * @param companyName Company name to check + *

+ * @return Whether the company name exists + */ + Boolean isCompanyNameUsed (final String companyName); + /** * Checks if given email address is already registered by an other * headquarter diff --git a/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsAdminOpeningTimeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsAdminOpeningTimeWebRequestBean.java index 7d29fe84..7e9976c1 100644 --- a/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsAdminOpeningTimeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsAdminOpeningTimeWebRequestBean.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/beans/business/opening_time/JobsAdminOpeningTimeWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsAdminOpeningTimeWebRequestController.java index 2d18e151..f3de43d6 100644 --- a/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsAdminOpeningTimeWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsAdminOpeningTimeWebRequestController.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/beans/business/opening_time/JobsOpeningTimeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsOpeningTimeWebRequestBean.java index 55a3cd5a..5010e67f 100644 --- a/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsOpeningTimeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsOpeningTimeWebRequestBean.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/beans/business/opening_time/JobsOpeningTimeWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsOpeningTimeWebRequestController.java index f13d8209..e0de25c7 100644 --- a/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsOpeningTimeWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsOpeningTimeWebRequestController.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/beans/contact/JobsAdminContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java index 4b28be06..7ea8c86b 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.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 @@ -36,7 +36,7 @@ import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException; import org.mxchange.jcontacts.model.contact.AdminContactSessionBeanRemote; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote; -import org.mxchange.jcontacts.model.contact.ContactUtils; +import org.mxchange.jcontacts.model.contact.Contacts; import org.mxchange.jcontacts.model.contact.UserContact; import org.mxchange.jcontacts.model.contact.title.PersonalTitle; import org.mxchange.jcountry.model.data.Country; @@ -1116,7 +1116,7 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs final Contact next = iterator.next(); // Is the same? - if (ContactUtils.isSameContact(contact, next)) { + if (Contacts.isSameContact(contact, next)) { // Yes, then abort loop IsFound = false; break; @@ -1158,13 +1158,13 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs contact.setContactCountry(this.getContactCountry()); // Update contact's cmobile number - this.isMobileNumberUnlinked = ContactUtils.updateMobileNumber(contact, this.getMobileProvider(), this.getMobileNumber()); + this.isMobileNumberUnlinked = Contacts.updateMobileNumber(contact, this.getMobileProvider(), this.getMobileNumber()); // Update contact's land-line number - this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber()); + this.isLandLineUnlinked = Contacts.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber()); // Update contact's fax number - this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); + this.isFaxUnlinked = Contacts.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); } } diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestController.java b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestController.java index 20ebac45..6c6ca87c 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestController.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/beans/contact/JobsContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java index 35ae96aa..d6a58e07 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.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 @@ -36,7 +36,7 @@ import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContac import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote; -import org.mxchange.jcontacts.model.contact.ContactUtils; +import org.mxchange.jcontacts.model.contact.Contacts; import org.mxchange.jcontacts.model.contact.UserContact; import org.mxchange.jcontacts.model.contact.title.PersonalTitle; import org.mxchange.jcountry.model.data.Country; @@ -601,13 +601,13 @@ public class JobsContactWebRequestBean extends BaseJobsBean implements JobsConta contact.setContactCountry(this.getCountry()); // Update contact's mobile number - this.isMobileUnlinked = ContactUtils.updateMobileNumber(contact, this.getMobileProvider(), this.getMobileNumber()); + this.isMobileUnlinked = Contacts.updateMobileNumber(contact, this.getMobileProvider(), this.getMobileNumber()); // Update contact's land-line number - this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber()); + this.isLandLineUnlinked = Contacts.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber()); // Update contact's fax number - this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); + this.isFaxUnlinked = Contacts.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); // Send it to the EJB this.contactBean.updateContactData(contact, this.isMobileUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked); @@ -1057,7 +1057,12 @@ public class JobsContactWebRequestBean extends BaseJobsBean implements JobsConta for (final Contact contact : contacts) { // Add it to cache this.contactCache.put(contact.getContactId(), contact); - this.emailAddressCache.put(contact.getContactId(), contact.getContactEmailAddress()); + + // Is email address given? + if (contact.getContactEmailAddress() != null) { + // Set it, too + this.emailAddressCache.put(contact.getContactId(), contact.getContactEmailAddress()); + } } } else if (this.selectableContactsCache.iterator().hasNext()) { // Has already entries, avoid executing below code diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestController.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestController.java index f31b1f2f..fae16169 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestController.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/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java index 70f71392..fada1d5b 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.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/beans/contact/phone/JobsAdminContactPhoneWebRequestController.java b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestController.java index 5e598b86..853974a7 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestController.java @@ -1,6 +1,6 @@ /* - * 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/beans/contact/phone/JobsContactPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebRequestBean.java index 14647f8d..a0a34128 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebRequestBean.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/beans/contact/phone/JobsContactPhoneWebRequestController.java b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebRequestController.java index 99ae852a..ae95149e 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebRequestController.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/beans/country/JobsAdminCountryWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebRequestBean.java index 698e5283..1f97a968 100644 --- a/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebRequestBean.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/beans/country/JobsAdminCountryWebRequestController.java b/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebRequestController.java index 21d02d1f..b2a04a59 100644 --- a/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebRequestController.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/beans/country/JobsCountryWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebRequestBean.java index 5a7acef5..a60f9d2c 100644 --- a/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebRequestBean.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/beans/country/JobsCountryWebRequestController.java b/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebRequestController.java index db908dfa..d04ad37e 100644 --- a/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebRequestController.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/beans/data/JobsDataWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/data/JobsDataWebApplicationBean.java index 93cb9841..6e29c400 100644 --- a/src/java/org/mxchange/jjobs/beans/data/JobsDataWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/data/JobsDataWebApplicationBean.java @@ -48,45 +48,45 @@ public class JobsDataWebApplicationBean extends BaseJobsBean { } /** - * Returns a list of all days of the week + * Returns an array of all days of the week *

- * @return A list of all days of the week + * @return An array of all days of the week */ public DayOfTheWeek[] getDayOfTheWeek () { return DayOfTheWeek.values(); } /** - * Returns a list of all payment types + * Returns an array of all payment types *

- * @return A list of all payment types + * @return An array of all payment types */ public PaymentType[] getPaymentTypes () { return PaymentType.values(); } /** - * Returns a list of all personal titles + * Returns an array of all personal titles *

- * @return A list of all personal titles + * @return An array of all personal titles */ public PersonalTitle[] getPersonalTitles () { return PersonalTitle.values(); } /** - * Returns a list of all profile modes

- * @return A list of all profile modes + * @return An array of all profile modes */ public ProfileMode[] getProfileModes () { return ProfileMode.values(); } /** - * Returns a list of all user account statuses + * Returns an array of all user account statuses *

- * @return A list of all user account statuses + * @return An array of all user account statuses */ public UserAccountStatus[] getUserAccountStatuses () { return UserAccountStatus.values(); diff --git a/src/java/org/mxchange/jjobs/beans/features/JobsFeatureWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/features/JobsFeatureWebApplicationBean.java index 2e63d013..81dab2ed 100644 --- a/src/java/org/mxchange/jjobs/beans/features/JobsFeatureWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/features/JobsFeatureWebApplicationBean.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/beans/features/JobsFeaturesWebApplicationController.java b/src/java/org/mxchange/jjobs/beans/features/JobsFeaturesWebApplicationController.java index 5afb2314..90c44b4d 100644 --- a/src/java/org/mxchange/jjobs/beans/features/JobsFeaturesWebApplicationController.java +++ b/src/java/org/mxchange/jjobs/beans/features/JobsFeaturesWebApplicationController.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/beans/gender/JobsGenderWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/gender/JobsGenderWebApplicationBean.java index 4d028c3b..4b692aa8 100644 --- a/src/java/org/mxchange/jjobs/beans/gender/JobsGenderWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/gender/JobsGenderWebApplicationBean.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/beans/gender/JobsGenderWebApplicationController.java b/src/java/org/mxchange/jjobs/beans/gender/JobsGenderWebApplicationController.java index 9188b321..13637679 100644 --- a/src/java/org/mxchange/jjobs/beans/gender/JobsGenderWebApplicationController.java +++ b/src/java/org/mxchange/jjobs/beans/gender/JobsGenderWebApplicationController.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/beans/helper/JobsWebRequestHelperBean.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java index 5bc0b0fc..15dccd04 100644 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.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 @@ -25,6 +25,7 @@ import javax.inject.Named; import org.mxchange.jcontacts.events.contact.created.CreatedContactEvent; import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent; import org.mxchange.jcontacts.model.contact.Contact; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.department.Department; import org.mxchange.jcontactsbusiness.model.employee.Employable; @@ -440,6 +441,39 @@ public class JobsWebRequestHelperBean extends BaseJobsBean implements JobsWebReq this.userCreatedEvent.fire(new CreatedUserEvent(this.getUser())); } + /** + * Renders data of basic company data + *

+ * @param basicData Basic company data instance + *

+ * @return Basic company data as string + */ + public String renderBasicData (final BasicData basicData) { + // Default is empty string, so let's get started + final StringBuilder sb = new StringBuilder(30); + + // Is basic company data set? + if (basicData instanceof BasicData) { + // Add company name + sb.append(basicData.getCompanyName()); //NOI18N + + // Is email address set? + if (basicData.getCompanyEmailAddress() != null) { + // Add it + sb.append(", ").append(basicData.getCompanyEmailAddress()); //NOI18N + } + + // Is tax number set? + if (basicData.getCompanyTaxNumber() != null) { + // Add it + sb.append(", ").append(basicData.getCompanyTaxNumber()); //NOI18N + } + } + + // Return it + return sb.toString(); + } + /** * Returns the branch office's full address. If null is provided, an empty * string is returned. @@ -454,6 +488,9 @@ public class JobsWebRequestHelperBean extends BaseJobsBean implements JobsWebReq // Is a branch office instance given? if (branchOffice instanceof BranchOffice) { + // This should not happen: + assert (branchOffice.getBranchCompany() instanceof BasicData) : "branchOffice.branchCompany is null"; //NOI18N + // Yes, then append all data sb.append(branchOffice.getBranchCompany().getCompanyName()); sb.append(", "); //NOI18N diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperController.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperController.java index 3fd3b517..48ecaf37 100644 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperController.java +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperController.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/beans/localization/JobsLocalizationSessionBean.java b/src/java/org/mxchange/jjobs/beans/localization/JobsLocalizationSessionBean.java index 132ec1cb..cc698199 100644 --- a/src/java/org/mxchange/jjobs/beans/localization/JobsLocalizationSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/localization/JobsLocalizationSessionBean.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/beans/localization/JobsLocalizationSessionController.java b/src/java/org/mxchange/jjobs/beans/localization/JobsLocalizationSessionController.java index 5abf20e4..517a2ce0 100644 --- a/src/java/org/mxchange/jjobs/beans/localization/JobsLocalizationSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/localization/JobsLocalizationSessionController.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/beans/mobileprovider/JobsAdminMobileProviderWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestBean.java index b0b5f406..578b05b3 100644 --- a/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestBean.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/beans/mobileprovider/JobsAdminMobileProviderWebRequestController.java b/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestController.java index 5535088d..8177b8dc 100644 --- a/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestController.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/beans/mobileprovider/JobsMobileProviderWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsMobileProviderWebRequestBean.java index ee463016..f02d24aa 100644 --- a/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsMobileProviderWebRequestBean.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/beans/mobileprovider/JobsMobileProviderWebRequestController.java b/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsMobileProviderWebRequestController.java index 0b5ff1eb..d00da4bd 100644 --- a/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsMobileProviderWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsMobileProviderWebRequestController.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/beans/phone/JobsAdminPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java index 0a521a0e..b83666a3 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.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/beans/phone/JobsAdminPhoneWebRequestController.java b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java index 8e22d2d0..9392e14d 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.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/beans/phone/JobsPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebRequestBean.java index dcb2ed6c..316f2ae9 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebRequestBean.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/beans/phone/JobsPhoneWebRequestController.java b/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebRequestController.java index acca9a3a..fd860aa2 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebRequestController.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/beans/profile/JobsUserProfileWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/profile/JobsUserProfileWebRequestBean.java index 9c2fcfb7..0b93f40c 100644 --- a/src/java/org/mxchange/jjobs/beans/profile/JobsUserProfileWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/profile/JobsUserProfileWebRequestBean.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/beans/profile/JobsUserProfileWebRequestController.java b/src/java/org/mxchange/jjobs/beans/profile/JobsUserProfileWebRequestController.java index 0173ce63..b2b46b98 100644 --- a/src/java/org/mxchange/jjobs/beans/profile/JobsUserProfileWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/profile/JobsUserProfileWebRequestController.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/beans/user/JobsAdminUserWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java index 39db1e8d..faeba8ee 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.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 @@ -34,6 +34,7 @@ import org.mxchange.jcoreee.utils.FacesUtils; import org.mxchange.jjobs.beans.BaseJobsBean; import org.mxchange.jjobs.beans.contact.JobsAdminContactWebRequestController; import org.mxchange.jjobs.beans.contact.JobsContactWebRequestController; +import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent; import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent; @@ -116,10 +117,10 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm private Event deleteUserEvent; /** - * Localization controller + * Features controller */ @Inject - private JobsLocalizationSessionController localizationController; + private JobsFeaturesWebApplicationController featureController; /** * An event fired when the administrator has updated a new user @@ -190,6 +191,11 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm */ private String userPasswordRepeat; + /** + * Whether the user wants a public profile + */ + private ProfileMode userProfileMode; + /** * Event being fired when administrator unlocks an account */ @@ -226,41 +232,11 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm } // Create new user instance - final User newUser = new LoginUser(); - - // Set user name, CONFIRMED and INVISIBLE - newUser.setUserName(this.getUserName()); - newUser.setUserMustChangePassword(this.getUserMustChangePassword()); - newUser.setUserAccountStatus(UserAccountStatus.CONFIRMED); - newUser.setUserProfileMode(ProfileMode.INVISIBLE); - - // Get locale from view-root - final Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); - - // Copy user locale - newUser.setUserLocale(locale); - - // Init instance - Contact userContact; - - // Is a contact instance in helper set? - if (this.getContact() instanceof Contact) { - // Then use it for contact linking - userContact = this.getContact(); - } else { - // Create contact instance - userContact = this.contactController.createContactInstance(); - } - - // Set contact in user - newUser.setUserContact(userContact); - - // Init variable for password - String password = null; + final User newUser = this.createUserInstance(); // Is the user name or email address used already? // @TODO Add password length check - if (this.userController.isUserNameRegistered(newUser)) { + if ((this.featureController.isFeatureEnabled("user_login_require_user_name")) && (this.userController.isUserNameRegistered(newUser))) { // User name is already used throw new FaceletException(new UserNameAlreadyRegisteredException(newUser)); } else if ((this.getContact() == null) && (this.contactController.isEmailAddressRegistered(newUser.getUserContact()))) { @@ -273,24 +249,8 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm // Skip it return ""; //NOI18N - } else if ((this.getUserPassword() == null && (this.getUserPasswordRepeat() == null)) || ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty()))) { - // Empty password entered, then generate one - password = UserLoginUtils.createRandomPassword(JobsUserWebRequestController.MINIMUM_PASSWORD_LENGTH); - } else if (!this.isSamePasswordEntered()) { - // Both passwords don't match - throw new FaceletException(new UserPasswordRepeatMismatchException(newUser)); - } else { - // Both match, so get it from this bean - password = this.getUserPassword(); } - // The password should not be null and at least 5 characters long - assert (password != null) : "password is null"; //NOI18N - assert (password.length() >= JobsUserWebRequestController.MINIMUM_PASSWORD_LENGTH) : "Password is not long enough."; //NOI18N - - // Encrypt password and set it - newUser.setUserEncryptedPassword(UserLoginUtils.encryptPassword(password)); - try { // Now, that all is set, call EJB if (this.getContact() instanceof Contact) { @@ -300,7 +260,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm // Fire event this.userLinkedEvent.fire(new AdminLinkedUserEvent(updatedUser)); } else { - // Add new contact + // Add new user final User updatedUser = this.adminUserBean.addUser(newUser); // Fire event @@ -630,6 +590,24 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm this.userPasswordRepeat = userPasswordRepeat; } + /** + * Getter for user profile mode + *

+ * @return User profile mode + */ + public ProfileMode getUserProfileMode () { + return this.userProfileMode; + } + + /** + * Setter for user profile mode + *

+ * @param userProfileMode User profile mode + */ + public void setUserProfileMode (final ProfileMode userProfileMode) { + this.userProfileMode = userProfileMode; + } + /** * Locks selected user's account. This method makes sure that a lock reason * is provided that th user later can read on login attempts. @@ -740,9 +718,65 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm private void clear () { // Clear all data this.setContact(null); + this.setUserDeleteReason(null); + this.setUser(null); this.setUserLockReason(null); this.setUserMustChangePassword(null); this.setUserName(null); + this.setUserPassword(null); + this.setUserPasswordRepeat(null); + this.setUserProfileMode(null); + + } + + /** + * Creates a new user instance from all currently saved data from this bean + *

+ * @return New user instance + */ + private User createUserInstance () { + // Init variable for password + String password = null; + + // Init instance + final Contact userContact; + + // Is a contact instance in helper set? + if ((this.getUserPassword() == null && (this.getUserPasswordRepeat() == null)) || ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty()))) { + // Empty password entered, then generate one + password = UserLoginUtils.createRandomPassword(JobsUserWebRequestController.MINIMUM_PASSWORD_LENGTH); + } else if (!this.isSamePasswordEntered()) { + // Both passwords don't match + throw new FaceletException(new UserPasswordRepeatMismatchException()); + } else { + // Both match, so get it from this bean + password = this.getUserPassword(); + } + + // The password should not be null and at least 5 characters long + assert (password != null) : "password is null"; //NOI18N + assert (password.length() >= JobsUserWebRequestController.MINIMUM_PASSWORD_LENGTH) : "Password is not long enough."; //NOI18N + + // Is contact instance given? Else create one + if (this.getContact() instanceof Contact) { + // Then use it for contact linking + userContact = this.getContact(); + } else { + // Create contact instance + userContact = this.contactController.createContactInstance(); + } + + // Create new instance + final User newUser = new LoginUser(this.getUserName(), this.getUserProfileMode(), this.getUserMustChangePassword(), UserLoginUtils.encryptPassword(password), UserAccountStatus.CONFIRMED, userContact); + + // Get locale from view-root + final Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); + + // Copy user locale + newUser.setUserLocale(locale); + + // Return it + return newUser; } /** diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestController.java b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestController.java index 3674d192..458b7fac 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestController.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/beans/user/JobsUserWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestBean.java index d5876796..fb9721e8 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestBean.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 @@ -609,14 +609,15 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR // Is user name required? if (!this.isUserNameRequired()) { // Generate pseudo-random user name - String randomName = this.userBean.generateRandomUserName(); + // @TODO Refacture this to avoid EJB call + final String randomName = this.userBean.generateRandomUserName(); // Set it and inivisible profile this.setUserName(randomName); this.setUserProfileMode(ProfileMode.INVISIBLE); // Generate random password - String randomPassword = UserLoginUtils.createRandomPassword(JobsUserWebRequestController.MINIMUM_PASSWORD_LENGTH); + final String randomPassword = UserLoginUtils.createRandomPassword(JobsUserWebRequestController.MINIMUM_PASSWORD_LENGTH); // Set random password this.setUserPassword(randomPassword); @@ -938,24 +939,6 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR return isFound; } - @Override - public boolean isPublicUserProfileEnabled () { - // Get context parameter - final String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter("is_public_profile_enabled"); //NOI18N - - // Is it set? - final boolean isEnabled = ((contextParameter instanceof String) && (contextParameter.toLowerCase().equals("true"))); //NOI18N - - // This requires user names being enabled, too. - if ((isEnabled) && (!this.isUserNameRequired())) { - // Not valid state, users must be able to modify their profile, especially when it is public - throw new IllegalStateException("Public user profiles are enabled but user name requirement is disabled, this is not possible."); //NOI18N - } - - // Return value - return isEnabled; - } - @Override public boolean isRequiredChangePersonalDataSet () { return ((this.getUserProfileMode() != null) && diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestController.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestController.java index dc1b1f46..3a421c40 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestController.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 @@ -186,12 +186,4 @@ public interface JobsUserWebRequestController extends Serializable { */ boolean isUserNameRequired (); - /** - * Checks wether public user profiles are enabled. This requires that user - * names are also enabled. - *

- * @return Whether public user profiles are enabled - */ - boolean isPublicUserProfileEnabled (); - } diff --git a/src/java/org/mxchange/jjobs/beans/user/activity/JobsUserActivityWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/activity/JobsUserActivityWebRequestBean.java index a5d6e377..bb342914 100644 --- a/src/java/org/mxchange/jjobs/beans/user/activity/JobsUserActivityWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/activity/JobsUserActivityWebRequestBean.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/beans/user/activity/JobsUserActivityWebRequestController.java b/src/java/org/mxchange/jjobs/beans/user/activity/JobsUserActivityWebRequestController.java index 4e4837cd..29f94c15 100644 --- a/src/java/org/mxchange/jjobs/beans/user/activity/JobsUserActivityWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/user/activity/JobsUserActivityWebRequestController.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/beans/user/confirmlink/JobsConfirmationLinkWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/confirmlink/JobsConfirmationLinkWebRequestBean.java index cb9943de..0fee5aef 100644 --- a/src/java/org/mxchange/jjobs/beans/user/confirmlink/JobsConfirmationLinkWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/confirmlink/JobsConfirmationLinkWebRequestBean.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/beans/user/confirmlink/JobsConfirmationLinkWebRequestController.java b/src/java/org/mxchange/jjobs/beans/user/confirmlink/JobsConfirmationLinkWebRequestController.java index 7d621901..959ffa81 100644 --- a/src/java/org/mxchange/jjobs/beans/user/confirmlink/JobsConfirmationLinkWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/user/confirmlink/JobsConfirmationLinkWebRequestController.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/beans/user/email_address/JobsEmailChangeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/email_address/JobsEmailChangeWebRequestBean.java index 3ccd4153..47ba8643 100644 --- a/src/java/org/mxchange/jjobs/beans/user/email_address/JobsEmailChangeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/email_address/JobsEmailChangeWebRequestBean.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/beans/user/email_address/JobsEmailChangeWebRequestController.java b/src/java/org/mxchange/jjobs/beans/user/email_address/JobsEmailChangeWebRequestController.java index f31fda04..68a76507 100644 --- a/src/java/org/mxchange/jjobs/beans/user/email_address/JobsEmailChangeWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/user/email_address/JobsEmailChangeWebRequestController.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/beans/user/login/JobsUserLoginWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/user/login/JobsUserLoginWebSessionBean.java index 4255d4f8..256ce813 100644 --- a/src/java/org/mxchange/jjobs/beans/user/login/JobsUserLoginWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/login/JobsUserLoginWebSessionBean.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/beans/user/login/JobsUserLoginWebSessionController.java b/src/java/org/mxchange/jjobs/beans/user/login/JobsUserLoginWebSessionController.java index d76afcc7..84964e9d 100644 --- a/src/java/org/mxchange/jjobs/beans/user/login/JobsUserLoginWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/user/login/JobsUserLoginWebSessionController.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/beans/user/password/JobsUserPasswordWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestBean.java index 72c5ffb4..cb71066d 100644 --- a/src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestBean.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/beans/user/password/JobsUserPasswordWebRequestController.java b/src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestController.java index 57680e7d..70a2c51a 100644 --- a/src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestController.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/beans/user/register/JobsUserRegisterWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/register/JobsUserRegisterWebRequestBean.java index 3bdf7f5e..e1afa115 100644 --- a/src/java/org/mxchange/jjobs/beans/user/register/JobsUserRegisterWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/register/JobsUserRegisterWebRequestBean.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/beans/user/register/JobsUserRegisterWebRequestController.java b/src/java/org/mxchange/jjobs/beans/user/register/JobsUserRegisterWebRequestController.java index 2dad7c6b..bfade811 100644 --- a/src/java/org/mxchange/jjobs/beans/user/register/JobsUserRegisterWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/user/register/JobsUserRegisterWebRequestController.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/beans/user/resendlink/JobsResendLinkWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/resendlink/JobsResendLinkWebRequestBean.java index 5b4d7ad3..643c51ed 100644 --- a/src/java/org/mxchange/jjobs/beans/user/resendlink/JobsResendLinkWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/resendlink/JobsResendLinkWebRequestBean.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/beans/user/resendlink/JobsResendLinkWebRequestController.java b/src/java/org/mxchange/jjobs/beans/user/resendlink/JobsResendLinkWebRequestController.java index 134fd175..30c3c097 100644 --- a/src/java/org/mxchange/jjobs/beans/user/resendlink/JobsResendLinkWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/user/resendlink/JobsResendLinkWebRequestController.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