2 * Copyright (C) 2016 quix0r
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jusercore.model.email_address;
19 import java.text.MessageFormat;
21 import javax.ejb.Stateless;
22 import javax.persistence.PersistenceException;
23 import org.mxchange.jcoreee.database.BaseDatabaseBean;
24 import org.mxchange.jusercore.model.user.User;
25 import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
28 * A session bean for changing email addresses
30 * @author Roland Haeder<roland@mxchange.org>
32 @Stateless (name = "email-change", mappedName = "ejb/stateless-addressbook-email-change", description = "A bean handling email changes")
33 public class EmailChangeSessionBean extends BaseDatabaseBean implements EmailChangeSessionBeanRemote {
38 private static final long serialVersionUID = 182_698_165_971_548L;
44 private UserSessionBeanRemote userBean;
49 public EmailChangeSessionBean () {
53 public void enqueueEmailAddressForChange (final User user) {
55 this.getLoggerBeanLocal().logTrace(MessageFormat.format("enqueueEmailAddressForChange: user={0} - CALLED!", user));
57 // user should not be null
60 throw new NullPointerException("user is null"); //NOI18N
61 } else if (user.getUserId() == null) {
63 throw new NullPointerException("user.userId is null"); //NOI18N
64 } else if (user.getUserId() < 1) {
66 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
67 } else if (user.getUserAccountStatus() == null) {
69 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
70 } else if (!this.userBean.ifUserIdExists(user.getUserId())) {
71 // User does not exist
72 throw new PersistenceException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
75 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
79 public void updateEmailAddress (final User user) {
81 this.getLoggerBeanLocal().logTrace(MessageFormat.format("updateEmailAddress: user={0} - CALLED!", user));
83 // user should not be null
86 throw new NullPointerException("user is null"); //NOI18N
87 } else if (user.getUserId() == null) {
89 throw new NullPointerException("user.userId is null"); //NOI18N
90 } else if (user.getUserId() < 1) {
92 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
93 } else if (user.getUserAccountStatus() == null) {
95 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
96 } else if (!this.userBean.ifUserIdExists(user.getUserId())) {
97 // User does not exist
98 throw new PersistenceException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
101 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.