From: Roland Haeder Date: Sat, 10 Oct 2015 20:00:43 +0000 (+0200) Subject: Rewrite: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cd670cf8db41c188c92217685b9eaec5d77112af;p=pizzaservice-mailer-ejb.git Rewrite: - introduced jcountry-core which is a library for handling country-related data, e.g. dial prefix, country code ... - introduced jphone-core which is a library for handling phone, fax and cell phone numbers - these both new libraries required a rewrite of many parts --- diff --git a/.gitignore b/.gitignore index bc920a3..0383bcc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ -/dist/ -/build/ /nbproject/private/ /nbproject/*~ +/manifest.mf +/build/ +/dist/ +/data/* +/*.properties diff --git a/lib/jcontacts-business-core.jar b/lib/jcontacts-business-core.jar index 9607d5c..5665c86 100644 Binary files a/lib/jcontacts-business-core.jar and b/lib/jcontacts-business-core.jar differ diff --git a/lib/jcontacts-core.jar b/lib/jcontacts-core.jar index 98ca617..855385d 100644 Binary files a/lib/jcontacts-core.jar and b/lib/jcontacts-core.jar differ diff --git a/lib/jcore-logger-lib.jar b/lib/jcore-logger-lib.jar new file mode 100644 index 0000000..4cb7da5 Binary files /dev/null and b/lib/jcore-logger-lib.jar differ diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar index 3900e4e..76ac2d3 100644 Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ diff --git a/lib/jcountry-core.jar b/lib/jcountry-core.jar new file mode 100644 index 0000000..ed08999 Binary files /dev/null and b/lib/jcountry-core.jar differ diff --git a/lib/jphone-core.jar b/lib/jphone-core.jar new file mode 100644 index 0000000..480f9f8 Binary files /dev/null and b/lib/jphone-core.jar differ diff --git a/lib/juser-core.jar b/lib/juser-core.jar index 764cab6..ae1dbfb 100644 Binary files a/lib/juser-core.jar and b/lib/juser-core.jar differ diff --git a/lib/juser-lib.jar b/lib/juser-lib.jar index 0d4d6af..2d9fa05 100644 Binary files a/lib/juser-lib.jar and b/lib/juser-lib.jar differ diff --git a/nbproject/ant-deploy.xml b/nbproject/ant-deploy.xml index 3c01560..2d5f877 100644 --- a/nbproject/ant-deploy.xml +++ b/nbproject/ant-deploy.xml @@ -1,111 +1,111 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index ca5393b..12a05fd 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -14,1237 +14,1257 @@ is divided into following sections: - javadoc - cleanup ---> + --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set build.generated.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - The Java EE server classpath is not correctly set up - server home directory is missing. - Either open the project in the IDE and assign the server or setup the server classpath manually. - For example like this: - ant -Dj2ee.server.home=<app_server_installation_directory> - - - The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. - Either open the project in the IDE and assign the server or setup the server classpath manually. - For example like this: - ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) - or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The libs.CopyLibs.classpath property is not set up. - This property must point to - org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part - of NetBeans IDE installation and is usually located at + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set build.generated.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at <netbeans_installation>/java<version>/ant/extra folder. - Either open the project in the IDE and make sure CopyLibs library - exists or setup the property manually. For example like this: - ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set main.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set main.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 6728257..85afed6 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -3,6 +3,6 @@ build.xml.script.CRC32=7d41e0fd build.xml.stylesheet.CRC32=5910fda3@1.51.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=18f264f5 -nbproject/build-impl.xml.script.CRC32=6e6325e1 +nbproject/build-impl.xml.data.CRC32=67e811b4 +nbproject/build-impl.xml.script.CRC32=db1e22fc nbproject/build-impl.xml.stylesheet.CRC32=6096d939@1.51.1 diff --git a/nbproject/project.properties b/nbproject/project.properties index 8b169c8..c746031 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -21,7 +21,12 @@ dist.jar=${dist.dir}/${jar.name} dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= +file.reference.jcontacts-business-core.jar=lib/jcontacts-business-core.jar +file.reference.jcontacts-core.jar=lib/jcontacts-core.jar +file.reference.jcore-logger-lib.jar=lib/jcore-logger-lib.jar file.reference.jcoreee.jar=lib/jcoreee.jar +file.reference.jcountry-core.jar=lib/jcountry-core.jar +file.reference.jphone-core.jar=lib/jphone-core.jar file.reference.juser-core.jar=lib/juser-core.jar file.reference.juser-lib.jar=lib/juser-lib.jar includes=** @@ -40,6 +45,11 @@ jar.name=addressbook-ejb.jar jars.in.ejbjar=false javac.classpath=\ ${file.reference.jcoreee.jar}:\ + ${file.reference.jcore-logger-lib.jar}:\ + ${file.reference.jcountry-core.jar}:\ + ${file.reference.jphone-core.jar}:\ + ${file.reference.jcontacts-core.jar}:\ + ${file.reference.jcontacts-business-core.jar}:\ ${file.reference.juser-core.jar}:\ ${file.reference.juser-lib.jar}:\ ${reference.addressbook-lib.jar} @@ -80,7 +90,12 @@ run.test.classpath=\ # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): runmain.jvmargs= source.encoding=UTF-8 +source.reference.jcontacts-business-core.jar=../jcontacts-business-core/src/ +source.reference.jcontacts-core.jar=../jcontacts-core/src/ +source.reference.jcore-logger-lib.jar=../jcore-logger-lib/src/ source.reference.jcoreee.jar=../jcoreee/src/ +source.reference.jcountry-core.jar=../jcountry-core/src/ +source.reference.jphone-core.jar=../jphone-core/src/ source.reference.juser-core.jar=../juser-core/src/ source.reference.juser-lib.jar=../juser-lib/src/ source.root=src diff --git a/nbproject/project.xml b/nbproject/project.xml index 1c4d2bf..e8cc12d 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -1,33 +1,38 @@ - org.netbeans.modules.j2ee.ejbjarproject - - - addressbook-ejb - 1.6.5 - file.reference.jcoreee.jar - file.reference.juser-core.jar - file.reference.juser-lib.jar - reference.addressbook-lib.jar - - - - - - - - - .\lib\nblibraries.properties - - - - addressbook-lib - jar - - jar - clean - jar - - - + org.netbeans.modules.j2ee.ejbjarproject + + + addressbook-ejb + 1.6.5 + file.reference.jcoreee.jar + file.reference.jcore-logger-lib.jar + file.reference.jcountry-core.jar + file.reference.jphone-core.jar + file.reference.jcontacts-core.jar + file.reference.jcontacts-business-core.jar + file.reference.juser-core.jar + file.reference.juser-lib.jar + reference.addressbook-lib.jar + + + + + + + + + .\lib\nblibraries.properties + + + + addressbook-lib + jar + + jar + clean + jar + + + diff --git a/src/conf/persistence.xml b/src/conf/persistence.xml index 6645ace..bae4482 100644 --- a/src/conf/persistence.xml +++ b/src/conf/persistence.xml @@ -1,21 +1,10 @@ - - jdbc/contacts - org.mxchange.addressbook.model.addressbook.UserAddressbook - org.mxchange.addressbook.model.addressbook.entry.UserAddressbookEntry - org.mxchange.jcontacts.contact.UserContact - org.mxchange.jcontactsbusiness.CompanyContact - org.mxchange.jcontactsbusiness.basicdata.CompanyBasicData - org.mxchange.jcontactsbusiness.branch.CompanyBranchOffice - org.mxchange.jcontactsbusiness.department.CompanyDepartment - org.mxchange.jcontactsbusiness.employee.CompanyEmployee - org.mxchange.jcontactsbusiness.headquarters.CompanyHeadQuartersData - org.mxchange.jcontactsbusiness.logo.CompanyLogo - org.mxchange.jusercore.model.user.LoginUser - false - - - - + + jdbc/contacts + false + + + + diff --git a/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java b/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java index 3003c4b..4edacc2 100644 --- a/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java +++ b/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java @@ -16,13 +16,13 @@ */ package org.mxchange.addressbook.model.addressbook; +import java.text.MessageFormat; import java.util.List; -import javax.ejb.EJB; import javax.ejb.Stateless; +import javax.persistence.NoResultException; import javax.persistence.Query; import org.mxchange.addressbook.exceptions.AddressbookNameAlreadyUsedException; import org.mxchange.jcoreee.database.BaseDatabaseBean; -import org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote; import org.mxchange.jusercore.model.user.User; /** @@ -38,17 +38,20 @@ public class AddressbookSessionBean extends BaseDatabaseBean implements Addressb */ private static final long serialVersionUID = 129_857_871_287_691L; - /** - * Login bean - */ - @EJB (mappedName = "ejb/stateless-login") - private UserLoginSessionBeanRemote loginBean; - @Override @SuppressWarnings ("unchecked") public List getUsersList (final User loggedInUser) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("getUsersList: loggedInUser={0} - CALLED!", loggedInUser)); + + // Is the user instance null? + if (null == loggedInUser) { + // Abort here + throw new NullPointerException("loggedInUser is null"); + } + // Get query instance - Query query = this.getEntityManager().createNamedQuery("AllUsersAddressbooks"); //NOI18N + Query query = this.getEntityManager().createNamedQuery("AllUsersAddressbooks", List.class); //NOI18N // Set parameter query.setParameter("param", loggedInUser); //NOI18N @@ -65,16 +68,16 @@ public class AddressbookSessionBean extends BaseDatabaseBean implements Addressb // Is it not null? if (null == addressbook) { // Abort here - throw new NullPointerException("addressbook is null"); + throw new NullPointerException("addressbook is null"); //NOI18N } else if (addressbook.getAddressbookUser() == null) { // User instance is null - throw new IllegalArgumentException("addressbook.user should not be null."); + throw new NullPointerException("addressbook.user should not be null."); //NOI18N } else if (addressbook.getAddressbookName() == null) { // Address book name not set - throw new IllegalArgumentException("addressbook.addressbookName should not be null"); + 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"); + 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); @@ -92,6 +95,47 @@ public class AddressbookSessionBean extends BaseDatabaseBean implements Addressb @Override public boolean isAddressbookNameUsed (final Addressbook addressbook) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + // 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 + } + + // Get query instance + Query query = this.getEntityManager().createNamedQuery("SearchUserAddressbookName", Addressbook.class); + + // Set parameter + query.setParameter("user", addressbook.getAddressbookUser()); + query.setParameter("name", addressbook.getAddressbookName()); + + // 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)); + + // Found one + isUsed = true; + } catch (final NoResultException ex) { + // No result found, so log it away + this.getLoggerBeanLocal().logDebug("isAddressbookNameUsed: getSingleResult() did not return a result: " + ex); + } + + // Return result + return isUsed; } }