From 7acbc3efa81f7ebc503fe0b7d82888d4c4ee1fd6 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 13 Apr 2016 20:49:33 +0200 Subject: [PATCH] Continued a bit: - 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) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- lib/juser-core.jar | Bin 40612 -> 40648 bytes .../data/JobsCountrySingletonBean.java | 2 +- .../JobsMobileProviderSingletonBean.java | 2 +- ...PizzaAdminMobileProviderSingletonBean.java | 91 ++++++++++++++++++ .../model/login/JobsUserLoginSessionBean.java | 6 +- .../JobsUserRegistrationSessionBean.java | 2 +- .../model/user/JobsUserSessionBean.java | 4 +- 7 files changed, 99 insertions(+), 8 deletions(-) create mode 100644 src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSingletonBean.java diff --git a/lib/juser-core.jar b/lib/juser-core.jar index 96bfe0721f41190085145aee77d4a15b1ea9f133..5d787e51c0cd470c74c4d07163a37464dcb86a0d 100644 GIT binary patch delta 1606 zcmZ9M`%e^C6vw|av+OLxEa2)2@=)5wvR$mSfC2)o0i-;Zms;prKo&*hAum~U7h6F5 z#Wq^-@{olEu~w>0TH`j0hS=608k_X_OOvKGsXw*$AF#EL*mLiYH0f?KpYOTnoO{nb zvwN=Gk-xYjTWcy5lLlCT%G>8AtPaIR$XQg12|sQT_}jt3Ql$*R1}R@~PAU|9Ams`s z$uA2w$t8lTii3SC+lBsB&RO$0*mtfCtVz*?-KkWr#TE$urIZVnnu<9?@0cD+Lio*{ zW+5KxrN&BTbc!NY>elTw#0MK1441aCUKXyy@%1JlK1s?k#N(6G@5r4$q(`z01?xmcDPGzrDMy(A(a1xV1k|f_2}3=TK**r+2@nrHd}o8M-wX zDMz_6t0JId4)g4*lRf63js+~TC%zOt_$rc@bd+LV#bq7u;);&< za8<`L-q&#r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17nSBL^PgRro+QAD1Y~z!3XY(f}IOpfnxj34~?5v%=Q$c=yAAcA? ZTp!*XV^1nktfV87eXty2Y#Zm^e*tGh-fRE> diff --git a/src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java b/src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java index 7d05693..26f7786 100644 --- a/src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java +++ b/src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java @@ -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 *

* @author Roland Haeder */ diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java index 7340569..6f7677d 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java @@ -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 *

* @author Roland Haeder */ 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 index 0000000..4ba7008 --- /dev/null +++ b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSingletonBean.java @@ -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 . + */ +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 + *

+ * @author Roland Haeder + */ +@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; + } + +} diff --git a/src/java/org/mxchange/jusercore/model/login/JobsUserLoginSessionBean.java b/src/java/org/mxchange/jusercore/model/login/JobsUserLoginSessionBean.java index 2e0793c..fa34ff2 100644 --- a/src/java/org/mxchange/jusercore/model/login/JobsUserLoginSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/login/JobsUserLoginSessionBean.java @@ -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 *

* @author Roland Haeder */ @@ -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; diff --git a/src/java/org/mxchange/jusercore/model/register/JobsUserRegistrationSessionBean.java b/src/java/org/mxchange/jusercore/model/register/JobsUserRegistrationSessionBean.java index 4228620..61dfec5 100644 --- a/src/java/org/mxchange/jusercore/model/register/JobsUserRegistrationSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/register/JobsUserRegistrationSessionBean.java @@ -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; diff --git a/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java index 669d2d4..3dbe54f 100644 --- a/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java @@ -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 *

* @author Roland Haeder */ @@ -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; -- 2.39.5