]> git.mxchange.org Git - jjobs-ejb.git/commitdiff
Some fixes:
authorRoland Haeder <roland@mxchange.org>
Fri, 1 Apr 2016 19:06:12 +0000 (21:06 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 1 Apr 2016 19:06:12 +0000 (21:06 +0200)
- fixed copyright (minor)
- moved class to proper package

src/java/org/mxchange/addressbook/model/addressbook/JobsAddressbookSessionBean.java [deleted file]
src/java/org/mxchange/jjobs/model/addressbook/JobsAddressbookSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jmailee/model/delivery/JobsEmailDeliveryMessageBean.java
src/java/org/mxchange/jusercore/model/email_address/JobsEmailChangeSessionBean.java

diff --git a/src/java/org/mxchange/addressbook/model/addressbook/JobsAddressbookSessionBean.java b/src/java/org/mxchange/addressbook/model/addressbook/JobsAddressbookSessionBean.java
deleted file mode 100644 (file)
index ea86ddf..0000000
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.model.addressbook;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import org.mxchange.jcoreee.database.BaseDatabaseBean;
-import org.mxchange.jjobs.exceptions.AddressbookNameAlreadyUsedException;
-import org.mxchange.jjobs.exceptions.AddressbookNotFoundException;
-import org.mxchange.jjobs.model.addressbook.Addressbook;
-import org.mxchange.jjobs.model.addressbook.AddressbookSessionBeanRemote;
-import org.mxchange.jjobs.model.addressbook.UserAddressbook;
-import org.mxchange.jjobs.model.addressbook.entry.AddressbookEntry;
-import org.mxchange.jjobs.model.addressbook.shared.ShareableAddressbook;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A stateless bean handling addressbooks
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Stateless (name = "jjobs-adr", mappedName = "ejb/stateless-jjobs-adr", description = "A stateless bean for handling JJobs addressbooks")
-public class JobsAddressbookSessionBean extends BaseDatabaseBean implements AddressbookSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 129_857_871_287_691L;
-
-       @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");
-               } else if (addressbook.getAddressbookId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("addressbook.addressbookId is null");
-               } else if (addressbook.getAddressbookId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId()));
-               } else if (addressbook.getAddressbookUser() == null) {
-                       // Throw again NPE
-                       throw new NullPointerException("addressbook.addressbookUser is null");
-               } else if (addressbook.getAddressbookUser().getUserId() == null) {
-                       // Throw again NPE
-                       throw new NullPointerException("addressbook.addressbookUser.userId is null");
-               } else if (addressbook.getAddressbookUser().getUserId() < 1) {
-                       // Invalid id number again
-                       throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookUser.userId={0} is invalid", addressbook.getAddressbookUser().getUserId()));
-               }
-
-               // 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);
-               }
-
-               // 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;
-       }
-}
diff --git a/src/java/org/mxchange/jjobs/model/addressbook/JobsAddressbookSessionBean.java b/src/java/org/mxchange/jjobs/model/addressbook/JobsAddressbookSessionBean.java
new file mode 100644 (file)
index 0000000..43a55e2
--- /dev/null
@@ -0,0 +1,260 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.List;
+import javax.ejb.Stateless;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import org.mxchange.jcoreee.database.BaseDatabaseBean;
+import org.mxchange.jjobs.exceptions.AddressbookNameAlreadyUsedException;
+import org.mxchange.jjobs.exceptions.AddressbookNotFoundException;
+import org.mxchange.jjobs.model.addressbook.entry.AddressbookEntry;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A stateless bean handling addressbooks
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Stateless (name = "jjobs-adr", mappedName = "ejb/stateless-jjobs-adr", description = "A stateless bean for handling JJobs addressbooks")
+public class JobsAddressbookSessionBean extends BaseDatabaseBean implements AddressbookSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 129_857_871_287_691L;
+
+       @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");
+               } else if (addressbook.getAddressbookId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("addressbook.addressbookId is null");
+               } else if (addressbook.getAddressbookId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId()));
+               } else if (addressbook.getAddressbookUser() == null) {
+                       // Throw again NPE
+                       throw new NullPointerException("addressbook.addressbookUser is null");
+               } else if (addressbook.getAddressbookUser().getUserId() == null) {
+                       // Throw again NPE
+                       throw new NullPointerException("addressbook.addressbookUser.userId is null");
+               } else if (addressbook.getAddressbookUser().getUserId() < 1) {
+                       // Invalid id number again
+                       throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookUser.userId={0} is invalid", addressbook.getAddressbookUser().getUserId()));
+               }
+
+               // 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);
+               }
+
+               // 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;
+       }
+
+}
index 11f421c9f05ae9b8c22a1d458fa3628333834eb3..1f68cc86148b03c1e399dbbd1e835c7d36483610 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 quix0r
+ * Copyright (C) 2016 Roland Haeder
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index 608a61be75ffb3c2d4a3a83eb4b5fd53d6cde34b..95b8fd73ce4d5cb370fb444cb0448045e94ce99a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 quix0r
+ * Copyright (C) 2016 Roland Haeder
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by