- added ability to link any contact with user and/or customer accounts (later is unfinished)
- to make thism working, a controller method selectableContacts() is needed (cached)
- also the event for administrators adding users (customers missing!) must be observed to remove contact from selectable list
- because of the above, the HTML form can no longer validate required="true", it must be done by the controller (ugly exceptions for now)
- some beans/controllers loaded/injected
- added missing i18n strings
- fixed some exception messages
- ignored strings for i18n
- changed CSS class in admin area pages from small to medium (needs more space)
- removed double underscore (one removed)
Signed-off-by: Roland Häder <roland@mxchange.org>
<Scene Scope="Project" version="2">
<Scope Scope="Faces Configuration Only"/>
<Scope Scope="Project">
- <Node id="admin/cellphone/admin_contact_cellphone_list.xhtml" x="900" y="1050" zoom="true"/>
- <Node id="admin/contact/admin_contact_show.xhtml" x="1150" y="900" zoom="true"/>
- <Node id="login/login_change_password.xhtml" x="650" y="600" zoom="true"/>
- <Node id="privacy.xhtml" x="1650" y="150" zoom="true"/>
- <Node id="admin/mobile_provider/admin_mobile_provider_show.xhtml" x="900" y="450" zoom="true"/>
- <Node id="admin/user/admin_user_show.xhtml" x="1400" y="450" zoom="true"/>
- <Node id="admin/index.xhtml" x="1650" y="300" zoom="true"/>
- <Node id="user/resend_link.xhtml" x="150" y="1350" zoom="true"/>
- <Node id="admin/admin_logout.xhtml" x="150" y="150" zoom="true"/>
- <Node id="admin/user/admin_user_unlock.xhtml" x="1400" y="150" zoom="true"/>
- <Node id="index.xhtml" x="400" y="900" zoom="true"/>
- <Node id="user/register_done.xhtml" x="150" y="1050" zoom="true"/>
- <Node id="*" x="400" y="300" zoom="true"/>
- <Node id="admin/admin_category_delete.xhtml" x="400" y="750" zoom="true"/>
- <Node id="user/login_error.xhtml" x="650" y="150" zoom="true"/>
- <Node id="admin/cellphone/admin_contact_cellphone_edit.xhtml" x="900" y="600" zoom="true"/>
- <Node id="user/show_addressbook_entries.xhtml" x="1900" y="300" zoom="true"/>
- <Node id="user/lost_passwd.xhtml" x="2400" y="150" zoom="true"/>
- <Node id="user/login.xhtml" x="1150" y="300" zoom="true"/>
+ <Node id="admin/cellphone/admin_contact_cellphone_list.xhtml" x="900" y="150" zoom="true"/>
+ <Node id="admin/contact/admin_contact_show.xhtml" x="400" y="900" zoom="true"/>
+ <Node id="login/login_change_password.xhtml" x="150" y="1200" zoom="true"/>
+ <Node id="privacy.xhtml" x="150" y="1500" zoom="true"/>
+ <Node id="admin/mobile_provider/admin_mobile_provider_show.xhtml" x="1400" y="300" zoom="true"/>
+ <Node id="admin/user/admin_user_show.xhtml" x="150" y="600" zoom="true"/>
+ <Node id="admin/index.xhtml" x="150" y="1350" zoom="true"/>
+ <Node id="user/resend_link.xhtml" x="900" y="450" zoom="true"/>
+ <Node id="user/index.xhtml" x="1400" y="600" zoom="true"/>
+ <Node id="admin/admin_logout.xhtml" x="400" y="1200" zoom="true"/>
+ <Node id="admin/user/admin_user_unlock.xhtml" x="400" y="450" zoom="true"/>
+ <Node id="index.xhtml" x="400" y="1350" zoom="true"/>
+ <Node id="user/register_done.xhtml" x="400" y="1050" zoom="true"/>
+ <Node id="*" x="150" y="300" zoom="true"/>
+ <Node id="admin/admin_category_delete.xhtml" x="1650" y="600" zoom="true"/>
+ <Node id="user/login_error.xhtml" x="400" y="150" zoom="true"/>
+ <Node id="user/login_index.xhtml" x="150" y="750" zoom="true"/>
+ <Node id="admin/cellphone/admin_contact_cellphone_edit.xhtml" x="1150" y="750" zoom="true"/>
+ <Node id="user/show_addressbook_entries.xhtml" x="1900" y="450" zoom="true"/>
+ <Node id="user/lost_passwd.xhtml" x="900" y="900" zoom="true"/>
+ <Node id="user/login.xhtml" x="650" y="1200" zoom="true"/>
<Node id="login/login_contact_data_saved.xhtml" x="400" y="600" zoom="true"/>
- <Node id="login/login_edit_user_data.xhtml" x="1150" y="450" zoom="true"/>
- <Node id="admin/cellphone/admin_contact_cellphone_unlink.xhtml" x="650" y="1050" zoom="true"/>
- <Node id="admin/country/admin_country_list.xhtml" x="1400" y="750" zoom="true"/>
- <Node id="admin/mobile_provider/admin_mobile_provider_delete.xhtml" x="1650" y="450" zoom="true"/>
- <Node id="admin/mobile_provider/admin_mobile_provider_list.xhtml" x="1400" y="600" zoom="true"/>
- <Node id="admin/user/admin_user_delete.xhtml" x="1150" y="150" zoom="true"/>
- <Node id="admin/cellphone/admin_contact_cellphone_delete.xhtml" x="650" y="450" zoom="true"/>
- <Node id="login/login_data_saved.xhtml" x="650" y="900" zoom="true"/>
- <Node id="exception.xhtml" x="650" y="1200" zoom="true"/>
+ <Node id="admin/cellphone/admin_contact_cellphone_unlink.xhtml" x="1650" y="300" zoom="true"/>
+ <Node id="login/login_edit_user_data.xhtml" x="1400" y="450" zoom="true"/>
+ <Node id="admin/country/admin_country_list.xhtml" x="2650" y="150" zoom="true"/>
+ <Node id="admin/mobile_provider/admin_mobile_provider_delete.xhtml" x="650" y="750" zoom="true"/>
+ <Node id="admin/mobile_provider/admin_mobile_provider_list.xhtml" x="2400" y="300" zoom="true"/>
+ <Node id="admin/user/admin_user_delete.xhtml" x="900" y="300" zoom="true"/>
+ <Node id="login/login_data_saved.xhtml" x="1150" y="300" zoom="true"/>
+ <Node id="admin/cellphone/admin_contact_cellphone_delete.xhtml" x="650" y="600" zoom="true"/>
+ <Node id="exception.xhtml" x="2400" y="150" zoom="true"/>
<Node id="user/register.xhtml" x="150" y="900" zoom="true"/>
- <Node id="login/login_index.xhtml" x="1900" y="150" zoom="true"/>
- <Node id="login/login_add_addressbook.xhtml" x="2150" y="150" zoom="true"/>
- <Node id="login/login_own_addressbooks.xhtml" x="1150" y="750" zoom="true"/>
- <Node id="admin/user/admin_user_edit.xhtml" x="900" y="150" zoom="true"/>
- <Node id="terms.xhtml" x="2150" y="300" zoom="true"/>
- <Node id="admin/contact/admin_contact_edit.xhtml" x="150" y="450" zoom="true"/>
- <Node id="admin/contact/admin_contact_list.xhtml" x="400" y="1200" zoom="true"/>
- <Node id="admin/user/admin_user_list.xhtml" x="150" y="300" zoom="true"/>
- <Node id="admin/admin_user_add.xhtml" x="900" y="750" zoom="true"/>
- <Node id="admin/country/admin_country_delete.xhtml" x="400" y="450" zoom="true"/>
- <Node id="login/login_user_data_saved.xhtml" x="150" y="600" zoom="true"/>
- <Node id="user/user_list.xhtml" x="400" y="1050" zoom="true"/>
- <Node id="logout.xhtml" x="650" y="300" zoom="true"/>
- <Node id="admin/country/admin_country_edit.xhtml" x="150" y="750" zoom="true"/>
- <Node id="login/login_change_personal_data.xhtml" x="400" y="150" zoom="true"/>
- <Node id="user/user_profile.xhtml" x="1150" y="600" zoom="true"/>
- <Node id="admin/contact/admin_contact_delete.xhtml" x="900" y="900" zoom="true"/>
- <Node id="user/show_addressbook.xhtml" x="900" y="300" zoom="true"/>
- <Node id="imprint.xhtml" x="1650" y="600" zoom="true"/>
- <Node id="admin/mobile_provider/admin_mobile_provider_edit.xhtml" x="1900" y="450" zoom="true"/>
- <Node id="admin/cellphone/admin_contact_cellphone_show.xhtml" x="650" y="750" zoom="true"/>
- <Node id="admin/admin_product_delete.xhtml" x="1400" y="300" zoom="true"/>
- <Node id="login/login_change_email_address.xhtml" x="150" y="1200" zoom="true"/>
+ <Node id="login/login_add_addressbook.xhtml" x="400" y="300" zoom="true"/>
+ <Node id="login/login_index.xhtml" x="650" y="1050" zoom="true"/>
+ <Node id="login/login_own_addressbooks.xhtml" x="1150" y="900" zoom="true"/>
+ <Node id="admin/user/admin_user_edit.xhtml" x="650" y="300" zoom="true"/>
+ <Node id="login/index.xhtml" x="1400" y="750" zoom="true"/>
+ <Node id="terms.xhtml" x="2150" y="150" zoom="true"/>
+ <Node id="admin/contact/admin_contact_edit.xhtml" x="400" y="750" zoom="true"/>
+ <Node id="admin/contact/admin_contact_list.xhtml" x="1650" y="450" zoom="true"/>
+ <Node id="admin/admin_user_add.xhtml" x="1150" y="450" zoom="true"/>
+ <Node id="admin/user/admin_user_list.xhtml" x="1900" y="300" zoom="true"/>
+ <Node id="admin/country/admin_country_delete.xhtml" x="150" y="1050" zoom="true"/>
+ <Node id="user/user_list.xhtml" x="150" y="450" zoom="true"/>
+ <Node id="login/login_user_data_saved.xhtml" x="2150" y="300" zoom="true"/>
+ <Node id="logout.xhtml" x="900" y="750" zoom="true"/>
+ <Node id="admin/country/admin_country_edit.xhtml" x="650" y="900" zoom="true"/>
+ <Node id="login/login_change_personal_data.xhtml" x="1150" y="150" zoom="true"/>
+ <Node id="admin/contact/admin_contact_delete.xhtml" x="1400" y="150" zoom="true"/>
+ <Node id="user/user_profile.xhtml" x="900" y="1050" zoom="true"/>
+ <Node id="imprint.xhtml" x="1900" y="150" zoom="true"/>
+ <Node id="user/show_addressbook.xhtml" x="1150" y="600" zoom="true"/>
+ <Node id="admin/mobile_provider/admin_mobile_provider_edit.xhtml" x="150" y="150" zoom="true"/>
+ <Node id="admin/cellphone/admin_contact_cellphone_show.xhtml" x="900" y="600" zoom="true"/>
+ <Node id="guest/user/login.xhtml" x="650" y="450" zoom="true"/>
+ <Node id="admin/admin_product_delete.xhtml" x="1650" y="150" zoom="true"/>
+ <Node id="login/login_change_email_address.xhtml" x="650" y="150" zoom="true"/>
</Scope>
<Scope Scope="All Faces Configurations"/>
</Scene>
throw new NullPointerException("event is null"); //NOI18N
} else if (event.getUpdatedContact() == null) {
// Throw NPE again
- throw new NullPointerException("event.user is null"); //NOI18N
+ throw new NullPointerException("event.updatedUser is null"); //NOI18N
} else if (event.getUpdatedContact().getContactId() == null) {
// userId is null
- throw new NullPointerException("event.user.userId is null"); //NOI18N
+ throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
} else if (event.getUpdatedContact().getContactId() < 1) {
// Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
+ throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
}
// Get iterator from list
@Override
public String addUser () {
// Create new user instance
- User localUser = new LoginUser();
+ User user = new LoginUser();
+
+ // As the form cannot validate the data (required="true"), check it here
+ if (this.getUserName() == null) {
+ // Throw NPE
+ throw new NullPointerException("userName is null"); //NOI18N
+ } else if (this.getUserName().isEmpty()) {
+ // Is empty
+ throw new IllegalArgumentException("userName is null"); //NOI18N
+ } else if (this.adminHelper.getContact() == null) {
+ // No contact instance set, so test required fields: gender, first name and family name
+ if (this.contactController.getGender() == null) {
+ // Throw NPE again
+ throw new NullPointerException("contactController.gender is null"); //NOI18N
+ } else if (this.contactController.getFirstName() == null) {
+ // ... and again
+ throw new NullPointerException("contactController.firstName is null"); //NOI18N //NOI18N
+ } else if (this.contactController.getFirstName().isEmpty()) {
+ // ... and again
+ throw new IllegalArgumentException("contactController.firstName is empty");
+ } else if (this.contactController.getFamilyName() == null) {
+ // ... and again
+ throw new NullPointerException("contactController.familyName is null"); //NOI18N
+ } else if (this.contactController.getFamilyName().isEmpty()) {
+ // ... and again
+ throw new IllegalArgumentException("contactController.familyName is empty"); //NOI18N //NOI18N
+ } else if (this.contactController.getEmailAddress()== null) {
+ // ... and again
+ throw new NullPointerException("contactController.emailAddress is null");
+ } else if (this.contactController.getEmailAddress().isEmpty()) {
+ // ... and again
+ throw new IllegalArgumentException("contactController.emailAddress is empty"); //NOI18N //NOI18N
+ } else if (this.contactController.getEmailAddressRepeat()== null) {
+ // ... and again
+ throw new NullPointerException("contactController.emailAddressRepeat is null");
+ } else if (this.contactController.getEmailAddressRepeat().isEmpty()) {
+ // ... and again
+ throw new IllegalArgumentException("contactController.emailAddressRepeat is empty"); //NOI18N //NOI18N
+ } else if (!Objects.equals(this.contactController.getEmailAddress(), this.contactController.getEmailAddressRepeat())) {
+ // Is not same email address
+ throw new IllegalArgumentException("Both entered email addresses don't match.");
+ }
+ }
// Set user name, CONFIRMED and INVISIBLE
- localUser.setUserName(this.getUserName());
- localUser.setUserAccountStatus(UserAccountStatus.CONFIRMED);
- localUser.setUserProfileMode(ProfileMode.INVISIBLE);
+ user.setUserName(this.getUserName());
+ user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
+ user.setUserProfileMode(ProfileMode.INVISIBLE);
// Create contact instance
Contact contact = this.contactController.createContactInstance();
// Set contact in user
- localUser.setUserContact(contact);
+ user.setUserContact(contact);
// Init variable for password
String password = null;
// Is the user name or email address used already?
// @TODO Add password length check
- if (this.userController.isUserNameRegistered(localUser)) {
+ if (this.userController.isUserNameRegistered(user)) {
// User name is already used
- throw new FaceletException(new UserNameAlreadyRegisteredException(localUser));
- } else if (this.contactController.isEmailAddressRegistered(localUser.getUserContact())) {
+ throw new FaceletException(new UserNameAlreadyRegisteredException(user));
+ } else if ((this.adminHelper.getContact() == null) && (this.contactController.isEmailAddressRegistered(user.getUserContact()))) {
// Email address is already used
- throw new FaceletException(new EmailAddressAlreadyRegisteredException(localUser));
+ throw new FaceletException(new EmailAddressAlreadyRegisteredException(user));
} else if ((this.getUserPassword() == null && (this.getUserPasswordRepeat() == null)) || ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty()))) {
// Empty password entered, then generate one
password = UserUtils.createRandomPassword(JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
} else if (!this.isSamePasswordEntered()) {
// Both passwords don't match
- throw new FaceletException(new UserPasswordRepeatMismatchException(localUser));
+ throw new FaceletException(new UserPasswordRepeatMismatchException(user));
} else {
// Both match, so get it from this bean
password = this.getUserPassword();
assert (password.length() >= JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH) : "Password is not long enough."; //NOI18N
// Encrypt password and set it
- localUser.setUserEncryptedPassword(UserUtils.encryptPassword(password));
+ user.setUserEncryptedPassword(UserUtils.encryptPassword(password));
// Init updated user instance
User updatedUser = null;
try {
// Now, that all is set, call EJB
- updatedUser = this.userBean.addUser(localUser);
- } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) {
+ if (this.adminHelper.getContact() instanceof Contact) {
+ // Link contact with this user
+ updatedUser = this.userBean.linkUser(user);
+ } else {
+ // Add new contact
+ updatedUser = this.userBean.addUser(user);
+ }
+ } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) {
// Throw again
throw new FaceletException(ex);
}
@Override
public void afterRegistrationEvent (final @Observes UserRegisteredEvent event) {
// Trace message
- System.out.println(MessageFormat.format("UserWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
// event should not be null
if (null == event) {
User registeredUser = event.getRegisteredUser();
// Debug message
- System.out.println(MessageFormat.format("UserWebBean:afterRegistration: registeredUser={0}", registeredUser)); //NOI18N
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: registeredUser={0}", registeredUser)); //NOI18N
// Copy all data from registered->user
this.copyUser(registeredUser);
}
// Trace message
- System.out.println("UserWebBean:afterRegistration: EXIT!"); //NOI18N
+ //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterRegistration: EXIT!"); //NOI18N
}
@Override
public void afterUserLogin (final @Observes UserLoggedInEvent event) {
// Trace message
- System.out.println(MessageFormat.format("UserWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
// event should not be null
if (null == event) {
this.copyUser(event.getLoggedInUser());
// Trace message
- System.out.println(MessageFormat.format("UserWebBean:afterUserLogin: this.visibleUserList.size()={0} - EXIT!", this.visibleUserList.size())); //NOI18N
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterUserLogin: this.visibleUserList.size()={0} - EXIT!", this.visibleUserList.size())); //NOI18N
}
@Override
</navigation-case>
</navigation-rule>
<navigation-rule>
-<<<<<<< HEAD
-=======
- <from-view-id>/user/login.xhtml</from-view-id>
+ <from-view-id>/guest/user/login.xhtml</from-view-id>
<navigation-case>
<from-outcome>login</from-outcome>
- <to-view-id>/login/login_index.xhtml</to-view-id>
+ <to-view-id>/user/login_index.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>login_index</from-outcome>
- <to-view-id>/login/index.xhtml</to-view-id>
+ <to-view-id>/user/index.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
->>>>>>> 8eb0fb9... added initial login templates and navigation rules
<from-view-id>/user/register.xhtml</from-view-id>
<navigation-case>
<from-outcome>register_done</from-outcome>
<ui:composition
template="/WEB-INF/templates/base.tpl"
xmlns="http://www.w3.org/1999/xhtml"
-<<<<<<< HEAD
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<ui:define name="footer">
<ui:include id="footer" class="login_footer" src="/WEB-INF/templates/login/login_footer.tpl" />
</ui:define>
-=======
- xmlns:ui="http://java.sun.com/jsf/facelets">
-
- <ui:define name="title">Benutzerbereich - <ui:insert name="login_title" class="login_title" /></ui:define>
->>>>>>> b5abdb2... added initial login templates and navigation rules
</ui:composition>
</h:column>
</h:dataTable>
- <div class="table">
+ <div class="table_medium">
<h:form id="admin_add_user">
<div class="table_header">
#{msg.ADMIN_ADD_USER_TITLE}
</div>
+ <div class="para">
+ <fieldset id="user_contact">
+ <legend title="#{msg.ADMIN_SELECT_USER_CONTACT_LEGEND_TITLE}">#{msg.ADMIN_SELECT_USER_CONTACT_LEGEND}</legend>
+
+ <div class="table_row">
+ <div class="table_left_medium">
+ <h:outputLabel for="userContact" value="#{msg.ADMIN_SELECT_USER_CONTACT}" />
+ </div>
+
+ <div class="table_right_medium">
+ <h:selectOneMenu class="select" id="userContact" value="#{adminHelper.contact}" converter="ContactConverter">
+ <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
+ <f:selectItems value="#{userController.selectableContacts()}" var="contact" itemValue="#{contact}" itemLabel="#{contact.contactId}: #{msg[contact.contactGender.messageKey]} #{contact.contactFirstName} #{contact.contactFamilyName}" />
+ </h:selectOneMenu>
+ </div>
+
+ <div class="clear"></div>
+ </div>
+ </fieldset>
+ </div>
+
+ <div class="para">
+ <h:outputText value="#{msg.ADMIN_ADD_OR_ENTER_CONTACT_DATA}" />
+ </div>
+
<ui:include src="/WEB-INF/templates/admin/user/admin_form_user_personal_data.tpl" />
<div class="table_footer">
}
.table_right_medium {
- width: 250px;
+ width: 300px;
min-height: 20px;
float: right;
}