]> git.mxchange.org Git - jjobs-ejb.git/commitdiff
Continued a bit:
authorRoland Haeder <roland@mxchange.org>
Wed, 13 Apr 2016 18:49:33 +0000 (20:49 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 13 Apr 2016 21:11:08 +0000 (23:11 +0200)
- added administrative EJB for mobile providers with first business method addMobileProvider() implemented (should work)
- The word "bean" may confuse here as these are all EJBs
- updated jar(s)

Signed-off-by: Roland Häder <roland@mxchange.org>
lib/juser-core.jar
src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java
src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java
src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSingletonBean.java [new file with mode: 0644]
src/java/org/mxchange/jusercore/model/login/JobsUserLoginSessionBean.java
src/java/org/mxchange/jusercore/model/register/JobsUserRegistrationSessionBean.java
src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java

index 96bfe0721f41190085145aee77d4a15b1ea9f133..5d787e51c0cd470c74c4d07163a37464dcb86a0d 100644 (file)
Binary files a/lib/juser-core.jar and b/lib/juser-core.jar differ
index 7d0569369782c1ed19f72f369edc329fd1131f61..26f778653be739cbbc8a177af5378396b5925cd8 100644 (file)
@@ -27,7 +27,7 @@ import org.mxchange.jcoreee.database.BaseDatabaseBean;
 import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
 
 /**
- * A singleton bean for country informations
+ * A singleton EJB for country informations
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
index 734056936a264188107b514e12f49bc62b8769d2..6f7677da0ff4ad8856d8b18da4e9a080efce1b15 100644 (file)
@@ -23,7 +23,7 @@ import javax.persistence.Query;
 import org.mxchange.jcoreee.database.BaseDatabaseBean;
 
 /**
- * A singleton bean for SMS provider informations
+ * A singleton EJB for mobile provider informations
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSingletonBean.java
new file mode 100644 (file)
index 0000000..4ba7008
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * 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.jphone.phonenumbers.mobileprovider;
+
+import java.text.MessageFormat;
+import java.util.GregorianCalendar;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import org.mxchange.jcoreee.database.BaseDatabaseBean;
+import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException;
+
+/**
+ * An administrative singleton EJB for mobile provider informations
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Startup
+@Singleton (name = "adminmobileprovider", mappedName = "ejb/pizzaservice-singleton-admin-mobile-provider", description = "A singleton session bean for mobile provider informations, admin-edition")
+public class PizzaAdminMobileProviderSingletonBean extends BaseDatabaseBean implements AdminMobileProviderSingletonBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 15_846_983_298_691_207L;
+
+       @Override
+       public MobileProvider addMobileProvider (final MobileProvider mobileProvider) throws MobileProviderAlreadyAddedException {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("addMobileProvider: mobileProvider={0} - CALLED!", mobileProvider)); //NOI18N
+
+               // Is the instance valid?
+               if (null == mobileProvider) {
+                       // Throw NPE
+                       throw new NullPointerException("mobileProvider is null"); //NOI18N
+               } else if (mobileProvider.getProviderDialPrefix() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileProvider.providerDialPrefix is null"); //NOI18N
+               } else if (mobileProvider.getProviderDialPrefix() < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerDialPrefix={0} is not valid.", mobileProvider.getProviderDialPrefix())); //NOI18N
+               } else if (mobileProvider.getProviderCountry() == null) {
+                       // Throw again a NPE
+                       throw new NullPointerException("mobileProvider.providerCountry is null"); //NOI18N
+               } else if (mobileProvider.getProviderMailPattern() == null) {
+                       // ... and again ...
+                       throw new NullPointerException("mobileProvider.providerMailPattern is null"); //NOI18N
+               } else if (mobileProvider.getProviderMailPattern().isEmpty()) {
+                       // Empty pattern set (not allowed)
+                       throw new IllegalArgumentException("mobileProvider.providerMailPattern is empty."); //NOI18N
+               } else if (!mobileProvider.getProviderMailPattern().contains("%s")) { //NOI18N
+                       // No place-holder found
+                       throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerMailPattern={0} does not contain '%s' which is need to be replaced with the full mobile number.", mobileProvider.getProviderMailPattern())); //NOI18N
+               } else if (mobileProvider.getProviderName() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileProvider.providerName is null"); //NOI18N
+               } else if (mobileProvider.getProviderName().isEmpty()) {
+                       // Empty name is not allowed
+                       throw new IllegalArgumentException("mobileProvider.providerName is empty"); //NOI18N
+               }
+
+               // Set creation timestamp
+               mobileProvider.setProviderEntryCreated(new GregorianCalendar());
+
+               // Persist it
+               this.getEntityManager().persist(mobileProvider);
+
+               // ... and flush it to get id back
+               this.getEntityManager().flush();
+
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("addMobileProvider: mobileProvider.providerId={0} - EXIT!", mobileProvider.getProviderId())); //NOI18N
+
+               // Return updated
+               return mobileProvider;
+       }
+
+}
index 2e0793cf633379c6c52dbcf2609e293491933bd3..fa34ff2792b542a54cf5c5cf5c7c9c7e505de716 100644 (file)
@@ -32,7 +32,7 @@ import org.mxchange.jusercore.model.user.UserUtils;
 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
 
 /**
- * A session bean for user logins
+ * A session EJB for user logins
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
@@ -45,13 +45,13 @@ public class JobsUserLoginSessionBean extends BaseDatabaseBean implements UserLo
        private static final long serialVersionUID = 21_785_978_127_581_965L;
 
        /**
-        * Registration bean
+        * Registration EJB
         */
        @EJB
        private UserRegistrationSessionBeanRemote registerBean;
 
        /**
-        * User bean
+        * User EJB
         */
        @EJB
        private UserSessionBeanRemote userBean;
index 42286209b98866499a5d070777f3a0e4111d5539..61dfec5c4e584ff89866061699dc90937f25a722 100644 (file)
@@ -39,7 +39,7 @@ public class JobsUserRegistrationSessionBean extends BaseDatabaseBean implements
        private static final long serialVersionUID = 12_348_958_986_818_627L;
 
        /**
-        * User bean
+        * User EJB
         */
        @EJB
        private UserSessionBeanRemote userBean;
index 669d2d428581af4b63983315c9d98dfd6b9bb458..3dbe54f2e216574d71acb516891c2a3912833d26 100644 (file)
@@ -37,7 +37,7 @@ import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
 
 /**
- * A user bean
+ * A user EJB
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
@@ -50,7 +50,7 @@ public class JobsUserSessionBean extends BaseDatabaseBean implements UserSession
        private static final long serialVersionUID = 542_145_347_916L;
 
        /**
-        * Registration bean
+        * Registration EJB
         */
        @EJB
        private UserRegistrationSessionBeanRemote registerBean;