From: Roland Haeder Date: Wed, 14 Oct 2015 08:16:24 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=65781370653f5ff1a5fecd0a81c1b8f59515e447;p=jfinancials-war.git Continued: - added bean for checking user's shared address books - added webpage login_shared_addressbooks.xhtml for user's shared address books - updated menu - updated jar(s) Signed-off-by:Roland Häder --- diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar index c2e022d6..4cdb134d 100644 Binary files a/lib/jcoreee.jar and b/lib/jcoreee.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 19112ca5..89427289 100644 --- a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java @@ -35,6 +35,7 @@ import org.mxchange.addressbook.model.addressbook.Addressbook; import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote; import org.mxchange.addressbook.model.addressbook.UserAddressbook; import org.mxchange.addressbook.model.addressbook.entry.AddressbookEntry; +import org.mxchange.addressbook.model.addressbook.shared.ShareableAddressbook; import org.mxchange.addressbook.model.addressbook.status.AddressbokStatus; /** @@ -60,7 +61,12 @@ public class AddressbookWebBean implements AddressbookWebController { /** * A list of all user's address books */ - private List 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 @@

  • +
  • + +