From 9390202452375474125088a4bf7e603676f672c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 10 Jun 2017 23:23:48 +0200 Subject: [PATCH] Please cherry-pick: - really have to call super(), else anything there, like logger bean, will not be initialized MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../FinancialsAdminContactSessionBean.java | 2 + .../contact/FinancialsContactSessionBean.java | 2 + ...inancialsAdminContactPhoneSessionBean.java | 10 +- .../data/FinancialsCountrySingletonBean.java | 8 + .../FinancialsResendLinkSessionBean.java | 8 + .../FinancialsEmailDeliveryMessageBean.java | 3 + ...ancialsAdminMobileProviderSessionBean.java | 8 + ...FinancialsMobileProviderSingletonBean.java | 8 + .../FinancialsAdminPhoneSessionBean.java | 8 + .../phone/FinancialsPhoneSessionBean.java | 2 + .../FinancialsUserEmailChangeSessionBean.java | 2 + .../login/FinancialsUserLoginSessionBean.java | 10 +- ...FinancialsUserRegistrationSessionBean.java | 8 + .../user/FinancialsAdminUserSessionBean.java | 2 + .../model/user/FinancialsUserSessionBean.java | 2 + .../FinancialsUserActivityLogMessageBean.java | 151 ++++++++++++++++++ ...ancialsUserPasswordHistorySessionBean.java | 2 + 17 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 src/java/org/mxchange/jusercore/model/user/activity/FinancialsUserActivityLogMessageBean.java diff --git a/src/java/org/mxchange/jcontacts/contact/FinancialsAdminContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/FinancialsAdminContactSessionBean.java index 71f2303..849b860 100644 --- a/src/java/org/mxchange/jcontacts/contact/FinancialsAdminContactSessionBean.java +++ b/src/java/org/mxchange/jcontacts/contact/FinancialsAdminContactSessionBean.java @@ -39,6 +39,8 @@ public class FinancialsAdminContactSessionBean extends BaseFinancialsDatabaseBea * Default constructor */ public FinancialsAdminContactSessionBean () { + // Call super constructor + super(); } @Override diff --git a/src/java/org/mxchange/jcontacts/contact/FinancialsContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/FinancialsContactSessionBean.java index 48ef52f..a0975b5 100644 --- a/src/java/org/mxchange/jcontacts/contact/FinancialsContactSessionBean.java +++ b/src/java/org/mxchange/jcontacts/contact/FinancialsContactSessionBean.java @@ -44,6 +44,8 @@ public class FinancialsContactSessionBean extends BaseFinancialsDatabaseBean imp * Default constructor */ public FinancialsContactSessionBean () { + // Call super constructor + super(); } @Override diff --git a/src/java/org/mxchange/jcontacts/phone/FinancialsAdminContactPhoneSessionBean.java b/src/java/org/mxchange/jcontacts/phone/FinancialsAdminContactPhoneSessionBean.java index 0d85909..bab50ed 100644 --- a/src/java/org/mxchange/jcontacts/phone/FinancialsAdminContactPhoneSessionBean.java +++ b/src/java/org/mxchange/jcontacts/phone/FinancialsAdminContactPhoneSessionBean.java @@ -21,9 +21,9 @@ import java.util.GregorianCalendar; import java.util.Objects; import javax.ejb.EJB; import javax.ejb.Stateless; -import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.ContactSessionBeanRemote; +import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean; import org.mxchange.jphone.exceptions.PhoneNumberAlreadyLinkedException; import org.mxchange.jphone.exceptions.PhoneNumberNotLinkedException; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; @@ -49,6 +49,14 @@ public class FinancialsAdminContactPhoneSessionBean extends BaseFinancialsDataba @EJB private ContactSessionBeanRemote contactBean; + /** + * Default constructor + */ + public FinancialsAdminContactPhoneSessionBean () { + // Call super constructor + super(); + } + @Override public Contact linkExistingFaxNumberWithContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException { // Trace message diff --git a/src/java/org/mxchange/jcountry/data/FinancialsCountrySingletonBean.java b/src/java/org/mxchange/jcountry/data/FinancialsCountrySingletonBean.java index 11810ce..f18462a 100644 --- a/src/java/org/mxchange/jcountry/data/FinancialsCountrySingletonBean.java +++ b/src/java/org/mxchange/jcountry/data/FinancialsCountrySingletonBean.java @@ -40,6 +40,14 @@ public class FinancialsCountrySingletonBean extends BaseDatabaseBean implements */ private static final long serialVersionUID = 15_846_983_298_691_207L; + /** + * Default constructor + */ + public FinancialsCountrySingletonBean () { + // Call super constructor + super(); + } + @Override public Country addCountry (final Country country) throws CountryAlreadyAddedException { // Trace message diff --git a/src/java/org/mxchange/jfinancials/beans/resendlink/FinancialsResendLinkSessionBean.java b/src/java/org/mxchange/jfinancials/beans/resendlink/FinancialsResendLinkSessionBean.java index 1e88731..4c94bc3 100644 --- a/src/java/org/mxchange/jfinancials/beans/resendlink/FinancialsResendLinkSessionBean.java +++ b/src/java/org/mxchange/jfinancials/beans/resendlink/FinancialsResendLinkSessionBean.java @@ -60,6 +60,14 @@ public class FinancialsResendLinkSessionBean extends BaseFinancialsDatabaseBean @EJB private UserSessionBeanRemote userBean; + /** + * Default constructor + */ + public FinancialsResendLinkSessionBean () { + // Call super constructor + super(); + } + @Override public void resendConfirmationLink (final User user, final Locale locale, final String baseUrl) throws UserNotFoundException, UserStatusLockedException, UserStatusConfirmedException { // Log trace message diff --git a/src/java/org/mxchange/jfinancials/mailer/model/delivery/FinancialsEmailDeliveryMessageBean.java b/src/java/org/mxchange/jfinancials/mailer/model/delivery/FinancialsEmailDeliveryMessageBean.java index a562f4f..6d69344 100644 --- a/src/java/org/mxchange/jfinancials/mailer/model/delivery/FinancialsEmailDeliveryMessageBean.java +++ b/src/java/org/mxchange/jfinancials/mailer/model/delivery/FinancialsEmailDeliveryMessageBean.java @@ -61,6 +61,9 @@ public class FinancialsEmailDeliveryMessageBean extends BaseFinancialsDatabaseBe * Default constructor */ public FinancialsEmailDeliveryMessageBean () { + // Call super constructor + super(); + // Init mailer instance this.mailer = new FinancialsMailer(); } diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/FinancialsAdminMobileProviderSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/FinancialsAdminMobileProviderSessionBean.java index a6b0014..3e93d0a 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/FinancialsAdminMobileProviderSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/FinancialsAdminMobileProviderSessionBean.java @@ -35,6 +35,14 @@ public class FinancialsAdminMobileProviderSessionBean extends BaseDatabaseBean i */ private static final long serialVersionUID = 15_846_983_298_691_207L; + /** + * Default constructor + */ + public FinancialsAdminMobileProviderSessionBean () { + // Call super constructor + super(); + } + @Override public MobileProvider addMobileProvider (final MobileProvider mobileProvider) throws MobileProviderAlreadyAddedException { // Log trace message diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/FinancialsMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/FinancialsMobileProviderSingletonBean.java index c800c75..14277fd 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/FinancialsMobileProviderSingletonBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/FinancialsMobileProviderSingletonBean.java @@ -37,6 +37,14 @@ public class FinancialsMobileProviderSingletonBean extends BaseDatabaseBean impl */ private static final long serialVersionUID = 15_846_983_298_691_207L; + /** + * Default constructor + */ + public FinancialsMobileProviderSingletonBean () { + // Call super constructor + super(); + } + @Override @SuppressWarnings ("unchecked") public List allMobileProvider () { diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/FinancialsAdminPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/FinancialsAdminPhoneSessionBean.java index 7936651..ffb2801 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/FinancialsAdminPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/FinancialsAdminPhoneSessionBean.java @@ -37,6 +37,14 @@ public class FinancialsAdminPhoneSessionBean extends BaseFinancialsDatabaseBean */ private static final long serialVersionUID = 18_597_165_817_401_853L; + /** + * Default constructor + */ + public FinancialsAdminPhoneSessionBean () { + // Call super constructor + super(); + } + @Override public void deleteFaxData (final DialableFaxNumber faxNumber) { // Trace message diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/FinancialsPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/FinancialsPhoneSessionBean.java index cab2cc2..2d695d9 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/FinancialsPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/FinancialsPhoneSessionBean.java @@ -47,6 +47,8 @@ public class FinancialsPhoneSessionBean extends BaseDatabaseBean implements Phon * Default constructor */ public FinancialsPhoneSessionBean () { + // Call super constructor + super(); } @SuppressWarnings ("unchecked") diff --git a/src/java/org/mxchange/jusercore/model/email_address/FinancialsUserEmailChangeSessionBean.java b/src/java/org/mxchange/jusercore/model/email_address/FinancialsUserEmailChangeSessionBean.java index 87a0e48..002509c 100644 --- a/src/java/org/mxchange/jusercore/model/email_address/FinancialsUserEmailChangeSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/email_address/FinancialsUserEmailChangeSessionBean.java @@ -54,6 +54,8 @@ public class FinancialsUserEmailChangeSessionBean extends BaseFinancialsDatabase * Default constructor */ public FinancialsUserEmailChangeSessionBean () { + // Call super constructor + super(); } @Override diff --git a/src/java/org/mxchange/jusercore/model/login/FinancialsUserLoginSessionBean.java b/src/java/org/mxchange/jusercore/model/login/FinancialsUserLoginSessionBean.java index d56e318..ab18289 100644 --- a/src/java/org/mxchange/jusercore/model/login/FinancialsUserLoginSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/login/FinancialsUserLoginSessionBean.java @@ -36,7 +36,7 @@ import org.mxchange.jusercore.model.user.status.UserAccountStatus; *

* @author Roland Häder */ -@Stateless (name = "login", description = "A bean handling the user login for Addressbook project") +@Stateless (name = "login", description = "A bean handling the user login for Financials project") public class FinancialsUserLoginSessionBean extends BaseDatabaseBean implements UserLoginSessionBeanRemote { /** @@ -56,6 +56,14 @@ public class FinancialsUserLoginSessionBean extends BaseDatabaseBean implements @EJB private UserSessionBeanRemote userBean; + /** + * Default constructor + */ + public FinancialsUserLoginSessionBean () { + // Call super constructor + super(); + } + @Override public User validateUserAccountStatus (final LoginContainer container) throws UserNotFoundException, UserStatusLockedException, UserStatusUnconfirmedException, UserPasswordMismatchException { // Trace message diff --git a/src/java/org/mxchange/jusercore/model/register/FinancialsUserRegistrationSessionBean.java b/src/java/org/mxchange/jusercore/model/register/FinancialsUserRegistrationSessionBean.java index ac57a4e..32cf506 100644 --- a/src/java/org/mxchange/jusercore/model/register/FinancialsUserRegistrationSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/register/FinancialsUserRegistrationSessionBean.java @@ -60,6 +60,14 @@ public class FinancialsUserRegistrationSessionBean extends BaseFinancialsDatabas @EJB private UserSessionBeanRemote userBean; + /** + * Default constructor + */ + public FinancialsUserRegistrationSessionBean () { + // Call super constructor + super(); + } + @Override public String generateConfirmationKey (final User user) { // Trace message diff --git a/src/java/org/mxchange/jusercore/model/user/FinancialsAdminUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/FinancialsAdminUserSessionBean.java index 6771ae3..f20b64c 100644 --- a/src/java/org/mxchange/jusercore/model/user/FinancialsAdminUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/FinancialsAdminUserSessionBean.java @@ -64,6 +64,8 @@ public class FinancialsAdminUserSessionBean extends BaseFinancialsDatabaseBean i * Default constructor */ public FinancialsAdminUserSessionBean () { + // Call super constructor + super(); } @Override diff --git a/src/java/org/mxchange/jusercore/model/user/FinancialsUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/FinancialsUserSessionBean.java index b0aec65..d4c7c35 100644 --- a/src/java/org/mxchange/jusercore/model/user/FinancialsUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/FinancialsUserSessionBean.java @@ -66,6 +66,8 @@ public class FinancialsUserSessionBean extends BaseFinancialsDatabaseBean implem * Default constructor */ public FinancialsUserSessionBean () { + // Call super constructor + super(); } @Override diff --git a/src/java/org/mxchange/jusercore/model/user/activity/FinancialsUserActivityLogMessageBean.java b/src/java/org/mxchange/jusercore/model/user/activity/FinancialsUserActivityLogMessageBean.java new file mode 100644 index 0000000..cb5d46e --- /dev/null +++ b/src/java/org/mxchange/jusercore/model/user/activity/FinancialsUserActivityLogMessageBean.java @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * 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.jusercore.model.user.activity; + +import java.io.Serializable; +import java.text.MessageFormat; +import javax.ejb.ActivationConfigProperty; +import javax.ejb.MessageDriven; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.ObjectMessage; +import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean; +import org.mxchange.jusercore.model.user.User; + +/** + * A message-driven bean for adding user activity log + *

+ * @author Roland Häder + */ +@MessageDriven ( + name = "userActivityLog", + description = "A message-driven bean for adding user activity log", + activationConfig = { + @ActivationConfigProperty ( + propertyName = "destinationLookup", + propertyValue = "jms/addressbook-user-activity-log" + ), + @ActivationConfigProperty ( + propertyName = "destinationType", + propertyValue = "javax.jms.Queue" + ) + } +) +public class FinancialsUserActivityLogMessageBean extends BaseFinancialsDatabaseBean implements MessageListener { + + /** + * Serial number + */ + private static final long serialVersionUID = 14_920_686_785_732_054L; + + /** + * Default constructor + */ + public FinancialsUserActivityLogMessageBean () { + // Call super constructor + super(); + } + + @Override + public void onMessage (final Message message) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.onMessage: message={1} - CALLED!", this.getClass().getSimpleName(), message)); //NOI18N + + // The parameter should be valid + if (null == message) { + // Throw NPE + throw new NullPointerException("message is null"); //NOI18N + } else if (!(message instanceof ObjectMessage)) { + // Not implementing right interface + throw new IllegalArgumentException(MessageFormat.format("message={0} does not implemented ObjectMessage", message)); //NOI18N + } + + // Securely cast it + ObjectMessage objectMessage = (ObjectMessage) message; + + // Init variable + Serializable serializable; + + try { + // Get object from message + serializable = objectMessage.getObject(); + } catch (final JMSException ex) { + // Log it and don't continue any further + this.getLoggerBeanLocal().logException(ex); + return; + } + + // Debug message + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.onMessage: serializable={1}", this.getClass().getSimpleName(), serializable)); //NOI18N + + // Okay, is it the right interface? + if (null == serializable) { + // Throw NPE + throw new NullPointerException("serializable is null"); //NOI18N + } else if (!(serializable instanceof LogableUserActivity)) { + // Not correct object send + throw new IllegalArgumentException(MessageFormat.format("serializable={0} does not implement LogableUserActivity", serializable)); //NOI18N + } + + // Securely cast it + LogableUserActivity userActivity = (LogableUserActivity) serializable; + + // Should be valid + if (null == userActivity) { + // Throw NPE + throw new NullPointerException("userActivity is null"); //NOI18N + } else if (userActivity.getActivityId() instanceof Long) { + // Id number should not be set + throw new IllegalArgumentException(MessageFormat.format("userActivity.activityId={0} should be null", userActivity.getActivityId())); //NOI18N + } else if (userActivity.getActivityUser() == null) { + // Throw NPE again + throw new NullPointerException("userActivity.activityUser is null"); //NOI18N + } else if (userActivity.getActivityUser().getUserId() == null) { + // Throw NPE again + throw new NullPointerException("userActivity.activityUser.userId is null"); //NOI18N + } else if (userActivity.getActivityUser().getUserId() < 1) { + // Throw NPE again + throw new IllegalArgumentException(MessageFormat.format("userActivity.activityUser.userId={0} is not valid", userActivity.getActivityUser().getUserId())); //NOI18N + } else if (userActivity.getActivityType() == null) { + // Throw again ... + throw new NullPointerException("userActivity.activityType is null"); //NOI18N + } else if (userActivity.getActivityType().isEmpty()) { + // Empty type + throw new IllegalArgumentException("userActivity.activityType is empty"); //NOI18N + } else if ((userActivity.getActivityMessage() instanceof String) && (userActivity.getActivityMessage().isEmpty())) { + // Set but empty message + throw new IllegalArgumentException("userActivity.activityMessage is empty"); //NOI18N + } else if (userActivity.getActivityTimestamp() == null) { + // Throw NPE again + throw new NullPointerException("userActivity.activityTimestamp is null"); //NOI18N + } + + // Make user instance managed + User managedUser = this.getManagedUser(userActivity.getActivityUser()); + + // Set it back + userActivity.setActivityUser(managedUser); + + // All fine, persist it + this.getEntityManager().persist(userActivity); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.onMessage: EXIT!", this.getClass().getSimpleName())); //NOI18N + } + +} diff --git a/src/java/org/mxchange/jusercore/model/user/password_history/FinancialsUserPasswordHistorySessionBean.java b/src/java/org/mxchange/jusercore/model/user/password_history/FinancialsUserPasswordHistorySessionBean.java index 9cda8e5..531efc3 100644 --- a/src/java/org/mxchange/jusercore/model/user/password_history/FinancialsUserPasswordHistorySessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/password_history/FinancialsUserPasswordHistorySessionBean.java @@ -40,6 +40,8 @@ public class FinancialsUserPasswordHistorySessionBean extends BaseFinancialsData * Default constructor */ public FinancialsUserPasswordHistorySessionBean () { + // Call super constructor + super(); } @Override -- 2.39.5