From 31c87725a0edfabbf329e46e6d9a3d234fa363a2 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 10 Apr 2016 19:36:20 +0200 Subject: [PATCH] Continued with admin area: - added admin user controller for administrative stuff - updated jar(s) --- lib/juser-core.jar | Bin 38902 -> 38977 bytes lib/juser-lib.jar | Bin 5111 -> 5138 bytes .../user/PizzaAdminUserWebSessionBean.java | 487 ++++++++++++++++++ .../PizzaAdminUserWebSessionController.java | 391 ++++++++++++++ .../user/PizzaUserWebSessionController.java | 1 + web/admin/admin_user_list.xhtml | 2 +- 6 files changed, 880 insertions(+), 1 deletion(-) create mode 100644 src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionBean.java create mode 100644 src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionController.java diff --git a/lib/juser-core.jar b/lib/juser-core.jar index 4599325e92b862d649145a8aa1aecd222a96ce84..988fcc9e393829606313edd4fb3e5da5bf749de6 100644 GIT binary patch delta 1300 zcmY+EZA?>F7{{M;+uPD|ol*fl+b9{A-RXJvxU+>h6+Nd@p(i% zV!X$QubBcS;*3%*@`lIO7%2OassvBk_X=-G*(H&GDRq~Tc){ToT*$~1%yu@4{#)uP zLC@1)3fgnR;(RQBA(_^7d!8{Txrg+!w7L4676$+wx%`D@C*N0V;b!mh)%UI7gi96} zgU>9G37=bW7*7N{4PWp=Z@xxhg7kM(y>5mZ6uz>;_i&SDlT?_*$OpYyE9fG(Y53I) zcg%2?Cuv&zFR#zUZty<}o`^S8&zqElt$~0qRCg%EU_HNGlg6DjtK#1MPqCH1DKHK7 z3e?e{Lzfw5_!}=48)o4i?^vtZ%rK|GVVGB-7y1+k!|(BgT5hns2SzvviSRxjsq0)l z3dbPC!db|MbFdLUg01i|RKO?vx%&3B3n0TqFvBIV;iKczV*4^=!4>{f{n2Gt zL4vRG8sC5ezU6fdCHUp9`IGrrgDT&`l~XbQDlQ*%v7d$Z98~2ysPB@Fpq>@_I_mqV zAH@76>`$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CcIfnnpEi9DK28|F+jU%<3x_QabCAo8~+kesZ>XbhsF87)E7 zG)8x(jdLd7XS4@V3QSHQ!4xJtAhmf3(?%ws=;m-%K4uV|&cVUVyJmKmhXGG=&LU<8 zhDDQWxP1lW*cqhR8D!WQWEmMa5_57Uzu``okp?n+Q*)D2ivmiMax#;{GK({la#BN! zQ;Ui>2lC`IF>+5n$fsJ*%D~9L#=yY9#K6wN$iT(G&ALunBxEy^GUHd7o-N-#(QX*QruQVa|M-i%Bl%&<_J9LjGA45rBw_#HqVzr=3< zqF4mLVPh}g4C1v2c!H?&0^y(_(h&3qQI�Ai=YOejrL#s1hVNLnt3aaSB(W1yjFp L5?c~K&=Cv(5MyYh delta 393 zcmbQF@m-xKz?+$ci-CcIfnjCNL>^716*&{l7cc?YHx)qSZ%rUMS&h*cL`5@Nf~aYX z?jY(uqdkaHU~&RcDNJ@iYV#7NjZ7dqoRyCmM5l9bF!Qd=>GDv&A-biVnSr5wat*gH zmn=Jj6gz`7JA=$*J069}54aOH$MNJcF>*~l!>3vgbPo$712+RJ10w?)0|NsS0}qhT zi^k_;;0LP{U=Re;LQq;5N{cXvg7u1lNpS`VAk79eQIdfnz?+dtgc;`TE)Sp#9B?vB zZr}%n!{pWc4j`Ys}*m1yCxN;rwl9q0uH1^}ozTA=^{ diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionBean.java new file mode 100644 index 00000000..92af11c2 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionBean.java @@ -0,0 +1,487 @@ +/* + * 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.pizzaapplication.beans.user; + +import java.util.Collections; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Objects; +import javax.annotation.PostConstruct; +import javax.enterprise.context.SessionScoped; +import javax.faces.view.facelets.FaceletException; +import javax.inject.Named; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcontacts.contact.gender.Gender; +import org.mxchange.jcountry.data.Country; +import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider; +import org.mxchange.jusercore.exceptions.UserNotFoundException; +import org.mxchange.jusercore.model.user.User; +import org.mxchange.jusercore.model.user.UserSessionBeanRemote; +import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; + +/** + * A user bean (controller) + *

+ * @author Roland Haeder + */ +@Named ("adminUserController") +@SessionScoped +public class PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionController { + + /** + * Serial number + */ + private static final long serialVersionUID = 542_145_347_916L; + + /////////////////////// Properties ///////////////////// + /** + * Birth day + */ + private Date birthday; + + /** + * Cellphone number's carrier + */ + private SmsProvider cellphoneCarrier; + + /** + * Cellphone number + */ + private Long cellphoneNumber; + + /** + * City + */ + private String city; + + /** + * Optional comments + */ + private String comment; + + /** + * Country instance + */ + private Country country; + + /** + * Email address + */ + private String emailAddress; + + /** + * Family name + */ + private String familyName; + + /** + * Fax number's area code + */ + private Integer faxAreaCode; + + /** + * Country instance for fax number + */ + private Country faxCountry; + + /** + * Fax number + */ + private Long faxNumber; + + /** + * First name + */ + private String firstName; + + /** + * Gender instance + */ + private Gender gender; + + /** + * House number + */ + private Short houseNumber; + + /** + * Phone number area code + */ + private Integer phoneAreaCode; + + /** + * Country instance for phone number + */ + private Country phoneCountry; + + /** + * Phone number + */ + private Long phoneNumber; + + /** + * Street + */ + private String street; + + /** + * Remote user bean + */ + private final UserSessionBeanRemote userBean; + + /** + * User id + */ + private Long userId; + + /** + * A list of all user profiles + */ + private List userList; + + /** + * User name + */ + private String userName; + + /** + * User password (unencrypted from web form) + */ + private String userPassword; + + /** + * User password repeated (unencrypted from web form) + */ + private String userPasswordRepeat; + + /** + * Whether the user wants a public profile + */ + private ProfileMode userProfileMode; + + /** + * ZIP code + */ + private Integer zipCode; + + /** + * Default constructor + */ + public PizzaAdminUserWebSessionBean () { + // Set gender to UNKNOWN + this.gender = Gender.UNKNOWN; + + // 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 + } catch (final NamingException e) { + // Throw again + throw new FaceletException(e); + } + } + + @Override + public List allUsers () { + // Return it + return Collections.unmodifiableList(this.userList); + } + + @Override + public Date getBirthday () { + return this.birthday; + } + + @Override + public void setBirthday (final Date birthday) { + this.birthday = birthday; + } + + @Override + public SmsProvider getCellphoneCarrier () { + return this.cellphoneCarrier; + } + + @Override + public void setCellphoneCarrier (final SmsProvider cellphoneCarrier) { + this.cellphoneCarrier = cellphoneCarrier; + } + + @Override + public Long getCellphoneNumber () { + return this.cellphoneNumber; + } + + @Override + public void setCellphoneNumber (Long cellphoneNumber) { + this.cellphoneNumber = cellphoneNumber; + } + + @Override + public String getCity () { + return this.city; + } + + @Override + public void setCity (final String city) { + this.city = city; + } + + @Override + public String getComment () { + return this.comment; + } + + @Override + public void setComment (final String comment) { + this.comment = comment; + } + + @Override + public Country getCountry () { + return this.country; + } + + @Override + public void setCountry (final Country country) { + this.country = country; + } + + @Override + public String getEmailAddress () { + return this.emailAddress; + } + + @Override + public void setEmailAddress (final String emailAddress) { + this.emailAddress = emailAddress; + } + + @Override + public String getFamilyName () { + return this.familyName; + } + + @Override + public void setFamilyName (final String familyName) { + this.familyName = familyName; + } + + @Override + public Integer getFaxAreaCode () { + return this.faxAreaCode; + } + + @Override + public void setFaxAreaCode (final Integer faxAreaCode) { + this.faxAreaCode = faxAreaCode; + } + + @Override + public Country getFaxCountry () { + return this.faxCountry; + } + + @Override + public void setFaxCountry (final Country faxCountry) { + this.faxCountry = faxCountry; + } + + @Override + public Long getFaxNumber () { + return this.faxNumber; + } + + @Override + public void setFaxNumber (final Long faxNumber) { + this.faxNumber = faxNumber; + } + + @Override + public String getFirstName () { + return this.firstName; + } + + @Override + public void setFirstName (final String firstName) { + this.firstName = firstName; + } + + @Override + public Gender getGender () { + return this.gender; + } + + @Override + public void setGender (final Gender gender) { + this.gender = gender; + } + + @Override + public Short getHouseNumber () { + return this.houseNumber; + } + + @Override + public void setHouseNumber (final Short houseNumber) { + this.houseNumber = houseNumber; + } + + @Override + public Integer getPhoneAreaCode () { + return this.phoneAreaCode; + } + + @Override + public void setPhoneAreaCode (final Integer phoneAreaCode) { + this.phoneAreaCode = phoneAreaCode; + } + + @Override + public Country getPhoneCountry () { + return this.phoneCountry; + } + + @Override + public void setPhoneCountry (final Country phoneCountry) { + this.phoneCountry = phoneCountry; + } + + @Override + public Long getPhoneNumber () { + return this.phoneNumber; + } + + @Override + public void setPhoneNumber (final Long phoneNumber) { + this.phoneNumber = phoneNumber; + } + + @Override + public String getStreet () { + return this.street; + } + + @Override + public void setStreet (final String street) { + this.street = street; + } + + @Override + public Long getUserId () { + return this.userId; + } + + @Override + public void setUserId (final Long userId) { + this.userId = userId; + } + + @Override + public String getUserName () { + return this.userName; + } + + @Override + public void setUserName (final String userName) { + this.userName = userName; + } + + @Override + public String getUserPassword () { + return this.userPassword; + } + + @Override + public void setUserPassword (final String userPassword) { + this.userPassword = userPassword; + } + + @Override + public String getUserPasswordRepeat () { + return this.userPasswordRepeat; + } + + @Override + public void setUserPasswordRepeat (final String userPasswordRepeat) { + this.userPasswordRepeat = userPasswordRepeat; + } + + @Override + public ProfileMode getUserProfileMode () { + return this.userProfileMode; + } + + @Override + public void setUserProfileMode (final ProfileMode userProfileMode) { + this.userProfileMode = userProfileMode; + } + + @Override + public Integer getZipCode () { + return this.zipCode; + } + + @Override + public void setZipCode (final Integer zipCode) { + this.zipCode = zipCode; + } + + /** + * Post-initialization of this class + */ + @PostConstruct + public void init () { + // Initialize user list + this.userList = this.userBean.allUsers(); + } + + @Override + public User lookupUserById (final Long userId) throws UserNotFoundException { + // Init variable + User user = null; + + // Try to lookup it in visible user list + for (final Iterator iterator = this.userList.iterator(); iterator.hasNext();) { + // Get next user + User next = iterator.next(); + + // Is the user id found? + if (Objects.equals(next.getUserId(), userId)) { + // Copy to other variable + user = next; + break; + } + } + + // Is it still null? + if (null == user) { + // Not visible for the current user + throw new UserNotFoundException(userId); + } + + // Return it + return user; + } + +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionController.java new file mode 100644 index 00000000..f2b25ad8 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionController.java @@ -0,0 +1,391 @@ +/* + * 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.pizzaapplication.beans.user; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import org.mxchange.jcontacts.contact.gender.Gender; +import org.mxchange.jcountry.data.Country; +import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider; +import org.mxchange.jusercore.exceptions.UserNotFoundException; +import org.mxchange.jusercore.model.user.User; +import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; + +/** + * An interface for user beans + *

+ * @author Roland Haeder + */ +public interface PizzaAdminUserWebSessionController extends Serializable { + + /** + * Tries to lookup user by given id number. If the user is not found or the + * account status is not CONFIRMED proper exceptions are thrown. + *

+ * @param userId User id + *

+ * @return User instance + *

+ * @throws UserNotFoundException If the user is not found + */ + User lookupUserById (final Long userId) throws UserNotFoundException; + + /** + * All users + *

+ * @return A list of all public user profiles + */ + List allUsers (); + + /** + * Getter for birth day + *

+ * @return Birth day + */ + Date getBirthday (); + + /** + * Setter for birth day + *

+ * @param birthday Birth day + */ + void setBirthday (final Date birthday); + + /** + * Getter for ellphone number's carrier + *

+ * @return Cellphone number's carrier + */ + SmsProvider getCellphoneCarrier (); + + /** + * Setter for cellphone number's carrier prefix + *

+ * @param cellphoneCarrier Cellphone number's carrier prefix + */ + void setCellphoneCarrier (final SmsProvider cellphoneCarrier); + + /** + * Getter for ellphone number + *

+ * @return Cellphone number + */ + Long getCellphoneNumber (); + + /** + * Setter for ellphone number + *

+ * @param cellphoneNumber Cellphone number + */ + void setCellphoneNumber (final Long cellphoneNumber); + + /** + * City + *

+ * @return the city + */ + String getCity (); + + /** + * City + *

+ * @param city the city to set + */ + void setCity (final String city); + + /** + * Getter for comments + *

+ * @return Comments + */ + String getComment (); + + /** + * Setter for comment + *

+ * @param comment Comments + */ + void setComment (final String comment); + + /** + * Getter for country instance + *

+ * @return Country instance + */ + Country getCountry (); + + /** + * Setter for country instance + *

+ * @param country Country instance + */ + void setCountry (final Country country); + + /** + * Getter for email address + *

+ * @return Email address + */ + String getEmailAddress (); + + /** + * Setter for email address + *

+ * @param emailAddress Email address + */ + void setEmailAddress (final String emailAddress); + + /** + * Family name + *

+ * @return the familyName + */ + String getFamilyName (); + + /** + * Family name + *

+ * @param familyName the familyName to set + */ + void setFamilyName (final String familyName); + + /** + * Getter for fax number's area code + *

+ * @return Fax number's area code + */ + Integer getFaxAreaCode (); + + /** + * Setter for fax number's area code + *

+ * @param faxAreaCode Fax number's area code + */ + void setFaxAreaCode (final Integer faxAreaCode); + + /** + * Getter for fax's country instance + *

+ * @return Fax' country instance + */ + Country getFaxCountry (); + + /** + * Setter for fax's country instance + *

+ * @param faxCountry Fax' country instance + */ + void setFaxCountry (final Country faxCountry); + + /** + * Getter for fax number + *

+ * @return Fax number + */ + Long getFaxNumber (); + + /** + * Setter for fax number + *

+ * @param faxNumber Fax number + */ + void setFaxNumber (final Long faxNumber); + + /** + * First name + *

+ * @return the first name + */ + String getFirstName (); + + /** + * First name + *

+ * @param firstName the first name to set + */ + void setFirstName (final String firstName); + + /** + * Gender of the contact + *

+ * @return the gender + */ + Gender getGender (); + + /** + * Gender of the contact + *

+ * @param gender the gender to set + */ + void setGender (final Gender gender); + + /** + * House number + *

+ * @return the houseNumber + */ + Short getHouseNumber (); + + /** + * House number + *

+ * @param houseNumber the houseNumber to set + */ + void setHouseNumber (final Short houseNumber); + + /** + * Getter for phone number's area code + *

+ * @return Phone number's area code + */ + Integer getPhoneAreaCode (); + + /** + * Setter for phone number's area code + *

+ * @param phoneAreaCode Phone number's area code + */ + void setPhoneAreaCode (final Integer phoneAreaCode); + + /** + * Getter for phone number's country instance + *

+ * @return Phone number's country instance + */ + Country getPhoneCountry (); + + /** + * Setter for phone number's country instance + *

+ * @param phoneCountry Phone number's country instance + */ + void setPhoneCountry (final Country phoneCountry); + + /** + * Getter for phone number + *

+ * @return Phone number + */ + Long getPhoneNumber (); + + /** + * Setter for phone number + *

+ * @param phoneNumber Phone number + */ + void setPhoneNumber (final Long phoneNumber); + + /** + * Street + *

+ * @return the street + */ + String getStreet (); + + /** + * Street + *

+ * @param street the street to set + */ + void setStreet (final String street); + + /** + * Getter for user id + *

+ * @return User id + */ + Long getUserId (); + + /** + * Setter for user id + *

+ * @param userId User id + */ + void setUserId (final Long userId); + + /** + * Getter for user name + *

+ * @return User name + */ + String getUserName (); + + /** + * Setter for user name + *

+ * @param userName User name + */ + void setUserName (final String userName); + + /** + * Getter for unencrypted user password + *

+ * @return Unencrypted user password + */ + String getUserPassword (); + + /** + * Setter for unencrypted user password + *

+ * @param userPassword Unencrypted user password + */ + void setUserPassword (final String userPassword); + + /** + * Getter for unencrypted user password repeated + *

+ * @return Unencrypted user password repeated + */ + String getUserPasswordRepeat (); + + /** + * Setter for unencrypted user password repeated + *

+ * @param userPasswordRepeat Unencrypted user password repeated + */ + void setUserPasswordRepeat (final String userPasswordRepeat); + + /** + * Getter for user profile mode + *

+ * @return User profile mode + */ + ProfileMode getUserProfileMode (); + + /** + * Setter for user profile mode + *

+ * @param userProfileMode User profile mode + */ + void setUserProfileMode (final ProfileMode userProfileMode); + + /** + * ZIP code + *

+ * @return the zipCode + */ + Integer getZipCode (); + + /** + * ZIP code + *

+ * @param zipCode the zipCode to set + */ + void setZipCode (final Integer zipCode); + +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java index 74b7d5b1..10d309f3 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java @@ -513,4 +513,5 @@ public interface PizzaUserWebSessionController extends Serializable { * @return Whether the user id is empty */ boolean isUserIdEmpty (); + } diff --git a/web/admin/admin_user_list.xhtml b/web/admin/admin_user_list.xhtml index 4f336b36..876f195d 100644 --- a/web/admin/admin_user_list.xhtml +++ b/web/admin/admin_user_list.xhtml @@ -14,7 +14,7 @@ - + -- 2.39.5