From: Roland Haeder Date: Thu, 15 Oct 2015 18:38:28 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5ccfeaa35eb1c9a388ab998606ca2ff301d8b9d0;p=jfinancials-war.git Continued: - added page login_start_sharing_addressbook.xhtml with some experimental content (not tested) - added their language strings - added whole address book instance property to bean - added bean method allUsersNotSharing() - updated jar(s) --- diff --git a/lib/juser-core.jar b/lib/juser-core.jar index 94920473..c8486cff 100644 Binary files a/lib/juser-core.jar and b/lib/juser-core.jar differ diff --git a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java index 1c66acdf..5593aa0a 100644 --- a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java @@ -65,6 +65,11 @@ public class AddressbookWebBean implements AddressbookWebController { */ private static final long serialVersionUID = 185_781_756_712_969L; + /** + * Address book instance + */ + private Addressbook addressbook; + /** * Remote address book bean */ @@ -144,16 +149,16 @@ public class AddressbookWebBean implements AddressbookWebController { } // Create address book instance with name - Addressbook addressbook = new UserAddressbook(this.getAddressbookName()); + Addressbook book = new UserAddressbook(this.getAddressbookName()); // Set default status to UNLOCKED and owner - addressbook.setAddressbookStatus(AddressbokStatus.UNLOCKED); - addressbook.setAddressbookUser(this.loginController.getLoggedInUser()); - addressbook.setAddressbookCreated(new GregorianCalendar()); + book.setAddressbookStatus(AddressbokStatus.UNLOCKED); + book.setAddressbookUser(this.loginController.getLoggedInUser()); + book.setAddressbookCreated(new GregorianCalendar()); try { // Register this address book - Addressbook updatedAddressbook = this.addressbookBean.createAddressbook(addressbook); + Addressbook updatedAddressbook = this.addressbookBean.createAddressbook(book); // Remove name this.setAddressbookName(null); @@ -174,29 +179,32 @@ public class AddressbookWebBean implements AddressbookWebController { // event should not be null if (null == event) { // Throw NPE - throw new NullPointerException("event is null"); + throw new NullPointerException("event is null"); //NOI18N } else if (event.getAddressbook() == null) { // Throw NPE again - throw new NullPointerException("event.addressbook is null"); + throw new NullPointerException("event.addressbook is null"); //NOI18N } else if (event.getAddressbook().getAddressbookId() == null) { // And again a NPE - throw new NullPointerException("event.addressbook.addressbookId is null"); + throw new NullPointerException("event.addressbook.addressbookId is null"); //NOI18N } else if (event.getAddressbook().getAddressbookId() < 1) { // Invalid id number - throw new IllegalArgumentException("Address book instance " + event.getAddressbook() + " has invalid id number: " + event.getAddressbook().getAddressbookId()); + throw new IllegalArgumentException(MessageFormat.format("Address book instance {0} has invalid id number: {1}", event.getAddressbook(), event.getAddressbook().getAddressbookId())); //NOI18N } else if (event.getAddressbook().getAddressbookUser() == null) { // One more NPE ... - throw new NullPointerException("event.addressbook.addressbookUser is null"); + throw new NullPointerException("event.addressbook.addressbookUser is null"); //NOI18N } // Get address book instance - Addressbook addressbook = event.getAddressbook(); + Addressbook book = event.getAddressbook(); // Set address book data - this.setAddressbookId(addressbook.getAddressbookId()); - this.setAddressbookName(addressbook.getAddressbookName()); - this.setAddressbookUser(addressbook.getAddressbookUser()); - this.setAddressbookCreated(addressbook.getAddressbookCreated()); + this.setAddressbookId(book.getAddressbookId()); + this.setAddressbookName(book.getAddressbookName()); + this.setAddressbookUser(book.getAddressbookUser()); + this.setAddressbookCreated(book.getAddressbookCreated()); + + // And instance ... + this.setAddressbook(book); } @Override @@ -204,13 +212,13 @@ public class AddressbookWebBean implements AddressbookWebController { // Is the user logged in? if (null == event) { // Is null - throw new NullPointerException("event is null"); + throw new NullPointerException("event is null"); //NOI18N } else if (event.getUser() == null) { // user is null - throw new NullPointerException("event.user is null"); + throw new NullPointerException("event.user is null"); //NOI18N } else if (!event.getUser().equals(this.loginController.getLoggedInUser())) { // Not matching - throw new IllegalStateException("event.user and loginController.loggedInUser don't match."); + throw new IllegalStateException("event.user and loginController.loggedInUser don't match."); //NOI18N } else if (!this.loginController.isUserLoggedIn()) { // Not logged in throw new FaceletException("This method can only be called as logged-in user."); //NOI18N @@ -260,6 +268,18 @@ public class AddressbookWebBean implements AddressbookWebController { return Collections.unmodifiableList(this.sharedAddressbooks); } + @Override + public List allUsersNotSharing () { + // Is the user logged in? + if (!this.loginController.isUserLoggedIn()) { + // Not logged in + throw new FaceletException("This method can only be called as logged-in user."); //NOI18N + } + + // Call EJB + return this.addressbookBean.allUsersNotSharing(this.loginController.getLoggedInUser(), this.getAddressbook()); + } + @Override public Integer countAllUserSharedAddressbooks (final User user) { // Is there cache? @@ -278,6 +298,16 @@ public class AddressbookWebBean implements AddressbookWebController { return count; } + @Override + public Addressbook getAddressbook () { + return this.addressbook; + } + + @Override + public void setAddressbook (final Addressbook addressbook) { + this.addressbook = addressbook; + } + @Override public Calendar getAddressbookCreated () { return this.addressbookCreated; @@ -360,9 +390,9 @@ public class AddressbookWebBean implements AddressbookWebController { boolean isFound = false; // Check all entries - for (final Addressbook addressbook : this.usersAddressbooks) { + for (final Addressbook book : this.usersAddressbooks) { // Is the name same? - if (addressbook.getAddressbookName().equals(addressbookName)) { + if (book.getAddressbookName().equals(addressbookName)) { // Found a match isFound = true; break; @@ -396,6 +426,6 @@ public class AddressbookWebBean implements AddressbookWebController { */ private void initAddressbookList () { // Fill list with entries - this.usersAddressbooks = this.addressbookBean.getUsersList(this.loginController.getLoggedInUser()); + this.usersAddressbooks = this.addressbookBean.getUsersAddressbookList(this.loginController.getLoggedInUser()); } } diff --git a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java index 285ce793..97995957 100644 --- a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java +++ b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java @@ -188,4 +188,25 @@ public interface AddressbookWebController extends Serializable { */ boolean isOtherAddressbook (); + /** + * Getter for address book instance + *

+ * @return Address book instance + */ + Addressbook getAddressbook (); + + /** + * Setter for address book instance + *

+ * @param addressbook Address book instance + */ + void setAddressbook (final Addressbook addressbook); + + /** + * Retrieves a list of all users this user is not sharing this address book + * with. + *

+ * @return List of not sharing users + */ + List allUsersNotSharing (); } diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index a0885892..e8dd33ed 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -224,3 +224,14 @@ TABLE_HEADER_ERROR_HANDLING_USER_ID=Fehler beim Verarbeiten der Benutzernummer: TABLE_HEADER_SHOW_ADDRESSBOOK=Adressbuchdaten: LINK_LOGIN_START_SHARING_ADDRESSBOOK=Mit jemandem dieses Adressbuch teilen LINK_LOGIN_START_SHARING_ADDRESSBOOK_TITLE=Dieses Adresssbuch k\u00f6nnen Sie mit einem anderen Benutzer teilen. Dadurch kann er Ihre Kontakte sehen. +PAGE_TITLE_LOGIN_START_SHARING_ADDRESSBOOK=Das Adressbuch mit anderen Benutzern teilen +CONTENT_TITLE_LOGIN_START_SHARING_ADDRESSBOOK=Teilen Sie dieses Adressbuch mit anderen Benutzern: +LOGIN_START_SHARING_TITLE=Teilen +LOGIN_START_SHARING_BUTTON=Mit diesem Benutzer teilen +#TODO: Please fix German umlaut! +LOGIN_START_SHARING_BUTTON_TITLE=Teilen Sie Ihr ausgewaehltes Adressbuch mit diesem Benutzer. +#TODO: Please fix German umlaut! +TABLE_HEADER_CHOOSE_USER_FOR_SHARING=Waehlen Sie einen Benutzer zum Teilen Ihres Adressbuches aus. +LOGIN_START_SHARING_NOTICE1=Damit werden Ihr gesamtes Adressbuch fuer den ausgewaehlten Benutzer sichtbar. +#TODO: Please fix German umlaut! +LOGIN_START_SHARING_NOTICE2=Sie koennen dies jederzeit wiederrufen. diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 8d59d3f9..aabbaccb 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -224,3 +224,11 @@ TABLE_HEADER_ERROR_HANDLING_USER_ID=Error while handling user id: TABLE_HEADER_SHOW_ADDRESSBOOK=Address book data: LINK_LOGIN_START_SHARING_ADDRESSBOOK=Start sharing this address book with another user LINK_LOGIN_START_SHARING_ADDRESSBOOK_TITLE=You can start sharing this address book with anther user. Then he cann see your contacts. +PAGE_TITLE_LOGIN_START_SHARING_ADDRESSBOOK=Share the address book with other users +CONTENT_TITLE_LOGIN_START_SHARING_ADDRESSBOOK=Start sharing this address book with other users: +LOGIN_START_SHARING_TITLE=Share +LOGIN_START_SHARING_BUTTON=Share with this user +LOGIN_START_SHARING_BUTTON_TITLE=Share your choosen address book with this user. +TABLE_HEADER_CHOOSE_USER_FOR_SHARING=Choose a user for sharing your address book with. +LOGIN_START_SHARING_NOTICE1=With this your whole address book becomes visible to the other user. +LOGIN_START_SHARING_NOTICE2=You can always revoke your choice. diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index 2c867026..af277878 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -159,4 +159,11 @@ /login/login_list_sharing_addressbooks.xhtml + + /login/login_show_addressbook.xhtml + + login_start_sharing_addressbook + /login/login_start_sharing_addressbook.xhtml + + diff --git a/web/login/login_start_sharing_addressbook.xhtml b/web/login/login_start_sharing_addressbook.xhtml new file mode 100644 index 00000000..432dc7be --- /dev/null +++ b/web/login/login_start_sharing_addressbook.xhtml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + #{msg.PAGE_TITLE_LOGIN_START_SHARING_ADDRESSBOOK} + + + #{msg.CONTENT_TITLE_LOGIN_START_SHARING_ADDRESSBOOK} + + + +

+ +
+ #{msg.TABLE_HEADER_CHOOSE_USER_FOR_SHARING} +
+ +
+ + + #{msg.USER_ID} + + + + + + + #{msg.USER_NAME} + + + + + #{msg.LOGIN_START_SHARING_TITLE} + + + + + +
+ + +
+ + +