X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjava%2Forg%2Fmxchange%2Fpizzaapplication%2Fbeans%2Fuser%2FPizzaAdminUserWebRequestBean.java;h=b053ea3043b8d162871a2788b4c6a52fb847f685;hb=7f0541570bda07790dcddb59eb93c84d82d793a9;hp=ecea11a916c650d6528ece0e18ae84afb61859c0;hpb=94d204235cf894eff47a73f4cb31ac19eb2f62c6;p=pizzaservice-war.git diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java index ecea11a9..b053ea30 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 Roland Häder + * 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 @@ -18,6 +18,7 @@ package org.mxchange.pizzaapplication.beans.user; import java.text.MessageFormat; import java.util.Objects; +import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Event; import javax.enterprise.event.Observes; @@ -95,7 +96,7 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements /** * Administrative user EJB */ - private final AdminUserSessionBeanRemote adminUserBean; + private AdminUserSessionBeanRemote adminUserBean; /** * Bean helper @@ -132,7 +133,7 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements /** * General user EJB */ - private final UserSessionBeanRemote userBean; + private UserSessionBeanRemote userBean; /** * Regular user controller @@ -196,18 +197,8 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements * Default constructor */ public PizzaAdminUserWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N - this.adminUserBean = (AdminUserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/adminUser!org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw again - throw new FaceletException(e); - } + // Call super constructor + super(); } @Override @@ -221,7 +212,7 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements throw new IllegalArgumentException("userName is null"); //NOI18N } 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) { + if (this.contactController.getPersonalTitle() == null) { // Throw NPE again throw new NullPointerException("contactController.gender is null"); //NOI18N } else if (this.contactController.getFirstName() == null) { @@ -531,6 +522,25 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements this.userPasswordRepeat = userPasswordRepeat; } + /** + * Post-construction method + */ + @PostConstruct + public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.userBean = (UserSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N + this.adminUserBean = (AdminUserSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/adminUser!org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw again + throw new FaceletException(e); + } + } + @Override public String lockUserAccount (final User user) { // Is the user instance valid and CONFIRMED?