From 65781370653f5ff1a5fecd0a81c1b8f59515e447 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 14 Oct 2015 10:16:24 +0200 Subject: [PATCH] =?utf8?q?Continued:=20-=20added=20bean=20for=20checking?= =?utf8?q?=20user's=20shared=20address=20books=20-=20added=20webpage=20log?= =?utf8?q?in=5Fshared=5Faddressbooks.xhtml=20for=20user's=20shared=20addre?= =?utf8?q?ss=20books=20-=20updated=20menu=20-=20updated=20jar(s)=20Signed-?= =?utf8?q?off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jcoreee.jar | Bin 18511 -> 18714 bytes .../beans/addressbook/AddressbookWebBean.java | 33 +++++-- .../addressbook/AddressbookWebController.java | 8 ++ .../beans/shares/SharesWebBean.java | 83 ++++++++++++++++++ .../beans/shares/SharesWebController.java | 34 +++++++ .../addressbook/beans/user/UserWebBean.java | 2 +- .../localization/bundle_de_DE.properties | 4 + .../localization/bundle_en_US.properties | 4 + web/WEB-INF/templates/login/login_menu.tpl | 3 + web/login/login_shared_addressbooks.xhtml | 25 ++++++ 10 files changed, 187 insertions(+), 9 deletions(-) create mode 100644 src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java create mode 100644 src/java/org/mxchange/addressbook/beans/shares/SharesWebController.java create mode 100644 web/login/login_shared_addressbooks.xhtml diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar index c2e022d69fedac84439d9796883f1931d015a012..4cdb134dfe55c2381d746baac342af402e2a4f80 100644 GIT binary patch delta 3118 zcma);X-r(#703T~2DrnUH^8vl;11Z}0fPavcm^=bFu;JpfEybdyanSicmbR761zWeR{kbJa+wVChIh zL8HeC$D$J#qbIg^U2Q4ZQ4^@CJGL{hwCs0k(?9ym@==9elwZ`DbzC%?_3NU=tZ$1B zv;NRgr-s9M?vDjm_jvF1aJu@Y!?mij$E^1pA+xqQBYKTrbKXw#Qi!~NZ}eY<%v_&A z^{&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c z4C9jgZ~K?JDNLY@|4c+;G)nBsk;yAqAQMVCDru!XEU+M@+QR}{Nvb_8V5L1QEVqYT zTq5q}I^Unv$P1zl;?1T&=K>8YePKHrLlc2))_tKVg(EMj`35T38?sqlQULh~$Q@fl z!Mx|yH(71ea|?%SU3v1yfeeL3(%<=Znr`AB_k`SE8PXeR)+;>`|K?A))5*lq`r&Pc zneSodranz#oWA+zyD8=1tDb+$E0I!d|C@;4EHUI~TZ*!8Gne0RX-F^0&(pm!*z0JE z&R)Oyw3=QkA6=fh#Hl}|rc`(PWO@2(pWn1ht*O3Sf_<6V!PlJLo0{h5%g?q|RCmKz2ft?cUPF69fWmd~1M@E`T3ya&sEf9`!^tez2 addressbookList; + private List usersAddressbooks; + + /** + * A list of all user's shared (with others) address books + */ + private List sharedAddressbooks; /** * Name of the address book @@ -128,7 +134,7 @@ public class AddressbookWebBean implements AddressbookWebController { this.setAddressbookName(null); // Add address book entry to list - this.addressbookList.add(updatedAddressbook); + this.usersAddressbooks.add(updatedAddressbook); // All fine return "login_own_addressbooks"; //NOI18N @@ -146,7 +152,18 @@ public class AddressbookWebBean implements AddressbookWebController { throw new FaceletException("This method can only be called as logged-in user."); //NOI18N } - return Collections.unmodifiableList(this.addressbookList); + return Collections.unmodifiableList(this.usersAddressbooks); + } + + @Override + public List allShares () { + // 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 + } + + return Collections.unmodifiableList(this.sharedAddressbooks); } @Override @@ -196,18 +213,18 @@ public class AddressbookWebBean implements AddressbookWebController { } // Check if the list is filled - return (!this.addressbookList.isEmpty()); + return (!this.usersAddressbooks.isEmpty()); } @PostConstruct public void init () { // Init list - this.addressbookList = new ArrayList<>(0); + this.usersAddressbooks = new ArrayList<>(0); // Is the user logged-in? if (this.loginController.isUserLoggedIn()) { // Fill list with entries - this.addressbookList = this.addressbookBean.getUsersList(this.loginController.getLoggedInUser()); + this.usersAddressbooks = this.addressbookBean.getUsersList(this.loginController.getLoggedInUser()); } } @@ -217,7 +234,7 @@ public class AddressbookWebBean implements AddressbookWebController { if (null == addressbookName) { // Is null throw new NullPointerException("addressbookName is null"); //NOI18N - } else if (this.addressbookList.isEmpty()) { + } else if (this.usersAddressbooks.isEmpty()) { // Not found! return false; } @@ -226,7 +243,7 @@ public class AddressbookWebBean implements AddressbookWebController { boolean isFound = false; // Check all entries - for (final Addressbook addressbook : this.addressbookList) { + for (final Addressbook addressbook : this.usersAddressbooks) { // Is the name same? if (addressbook.getAddressbookName().equals(addressbookName)) { // Found a match diff --git a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java index cab2c821..b57cf584 100644 --- a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java +++ b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java @@ -20,6 +20,7 @@ import java.io.Serializable; import java.util.List; import org.mxchange.addressbook.model.addressbook.Addressbook; import org.mxchange.addressbook.model.addressbook.entry.AddressbookEntry; +import org.mxchange.addressbook.model.addressbook.shared.ShareableAddressbook; /** * An interface for user beans @@ -84,6 +85,13 @@ public interface AddressbookWebController extends Serializable { */ public List allEntries (final Addressbook addressbook); + /** + * Returns a list of all address books the user is sharing with others. + *

+ * @return List of all shared address books + */ + public List allShares (); + /** * Size of all entries in given address book *

diff --git a/src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java b/src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java new file mode 100644 index 00000000..d83bba58 --- /dev/null +++ b/src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.addressbook.beans.shares; + +import javax.enterprise.context.SessionScoped; +import javax.faces.view.facelets.FaceletException; +import javax.inject.Inject; +import javax.inject.Named; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.addressbook.beans.login.UserLoginWebController; +import org.mxchange.addressbook.model.shared.SharedAddressbooksSessionBeanRemote; + +/** + * A bean for sharing address books with other users + *

+ * @author Roland Haeder + */ +@Named (value = "shareController") +@SessionScoped +public class SharesWebBean implements SharesWebController { + + /** + * Serial number + */ + private static final long serialVersionUID = 19_868_976_871_976_780L; + + /** + * Login controller injection + */ + @Inject + private UserLoginWebController loginController; + + /** + * Remote bean for sharing address books + */ + private SharedAddressbooksSessionBeanRemote shareBean; + + /** + * Default constructor + */ + public SharesWebBean () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Look up bean + this.shareBean = (SharedAddressbooksSessionBeanRemote) context.lookup("ejb/stateless-share"); + } catch (final NamingException ex) { + // Continue to throw + throw new FaceletException(ex); + } + } + + @Override + public boolean isSharingAddressbooks () { + // Only to be called for logged-in users + if (!this.loginController.isUserLoggedIn()) { + // Not logged in + throw new FaceletException("This method can only be called as logged-in user."); //NOI18N + } + + // Call the proper bean + return this.shareBean.isUserSharingAddressbooks(this.loginController.getLoggedInUser()); + } + +} diff --git a/src/java/org/mxchange/addressbook/beans/shares/SharesWebController.java b/src/java/org/mxchange/addressbook/beans/shares/SharesWebController.java new file mode 100644 index 00000000..2fe90ffc --- /dev/null +++ b/src/java/org/mxchange/addressbook/beans/shares/SharesWebController.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.addressbook.beans.shares; + +import java.io.Serializable; + +/** + * Controller interface sharing address books + *

+ * @author Roland Haeder + */ +public interface SharesWebController extends Serializable { + + /** + * Checks wether the current user is sharing address books with others + *

+ * @return Whether the current user is sharing address books + */ + public boolean isSharingAddressbooks (); +} diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java index c9467c04..09db6e22 100644 --- a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java @@ -328,7 +328,7 @@ public class UserWebBean implements UserWebController { contact.setContactEmailAddress(this.getEmailAddress()); // Don't set null or wrong references - if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) &&(this.getPhoneNumber() > 0)) { + if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) { // Now the number must be given if (phone.getPhoneAreaCode() == null) { // Is null diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 479bf331..9a97a5bd 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -190,3 +190,7 @@ PARAMETER_ADDRESSBOOK_ID_INVALID=Id-Nummer f\u00fcr Adressbuch ung\u00fcltig. Bi ENTERED_HOUSE_NUMBER_INVALID=Die eingegebene Hausnummer ist ung\u00fcltig. ENTERED_ZIP_CODE_INVALID=Die eingegebene Postleitzahl ist ung\u00fcltig. PARAMETER_ADDRESSBOOK_ID_NOT_FOUND=Der angeklickte Link ist nicht mehr g\u00fcltig: Adressbuch mit der Id-Nummer nicht gefunden. +LINK_LOGIN_SHARED_ADDRESS_BOOKS=Mit anderen geteilt +LINK_LOGIN_SHARED_ADDRESS_BOOKS_TITLE=Mit anderen Benutzern geteilte Adressb\u00fccher +PAGE_TITLE_LOGIN_SHARED_ADDRESSBOOKS=Mit anderen geteilte Adressb\u00fccher +CONTENT_TITLE_LOGIN_SHARED_ADDRESSBOOKS=Meine mit anderen Benutzern geteilte Adressb\u00fccher: diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index b4fb91b2..0722a350 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -190,3 +190,7 @@ PARAMETER_ADDRESSBOOK_ID_INVALID=Id number for address book invalid. Please cont ENTERED_HOUSE_NUMBER_INVALID=The entered house number is invalid. ENTERED_ZIP_CODE_INVALID=The entered ZIP code is invalid. PARAMETER_ADDRESSBOOK_ID_NOT_FOUND=The clicked link is no longer valid: Address book with entered id number does not exist (anymore). +LINK_LOGIN_SHARED_ADDRESS_BOOKS=Shared with others +LINK_LOGIN_SHARED_ADDRESS_BOOKS_TITLE=With other users shared address books +PAGE_TITLE_LOGIN_SHARED_ADDRESSBOOKS=With others shared address books +CONTENT_TITLE_LOGIN_SHARED_ADDRESSBOOKS=Mine with other users shared address books: diff --git a/web/WEB-INF/templates/login/login_menu.tpl b/web/WEB-INF/templates/login/login_menu.tpl index 5133db82..173f7dd8 100644 --- a/web/WEB-INF/templates/login/login_menu.tpl +++ b/web/WEB-INF/templates/login/login_menu.tpl @@ -44,6 +44,9 @@

  • +
  • + +