<ant antfile="${project.jjobs-lib}/build.xml" inheritall="false" target="jar">
<property name="deploy.on.save" value="false"/>
</ant>
+ <ant antfile="${project.jjobs-mailer}/build.xml" inheritall="false" target="jar">
+ <property name="deploy.on.save" value="false"/>
+ </ant>
<ant antfile="${project.jjobs-mailer-lib}/build.xml" inheritall="false" target="jar">
<property name="deploy.on.save" value="false"/>
</ant>
<ant antfile="${project.jjobs-lib}/build.xml" inheritall="false" target="jar">
<property name="deploy.on.save" value="false"/>
</ant>
+ <ant antfile="${project.jjobs-mailer}/build.xml" inheritall="false" target="jar">
+ <property name="deploy.on.save" value="false"/>
+ </ant>
<ant antfile="${project.jjobs-mailer-lib}/build.xml" inheritall="false" target="jar">
<property name="deploy.on.save" value="false"/>
</ant>
<target depends="compile,-library-inclusion-in-archive-weblogic,-library-inclusion-in-archive-by-user" name="library-inclusion-in-archive"/>
<target if="is.jars.in.ejbjar" name="-library-inclusion-in-archive-by-user">
<copyfiles files="${file.reference.jcore-logger-lib.jar}" todir="${build.classes.dir}"/>
- <copyfiles files="${file.reference.jcountry-core.jar}" todir="${build.classes.dir}"/>
- <copyfiles files="${file.reference.jcountry-lib.jar}" todir="${build.classes.dir}"/>
- <copyfiles files="${file.reference.jphone-core.jar}" todir="${build.classes.dir}"/>
- <copyfiles files="${file.reference.jphone-lib.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.jcontacts-core.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.jcontacts-lib.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.jcontacts-business-core.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.jcontacts-business-lib.jar}" todir="${build.classes.dir}"/>
- <copyfiles files="${file.reference.jproduct-core.jar}" todir="${build.classes.dir}"/>
- <copyfiles files="${file.reference.jproduct-lib.jar}" todir="${build.classes.dir}"/>
- <copyfiles files="${file.reference.jcustomer-core.jar}" todir="${build.classes.dir}"/>
- <copyfiles files="${file.reference.jcustomer-lib.jar}" todir="${build.classes.dir}"/>
+ <copyfiles files="${file.reference.jcountry-core.jar}" todir="${build.classes.dir}"/>
+ <copyfiles files="${file.reference.jcountry-lib.jar}" todir="${build.classes.dir}"/>
+ <copyfiles files="${file.reference.jphone-core.jar}" todir="${build.classes.dir}"/>
+ <copyfiles files="${file.reference.jphone-lib.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.juser-core.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.juser-lib.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.juser-login-core.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.juser-login-lib.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.juser-activity-core.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.juser-activity-lib.jar}" todir="${build.classes.dir}"/>
+ <copyfiles files="${file.reference.jletter-lib.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.jmailer-ee.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${reference.jjobs-core.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${reference.jjobs-lib.jar}" todir="${build.classes.dir}"/>
</target>
<target if="is.server.weblogic" name="-library-inclusion-in-archive-weblogic">
<basename file="${file.reference.jcore-logger-lib.jar}" property="manifest.file.reference.jcore-logger-lib.jar"/>
- <basename file="${file.reference.jcountry-core.jar}" property="manifest.file.reference.jcountry-core.jar"/>
- <basename file="${file.reference.jcountry-lib.jar}" property="manifest.file.reference.jcountry-lib.jar"/>
- <basename file="${file.reference.jphone-core.jar}" property="manifest.file.reference.jphone-core.jar"/>
- <basename file="${file.reference.jphone-lib.jar}" property="manifest.file.reference.jphone-lib.jar"/>
<basename file="${file.reference.jcontacts-core.jar}" property="manifest.file.reference.jcontacts-core.jar"/>
<basename file="${file.reference.jcontacts-lib.jar}" property="manifest.file.reference.jcontacts-lib.jar"/>
<basename file="${file.reference.jcontacts-business-core.jar}" property="manifest.file.reference.jcontacts-business-core.jar"/>
<basename file="${file.reference.jcontacts-business-lib.jar}" property="manifest.file.reference.jcontacts-business-lib.jar"/>
- <basename file="${file.reference.jproduct-core.jar}" property="manifest.file.reference.jproduct-core.jar"/>
- <basename file="${file.reference.jproduct-lib.jar}" property="manifest.file.reference.jproduct-lib.jar"/>
- <basename file="${file.reference.jcustomer-core.jar}" property="manifest.file.reference.jcustomer-core.jar"/>
- <basename file="${file.reference.jcustomer-lib.jar}" property="manifest.file.reference.jcustomer-lib.jar"/>
+ <basename file="${file.reference.jcountry-core.jar}" property="manifest.file.reference.jcountry-core.jar"/>
+ <basename file="${file.reference.jcountry-lib.jar}" property="manifest.file.reference.jcountry-lib.jar"/>
+ <basename file="${file.reference.jphone-core.jar}" property="manifest.file.reference.jphone-core.jar"/>
+ <basename file="${file.reference.jphone-lib.jar}" property="manifest.file.reference.jphone-lib.jar"/>
<basename file="${file.reference.juser-core.jar}" property="manifest.file.reference.juser-core.jar"/>
<basename file="${file.reference.juser-lib.jar}" property="manifest.file.reference.juser-lib.jar"/>
<basename file="${file.reference.juser-login-core.jar}" property="manifest.file.reference.juser-login-core.jar"/>
<basename file="${file.reference.juser-login-lib.jar}" property="manifest.file.reference.juser-login-lib.jar"/>
<basename file="${file.reference.juser-activity-core.jar}" property="manifest.file.reference.juser-activity-core.jar"/>
<basename file="${file.reference.juser-activity-lib.jar}" property="manifest.file.reference.juser-activity-lib.jar"/>
+ <basename file="${file.reference.jletter-lib.jar}" property="manifest.file.reference.jletter-lib.jar"/>
<basename file="${file.reference.jmailer-ee.jar}" property="manifest.file.reference.jmailer-ee.jar"/>
<basename file="${reference.jjobs-core.jar}" property="manifest.reference.jjobs-core.jar"/>
<basename file="${reference.jjobs-lib.jar}" property="manifest.reference.jjobs-lib.jar"/>
<basename file="${reference.jjobs-mailer-lib.jar}" property="manifest.reference.jjobs-mailer-lib.jar"/>
<basename file="${file.reference.cdi-api.jar}" property="manifest.file.reference.cdi-api.jar"/>
<manifest file="${build.ear.classes.dir}/META-INF/MANIFEST.MF" mode="update">
- <attribute name="Extension-List" value="jar-1 jar-2 jar-3 jar-4 jar-5 jar-6 jar-7 jar-8 jar-9 jar-10 jar-11 jar-12 jar-13 jar-14 jar-15 jar-16 jar-17 jar-18 jar-19 jar-20 jar-21 jar-22 jar-23 jar-24 "/>
+ <attribute name="Extension-List" value="jar-1 jar-2 jar-3 jar-4 jar-5 jar-6 jar-7 jar-8 jar-9 jar-10 jar-11 jar-12 jar-13 jar-14 jar-15 jar-16 jar-17 jar-18 jar-19 jar-20 jar-21 "/>
<attribute name="jar-1-Extension-Name" value="${manifest.file.reference.jcore-logger-lib.jar}"/>
- <attribute name="jar-2-Extension-Name" value="${manifest.file.reference.jcountry-core.jar}"/>
- <attribute name="jar-3-Extension-Name" value="${manifest.file.reference.jcountry-lib.jar}"/>
- <attribute name="jar-4-Extension-Name" value="${manifest.file.reference.jphone-core.jar}"/>
- <attribute name="jar-5-Extension-Name" value="${manifest.file.reference.jphone-lib.jar}"/>
- <attribute name="jar-6-Extension-Name" value="${manifest.file.reference.jcontacts-core.jar}"/>
- <attribute name="jar-7-Extension-Name" value="${manifest.file.reference.jcontacts-lib.jar}"/>
- <attribute name="jar-8-Extension-Name" value="${manifest.file.reference.jcontacts-business-core.jar}"/>
- <attribute name="jar-9-Extension-Name" value="${manifest.file.reference.jcontacts-business-lib.jar}"/>
- <attribute name="jar-10-Extension-Name" value="${manifest.file.reference.jproduct-core.jar}"/>
- <attribute name="jar-11-Extension-Name" value="${manifest.file.reference.jproduct-lib.jar}"/>
- <attribute name="jar-12-Extension-Name" value="${manifest.file.reference.jcustomer-core.jar}"/>
- <attribute name="jar-13-Extension-Name" value="${manifest.file.reference.jcustomer-lib.jar}"/>
- <attribute name="jar-14-Extension-Name" value="${manifest.file.reference.juser-core.jar}"/>
- <attribute name="jar-15-Extension-Name" value="${manifest.file.reference.juser-lib.jar}"/>
- <attribute name="jar-16-Extension-Name" value="${manifest.file.reference.juser-login-core.jar}"/>
- <attribute name="jar-17-Extension-Name" value="${manifest.file.reference.juser-login-lib.jar}"/>
- <attribute name="jar-18-Extension-Name" value="${manifest.file.reference.juser-activity-core.jar}"/>
- <attribute name="jar-19-Extension-Name" value="${manifest.file.reference.juser-activity-lib.jar}"/>
- <attribute name="jar-20-Extension-Name" value="${manifest.file.reference.jmailer-ee.jar}"/>
- <attribute name="jar-21-Extension-Name" value="${manifest.reference.jjobs-core.jar}"/>
- <attribute name="jar-22-Extension-Name" value="${manifest.reference.jjobs-lib.jar}"/>
- <attribute name="jar-23-Extension-Name" value="${manifest.reference.jjobs-mailer-lib.jar}"/>
- <attribute name="jar-24-Extension-Name" value="${manifest.file.reference.cdi-api.jar}"/>
+ <attribute name="jar-2-Extension-Name" value="${manifest.file.reference.jcontacts-core.jar}"/>
+ <attribute name="jar-3-Extension-Name" value="${manifest.file.reference.jcontacts-lib.jar}"/>
+ <attribute name="jar-4-Extension-Name" value="${manifest.file.reference.jcontacts-business-core.jar}"/>
+ <attribute name="jar-5-Extension-Name" value="${manifest.file.reference.jcontacts-business-lib.jar}"/>
+ <attribute name="jar-6-Extension-Name" value="${manifest.file.reference.jcountry-core.jar}"/>
+ <attribute name="jar-7-Extension-Name" value="${manifest.file.reference.jcountry-lib.jar}"/>
+ <attribute name="jar-8-Extension-Name" value="${manifest.file.reference.jphone-core.jar}"/>
+ <attribute name="jar-9-Extension-Name" value="${manifest.file.reference.jphone-lib.jar}"/>
+ <attribute name="jar-10-Extension-Name" value="${manifest.file.reference.juser-core.jar}"/>
+ <attribute name="jar-11-Extension-Name" value="${manifest.file.reference.juser-lib.jar}"/>
+ <attribute name="jar-12-Extension-Name" value="${manifest.file.reference.juser-login-core.jar}"/>
+ <attribute name="jar-13-Extension-Name" value="${manifest.file.reference.juser-login-lib.jar}"/>
+ <attribute name="jar-14-Extension-Name" value="${manifest.file.reference.juser-activity-core.jar}"/>
+ <attribute name="jar-15-Extension-Name" value="${manifest.file.reference.juser-activity-lib.jar}"/>
+ <attribute name="jar-16-Extension-Name" value="${manifest.file.reference.jletter-lib.jar}"/>
+ <attribute name="jar-17-Extension-Name" value="${manifest.file.reference.jmailer-ee.jar}"/>
+ <attribute name="jar-18-Extension-Name" value="${manifest.reference.jjobs-core.jar}"/>
+ <attribute name="jar-19-Extension-Name" value="${manifest.reference.jjobs-lib.jar}"/>
+ <attribute name="jar-20-Extension-Name" value="${manifest.reference.jjobs-mailer-lib.jar}"/>
+ <attribute name="jar-21-Extension-Name" value="${manifest.file.reference.cdi-api.jar}"/>
</manifest>
</target>
<target depends="compile" name="library-inclusion-in-manifest">
<copyfiles files="${file.reference.jcore-logger-lib.jar}" todir="${dist.ear.dir}/lib"/>
- <copyfiles files="${file.reference.jcountry-core.jar}" todir="${dist.ear.dir}/lib"/>
- <copyfiles files="${file.reference.jcountry-lib.jar}" todir="${dist.ear.dir}/lib"/>
- <copyfiles files="${file.reference.jphone-core.jar}" todir="${dist.ear.dir}/lib"/>
- <copyfiles files="${file.reference.jphone-lib.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.jcontacts-core.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.jcontacts-lib.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.jcontacts-business-core.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.jcontacts-business-lib.jar}" todir="${dist.ear.dir}/lib"/>
- <copyfiles files="${file.reference.jproduct-core.jar}" todir="${dist.ear.dir}/lib"/>
- <copyfiles files="${file.reference.jproduct-lib.jar}" todir="${dist.ear.dir}/lib"/>
- <copyfiles files="${file.reference.jcustomer-core.jar}" todir="${dist.ear.dir}/lib"/>
- <copyfiles files="${file.reference.jcustomer-lib.jar}" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jcountry-core.jar}" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jcountry-lib.jar}" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jphone-core.jar}" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jphone-lib.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.juser-core.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.juser-lib.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.juser-login-core.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.juser-login-lib.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.juser-activity-core.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.juser-activity-lib.jar}" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jletter-lib.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.jmailer-ee.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${reference.jjobs-core.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${reference.jjobs-lib.jar}" todir="${dist.ear.dir}/lib"/>
<target depends="init" name="deps-clean" unless="no.deps">
<ant antfile="${project.jjobs-core}/build.xml" inheritall="false" target="clean"/>
<ant antfile="${project.jjobs-lib}/build.xml" inheritall="false" target="clean"/>
+ <ant antfile="${project.jjobs-mailer}/build.xml" inheritall="false" target="clean"/>
<ant antfile="${project.jjobs-mailer-lib}/build.xml" inheritall="false" target="clean"/>
</target>
<target depends="init" name="-do-clean">
endorsed.classpath=
excludes=
file.reference.cdi-api.jar=lib/cdi-api.jar
-file.reference.jaddressbook-core.jar=lib/jaddressbook-core.jar
-file.reference.jaddressbook-lib.jar=lib/jaddressbook-lib.jar
file.reference.jcontacts-business-core.jar=lib/jcontacts-business-core.jar
file.reference.jcontacts-business-lib.jar=lib/jcontacts-business-lib.jar
file.reference.jcontacts-core.jar=lib/jcontacts-core.jar
${file.reference.juser-activity-core.jar}:\
${file.reference.juser-activity-lib.jar}:\
${file.reference.jletter-lib.jar}:\
- ${file.reference.jaddressbook-core.jar}:\
- ${file.reference.jaddressbook-lib.jar}:\
${file.reference.jmailer-ee.jar}:\
${reference.jjobs-core.jar}:\
${reference.jjobs-lib.jar}:\
<included-library dirs="200">file.reference.juser-activity-core.jar</included-library>
<included-library dirs="200">file.reference.juser-activity-lib.jar</included-library>
<included-library dirs="200">file.reference.jletter-lib.jar</included-library>
- <included-library dirs="200">file.reference.jaddressbook-core.jar</included-library>
- <included-library dirs="200">file.reference.jaddressbook-lib.jar</included-library>
<included-library dirs="200">file.reference.jmailer-ee.jar</included-library>
<included-library dirs="200">reference.jjobs-core.jar</included-library>
<included-library dirs="200">reference.jjobs-lib.jar</included-library>
import org.mxchange.jcontactsbusiness.model.employee.Employable;
import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition;
-import org.mxchange.jcontactsbusiness.model.jobposition.JobPosition;
import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
import org.mxchange.jcoreee.bean.ejb.BaseEnterpriseBean;
import org.mxchange.jcountry.model.data.Country;
return managedHeadquarter;
}
- /**
- * Get back a managed instance from given job position
- * <p>
- * @param jobPosition Unmanaged/detached job position instance
- * <p>
- * @return Managed job position instance
- */
- protected JobPosition createManaged (final JobPosition jobPosition) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: jobPosition={1} - CALLED!", this.getClass().getSimpleName(), jobPosition)); //NOI18N
-
- // user should not be null
- if (null == jobPosition) {
- // Abort here
- throw new NullPointerException("jobPosition is null"); //NOI18N
- } else if (jobPosition.getJobPositionId() == null) {
- // Id is set
- throw new NullPointerException("jobPosition.jobPositionId is null"); //NOI18N
- } else if (jobPosition.getJobPositionId() < 1) {
- // Id is set
- throw new IllegalArgumentException(MessageFormat.format("jobPosition.jobPositionId={0} is invalid", jobPosition.getJobPositionId())); //NOI18N
- }
-
- // Try to find it (should be there)
- final JobPosition managedJobPosition = this.getEntityManager().find(jobPosition.getClass(), jobPosition.getJobPositionId());
-
- // Should be there
- assert (managedJobPosition instanceof JobPosition) : "managedJobPosition is null"; //NOI18N
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedJobPosition={1} - EXIT!", this.getClass().getSimpleName(), managedJobPosition)); //NOI18N
-
- // Return it
- return managedJobPosition;
- }
-
/**
* Get back a managed instance from given mobile provider
* <p>
+++ /dev/null
-/*
- * Copyright (C) 2016 - 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jjobs.model.addressbook;
-
-import java.text.MessageFormat;
-import java.util.Date;
-import java.util.List;
-import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote;
-import org.mxchange.jaddressbook.exceptions.AddressbookNameAlreadyUsedException;
-import org.mxchange.jaddressbook.exceptions.AddressbookNotFoundException;
-import org.mxchange.jaddressbook.model.addressbook.Addressbook;
-import org.mxchange.jaddressbook.model.addressbook.UserAddressbook;
-import org.mxchange.jaddressbook.model.addressbook.entry.AddressbookEntry;
-import org.mxchange.jjobs.enterprise.BaseJobsEnterpriseBean;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A stateless bean handling address books
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "addressbook", description = "A stateless bean for handling JJobs addressbooks")
-public class JobsAddressbookSessionBean extends BaseJobsEnterpriseBean implements AddressbookSessionBeanRemote {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 129_857_871_287_691L;
-
- /**
- * Default constructor
- */
- public JobsAddressbookSessionBean () {
- // Call super constructor
- super();
- }
-
- @Override
- @SuppressWarnings ("unchecked")
- public List<AddressbookEntry> allEntries (final Addressbook addressbook) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("allEntries: addressbook={0} - CALLED!", addressbook)); //NOI18N
-
- // Validate parameter
- if (null == addressbook) {
- // Throw NPE
- throw new NullPointerException("addressbook is null"); //NOI18N
- } else if (addressbook.getAddressbookId() == null) {
- // Throw NPE again
- throw new NullPointerException("addressbook.addressbookId is null"); //NOI18N
- } else if (addressbook.getAddressbookId() < 1) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId())); //NOI18N
- } else if (addressbook.getAddressbookUser() == null) {
- // Throw again NPE
- throw new NullPointerException("addressbook.addressbookUser is null"); //NOI18N
- } else if (addressbook.getAddressbookUser().getUserId() == null) {
- // Throw again NPE
- throw new NullPointerException("addressbook.addressbookUser.userId is null"); //NOI18N
- } else if (addressbook.getAddressbookUser().getUserId() < 1) {
- // Invalid id number again
- throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookUser.userId={0} is invalid", addressbook.getAddressbookUser().getUserId())); //NOI18N
- }
-
- // Generate query
- Query query = this.getEntityManager().createNamedQuery("SearchUsersAddressbookEntries", List.class); //NOI18N
-
- // Set parameters
- query.setParameter("addressbook", addressbook); //NOI18N
- query.setParameter("owner", addressbook.getAddressbookUser()); //NOI18N
-
- // Return it
- return query.getResultList();
- }
-
- @Override
- public Addressbook createAddressbook (final Addressbook addressbook) throws AddressbookNameAlreadyUsedException {
- // Is it not null?
- if (null == addressbook) {
- // Abort here
- throw new NullPointerException("addressbook is null"); //NOI18N
- } else if (addressbook.getAddressbookUser() == null) {
- // User instance is null
- throw new NullPointerException("addressbook.user should not be null."); //NOI18N
- } else if (addressbook.getAddressbookName() == null) {
- // Address book name not set
- throw new NullPointerException("addressbook.addressbookName should not be null"); //NOI18N
- } else if (addressbook.getAddressbookName().isEmpty()) {
- // Address book name not set
- throw new IllegalArgumentException("addressbook.addressbookName should not be empty"); //NOI18N
- } else if (this.isAddressbookNameUsed(addressbook)) {
- // The assigned user already used that name
- throw new AddressbookNameAlreadyUsedException(addressbook);
- }
-
- // Add timestamp of creation
- addressbook.setAddressbookCreated(new Date());
-
- // Persist it now
- this.getEntityManager().persist(addressbook);
-
- // Flush it to get all data
- this.getEntityManager().flush();
-
- // Return it updated
- return addressbook;
- }
-
- @Override
- public Addressbook getAddressbookById (final Long addressbookId) throws AddressbookNotFoundException {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getAddressbookById: addressbookId={0} - CALLED!", addressbookId)); //NOI18N
-
- // addressbookId should not be null or below 1
- if (null == addressbookId) {
- // Throw NPE
- throw new NullPointerException("addressbookId is null"); //NOI18N
- } else if (addressbookId < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("addressbookId is not valid: {0}", addressbookId)); //NOI18N
- } else if (!this.isAddressbookIdUsed(addressbookId)) {
- // No address book found
- throw new AddressbookNotFoundException(addressbookId);
- }
-
- // Get named query instance
- Query query = this.getEntityManager().createNamedQuery("SearchAddressbookById", UserAddressbook.class); //NOI18N
-
- // Set parameter
- query.setParameter("id", addressbookId); //NOI18N
-
- // Return it
- return (Addressbook) query.getSingleResult();
- }
-
- @Override
- @SuppressWarnings ("unchecked")
- public List<Addressbook> getUsersAddressbookList (final User loggedInUser) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getUsersList: loggedInUser={0} - CALLED!", loggedInUser)); //NOI18N
-
- // Is the user instance null?
- if (null == loggedInUser) {
- // Abort here
- throw new NullPointerException("loggedInUser is null"); //NOI18N
- }
-
- // Get query instance
- Query query = this.getEntityManager().createNamedQuery("AllUsersAddressbooks", List.class); //NOI18N
-
- // Set parameter
- query.setParameter("param", loggedInUser); //NOI18N
-
- // Get full list from JPA
- List<Addressbook> addressbooks = query.getResultList();
-
- // Return it
- return addressbooks;
- }
-
- @Override
- public boolean isAddressbookIdUsed (final Long addressbookId) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("isAddressbookIdUsed: addressbookId={0} - CALLED!", addressbookId)); //NOI18N
-
- // Is it null or zero?
- if (null == addressbookId) {
- // Throw NPE
- throw new NullPointerException("addressbookId is null"); //NOI18N
- } else if (addressbookId < 1) {
- // Not valid id number
- throw new IllegalArgumentException(MessageFormat.format("addressbookId is not valid: {0}", addressbookId)); //NOI18N
- }
-
- // Get query instance
- Query query = this.getEntityManager().createNamedQuery("SearchAddressbookById", UserAddressbook.class); //NOI18N
-
- // Set parameter
- query.setParameter("id", addressbookId); //NOI18N
-
- // Default is not valid
- boolean isValid = false;
-
- // Try it again, yes no other way
- try {
- // Get single result
- Addressbook addressbook = (Addressbook) query.getSingleResult();
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookIdUsed: addressbook={0} - FOUND!", addressbook)); //NOI18N
-
- // Found one!
- isValid = true;
- } catch (final NoResultException ex) {
- // Debug log only, maybe out-dated link followed
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookIdUsed: addressbookId={0} is not valid: {1}", addressbookId, ex)); //NOI18N
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("isAddressbookIdUsed: isValid={0} - EXIT!", isValid)); //NOI18N
-
- // Return result
- return isValid;
- }
-
- @Override
- public boolean isAddressbookNameUsed (final Addressbook addressbook) {
- // Is it not null?
- if (null == addressbook) {
- // Abort here
- throw new NullPointerException("addressbook is null"); //NOI18N
- } else if (addressbook.getAddressbookUser() == null) {
- // User instance is null
- throw new NullPointerException("addressbook.addressbookUser is null."); //NOI18N
- } else if (addressbook.getAddressbookUser().getUserId() == null) {
- // User instance is null
- throw new NullPointerException("addressbook.addressbookUser.userId is null."); //NOI18N
- } else if (addressbook.getAddressbookUser().getUserId() < 1) {
- // User instance is null
- throw new NullPointerException(MessageFormat.format("addressbook.addressbookUser.userId={0} is invalid.", addressbook.getAddressbookUser().getUserId())); //NOI18N
- } else if (addressbook.getAddressbookName() == null) {
- // Address book name not set
- throw new NullPointerException("addressbook.addressbookName should not be null"); //NOI18N
- } else if (addressbook.getAddressbookName().isEmpty()) {
- // Address book name not set
- throw new IllegalArgumentException("addressbook.addressbookName should not be empty"); //NOI18N
- }
-
- // Get query instance
- Query query = this.getEntityManager().createNamedQuery("SearchUserAddressbookName", Addressbook.class); //NOI18N
-
- // Set parameter
- query.setParameter("user", addressbook.getAddressbookUser()); //NOI18N
- query.setParameter("name", addressbook.getAddressbookName()); //NOI18N
-
- // Default is not found
- boolean isUsed = false;
-
- // Try it
- try {
- // Get a single result
- Addressbook dummy = (Addressbook) query.getSingleResult();
-
- // Log it
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookNameUsed: Found an address book: {0}", dummy)); //NOI18N
-
- // Found one
- isUsed = true;
- } catch (final NoResultException ex) {
- // No result found, so log it away
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookNameUsed: getSingleResult() did not return a result: {0}", ex)); //NOI18N
- }
-
- // Return result
- return isUsed;
- }
-
-}
final User foundUser = this.getEntityManager().find(user.getClass(), user.getUserId());
// Should be found!
- assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", detachedUser.getUserId()); //NOI18N
+ assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
// Copy all data
- Users.copyUserData(detachedUser, foundUser);
+ Users.copyUserData(user, foundUser);
// Merge user
final User managedUser = this.getEntityManager().merge(foundUser);
+++ /dev/null
-/*
- * Copyright (C) 2016 - 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.juserlogincore.model.user.login;
-
-import java.text.MessageFormat;
-import javax.ejb.EJB;
-import javax.ejb.Stateless;
-import org.mxchange.jjobs.enterprise.BaseJobsEnterpriseBean;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.exceptions.UserStatusLockedException;
-import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
-import org.mxchange.jusercore.model.user.status.UserAccountStatus;
-import org.mxchange.juserlogincore.container.login.LoginContainer;
-import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
-import org.mxchange.juserlogincore.login.UserLoginUtils;
-
-/**
- * A session EJB for user logins
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "userLogin", description = "A bean handling the user login for Jobs project")
-public class JobsUserLoginSessionBean extends BaseJobsEnterpriseBean implements UserLoginSessionBeanRemote {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 21_785_978_127_581_965L;
-
- /**
- * User EJB
- */
- @EJB (lookup = "java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
- private UserSessionBeanRemote userBean;
-
- /**
- * Default constructor
- */
- public JobsUserLoginSessionBean () {
- // Call super constructor
- super();
- }
-
- @Override
- public User validateUserAccountStatus (final LoginContainer container) throws UserNotFoundException, UserStatusLockedException, UserStatusUnconfirmedException, UserPasswordMismatchException {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.loginUser: container={1} - CALLED!", this.getClass().getSimpleName(), container)); //NOI18N
-
- // user should not be null
- if (null == container) {
- // Abort here
- throw new NullPointerException("container is null"); //NOI18N
- } else if (container.getUser() == null) {
- // NPE again
- throw new NullPointerException("container.user is null"); //NOI18N
- } else if (container.getUserPassword() == null) {
- // And yet again NPE
- throw new NullPointerException("container.userPassword is null"); //NOI18N
- } else if (container.getUserPassword().isEmpty()) {
- // Empty password is not allowed, hardcoded.
- throw new IllegalArgumentException("container.userPassword is empty"); //NOI18N
- }
-
- // Is the account there?
- if (!this.userBean.isUserNameRegistered(container.getUser())) {
- // Not registered
- throw new UserNotFoundException(container.getUser());
- }
-
- // Get user instance from persistance
- // @TODO Rewrite this to use JCache instead
- final User updatedUser = this.userBean.fillUserData(container.getUser());
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("loginUser: updatedUser={0}", updatedUser)); //NOI18N
-
- // Is the user account unconfirmed?
- if (updatedUser.getUserAccountStatus().equals(UserAccountStatus.UNCONFIRMED)) {
- // Is unconfirmed
- throw new UserStatusUnconfirmedException(container.getUser());
- } else if (updatedUser.getUserAccountStatus().equals(UserAccountStatus.LOCKED)) {
- // Is locked
- throw new UserStatusLockedException(container.getUser());
- } else if (!this.isPasswordMatching(container, updatedUser)) {
- // Not matcing passwords
- throw new UserPasswordMismatchException(container.getUser());
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.loginUser: updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N
-
- // Return it
- return updatedUser;
- }
-
- /**
- * Checks if password matches of both instances. Both user instances must
- * not match, the first one is the one from the calling bean/controller, the
- * second is the from database.
- * <p>
- * @param container Container instance holding the user instance and
- * clear-text password
- * @param updatedUser Updated user instance found for given user name
- * <p>
- * @return Whether the password matches
- */
- private boolean isPasswordMatching (final LoginContainer container, final User updatedUser) {
- // First math both instances
- if (null == container) {
- // Throw NPE
- throw new NullPointerException("container is null"); //NOI18N
- } else if (null == updatedUser) {
- // Throw NPE
- throw new NullPointerException("updatedUser is null"); //NOI18N
- } else if (container.getUser().equals(updatedUser)) {
- // Both same instance!
- throw new IllegalArgumentException(MessageFormat.format("container.user matches updatedUser: {0}", container.getUser())); //NOI18N
- }
-
- // Is it the same same password?
- return UserLoginUtils.ifPasswordMatches(container, updatedUser);
- }
-
-}