From: Roland Häder Date: Wed, 27 Apr 2016 08:54:32 +0000 (+0200) Subject: Refactured a lot: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f6aee6c52b6c09eb6d119f51af2404f227f90604;p=jjobs-war.git Refactured a lot: - administrative controller are request-scoped, therefor their "cached" lists are never cached for a longer time. So all lists has to be moved to general controllers - added new general customer bean for above refacturing Signed-off-by: Roland Häder Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestController.java b/src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestController.java index 1cb8f2e7..a5b7985f 100644 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestController.java @@ -46,6 +46,16 @@ public interface JobsAdminWebRequestController extends Serializable { */ 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 *

diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestHelper.java b/src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestHelper.java index 9d469410..fafd21db 100644 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestHelper.java +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestHelper.java @@ -40,13 +40,13 @@ public class JobsAdminWebRequestHelper implements JobsAdminWebRequestController private static final long serialVersionUID = 17_258_793_567_145_701L; /** - * Admin contact controller + * Administrative contact controller */ @Inject private JobsAdminContactWebRequestController adminContactController; /** - * Admin user controller + * Administrative user controller */ @Inject private JobsAdminUserWebRequestController adminUserController; @@ -70,7 +70,7 @@ public class JobsAdminWebRequestHelper implements JobsAdminWebRequestController @Override public void copyContactToController () { // Log message - System.out.println("AdminHelper::copyContactToController - CALLED!"); //NOI18N + //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyContactToController - CALLED!"); //NOI18N // Validate user instance if (this.getContact() == null) { @@ -88,11 +88,14 @@ public class JobsAdminWebRequestHelper implements JobsAdminWebRequestController this.adminContactController.copyContactToController(this.getContact()); // Log message - System.out.println("AdminHelper::copyContactToController - EXIT!"); //NOI18N + //* 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 @@ -109,7 +112,7 @@ public class JobsAdminWebRequestHelper implements JobsAdminWebRequestController this.adminUserController.setUserName(this.getUser().getUserName()); // Log message - System.out.println("AdminHelper::copyUserToController - EXIT!"); //NOI18N + //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - EXIT!"); //NOI18N } @Override @@ -122,6 +125,16 @@ public class JobsAdminWebRequestHelper implements JobsAdminWebRequestController this.contact = contact; } + @Override + public User getUser () { + return this.user; + } + + @Override + public void setUser (final User user) { + this.user = user; + } + @Override public String getContactUsageMessageKey (final Contact contact) { // The contact must be valid @@ -152,14 +165,4 @@ public class JobsAdminWebRequestHelper implements JobsAdminWebRequestController 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 194a85be..ae35f286 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java @@ -142,9 +142,6 @@ public class JobsAdminUserWebRequestBean implements JobsAdminUserWebRequestContr @Override public String addUser () { - // Create new user instance - User user = new LoginUser(); - // As the form cannot validate the data (required="true"), check it here if (this.getUserName() == null) { // Throw NPE @@ -169,13 +166,13 @@ public class JobsAdminUserWebRequestBean implements JobsAdminUserWebRequestContr } else if (this.contactController.getFamilyName().isEmpty()) { // ... and again throw new IllegalArgumentException("contactController.familyName is empty"); //NOI18N //NOI18N - } else if (this.contactController.getEmailAddress()== null) { + } 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) { + } else if (this.contactController.getEmailAddressRepeat() == null) { // ... and again throw new NullPointerException("contactController.emailAddressRepeat is null"); } else if (this.contactController.getEmailAddressRepeat().isEmpty()) { @@ -187,6 +184,9 @@ public class JobsAdminUserWebRequestBean implements JobsAdminUserWebRequestContr } } + // Create new user instance + User user = new LoginUser(); + // Set user name, CONFIRMED and INVISIBLE user.setUserName(this.getUserName()); user.setUserAccountStatus(UserAccountStatus.CONFIRMED); @@ -239,7 +239,7 @@ public class JobsAdminUserWebRequestBean implements JobsAdminUserWebRequestContr // Add new contact updatedUser = this.userBean.addUser(user); } - } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) { + } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) { // Throw again throw new FaceletException(ex); } @@ -301,7 +301,7 @@ public class JobsAdminUserWebRequestBean implements JobsAdminUserWebRequestContr throw new NullPointerException("adminHelper.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())); + throw new IllegalStateException(MessageFormat.format("adminHelper.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/jjobs/beans/user/JobsUserWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java index 21bbde26..76d291dc 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java @@ -140,7 +140,7 @@ public class JobsUserWebSessionBean implements JobsUserWebSessionController { } @Override - public void afterRegistrationEvent (final @Observes UserRegisteredEvent event) { + public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) { // Trace message //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N @@ -271,12 +271,12 @@ public class JobsUserWebSessionBean implements JobsUserWebSessionController { this.contactController.updateContactDataFromController(user.getUserContact()); // It should be there, so run some tests on it - assert (user instanceof User) : "Instance loginController.loggedInUser is null"; - assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null"; - assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId()); - assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; - assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; - assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); + assert (user instanceof User) : "Instance loginController.loggedInUser is null"; //NOI18N + assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null"; //NOI18N + assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N + assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; //NOI18N + assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N + assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N // Update all fields user.setUserProfileMode(this.getUserProfileMode()); @@ -483,4 +483,5 @@ public class JobsUserWebSessionBean implements JobsUserWebSessionController { DialableFaxNumber fax = user.getUserContact().getContactFaxNumber(); DialableLandLineNumber phone = user.getUserContact().getContactLandLineNumber(); } + } diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 08bdc0f1..3616ca1b 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -471,4 +471,7 @@ ADMIN_DELETE_CONTACT_TITLE=Kontaktdaten unwiederruflich l\u00f6schen BUTTON_ADMIN_DELETE_CONTACT=Kontaktdaten l\u00f6schen ADMIN_DELETE_CONTACT_NOTICE=Sie wollen Kontaktdaten l\u00f6schen. Diese k\u00f6nnten noch evtl. mit anderen Daten verkn\u00fcft sein, was zu Fehlern f\u00fchrt. Bitte l\u00f6schen Sie nur, wenn Sie sich absolut sicher sind, dass keine fremden Daten auf diesen Datensatz mehr verweisen. ADMIN_CONTACT_PERSONAL_DATA_MINIMUM_NOTICE=Bitte geben Sie mindestens Anrede, Vor- und Nachnamen ein. -ERROR_CUSTOMER_ID_NOT_FOUND=Fehler: Kundeneintrag nicht gefunden. +ADMIN_MENU_CONTACT_TITLE=Manage contact data +LINK_ADMIN_LIST_CONTACT=Kontaktdaten auflisten +LINK_ADMIN_LIST_CONTACT_TITLE=Listet alle Kontaktdaten auf, egal wo her sie angelegt wurden. +CONTACT_IS_USER=Ist Benutzer diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 1b181b87..a6b36f3b 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -440,7 +440,7 @@ ADMIN_ADD_CONTACT_MINIMUM_DATA=Please enter at least gender, first name and fami ERROR_PARAMETER_CONTACT_NOT_SET=Error: Parameter 'contact' is not set. ADMIN_HEADER_SHOW_CONTACT=Contact data for {0}: ADMIN_CONTACT_UPDATED=Contact data updated: -ADMIN_LINK_DELETE_CONTACT=Kontakt l\u00f6schen +ADMIN_LINK_DELETE_CONTACT=Delete contact data ADMIN_LINK_DELETE_CONTACT_TITLE=Deletes contact data, a confirmation is needed. PAGE_TITLE_ADMIN_DELETE_CONTACT=Delete contact data CONTENT_TITLE_ADMIN_DELETE_CONTACT=Delete contact data: @@ -448,4 +448,7 @@ ADMIN_DELETE_CONTACT_TITLE=Delete contact data unreverseable BUTTON_ADMIN_DELETE_CONTACT=Delete contact data ADMIN_DELETE_CONTACT_NOTICE=You want to delete contact data. This data could be still linked with other data which could lead to errors. Please delete only, if you are sure that no foreign data links to this record. ADMIN_CONTACT_PERSONAL_DATA_MINIMUM_NOTICE=Please enter at least gender, first name and family name. -ERROR_CUSTOMER_ID_NOT_FOUND=Error: Customer entry not found. +ADMIN_MENU_CONTACT_TITLE=Manage contact data +LINK_ADMIN_LIST_CONTACT=List contact data +LINK_ADMIN_LIST_CONTACT_TITLE=Lists all contact data regardless where they was created. +CONTACT_IS_USER=Is a user diff --git a/web/admin/contact/admin_contact_list.xhtml b/web/admin/contact/admin_contact_list.xhtml index dca2708a..81a29c4a 100644 --- a/web/admin/contact/admin_contact_list.xhtml +++ b/web/admin/contact/admin_contact_list.xhtml @@ -46,7 +46,7 @@ #{msg.ADMIN_CONTACT_USAGE} - + diff --git a/web/admin/user/admin_user_list.xhtml b/web/admin/user/admin_user_list.xhtml index c0168f1d..11ead762 100644 --- a/web/admin/user/admin_user_list.xhtml +++ b/web/admin/user/admin_user_list.xhtml @@ -16,9 +16,9 @@ - + - #{msg.ADMIN_LIST_USER_ID} + #{msg.ADMIN_USER_ID} @@ -26,43 +26,43 @@ - #{msg.ADMIN_LIST_USER_NAME} + #{msg.ADMIN_USER_NAME} - #{msg.ADMIN_LIST_USER_GENDER} + #{msg.ADMIN_CONTACT_GENDER} - #{msg.ADMIN_LIST_USER_FIRST_NAME} + #{msg.ADMIN_CONTACT_FIRST_NAME} - #{msg.ADMIN_LIST_USER_FAMILY_NAME} + #{msg.ADMIN_CONTACT_FAMILY_NAME} - #{msg.ADMIN_LIST_USER_ACCOUNT_STATUS} + #{msg.ADMIN_USER_ACCOUNT_STATUS} - #{msg.ADMIN_LIST_USER_PROFILE_MODE} + #{msg.ADMIN_USER_PROFILE_MODE} - #{msg.ADMIN_LIST_USER_CREATED} + #{msg.ADMIN_USER_CREATED}