From: Roland Häder Date: Thu, 4 Aug 2016 12:36:20 +0000 (+0200) Subject: Continued with logging: (please cherry-pick) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=32255b8bf1cb6b3974b9a661368b17762257ce6e;p=jjobs-ejb.git Continued with logging: (please cherry-pick) - added simple class name to all log messages - added possible missing log messages Signed-off-by: Roland Häder Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jcontacts/contact/JobsContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/JobsContactSessionBean.java index db7dce1..8eafc5c 100644 --- a/src/java/org/mxchange/jcontacts/contact/JobsContactSessionBean.java +++ b/src/java/org/mxchange/jcontacts/contact/JobsContactSessionBean.java @@ -17,6 +17,7 @@ package org.mxchange.jcontacts.contact; import java.text.MessageFormat; +import java.util.GregorianCalendar; import java.util.Iterator; import java.util.List; import java.util.Objects; @@ -49,13 +50,41 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont @Override public Contact addContact (final Contact contact) throws ContactAlreadyAddedException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addContact: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N + + // Is the instance set? + if (null == contact) { + // Throw NPE + throw new NullPointerException("contact is null"); //NOI18N + } else if (contact.getContactId() != null) { + // Should be null + throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} - is not null", contact.getContactId())); //NOI18N + } + + // Set created timestamp + contact.setContactCreated(new GregorianCalendar()); + + // Set all created timestamps, if instance is there + this.setAllContactPhoneEntriesCreated(contact); + + // Persist it + this.getEntityManager().persist(contact); + + // Flush it to get contactId set + this.getEntityManager().flush(); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addContact: contact.contactId={1} after persisting - EXIT!", this.getClass().getSimpleName(), contact.getContactId())); //NOI18N + + // Return it + return contact; } @Override public Contact findContactByEmailAddress (final String emailAddress) throws ContactNotFoundException { // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("findContactByEmailAddress: emailAddress={0} - CALLED!", emailAddress)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: emailAddress={1} - CALLED!", this.getClass().getSimpleName(), emailAddress)); //NOI18N // The parameter must be valid if (null == emailAddress) { @@ -81,14 +110,14 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont contact = (Contact) query.getSingleResult(); // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("findContactByEmailAddress: Found contact={0}", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: Found contact={1}", this.getClass().getSimpleName(), contact)); //NOI18N } catch (final NoResultException ex) { // No result found throw new ContactNotFoundException(emailAddress, ex); } // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("findContactByEmailAddress: contact={0} - EXIT!", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: contact={1} - EXIT!", this.getClass().getSimpleName(), contact)); //NOI18N // Return found instance return contact; @@ -97,7 +126,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont @Override public Contact findContactById (final Long contactId) throws ContactNotFoundException { // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("findContactById: contactId={0} - CALLED!", contactId)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: contactId={1} - CALLED!", this.getClass().getSimpleName(), contactId)); //NOI18N // The parameter must be valid if (null == contactId) { @@ -123,14 +152,14 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont contact = (Contact) query.getSingleResult(); // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("findContactById: Found contact={0}", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: Found contact={1}", this.getClass().getSimpleName(), contact)); //NOI18N } catch (final NoResultException ex) { // No result found throw new ContactNotFoundException(contactId, ex); } // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("findContactById: contact={0} - EXIT!", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: contact={1} - EXIT!", this.getClass().getSimpleName(), contact)); //NOI18N // Return found instance return contact; @@ -140,7 +169,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont @SuppressWarnings ("unchecked") public List getAllContacts () { // Log trace message - this.getLoggerBeanLocal().logTrace("getAllContacts - CALLED!"); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getAllContacts - CALLED!", this.getClass().getSimpleName())); //NOI18N // Create query instance Query query = this.getEntityManager().createNamedQuery("AllContacts", UserContact.class); //NOI18N @@ -149,7 +178,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont List contacts = query.getResultList(); // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("getAllContacts: contacts.size()={0} - EXIT!", contacts.size())); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getAllContacts: contacts.size()={1} - EXIT!", this.getClass().getSimpleName(), contacts.size())); //NOI18N // Return it return contacts; @@ -159,7 +188,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont @SuppressWarnings ("unchecked") public List getEmailAddressList () { // Log trace message - this.getLoggerBeanLocal().logTrace("getEmailAddressList - CALLED!"); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList - CALLED!", this.getClass().getSimpleName())); //NOI18N // Create query instance Query query = this.getEntityManager().createNamedQuery("AllContactEmailAddresses", String.class); //NOI18N @@ -168,7 +197,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont List emailAddresses = query.getResultList(); // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("getEmailAddressList: emailAddresses.size()={0} - EXIT!", emailAddresses.size())); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: emailAddresses.size()={1} - EXIT!", this.getClass().getSimpleName(), emailAddresses.size())); //NOI18N // Return it return emailAddresses; @@ -177,15 +206,15 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont @Override public boolean isEmailAddressRegistered (final String emailAddress) { // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("isEmailAddressRegistered: emailAddress={0} - CALLED!", emailAddress)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: emailAddress={1} - CALLED!", this.getClass().getSimpleName(), emailAddress)); //NOI18N // The email address should be valid if (null == emailAddress) { // Is null - throw new NullPointerException("emailAddress is null"); + throw new NullPointerException("emailAddress is null"); //NOI18N } else if (emailAddress.isEmpty()) { // Is empty - throw new IllegalArgumentException("emailAddress is empty"); + throw new IllegalArgumentException("emailAddress is empty"); //NOI18N } // Default is not found @@ -196,7 +225,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont Contact contact = this.findContactByEmailAddress(emailAddress); // Log debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("isEmailAddressRegistered: Found contact={0} for emailAddress={1}", contact, emailAddress)); + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: Found contact={1} for emailAddress={2}", this.getClass().getSimpleName(), contact, emailAddress)); //NOI18N // It is found ... isFound = true; @@ -205,7 +234,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont } // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("isEmailAddressRegistered: isFound={0} - EXIT!", isFound)); + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: isFound={1} - EXIT!", this.getClass().getSimpleName(), isFound)); //NOI18N // Return status return isFound; @@ -214,7 +243,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont @Override public Contact lookupContact (final Contact contact) { // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("isContactFound: contact={0} - CALLED!", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactFound: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N // Parameter should be valid if (null == contact) { @@ -239,7 +268,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont // Is the list empty? if (contacts.isEmpty()) { // Then abort here - this.getLoggerBeanLocal().logTrace("isContactFound: No contacts registered, returning 'false' ..."); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactFound: No contacts registered, returning NULL ...", this.getClass().getSimpleName())); //NOI18N return null; } @@ -254,7 +283,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont // Is same contact? if ((Objects.equals(contact, next)) || (ContactUtils.isSameContact(contact, next))) { // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("isContactFound: Found same contact, id={0}", next.getContactId())); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isContactFound: Found same contact: contactId={1}", this.getClass().getSimpleName(), next.getContactId())); //NOI18N // Found it foundContact = next; @@ -263,7 +292,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont } // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("isContactFound: foundContact={0} - EXIT!", foundContact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactFound: foundContact={1} - EXIT!", this.getClass().getSimpleName(), foundContact)); //NOI18N // Return found contact return foundContact; @@ -272,7 +301,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont @Override public Contact updateContactData (final Contact contact, final boolean isCellphoneUnlinked, final boolean isLandlineUnlinked, final boolean isFaxUnlinked) { // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("updateContactData: contact={0},isCellphoneUnlinked={1},isLandlineUnlinked={2},isFaxUnlinked={3} - CALLED!", contact, isCellphoneUnlinked, isLandlineUnlinked, isFaxUnlinked)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: contact={1},isCellphoneUnlinked={2},isLandlineUnlinked={3},isFaxUnlinked={4} - CALLED!", this.getClass().getSimpleName(), contact, isCellphoneUnlinked, isLandlineUnlinked, isFaxUnlinked)); //NOI18N // The contact instance must be valid if (null == contact) { @@ -293,7 +322,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont Contact detachedContact = this.mergeContactData(contact); // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("updateContactData: detachedContact={0} - EXIT!", detachedContact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: detachedContact={1} - EXIT!", this.getClass().getSimpleName(), detachedContact)); //NOI18N // Return it return detachedContact; @@ -302,7 +331,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont @Override public Contact updateContactData (final Contact contact) { // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("updateContactData: contact={0} - CALLED!", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N // The contact instance must be valid if (null == contact) { @@ -325,7 +354,7 @@ public class JobsContactSessionBean extends BaseJobsDatabaseBean implements Cont Contact detachedContact = this.updateContactData(contact, isCellphoneUnlinked, isLandLineUnlinked, isFaxUnlinked); // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("updateContactData: detachedContact={0} - EXIT!", detachedContact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: detachedContact={1} - EXIT!", this.getClass().getSimpleName(), detachedContact)); //NOI18N // Return it return detachedContact; diff --git a/src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java b/src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java index f6d4678..c75f469 100644 --- a/src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java +++ b/src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java @@ -42,6 +42,9 @@ public class JobsCountrySingletonBean extends BaseJobsDatabaseBean implements Co @Override public Country addCountry (final Country country) throws CountryAlreadyAddedException { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addCountry: country={1} - CALLED!", this.getClass().getSimpleName(), country)); //NOI18N + // Is it already there? if (null == country) { // Throw NPE @@ -69,6 +72,9 @@ public class JobsCountrySingletonBean extends BaseJobsDatabaseBean implements Co // Flush it to get id number back, maybe it is directly needed? this.getEntityManager().flush(); + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addCountry: country={1} - EXIT!", this.getClass().getSimpleName(), country)); //NOI18N + // Return updated instance return country; } @@ -76,11 +82,20 @@ public class JobsCountrySingletonBean extends BaseJobsDatabaseBean implements Co @Override @SuppressWarnings ("unchecked") public List allCountries () { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCountries: CALLED!", this.getClass().getSimpleName())); //NOI18N + // Init query Query query = this.getEntityManager().createNamedQuery("AllCountries", CountryData.class); //NOI18N + // Get list + List countries = query.getResultList(); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCountries: countries.size()={1} - EXIT!", this.getClass().getSimpleName(), countries.size())); //NOI18N + // Return it - return query.getResultList(); + return countries; } /** diff --git a/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkSessionBean.java b/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkSessionBean.java index 1eeeb9a..ee8ebb7 100644 --- a/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkSessionBean.java @@ -43,7 +43,7 @@ public class JobsResendLinkSessionBean extends BaseJobsDatabaseBean implements R @Override public void resendConfirmationLink (final User user, final Locale locale, final String baseUrl) { // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("resendConfirmationLink: user={0},locale={1},baseUrl={2} - CALLED!", user, locale, baseUrl)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.resendConfirmationLink: user={1},locale={2},baseUrl={3} - CALLED!", this.getClass().getSimpleName(), user, locale, baseUrl)); //NOI18N // The user instance should be valid if (null == user) { @@ -84,7 +84,7 @@ public class JobsResendLinkSessionBean extends BaseJobsDatabaseBean implements R this.sendEmail("Resend confirmation link", "resend_confirmation_link", emailAddress, user, baseUrl); //NOI18N // Log trace message - this.getLoggerBeanLocal().logTrace("resendConfirmationLink: CALLED!"); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.resendConfirmationLink: EXIT!", this.getClass().getSimpleName())); //NOI18N } } diff --git a/src/java/org/mxchange/jmailee/model/delivery/JobsEmailDeliveryMessageBean.java b/src/java/org/mxchange/jmailee/model/delivery/JobsEmailDeliveryMessageBean.java index 48c4ec9..46b35a0 100644 --- a/src/java/org/mxchange/jmailee/model/delivery/JobsEmailDeliveryMessageBean.java +++ b/src/java/org/mxchange/jmailee/model/delivery/JobsEmailDeliveryMessageBean.java @@ -76,13 +76,13 @@ public class JobsEmailDeliveryMessageBean extends BaseJobsDatabaseBean implement @PostConstruct public void init () { // Trace message - this.getLoggerBeanLocal().logTrace("init: CALLED!"); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.init: CALLED!", this.getClass().getSimpleName())); //NOI18N // Try to load bundle ResourceBundle bundle = ResourceBundle.getBundle(this.configFile); // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("init: bundle={0}", bundle)); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.init: bundle={1}", this.getClass().getSimpleName(), bundle)); //NOI18N // The bunble should be valid if (null == bundle) { @@ -98,7 +98,7 @@ public class JobsEmailDeliveryMessageBean extends BaseJobsDatabaseBean implement // Loop through all for (final String key : bundle.keySet()) { // Log debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("init: key={0}", key)); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.init: key={1}", this.getClass().getSimpleName(), key)); //NOI18N // Get string from bundle and set it in properties properties.put(key, bundle.getString(key)); @@ -109,13 +109,13 @@ public class JobsEmailDeliveryMessageBean extends BaseJobsDatabaseBean implement this.mailer.init(properties); // Trace message - this.getLoggerBeanLocal().logTrace("init: EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.init: EXIT!", this.getClass().getSimpleName())); //NOI18N } @Override public void onMessage (final Message message) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("onMessage: message={0} - CALLED!", message)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.onMessage: message={1} - CALLED!", this.getClass().getSimpleName(), message)); //NOI18N // The parameter should be valid if (null == message) { @@ -142,7 +142,7 @@ public class JobsEmailDeliveryMessageBean extends BaseJobsDatabaseBean implement } // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("onMessage: serializable={0}", serializable)); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.onMessage: serializable={1}", this.getClass().getSimpleName(), serializable)); //NOI18N // Okay, is it the right interface? if (null == serializable) { @@ -187,7 +187,7 @@ public class JobsEmailDeliveryMessageBean extends BaseJobsDatabaseBean implement } // Trace message - this.getLoggerBeanLocal().logTrace("onMessage - EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.onMessage - EXIT!", this.getClass().getSimpleName())); //NOI18N } } diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsAdminMobileProviderSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsAdminMobileProviderSessionBean.java index b74f248..938b138 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsAdminMobileProviderSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsAdminMobileProviderSessionBean.java @@ -38,7 +38,7 @@ public class JobsAdminMobileProviderSessionBean extends BaseJobsDatabaseBean imp @Override public MobileProvider addMobileProvider (final MobileProvider mobileProvider) throws MobileProviderAlreadyAddedException { // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("addMobileProvider: mobileProvider={0} - CALLED!", mobileProvider)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addMobileProvider: mobileProvider={1} - CALLED!", this.getClass().getSimpleName(), mobileProvider)); //NOI18N // Is the instance valid? if (null == mobileProvider) { @@ -80,7 +80,7 @@ public class JobsAdminMobileProviderSessionBean extends BaseJobsDatabaseBean imp this.getEntityManager().flush(); // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("addMobileProvider: mobileProvider.providerId={0} - EXIT!", mobileProvider.getProviderId())); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addMobileProvider: mobileProvider.providerId={1} - EXIT!", this.getClass().getSimpleName(), mobileProvider.getProviderId())); //NOI18N // Return updated return mobileProvider; diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java index 80fe7f1..3ac72b9 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.jphone.phonenumbers.mobileprovider; +import java.text.MessageFormat; import java.util.List; import javax.ejb.Singleton; import javax.ejb.Startup; @@ -39,11 +40,20 @@ public class JobsMobileProviderSingletonBean extends BaseJobsDatabaseBean implem @Override @SuppressWarnings ("unchecked") public List allMobileProvider () { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileProvider: CALLED!", this.getClass().getSimpleName())); //NOI18N + // Init query Query query = this.getEntityManager().createNamedQuery("AllMobileProvider", CellphoneProvider.class); //NOI18N + // Get list from it + List mobileProviders = query.getResultList(); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileProvider: mobileProviders.size()={1} - EXIT!", this.getClass().getSimpleName(), mobileProviders.size())); //NOI18N + // Return it - return query.getResultList(); + return mobileProviders; } } diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/JobsAdminContactPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/JobsAdminContactPhoneSessionBean.java index 16ac9a6..bc72928 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/JobsAdminContactPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/JobsAdminContactPhoneSessionBean.java @@ -17,6 +17,7 @@ package org.mxchange.jphone.phonenumbers.phone; import java.text.MessageFormat; +import java.util.LinkedList; import java.util.List; import javax.ejb.Stateless; import javax.persistence.NoResultException; @@ -43,6 +44,9 @@ public class JobsAdminContactPhoneSessionBean extends BaseJobsDatabaseBean imple @Override @SuppressWarnings ("unchecked") public List allContacts (final DialableCellphoneNumber cellPhone) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allContacts: cellPhone={1} - CALLED!", this.getClass().getSimpleName(), cellPhone)); //NOI18N + // The parameter should be valid if (null == cellPhone) { // Throw NPE @@ -56,7 +60,7 @@ public class JobsAdminContactPhoneSessionBean extends BaseJobsDatabaseBean imple } // Init list instance - List contacts = null; + List contacts = new LinkedList<>(); // Get query object from all found contact-cellphone links Query query = this.getEntityManager().createNamedQuery("AllContactsByCellphone", UserContact.class); //NOI18N @@ -71,6 +75,9 @@ public class JobsAdminContactPhoneSessionBean extends BaseJobsDatabaseBean imple // No results found } + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allContacts: contacts.size()={1} - EXIT!", this.getClass().getSimpleName(), contacts.size())); //NOI18N + // Return list return contacts; } diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/JobsPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/JobsPhoneSessionBean.java index 0766c46..4249eed 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/JobsPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/JobsPhoneSessionBean.java @@ -46,6 +46,9 @@ public class JobsPhoneSessionBean extends BaseJobsDatabaseBean implements PhoneS @Override public DialableCellphoneNumber findCellphoneById (final Long cellphoneId) throws PhoneEntityNotFoundException { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCellphoneById: cellphoneId={1} - CALLED!", this.getClass().getSimpleName(), cellphoneId)); //NOI18N + // The id number should be valid if (null == cellphoneId) { // Throw NPE @@ -73,6 +76,9 @@ public class JobsPhoneSessionBean extends BaseJobsDatabaseBean implements PhoneS throw new PhoneEntityNotFoundException(cellphoneId, ex); } + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCellphoneById: cellphone={1} - EXIT!", this.getClass().getSimpleName(), cellphone)); //NOI18N + // Return found instance return cellphone; } diff --git a/src/java/org/mxchange/jusercore/model/email_address/JobsEmailChangeSessionBean.java b/src/java/org/mxchange/jusercore/model/email_address/JobsEmailChangeSessionBean.java index faff72d..6ddb919 100644 --- a/src/java/org/mxchange/jusercore/model/email_address/JobsEmailChangeSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/email_address/JobsEmailChangeSessionBean.java @@ -60,7 +60,7 @@ public class JobsEmailChangeSessionBean extends BaseJobsDatabaseBean implements @SuppressWarnings ("unchecked") public List allQueuedAddresses () { // Trace message - this.getLoggerBeanLocal().logTrace("allQueuedAddressesAsList: CALLED!"); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allQueuedAddresses: CALLED!", this.getClass().getSimpleName())); //NOI18N // Get named query Query query = this.getEntityManager().createNamedQuery("AllEmailAddressChanges", String.class); //NOI18N @@ -69,7 +69,7 @@ public class JobsEmailChangeSessionBean extends BaseJobsDatabaseBean implements List emailAddresses = query.getResultList(); // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("allQueuedAddressesAsList: emailAddresses.size()={0} - EXIT!", emailAddresses.size())); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allQueuedAddresses: emailAddresses.size()={1} - EXIT!", this.getClass().getSimpleName(), emailAddresses.size())); //NOI18N // Return it return emailAddresses; @@ -78,7 +78,7 @@ public class JobsEmailChangeSessionBean extends BaseJobsDatabaseBean implements @Override public void enqueueEmailAddressForChange (final ChangeableEmailAddress emailChange, final String baseUrl) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("enqueueEmailAddressForChange: emailChange={0},baseUrl={1} - CALLED!", emailChange, baseUrl)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.enqueueEmailAddressForChange: emailChange={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), emailChange, baseUrl)); //NOI18N // Email address change should be valid if (null == emailChange) { @@ -109,8 +109,7 @@ public class JobsEmailChangeSessionBean extends BaseJobsDatabaseBean implements this.generateSecureHash(emailChange); // Persist it - //this.getEntityManager().persist(emailChange); - + //@TODO Fix email delivery then allow this: this.getEntityManager().persist(emailChange); // Init variable Address emailAddress; @@ -126,13 +125,13 @@ public class JobsEmailChangeSessionBean extends BaseJobsDatabaseBean implements this.sendEmail("Email change", "email_change", emailAddress, emailChange.getEmailChangeUser(), baseUrl); //NOI18N // Trace message - this.getLoggerBeanLocal().logTrace("enqueueEmailAddressForChange - EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.enqueueEmailAddressForChange - EXIT!", this.getClass().getSimpleName())); //NOI18N } @Override public boolean isEmailAddressEnqueued (final String emailAddress) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("isEmailAddressEnqueued: emailAddress={0} - CALLED!", emailAddress)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressEnqueued: emailAddress={1} - CALLED!", this.getClass().getSimpleName(), emailAddress)); //NOI18N // Create query instance Query query = this.getEntityManager().createNamedQuery("SearchEmailChangeByEmail"); //NOI18N @@ -156,7 +155,7 @@ public class JobsEmailChangeSessionBean extends BaseJobsDatabaseBean implements } // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("isEmailAddressEnqueued: isFound={0} - EXIT!", isFound)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressEnqueued: isFound={1} - EXIT!", this.getClass().getSimpleName(), isFound)); //NOI18N // Return it return isFound; @@ -165,7 +164,7 @@ public class JobsEmailChangeSessionBean extends BaseJobsDatabaseBean implements @Override public void updateEmailAddress (final ChangeableEmailAddress emailAddress) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("updateEmailAddress: emailAddress={0} - CALLED!", emailAddress)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateEmailAddress: emailAddress={1} - CALLED!", this.getClass().getSimpleName(), emailAddress)); //NOI18N // Email address change should be valid if (null == emailAddress) { diff --git a/src/java/org/mxchange/jusercore/model/login/JobsUserLoginSessionBean.java b/src/java/org/mxchange/jusercore/model/login/JobsUserLoginSessionBean.java index dd74ed1..b41d509 100644 --- a/src/java/org/mxchange/jusercore/model/login/JobsUserLoginSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/login/JobsUserLoginSessionBean.java @@ -59,7 +59,7 @@ public class JobsUserLoginSessionBean extends BaseJobsDatabaseBean implements Us @Override public User validateUserAccountStatus (final LoginContainer container) throws UserNotFoundException, UserStatusLockedException, UserStatusUnconfirmedException, UserPasswordMismatchException { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("loginUser: container={0} - CALLED!", container)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.loginUser: container={1} - CALLED!", this.getClass().getSimpleName(), container)); //NOI18N // Check some beans assert(this.userBean instanceof UserSessionBeanRemote) : "this.userBean is not set"; //NOI18N @@ -105,7 +105,7 @@ public class JobsUserLoginSessionBean extends BaseJobsDatabaseBean implements Us } // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("loginUser: updatedUser={0} - EXIT!", updatedUser)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.loginUser: updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N // Return it return updatedUser; @@ -118,7 +118,7 @@ public class JobsUserLoginSessionBean extends BaseJobsDatabaseBean implements Us *

* @param container Container instance holding the user instance and * unencrypted password - * @param updatedUser User instance found for given user name + * @param updatedUser Updated user instance found for given user name *

* @return Whether the password matches */ @@ -138,4 +138,5 @@ public class JobsUserLoginSessionBean extends BaseJobsDatabaseBean implements Us // Is it the same same password? return UserUtils.ifPasswordMatches(container, updatedUser); } + } diff --git a/src/java/org/mxchange/jusercore/model/register/JobsUserRegistrationSessionBean.java b/src/java/org/mxchange/jusercore/model/register/JobsUserRegistrationSessionBean.java index 84677d9..35be0ab 100644 --- a/src/java/org/mxchange/jusercore/model/register/JobsUserRegistrationSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/register/JobsUserRegistrationSessionBean.java @@ -56,7 +56,7 @@ public class JobsUserRegistrationSessionBean extends BaseJobsDatabaseBean implem @Override public String generateConfirmationKey (final User user) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("generateConfirmationKey: user={0} - CALLED!", user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.generateConfirmationKey: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N // user should not be null if (null == user) { @@ -84,7 +84,7 @@ public class JobsUserRegistrationSessionBean extends BaseJobsDatabaseBean implem Contact contact = (Contact) query.getSingleResult(); // Warning message - this.getLoggerBeanLocal().logWarning(MessageFormat.format("generateConfirmationKey: key {0} already found: contact.contactId={1}", key, contact.getContactId())); //NOI18N + this.getLoggerBeanLocal().logWarning(MessageFormat.format("{0}.generateConfirmationKey: key {1} already found: contact.contactId={2}", this.getClass().getSimpleName(), key, contact.getContactId())); //NOI18N } catch (final NoResultException ex) { // Not found, normal case confirmationKey = key; @@ -93,7 +93,7 @@ public class JobsUserRegistrationSessionBean extends BaseJobsDatabaseBean implem } // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("generateConfirmationKey: confirmationKey={0} - EXIT!", confirmationKey)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.generateConfirmationKey: confirmationKey={1} - EXIT!", this.getClass().getSimpleName(), confirmationKey)); //NOI18N // Return it return confirmationKey; @@ -102,7 +102,7 @@ public class JobsUserRegistrationSessionBean extends BaseJobsDatabaseBean implem @Override public boolean isEmailAddressRegistered (final User user) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("isEmailAddressRegistered: user={0} - CALLED!", user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N // Check bean assert (this.userBean instanceof UserSessionBeanRemote) : "this.userBean is not set"; //NOI18N @@ -120,7 +120,7 @@ public class JobsUserRegistrationSessionBean extends BaseJobsDatabaseBean implem @Override public boolean isUserNameRegistered (final User user) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("isUserNameRegistered: user={0} - CALLED!", user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isUserNameRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N // Check bean assert (this.userBean instanceof UserSessionBeanRemote) : "this.userBean is not set"; //NOI18N @@ -138,7 +138,7 @@ public class JobsUserRegistrationSessionBean extends BaseJobsDatabaseBean implem @Override public User registerUser (final User user, final String baseUrl) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("registerUser: user={0},baseUrl={1} - CALLED!", user, baseUrl)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.registerUser: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N // user should not be null if (null == user) { @@ -183,7 +183,7 @@ public class JobsUserRegistrationSessionBean extends BaseJobsDatabaseBean implem this.sendEmail("Registration", "registration", emailAddress, addedUser, baseUrl); //NOI18N // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("registerUser: addedUser={0},addedUser.userId={1} - EXIT!", addedUser, addedUser.getUserId())); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.registerUser: addedUser={1},addedUser.userId={2} - EXIT!", this.getClass().getSimpleName(), addedUser, addedUser.getUserId())); //NOI18N // Return it return addedUser; diff --git a/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java index cd0737b..2cab791 100644 --- a/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java @@ -73,7 +73,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override public User addUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("addUser: user={0} - CALLED!", user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addUser: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N // user should not be null if (null == user) { @@ -107,7 +107,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes this.getEntityManager().flush(); // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("addUser: user={0},user.id={1} - EXIT!", user, user.getUserId())); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addUser: user={1},user.userId={2} - EXIT!", this.getClass().getSimpleName(), user, user.getUserId())); //NOI18N // Return it return user; @@ -117,7 +117,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @SuppressWarnings ("unchecked") public List allMemberPublicVisibleUsers () { // Trace message - this.getLoggerBeanLocal().logTrace("allMemberPublicVisibleUsers: CALLED!"); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMemberPublicVisibleUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N // Get named query Query query = this.getEntityManager().createNamedQuery("AllMemberPublicUsers", LoginUser.class); //NOI18N @@ -131,7 +131,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes List users = query.getResultList(); // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("allMemberPublicVisibleUsers: users.size()={0} - EXIT!", users.size())); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMemberPublicVisibleUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N // Return full list return users; @@ -141,7 +141,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @SuppressWarnings ("unchecked") public List allPublicUsers () { // Trace message - this.getLoggerBeanLocal().logTrace("allPublicUsers: CALLED!"); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allPublicUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N // Get named query Query query = this.getEntityManager().createNamedQuery("AllPublicUsers", LoginUser.class); //NOI18N @@ -154,7 +154,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes List users = query.getResultList(); // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("allPublicUsers: users.size()={0} - EXIT!", users.size())); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allPublicUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N // Return full list return users; @@ -164,7 +164,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @SuppressWarnings ("unchecked") public List allUsers () { // Trace message - this.getLoggerBeanLocal().logTrace("allUsers: CALLED!"); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N // Get named query Query query = this.getEntityManager().createNamedQuery("AllUsers", LoginUser.class); //NOI18N @@ -173,7 +173,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes List users = query.getResultList(); // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("allUsers: users.size()={0} - EXIT!", users.size())); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N // Return full list return users; @@ -182,7 +182,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override public User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("confirmAccount: user={0},baseUrl={1} - CALLED!", user, baseUrl)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.confirmAccount: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N // Parameter must be valid if (null == user) { @@ -228,7 +228,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes this.sendEmail("Account confirmed", "account_confirmed", emailAddress, updatedUser, baseUrl); //NOI18N // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("confirmAccount: updatedUser={0} - EXIT!", updatedUser)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.confirmAccount: updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N // Return updated instance return updatedUser; @@ -237,7 +237,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override public User fillUserData (final User user) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("fillUserData: user={0} - CALLED!", user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fillUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N // user should not be null if (null == user) { @@ -264,7 +264,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes } // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("fillUserData: foundUser={0} - EXIT!", foundUser)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fillUserData: foundUser={1} - EXIT!", this.getClass().getSimpleName(), foundUser)); //NOI18N // Return prepared instance return foundUser; @@ -273,7 +273,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override public User findUserById (final Long userId) throws UserNotFoundException { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("findUserById: userId={0} - CALLED!", userId)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findUserById: userId={1} - CALLED!", this.getClass().getSimpleName(), userId)); //NOI18N // Is the parameter valid? if (null == userId) { @@ -297,7 +297,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes User user = (User) query.getSingleResult(); // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("findUserById: user={0} - EXIT!", user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findUserById: user={1} - EXIT!", this.getClass().getSimpleName(), user)); //NOI18N // Return found user return user; @@ -306,7 +306,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override public String generateRandomUserName () { // Trace message - this.getLoggerBeanLocal().logTrace("generateRandomUserName - CALLED!"); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.generateRandomUserName - CALLED!", this.getClass().getSimpleName())); //NOI18N // Get full list List userList = this.getUserNameList(); @@ -321,7 +321,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes } // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("generateRandomUserName: userName={0} - EXIT!", userName)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.generateRandomUserName: userName={1} - EXIT!", this.getClass().getSimpleName(), userName)); //NOI18N // Found one, so return it return userName; @@ -330,12 +330,18 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override @SuppressWarnings ("unchecked") public List getEmailAddressList () { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: CALLED!", this.getClass().getSimpleName())); //NOI18N + // Get query Query query = this.getEntityManager().createNamedQuery("AllEmailAddresses", String.class); //NOI18N // Get result list List emailAddressList = query.getResultList(); + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: emailAddressList.size()={1} - EXIT!", this.getClass().getSimpleName(), emailAddressList.size())); //NOI18N + // Return it return emailAddressList; } @@ -343,12 +349,18 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override @SuppressWarnings ("unchecked") public List getUserNameList () { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserNameList: CALLED!", this.getClass().getSimpleName())); //NOI18N + // Get query Query query = this.getEntityManager().createNamedQuery("AllUserNames", String.class); //NOI18N // Get result list List userNameList = query.getResultList(); + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserNameList: userNameList.size()={1} - EXIT!", this.getClass().getSimpleName(), userNameList.size())); //NOI18N + // Return it return userNameList; } @@ -356,7 +368,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override public boolean ifUserExists (final User user) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("ifUserExists: user={0} - CALLED!", user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserExists: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N // userId should not be null if (null == user) { @@ -397,7 +409,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes } // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("ifUserExists: Found user {0} - EXIT!", user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserExists: Found user {1} - EXIT!", this.getClass().getSimpleName(), user)); //NOI18N // Found it return true; @@ -406,7 +418,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override public boolean ifUserIdExists (final Long userId) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("ifUserIdExists: userId={0} - CALLED!", userId)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserIdExists: userId={1} - CALLED!", this.getClass().getSimpleName(), userId)); //NOI18N // userId should not be null if (null == userId) { @@ -428,10 +440,10 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes User dummy = (User) query.getSingleResult(); // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserIdExists: dummy.id={0} found.", dummy.getUserId())); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserIdExists: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N } catch (final NoResultException ex) { // Log it - this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserIdExists: getSingleResult() returned no result: {0}", ex)); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserIdExists: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N // User name does not exist return false; @@ -444,7 +456,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes } // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("ifUserIdExists: Found user id {0} - EXIT!", userId)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserIdExists: Found userId={1} - EXIT!", this.getClass().getSimpleName(), userId)); //NOI18N // Found it return true; @@ -453,7 +465,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override public boolean ifUserNameExists (final String userName) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("ifUserNameExists: userName={0} - CALLED!", userName)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserNameExists: userName={1} - CALLED!", this.getClass().getSimpleName(), userName)); //NOI18N // userId should not be null if (null == userName) { @@ -475,17 +487,17 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes User dummy = (User) query.getSingleResult(); // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserNameExists: dummy.id={0} found.", dummy.getUserId())); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserNameExists: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N } catch (final NoResultException ex) { // Log it - this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserNameExists: getSingleResult() returned no result: {0}", ex)); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserNameExists: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N // User name does not exist return false; } // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("ifUserNameExists: Found user name {0} - EXIT!", userName)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserNameExists: Found userName={1} - EXIT!", this.getClass().getSimpleName(), userName)); //NOI18N // Found it return true; @@ -494,7 +506,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override public boolean isEmailAddressRegistered (final User user) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("isEmailAddressRegistered: user={0} - CALLED!", user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N // user should not be null if (null == user) { @@ -513,10 +525,10 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes User dummy = (User) query.getSingleResult(); // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("isEmailAddressRegistered: dummy.id={0} found.", dummy.getUserId())); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N } catch (final NoResultException ex) { // Log it - this.getLoggerBeanLocal().logDebug(MessageFormat.format("isEmailAddressRegistered: getSingleResult() returned no result: {0}", ex)); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N // Email address does not exist return false; @@ -528,6 +540,9 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes throw ex; } + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: Returning true ... - EXIT!", this.getClass().getSimpleName())); //NOI18N + // Found it return true; } @@ -535,7 +550,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override public boolean isUserNameRegistered (final User user) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("isUserNameRegistered: user={0} - CALLED!", user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isUserNameRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N // user should not be null if (null == user) { @@ -554,10 +569,10 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes User dummy = (User) query.getSingleResult(); // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("isUserNameRegistered: dummy.id={0} found.", dummy.getUserId())); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isUserNameRegistered: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N } catch (final NoResultException ex) { // Log it - this.getLoggerBeanLocal().logDebug(MessageFormat.format("isUserNameRegistered: getSingleResult() returned no result: {0}", ex)); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isUserNameRegistered: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N // User name does not exist return false; @@ -569,6 +584,9 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes throw ex; } + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isUserNameRegistered: Returning true ... - EXIT!", this.getClass().getSimpleName())); //NOI18N + // Found it return true; } @@ -576,7 +594,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override public User linkUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("linkUser: user={0} - CALLED!", user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkUser: user={0} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N // user should not be null if (null == user) { @@ -629,8 +647,8 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes // Flush it to get id this.getEntityManager().flush(); - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("linkUser: user.userId={0} - EXIT!", user.getUserId())); //NOI18N + // Log trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkUser: user={1} - EXIT!", this.getClass().getSimpleName(), user)); //NOI18N // Return updated instanc return user; @@ -639,7 +657,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override public User updateUserData (final User user) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("updateUserData: user={0} - CALLED!", user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N // user should not be null if (null == user) { @@ -680,6 +698,9 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes // Set as updated detachedUser.setUserUpdated(new GregorianCalendar()); + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: detachedUser={1} - CALLED!", this.getClass().getSimpleName(), detachedUser)); //NOI18N + // Return updated instance return detachedUser; } @@ -687,7 +708,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override public PasswordHistory updateUserPassword (final User user) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("updateUserPassword: user={0} - CALLED!", user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N // user should not be null if (null == user) { @@ -723,7 +744,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes this.getEntityManager().flush(); // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("updateUserPassword: entry.userPasswordHistoryId={0} - EXIT!", entry.getUserPasswordHistoryId())); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: entry.userPasswordHistoryId={1} - EXIT!", this.getClass().getSimpleName(), entry.getUserPasswordHistoryId())); //NOI18N // Return it return entry; @@ -732,7 +753,7 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes @Override public User updateUserPersonalData (final User user) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("updateUserPersonalData: user={0} - CALLED!", user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N // user should not be null if (null == user) { @@ -873,6 +894,9 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes detachedContact.setContactLandLineNumber(detachedLandLine); } + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: entry.detachedUser={1} - EXIT!", this.getClass().getSimpleName(), detachedUser)); //NOI18N + // Return updated user instance return detachedUser; } diff --git a/src/java/org/mxchange/jusercore/model/user/password_history/JobsUserPasswordHistorySessionBean.java b/src/java/org/mxchange/jusercore/model/user/password_history/JobsUserPasswordHistorySessionBean.java new file mode 100644 index 0000000..853f2c2 --- /dev/null +++ b/src/java/org/mxchange/jusercore/model/user/password_history/JobsUserPasswordHistorySessionBean.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2016 Cho-Time GmbH + * + * 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.password_history; + +import de.chotime.landingpage.database.BaseLandingDatabaseBean; +import java.text.MessageFormat; +import java.util.List; +import javax.ejb.Stateless; +import javax.persistence.Query; +import org.mxchange.jusercore.model.user.User; + +/** + * A user password history EJB + *

+ * @author Roland Haeder + */ +@Stateless (name = "userPasswordHistory", description = "A stateless EJB for user's password history. This bean does return the full user's password history and not limited. The application then needs to limit it to it's purpose.") +public class JobsUserPasswordHistorySessionBean extends BaseLandingDatabaseBean implements UserPasswordHistorySessionBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 395_767_546_195_014L; + + /** + * Default constructor + */ + public JobsUserPasswordHistorySessionBean () { + } + + @Override + @SuppressWarnings ("unchecked") + public List getUserPasswordHistory (final User user) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserPasswordHistory(): user={1} - EXIT!", this.getClass().getSimpleName(), user)); //NOI18N + + // user should not be null + if (null == user) { + // Abort here + throw new NullPointerException("user is null"); //NOI18N + } else if (user.getUserId() == null) { + // Throw NPE again + throw new NullPointerException("user.userId is null"); //NOI18N + } else if (user.getUserId() < 1) { + // Illegal id number + throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not allowed.", user.getUserId())); //NOI18N + } + + // Get named query + Query query = this.getEntityManager().createNamedQuery("AllUsersHistoryEntries", UserPasswordHistory.class); //NOI18N + + // Set parameter + query.setParameter("user", user); //NOI18N + + // Get full history + List history = query.getResultList(); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserPasswordHistory(): history.size()={1} - EXIT !", this.getClass().getSimpleName(), history.size())); //NOI18N + + // Return it + return history; + } + +} diff --git a/src/java/org/mxchange/jusercore/model/user/password_history/LandingUserPasswordHistorySessionBean.java b/src/java/org/mxchange/jusercore/model/user/password_history/LandingUserPasswordHistorySessionBean.java deleted file mode 100644 index fa3461c..0000000 --- a/src/java/org/mxchange/jusercore/model/user/password_history/LandingUserPasswordHistorySessionBean.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2016 Cho-Time GmbH - * - * 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.password_history; - -import de.chotime.landingpage.database.BaseLandingDatabaseBean; -import java.text.MessageFormat; -import java.util.List; -import javax.ejb.Stateless; -import javax.persistence.Query; -import org.mxchange.jusercore.model.user.User; - -/** - * A user password history EJB - *

- * @author Roland Haeder - */ -@Stateless (name = "userPasswordHistory", description = "A stateless EJB for user's password history. This bean does return the full user's password history and not limited. The application then needs to limit it to it's purpose.") -public class LandingUserPasswordHistorySessionBean extends BaseLandingDatabaseBean implements UserPasswordHistorySessionBeanRemote { - - /** - * Serial number - */ - private static final long serialVersionUID = 395_767_546_195_014L; - - /** - * Default constructor - */ - public LandingUserPasswordHistorySessionBean () { - } - - @Override - @SuppressWarnings ("unchecked") - public List getUserPasswordHistory (final User user) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserPasswordHistory(): user={1} - EXIT!", this.getClass().getSimpleName(), user)); //NOI18N - - // user should not be null - if (null == user) { - // Abort here - throw new NullPointerException("user is null"); //NOI18N - } else if (user.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("user.userId is null"); //NOI18N - } else if (user.getUserId() < 1) { - // Illegal id number - throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not allowed.", user.getUserId())); //NOI18N - } - - // Get named query - Query query = this.getEntityManager().createNamedQuery("AllUsersHistoryEntries", UserPasswordHistory.class); //NOI18N - - // Set parameter - query.setParameter("user", user); //NOI18N - - // Get full history - List history = query.getResultList(); - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserPasswordHistory(): history.size()={1} - EXIT !", this.getClass().getSimpleName(), history.size())); //NOI18N - - // Return it - return history; - } - -}