]> git.mxchange.org Git - addressbook-mailer-ejb.git/blobdiff - src/java/org/mxchange/jusercore/model/user/resendlink/AddressbookResendLinkSessionBean.java
Please cherry-pick:
[addressbook-mailer-ejb.git] / src / java / org / mxchange / jusercore / model / user / resendlink / AddressbookResendLinkSessionBean.java
diff --git a/src/java/org/mxchange/jusercore/model/user/resendlink/AddressbookResendLinkSessionBean.java b/src/java/org/mxchange/jusercore/model/user/resendlink/AddressbookResendLinkSessionBean.java
deleted file mode 100644 (file)
index 70ed720..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jusercore.model.user.resendlink;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-import javax.ejb.EJB;
-import javax.ejb.Stateless;
-import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
-import org.mxchange.jusercore.exceptions.UserStatusLockedException;
-import org.mxchange.jusercore.model.user.LoginUser;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
-import org.mxchange.jusercore.model.user.register.UserRegistrationSessionBeanRemote;
-import org.mxchange.jusercore.model.user.status.UserAccountStatus;
-
-/**
- * A session-based EJB for resending confirmation links
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "userResendConfirmationLink", description = "A bean resending confirmation links")
-public class AddressbookResendLinkSessionBean extends BaseAddressbookDatabaseBean implements ResendLinkSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 71_546_726_857_195_360L;
-
-       /**
-        * Registration bean
-        */
-       @EJB
-       private UserRegistrationSessionBeanRemote registerBean;
-
-       /**
-        * Regular user bean
-        */
-       @EJB
-       private UserSessionBeanRemote userBean;
-
-       /**
-        * Default constructor
-        */
-       public AddressbookResendLinkSessionBean () {
-               // Call super constructor
-               super("jms/addressbook-queue-factory", "jms/addressbook-email-queue"); //NOI18N
-       }
-
-       @Override
-       public void resendConfirmationLink (final User user, final Locale locale, final String baseUrl) throws UserNotFoundException, UserStatusConfirmedException, UserStatusLockedException {
-               // Log trace message
-               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) {
-                       // Throw NPE
-                       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) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
-               } else if (!this.userBean.ifUserExists(user)) {
-                       // User not found
-                       throw new UserNotFoundException(user);
-               } else if (user.getUserConfirmKey() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.userConfirmKey is null"); //NOI18N
-               } else if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
-                       // User account status is not UNCONFIRMED
-                       throw new UserStatusConfirmedException(user);
-               } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
-                       // User account status is not UNCONFIRMED
-                       throw new UserStatusLockedException(user);
-               } else if (null == locale) {
-                       // Locale should be set
-                       throw new NullPointerException("locale is null"); //NOI18N
-               }
-
-               // Get new registration key
-               String confirmationKey = this.registerBean.generateConfirmationKey(user);
-
-               // Get managed instance
-               User managedUser = this.getEntityManager().find(LoginUser.class, user.getUserId());
-
-               // Set it in user
-               managedUser.setUserConfirmKey(confirmationKey);
-
-               // Send email
-               // @TODO: Internationlize the subject line somehow
-               this.sendEmail("Resend user confirmation link", "user_resend_confirmation_link",  user, baseUrl, null); //NOI18N
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.resendConfirmationLink: EXIT!", this.getClass().getSimpleName())); //NOI18N
-       }
-
-}