From: Roland Häder Date: Thu, 19 May 2016 11:42:54 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=74cd74c553bfa6c67fc677dfacfe7cd0d644e53b;p=jjobs-war.git Continued: - renamed adminHelper to beanHelp as this is a really generic bean helper - renames same class/interface, too - added JSF page for confirming accounts with optional parameter confirmKey. If this is not set, a message will be shown - added i18n keys for above new page - added controller bean for above page to handle the confirmation + calling proper EJB business method Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/beans/confirmlink/JobsConfirmationLinkWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/confirmlink/JobsConfirmationLinkWebRequestBean.java new file mode 100644 index 00000000..0f075181 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/confirmlink/JobsConfirmationLinkWebRequestBean.java @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.beans.confirmlink; + +import java.text.MessageFormat; +import java.util.Iterator; +import java.util.List; +import java.util.Objects; +import javax.enterprise.context.RequestScoped; +import javax.faces.view.facelets.FaceletException; +import javax.inject.Inject; +import javax.inject.Named; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcoreee.utils.FacesUtils; +import org.mxchange.jjobs.beans.BaseJobsController; +import org.mxchange.jjobs.beans.helper.JobsWebRequestController; +import org.mxchange.jjobs.beans.user.JobsUserWebSessionController; +import org.mxchange.jusercore.exceptions.UserStatusConfirmedException; +import org.mxchange.jusercore.exceptions.UserStatusLockedException; +import org.mxchange.jusercore.model.user.User; +import org.mxchange.jusercore.model.user.UserSessionBeanRemote; +import org.mxchange.jusercore.model.user.status.UserAccountStatus; + +/** + * A web request bean for confirmation link handling + *

+ * @author Roland Haeder + */ +@Named ("confirmationLinkController") +@RequestScoped +public class JobsConfirmationLinkWebRequestBean extends BaseJobsController implements JobsConfirmationLinkWebRequestController { + + /** + * Serial number + */ + private static final long serialVersionUID = 57_637_182_796_370L; + + /** + * Admin helper instance + */ + @Inject + private JobsWebRequestController beanHelper; + + /** + * Confirmation key + */ + private String confirmationKey; + + /** + * Remote user bean + */ + private final UserSessionBeanRemote userBean; + + /** + * User controller + */ + @Inject + private JobsUserWebSessionController userController; + + /** + * Default constructor + */ + public JobsConfirmationLinkWebRequestBean () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jlandingpage-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw again + throw new FaceletException(e); + } + } + + @Override + public String getConfirmationKey () { + return this.confirmationKey; + } + + @Override + public void setConfirmationKey (final String confirmationKey) { + this.confirmationKey = confirmationKey; + } + + @Override + public void maybeConfirmUserAccount () { + // Is the confirmation key set? + if (this.getConfirmationKey() == null) { + // May be null if not set + return; + } else if (this.getConfirmationKey().isEmpty()) { + // Is empty string + return; + } + + // Now try to find the user in user list, first get the whole list + List users = this.userController.allUsers(); + + // Get iterator from it + Iterator iterator = users.iterator(); + + // Init instance + User user = null; + + // Then loop through all + while (iterator.hasNext()) { + // Get next user + User next = iterator.next(); + + // Same confirmation key? + if (Objects.equals(this.getConfirmationKey(), next.getUserConfirmKey())) { + // Found it, then set it and abort loop + user = next; + break; + } + } + + // Is the user instance null? + if ((null == user) || (user.getUserAccountStatus() != UserAccountStatus.UNCONFIRMED)) { + // Then clear this bean and the helper + this.beanHelper.setUser(null); + } else { + // Set user ... + this.beanHelper.setUser(user); + + // ... and copy it to the controller + this.beanHelper.copyUserToController(); + + // Try to confirm it + this.confirmUserAccount(); + } + } + + /** + * Tries to confirm the currently set user instance (in helper). + */ + private void confirmUserAccount () { + // Get user instance + User user = this.beanHelper.getUser(); + + // Should be set + if (null == user) { + // Throw NPE + throw new NullPointerException("user is null"); + } else if (user.getUserId() == null) { + // Abort here + throw new NullPointerException("user.userId is null"); //NOI18N + } else if (user.getUserId() < 1) { + // Invalid number + throw new IllegalArgumentException(MessageFormat.format("userId is not valid: {0}", user.getUserId())); //NOI18N + } else if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) { + // Account is already confirmed + throw new FaceletException(new UserStatusConfirmedException(user)); + } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) { + // Account is already confirmed + throw new FaceletException(new UserStatusLockedException(user)); + } else if (user.getUserConfirmKey() == null) { + // Throw NPE + throw new NullPointerException("user.userConfirmKey is null"); //NOI18N + } + + // Updated user instance + User updatedUser; + + try { + // Get base URL + String baseUrl = FacesUtils.generateBaseUrl(); + + // Confirm account + updatedUser = this.userBean.confirmAccount(user, baseUrl); + } catch (final UserStatusConfirmedException | UserStatusLockedException ex) { + // Something unexpected happened + throw new FaceletException(MessageFormat.format("Cannot confirm user account {0}", user.getUserName()), ex); //NOI18N + } + + // Set it again in helper + this.beanHelper.setUser(updatedUser); + } + +} diff --git a/src/java/org/mxchange/jjobs/beans/confirmlink/JobsConfirmationLinkWebRequestController.java b/src/java/org/mxchange/jjobs/beans/confirmlink/JobsConfirmationLinkWebRequestController.java new file mode 100644 index 00000000..183a472f --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/confirmlink/JobsConfirmationLinkWebRequestController.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.beans.confirmlink; + +import java.io.Serializable; + +/** + * An interface for an email change controller + *

+ * @author Roland Haeder + */ +public interface JobsConfirmationLinkWebRequestController extends Serializable { + + /** + * Getter for confirmation key + *

+ * @return Confirmation key + */ + String getConfirmationKey (); + + /** + * Setter for confirmation key + *

+ * @param confirmationKey Confirmation key + */ + void setConfirmationKey (final String confirmationKey); + + /** + * Tries to lookup the user by currently set confirmation key and if found + * tries to confirm it. If no user is found, the instance beanHelper.user is + * set to null. Other methods or JSF pages should then respond on this + * accordingly. + */ + void maybeConfirmUserAccount (); + +} diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java index 26c6baa5..2dcca6da 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java @@ -41,7 +41,6 @@ import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent; import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException; import org.mxchange.jcountry.data.Country; import org.mxchange.jjobs.beans.BaseJobsController; -import org.mxchange.jjobs.beans.helper.JobsAdminWebRequestController; import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber; import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; @@ -49,6 +48,7 @@ import org.mxchange.jphone.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.phonenumbers.landline.LandLineNumber; import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; +import org.mxchange.jjobs.beans.helper.JobsWebRequestController; /** * An administrative user bean (controller) @@ -75,7 +75,7 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement * Admin helper instance */ @Inject - private JobsAdminWebRequestController adminHelper; + private JobsWebRequestController beanHelper; /** * Birth day @@ -352,13 +352,13 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement // Check if contact instance is in helper and valid if (null == contact) { // Throw NPE - throw new NullPointerException("adminHelper.contact is null"); //NOI18N + throw new NullPointerException("beanHelper.contact is null"); //NOI18N } else if (contact.getContactId() == null) { // Throw NPE again - throw new NullPointerException("adminHelper.contact.contactId is null"); //NOI18N //NOI18N + throw new NullPointerException("beanHelper.contact.contactId is null"); //NOI18N //NOI18N } else if (contact.getContactId() < 1) { // Invalid id - throw new IllegalStateException(MessageFormat.format("adminHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N + throw new IllegalStateException(MessageFormat.format("beanHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N } // Update all data in contact @@ -380,18 +380,18 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement @Override public String editContactData () { // Get contact instance - Contact contact = this.adminHelper.getContact(); + Contact contact = this.beanHelper.getContact(); // Check if contact instance is in helper and valid if (null == contact) { // Throw NPE - throw new NullPointerException("adminHelper.contact is null"); //NOI18N + throw new NullPointerException("beanHelper.contact is null"); //NOI18N } else if (contact.getContactId() == null) { // Throw NPE again - throw new NullPointerException("adminHelper.contact.contactId is null"); //NOI18N //NOI18N + throw new NullPointerException("beanHelper.contact.contactId is null"); //NOI18N //NOI18N } else if (contact.getContactId() < 1) { // Invalid id - throw new IllegalStateException(MessageFormat.format("adminHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N + throw new IllegalStateException(MessageFormat.format("beanHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N } // Update all data in contact diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestController.java b/src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestController.java deleted file mode 100644 index 0249d9bb..00000000 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestController.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jjobs.beans.helper; - -import java.io.Serializable; -import org.mxchange.jcontacts.contact.Contact; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for general bean helper - *

- * @author Roland Haeder - */ -public interface JobsAdminWebRequestController extends Serializable { - - /** - * Getter for user instance - *

- * @return User instance - */ - User getUser (); - - /** - * Setter for user instance - *

- * @param user User instance - */ - void setUser (final User user); - - /** - * Copies currently set user instance's data to adminUserController - */ - void copyUserToController (); - - /** - * Returns a message key depending on if this contact is a user and/or a - * contact. If this contact is unused, a default key is returned. - *

- * @param contact Contact instance to check - *

- * @return Message key - */ - String getContactUsageMessageKey (final Contact contact); - - /** - * Getter for contact instance - *

- * @return Contact instance - */ - Contact getContact (); - - /** - * Setter for contact instance - *

- * @param contact Contact instance - */ - void setContact (final Contact contact); - - /** - * Copies currently set contact instance's data to adminContactController - */ - void copyContactToController (); - -} diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestHelper.java b/src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestHelper.java deleted file mode 100644 index e3ae2c7a..00000000 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestHelper.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jjobs.beans.helper; - -import java.text.MessageFormat; -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import org.mxchange.jcontacts.contact.Contact; -import org.mxchange.jjobs.beans.contact.JobsAdminContactWebRequestController; -import org.mxchange.jjobs.beans.user.JobsUserWebSessionController; -import org.mxchange.jusercore.model.user.User; - -/** - * A general helper for beans - *

- * @author Roland Haeder - */ -@Named ("adminHelper") -@RequestScoped -public class JobsAdminWebRequestHelper implements JobsAdminWebRequestController { - - /** - * Serial number - */ - private static final long serialVersionUID = 17_258_793_567_145_701L; - - /** - * Regular contact controller - */ - @Inject - private JobsAdminContactWebRequestController adminContactController; - - /** - * Contact instance - */ - private Contact contact; - - /** - * User instance - */ - private User user; - - /** - * Regular user controller - */ - @Inject - private JobsUserWebSessionController userController; - - /** - * Default constructor - */ - public JobsAdminWebRequestHelper () { - } - - @Override - public void copyContactToController () { - // Log message - //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyContactToController - CALLED!"); //NOI18N - - // Validate user instance - if (this.getContact() == null) { - // Throw NPE - throw new NullPointerException("this.contact is null"); //NOI18N - } else if (this.getContact().getContactId() == null) { - // Throw NPE again - throw new NullPointerException("this.contact.contactId is null"); //NOI18N - } else if (this.getContact().getContactId() < 1) { - // Not valid - throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N - } - - // Set all fields: user - this.adminContactController.copyContactToController(this.getContact()); - - // Log message - //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyContactToController - EXIT!"); //NOI18N - } - - @Override - public void copyUserToController () { - // Log message - //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - CALLED!"); //NOI18N - - // Validate user instance - if (this.getUser() == null) { - // Throw NPE - throw new NullPointerException("this.user is null"); - } else if (this.getUser().getUserId() == null) { - // Throw NPE again - throw new NullPointerException("this.user.userId is null"); - } else if (this.getUser().getUserId() < 1) { - // Not valid - throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); - } - - // Set all fields: user - this.userController.setUserName(this.getUser().getUserName()); - - // Log message - //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - EXIT!"); //NOI18N - } - - @Override - public Contact getContact () { - return this.contact; - } - - @Override - public void setContact (final Contact contact) { - this.contact = contact; - } - - @Override - public String getContactUsageMessageKey (final Contact contact) { - // The contact must be valid - if (null == contact) { - // Throw NPE - throw new NullPointerException("contact is null"); //NOI18N - } else if (contact.getContactId() == null) { - // Throw again ... - throw new NullPointerException("contact.contactId is null"); //NOI18N - } else if (contact.getContactId() < 1) { - // Not valid - throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N - } - - // Default key is "unused" - String messageKey = "CONTACT_IS_UNUSED"; //NOI18N - - // Check user - boolean isUserContact = this.userController.isContactFound(contact); - - // Check user first - if (isUserContact) { - // Only user - messageKey = "CONTACT_IS_USER"; //NOI18N - } - - // Return message key - return messageKey; - } - - @Override - public User getUser () { - return this.user; - } - - @Override - public void setUser (final User user) { - this.user = user; - } - -} diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestController.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestController.java new file mode 100644 index 00000000..5fbc8d45 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestController.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.beans.helper; + +import java.io.Serializable; +import org.mxchange.jcontacts.contact.Contact; +import org.mxchange.jusercore.model.user.User; + +/** + * An interface for general bean helper + *

+ * @author Roland Haeder + */ +public interface JobsWebRequestController extends Serializable { + + /** + * Getter for user instance + *

+ * @return User instance + */ + User getUser (); + + /** + * Setter for user instance + *

+ * @param user User instance + */ + void setUser (final User user); + + /** + * Copies currently set user instance's data to adminUserController + */ + void copyUserToController (); + + /** + * Returns a message key depending on if this contact is a user and/or a + * contact. If this contact is unused, a default key is returned. + *

+ * @param contact Contact instance to check + *

+ * @return Message key + */ + String getContactUsageMessageKey (final Contact contact); + + /** + * Getter for contact instance + *

+ * @return Contact instance + */ + Contact getContact (); + + /** + * Setter for contact instance + *

+ * @param contact Contact instance + */ + void setContact (final Contact contact); + + /** + * Copies currently set contact instance's data to adminContactController + */ + void copyContactToController (); + +} diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java new file mode 100644 index 00000000..99d676d8 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.beans.helper; + +import java.text.MessageFormat; +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; +import org.mxchange.jcontacts.contact.Contact; +import org.mxchange.jjobs.beans.contact.JobsAdminContactWebRequestController; +import org.mxchange.jjobs.beans.user.JobsUserWebSessionController; +import org.mxchange.jusercore.model.user.User; + +/** + * A general helper for beans + *

+ * @author Roland Haeder + */ +@Named ("adminHelper") +@RequestScoped +public class JobsWebRequestHelper implements JobsWebRequestController { + + /** + * Serial number + */ + private static final long serialVersionUID = 17_258_793_567_145_701L; + + /** + * Regular contact controller + */ + @Inject + private JobsAdminContactWebRequestController adminContactController; + + /** + * Contact instance + */ + private Contact contact; + + /** + * User instance + */ + private User user; + + /** + * Regular user controller + */ + @Inject + private JobsUserWebSessionController userController; + + /** + * Default constructor + */ + public JobsWebRequestHelper () { + } + + @Override + public void copyContactToController () { + // Log message + //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyContactToController - CALLED!"); //NOI18N + + // Validate user instance + if (this.getContact() == null) { + // Throw NPE + throw new NullPointerException("this.contact is null"); //NOI18N + } else if (this.getContact().getContactId() == null) { + // Throw NPE again + throw new NullPointerException("this.contact.contactId is null"); //NOI18N + } else if (this.getContact().getContactId() < 1) { + // Not valid + throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N + } + + // Set all fields: user + this.adminContactController.copyContactToController(this.getContact()); + + // Log message + //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyContactToController - EXIT!"); //NOI18N + } + + @Override + public void copyUserToController () { + // Log message + //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - CALLED!"); //NOI18N + + // Validate user instance + if (this.getUser() == null) { + // Throw NPE + throw new NullPointerException("this.user is null"); + } else if (this.getUser().getUserId() == null) { + // Throw NPE again + throw new NullPointerException("this.user.userId is null"); + } else if (this.getUser().getUserId() < 1) { + // Not valid + throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); + } + + // Set all fields: user + this.userController.setUserName(this.getUser().getUserName()); + + // Log message + //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - EXIT!"); //NOI18N + } + + @Override + public Contact getContact () { + return this.contact; + } + + @Override + public void setContact (final Contact contact) { + this.contact = contact; + } + + @Override + public String getContactUsageMessageKey (final Contact contact) { + // The contact must be valid + if (null == contact) { + // Throw NPE + throw new NullPointerException("contact is null"); //NOI18N + } else if (contact.getContactId() == null) { + // Throw again ... + throw new NullPointerException("contact.contactId is null"); //NOI18N + } else if (contact.getContactId() < 1) { + // Not valid + throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N + } + + // Default key is "unused" + String messageKey = "CONTACT_IS_UNUSED"; //NOI18N + + // Check user + boolean isUserContact = this.userController.isContactFound(contact); + + // Check user first + if (isUserContact) { + // Only user + messageKey = "CONTACT_IS_USER"; //NOI18N + } + + // Return message key + return messageKey; + } + + @Override + public User getUser () { + return this.user; + } + + @Override + public void setUser (final User user) { + this.user = user; + } + +} diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java index b4259c1f..ae6f6ca4 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java @@ -32,7 +32,6 @@ import javax.naming.NamingException; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jjobs.beans.contact.JobsContactWebSessionController; -import org.mxchange.jjobs.beans.helper.JobsAdminWebRequestController; import org.mxchange.jjobs.beans.login.JobsUserLoginWebSessionController; import org.mxchange.jusercore.container.login.UserLoginContainer; import org.mxchange.jusercore.events.registration.UserRegisteredEvent; @@ -49,6 +48,7 @@ import org.mxchange.jusercore.model.user.UserSessionBeanRemote; import org.mxchange.jusercore.model.user.UserUtils; import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; import org.mxchange.jusercore.model.user.status.UserAccountStatus; +import org.mxchange.jjobs.beans.helper.JobsWebRequestController; /** * A user bean (controller) @@ -72,10 +72,10 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J private Event addedUserEvent; /** - * Admin helper instance + * Bean helper instance */ @Inject - private JobsAdminWebRequestController adminHelper; + private JobsWebRequestController beanHelper; /** * Regular contact controller @@ -101,12 +101,6 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J @Inject private JobsUserWebSessionController userController; - /** - * Login bean (controller) - */ - @Inject - private JobsUserLoginWebSessionController userLoginController; - /** * User name */ @@ -148,7 +142,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J } else if (this.getUserName().isEmpty()) { // Is empty throw new IllegalArgumentException("userName is null"); //NOI18N - } else if (this.adminHelper.getContact() == null) { + } else if (this.beanHelper.getContact() == null) { // No contact instance set, so test required fields: gender, first name and family name if (this.contactController.getGender() == null) { // Throw NPE again @@ -191,8 +185,17 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J user.setUserAccountStatus(UserAccountStatus.CONFIRMED); user.setUserProfileMode(ProfileMode.INVISIBLE); - // Create contact instance - Contact contact = this.contactController.createContactInstance(); + // Init instance + Contact contact; + + // Is a contact instance in helper set? + if (this.beanHelper.getContact() instanceof Contact) { + // Then use it for contact linking + contact = this.beanHelper.getContact(); + } else { + // Create contact instance + contact = this.contactController.createContactInstance(); + } // Set contact in user user.setUserContact(contact); @@ -205,7 +208,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J if (this.userController.isUserNameRegistered(user)) { // User name is already used throw new FaceletException(new UserNameAlreadyRegisteredException(user)); - } else if ((this.adminHelper.getContact() == null) && (this.contactController.isEmailAddressRegistered(user.getUserContact()))) { + } else if ((this.beanHelper.getContact() == null) && (this.contactController.isEmailAddressRegistered(user.getUserContact()))) { // Email address is already used throw new FaceletException(new EmailAddressAlreadyRegisteredException(user)); } else if ((this.getUserPassword() == null && (this.getUserPasswordRepeat() == null)) || ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty()))) { @@ -231,9 +234,12 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J try { // Now, that all is set, call EJB - if (this.adminHelper.getContact() instanceof Contact) { + if (this.beanHelper.getContact() instanceof Contact) { // Link contact with this user updatedUser = this.userBean.linkUser(user); + + // Remove contact instance + this.beanHelper.setContact(null); } else { // Add new contact updatedUser = this.userBean.addUser(user); @@ -244,7 +250,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J } // Clear helper - this.adminHelper.setContact(null); + this.beanHelper.setContact(null); // Fire event this.addedUserEvent.fire(new AdminUserAddedEvent(updatedUser)); @@ -289,7 +295,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J @Override public String editUserData () { // Get user instance - User user = this.adminHelper.getUser(); + User user = this.beanHelper.getUser(); // Null password means not setting it String encryptedPassword = null; @@ -297,13 +303,13 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J // Check if user instance is in helper and valid if (null == user) { // Throw NPE - throw new NullPointerException("adminHelper.user is null"); //NOI18N + throw new NullPointerException("beanHelper.user is null"); //NOI18N } else if (user.getUserId() == null) { // Throw NPE again - throw new NullPointerException("adminHelper.user.userId is null"); //NOI18N //NOI18N + throw new NullPointerException("beanHelper.user.userId is null"); //NOI18N //NOI18N } else if (user.getUserId() < 1) { // Invalid id - throw new IllegalStateException(MessageFormat.format("adminHelper.user.userId={0} is invalid", user.getUserId())); //NOI18N + throw new IllegalStateException(MessageFormat.format("beanHelper.user.userId={0} is invalid", user.getUserId())); //NOI18N } else if (this.getUserName() == null) { // Not all required fields are set throw new NullPointerException("this.userName is null"); //NOI18N diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 89df9365..b32b8f55 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -496,3 +496,10 @@ GUEST_RESEND_LINK_ENTER_EMAIL_ADDRESS=Bitte bei der Anmeldung verwendete Email-A GUEST_RESEND_CONFIRMATION_LINK_NOTICE=Der alte Best\u00e4tigungslink wird hiernach verfallen, bitte dann den aus der neueren Mail verwenden. RESEND_CONFIRMATION_LINK_LEGEND=Email-Adresse eingeben: RESEND_CONFIRMATION_LINK_LEGEND_TITLE=Bitte geben Sie Ihre Email-Adresse ein, die Sie bei der Anmeldung verwendet haben. +PAGE_TITLE_INDEX_CONFIRM_ACCOUNT=Anmeldung best\u00e4tigen +CONTENT_TITLE_INDEX_CONFIRM_ACCOUNT=Benutzeranmeldung best\u00e4tigen: +GUEST_CONFIRMATION_LINK_INVALID=Best\u00e4tigungslink nicht mehr g\u00fcltig. Bitte lassen Sie sich einen neuen Link zusenden oder wenden Sie sich an den Support. +GUEST_CONFIRMATION_KEY_NOT_SET=Es wurde keine Best\u00e4tigungsschl\u00fcssel angegeben. Bitte pr\u00fcfen Sie den Link aus der Mail. +GUEST_CONFIRM_USER_ACCOUNT_DONE_TITLE=Vielen Dank f\u00fcr die Best\u00e4tigung +GUEST_USER_CONFIRM_ACCOUNT_DONE=Hallo {0} {1} {2}. Sie haben soeben Ihren Account best\u00e4tigt. Es ist eine Mail mit weiteren Details an Sie unterwegs. +BUTTON_GUEST_CONFIRM_USER_ACCOUNT=Account best\u00e4tigen diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index abf1b1dd..97e1210b 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -496,3 +496,10 @@ LOGIN_CHANGE_PERSONAL_DATA_TITLE=Change personal data: LINK_LOGIN_CHANGE_PASSWORD_TITLE=Change here your password, if you want another one. LINK_LOGIN_CHANGE_EMAIL_ADDRESS=Change your email address LINK_TITLE_GUEST_LOGIN_LOST_PASSWORD=Restore your password +PAGE_TITLE_INDEX_CONFIRM_ACCOUNT=Confirm registration +CONTENT_TITLE_INDEX_CONFIRM_ACCOUNT=Confirm user registration: +GUEST_CONFIRMATION_LINK_INVALID=Confirmation link is no longer valid. Please try to send a new link to your email address or contact support. +GUEST_CONFIRMATION_KEY_NOT_SET=No confirmation key was provided. Please check the link from the mail. +GUEST_CONFIRM_USER_ACCOUNT_DONE_TITLE=Thank you for confirmation of your account +GUEST_USER_CONFIRM_ACCOUNT_DONE=Hello {0} {1} {2}. You have successfully confirmed your account. An email with more details is on it's way to you. +BUTTON_GUEST_CONFIRM_USER_ACCOUNT=Confirm account diff --git a/web/WEB-INF/templates/admin/contact/admin_contact_data.tpl b/web/WEB-INF/templates/admin/contact/admin_contact_data.tpl index 799a19b6..5e29f6f6 100644 --- a/web/WEB-INF/templates/admin/contact/admin_contact_data.tpl +++ b/web/WEB-INF/templates/admin/contact/admin_contact_data.tpl @@ -1,107 +1,107 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/WEB-INF/templates/guest/user/register/guest_form_register_page2.tpl b/web/WEB-INF/templates/guest/user/register/guest_form_register_page2.tpl new file mode 100644 index 00000000..1e7e0a89 --- /dev/null +++ b/web/WEB-INF/templates/guest/user/register/guest_form_register_page2.tpl @@ -0,0 +1,22 @@ + + + + +

+
+ #{msg.GUEST_REGISTRATION_PAGE2_TITLE} +
+ + + + +
+ + diff --git a/web/WEB-INF/templates/guest/user/register/guest_form_register_single.tpl b/web/WEB-INF/templates/guest/user/register/guest_form_register_single.tpl index 043babe7..df3087a7 100644 --- a/web/WEB-INF/templates/guest/user/register/guest_form_register_single.tpl +++ b/web/WEB-INF/templates/guest/user/register/guest_form_register_single.tpl @@ -71,7 +71,7 @@ diff --git a/web/admin/contact/admin_contact_delete.xhtml b/web/admin/contact/admin_contact_delete.xhtml index badc92e3..a3ae28a0 100644 --- a/web/admin/contact/admin_contact_delete.xhtml +++ b/web/admin/contact/admin_contact_delete.xhtml @@ -9,8 +9,8 @@ > - - + + @@ -21,13 +21,13 @@ - + - +
- +
@@ -39,7 +39,7 @@
diff --git a/web/admin/contact/admin_contact_edit.xhtml b/web/admin/contact/admin_contact_edit.xhtml index 0ac502ad..bd123b61 100644 --- a/web/admin/contact/admin_contact_edit.xhtml +++ b/web/admin/contact/admin_contact_edit.xhtml @@ -9,8 +9,8 @@ > - - + + @@ -21,13 +21,13 @@
- + - +
- +
@@ -41,7 +41,7 @@
diff --git a/web/admin/contact/admin_contact_list.xhtml b/web/admin/contact/admin_contact_list.xhtml index 98821772..bc9b16ed 100644 --- a/web/admin/contact/admin_contact_list.xhtml +++ b/web/admin/contact/admin_contact_list.xhtml @@ -72,7 +72,7 @@
diff --git a/web/admin/contact/admin_contact_show.xhtml b/web/admin/contact/admin_contact_show.xhtml index fccf2ebc..28131f20 100644 --- a/web/admin/contact/admin_contact_show.xhtml +++ b/web/admin/contact/admin_contact_show.xhtml @@ -1,42 +1,42 @@ - - - - - - - - - - - #{msg.PAGE_TITLE_ADMIN_SHOW_CONTACT} - - - #{msg.CONTENT_TITLE_ADMIN_SHOW_CONTACT} - - - - - - - -
- - - -
- -
- - - - -
-
-
- + + + + + + + + + + + #{msg.PAGE_TITLE_ADMIN_SHOW_CONTACT} + + + #{msg.CONTENT_TITLE_ADMIN_SHOW_CONTACT} + + + + + + + +
+ + + +
+ +
+ + + + +
+
+
+ diff --git a/web/admin/country/admin_country_list.xhtml b/web/admin/country/admin_country_list.xhtml index 2d172240..73737268 100644 --- a/web/admin/country/admin_country_list.xhtml +++ b/web/admin/country/admin_country_list.xhtml @@ -44,7 +44,7 @@ - +
#{msg.ADMIN_ADD_COUNTRY_TITLE} @@ -54,7 +54,7 @@
diff --git a/web/admin/mobile_provider/admin_mobile_provider_list.xhtml b/web/admin/mobile_provider/admin_mobile_provider_list.xhtml index bf450a76..ebb50f94 100644 --- a/web/admin/mobile_provider/admin_mobile_provider_list.xhtml +++ b/web/admin/mobile_provider/admin_mobile_provider_list.xhtml @@ -52,7 +52,7 @@ - +
#{msg.ADMIN_ADD_MOBILE_PROVIDER_TITLE} @@ -62,7 +62,7 @@
diff --git a/web/admin/user/admin_user_delete.xhtml b/web/admin/user/admin_user_delete.xhtml index 720c9033..bc0f33aa 100644 --- a/web/admin/user/admin_user_delete.xhtml +++ b/web/admin/user/admin_user_delete.xhtml @@ -1,29 +1,29 @@ - - - - - - - - - - - #{msg.PAGE_TITLE_ADMIN_DELETE_USER} - - - #{msg.CONTENT_TITLE_ADMIN_DELETE_USER} - - - - - - Here goes your content. - - - + + + + + + + + + + + #{msg.PAGE_TITLE_ADMIN_DELETE_USER} + + + #{msg.CONTENT_TITLE_ADMIN_DELETE_USER} + + + + + + Here goes your content. + + + diff --git a/web/admin/user/admin_user_edit.xhtml b/web/admin/user/admin_user_edit.xhtml index 1578ec17..f7a826ff 100644 --- a/web/admin/user/admin_user_edit.xhtml +++ b/web/admin/user/admin_user_edit.xhtml @@ -9,8 +9,8 @@ > - - + + @@ -21,9 +21,9 @@ - + - +
#{msg.ADMIN_EDIT_USER_TITLE} @@ -39,7 +39,7 @@
diff --git a/web/admin/user/admin_user_list.xhtml b/web/admin/user/admin_user_list.xhtml index 3e05b27b..236c3824 100644 --- a/web/admin/user/admin_user_list.xhtml +++ b/web/admin/user/admin_user_list.xhtml @@ -86,7 +86,7 @@
- + @@ -105,7 +105,7 @@
diff --git a/web/admin/user/admin_user_show.xhtml b/web/admin/user/admin_user_show.xhtml index 927dfc9b..3eb471cb 100644 --- a/web/admin/user/admin_user_show.xhtml +++ b/web/admin/user/admin_user_show.xhtml @@ -1,189 +1,189 @@ - - - - - - - - - - - #{msg.PAGE_TITLE_ADMIN_SHOW_USER} - - - #{msg.CONTENT_TITLE_ADMIN_SHOW_USER} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- -
- - - - -
-
-
- + + + + + + + + + + + #{msg.PAGE_TITLE_ADMIN_SHOW_USER} + + + #{msg.CONTENT_TITLE_ADMIN_SHOW_USER} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+ + + + +
+
+
+ diff --git a/web/admin/user/admin_user_unlock.xhtml b/web/admin/user/admin_user_unlock.xhtml index 7b33fdaa..f5df7f75 100644 --- a/web/admin/user/admin_user_unlock.xhtml +++ b/web/admin/user/admin_user_unlock.xhtml @@ -1,29 +1,29 @@ - - - - - - - - - - - #{msg.PAGE_TITLE_ADMIN_UNLOCK_USER} - - - #{msg.CONTENT_TITLE_ADMIN_UNLOCK_USER} - - - - - - Here goes your content. - - - + + + + + + + + + + + #{msg.PAGE_TITLE_ADMIN_UNLOCK_USER} + + + #{msg.CONTENT_TITLE_ADMIN_UNLOCK_USER} + + + + + + Here goes your content. + + + diff --git a/web/guest/user/confirm_account.xhtml b/web/guest/user/confirm_account.xhtml new file mode 100644 index 00000000..8b6a4571 --- /dev/null +++ b/web/guest/user/confirm_account.xhtml @@ -0,0 +1,51 @@ + + + + + + + + + + + #{msg.PAGE_TITLE_INDEX_CONFIRM_ACCOUNT} + + + #{msg.CONTENT_TITLE_INDEX_CONFIRM_ACCOUNT} + + + + + +
+
+ +
+ +
+ + + + + +
+
+
+ + + + +
+ + + + +
+
+ diff --git a/web/guest/user/resend_link.xhtml b/web/guest/user/resend_link.xhtml index 6d5c6173..02d6c5cb 100644 --- a/web/guest/user/resend_link.xhtml +++ b/web/guest/user/resend_link.xhtml @@ -17,7 +17,7 @@ - +
@@ -49,7 +49,7 @@