]> git.mxchange.org Git - addressbook-war.git/commitdiff
Continued:
authorRoland Haeder <roland@mxchange.org>
Wed, 14 Oct 2015 08:16:24 +0000 (10:16 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 14 Oct 2015 08:16:24 +0000 (10:16 +0200)
- 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 <roland@mxchange.org>

lib/jcoreee.jar
src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java
src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java
src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java [new file with mode: 0644]
src/java/org/mxchange/addressbook/beans/shares/SharesWebController.java [new file with mode: 0644]
src/java/org/mxchange/addressbook/beans/user/UserWebBean.java
src/java/org/mxchange/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
web/WEB-INF/templates/login/login_menu.tpl
web/login/login_shared_addressbooks.xhtml [new file with mode: 0644]

index c2e022d69fedac84439d9796883f1931d015a012..4cdb134dfe55c2381d746baac342af402e2a4f80 100644 (file)
Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ
index 19112ca5f1105738527c0a1f11cc009967188855..89427289eed9c290a452f345d5ee7ba37cb3e391 100644 (file)
@@ -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<Addressbook> addressbookList;
+       private List<Addressbook> usersAddressbooks;
+
+       /**
+        * A list of all user's shared (with others) address books
+        */
+       private List<ShareableAddressbook> 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<ShareableAddressbook> 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
index cab2c821cac9ff7cc67646c1e3357b2057cc0262..b57cf584e3b85c48371e6fc54aa6f10f7c32e039 100644 (file)
@@ -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<AddressbookEntry> allEntries (final Addressbook addressbook);
 
+       /**
+        * Returns a list of all address books the user is sharing with others.
+        * <p>
+        * @return List of all shared address books
+        */
+       public List<ShareableAddressbook> allShares ();
+
        /**
         * Size of all entries in given address book
         * <p>
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 (file)
index 0000000..d83bba5
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @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 (file)
index 0000000..2fe90ff
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.beans.shares;
+
+import java.io.Serializable;
+
+/**
+ * Controller interface sharing address books
+ * <p>
+ * @author Roland Haeder
+ */
+public interface SharesWebController extends Serializable {
+
+       /**
+        * Checks wether the current user is sharing address books with others
+        * <p>
+        * @return Whether the current user is sharing address books
+        */
+       public boolean isSharingAddressbooks ();
+}
index c9467c045e25f55b313622ed224933afa1071775..09db6e22cf41dff3d68bc7715a9657645273dabc 100644 (file)
@@ -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
index 479bf3319d4d66e461f0471fdb4740ef3d123634..9a97a5bdb196ebef48a6bd7ea223ece86e5855f0 100644 (file)
@@ -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:
index b4fb91b28a7155e8fbc0008ca269893a8437d1b2..0722a35092bdbe7d103d9510e4b4aa22803f2eee 100644 (file)
@@ -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:
index 5133db823307f034b4794967cf1ce654ad6cc26c..173f7dd8b48e5ae25e729326a49e01e57e18c22b 100644 (file)
@@ -44,6 +44,9 @@
                                <li>
                                        <h:link title="#{msg.LINK_LOGIN_OTHER_ADDRESSBOOKS_TITLE}" outcome="login_other_addressbooks" value="#{msg.LINK_LOGIN_OTHER_ADDRESSBOOKS}" />
                                </li>
+                               <li>
+                                       <h:link title="#{msg.LINK_LOGIN_SHARED_ADDRESS_BOOKS_TITLE}" outcome="login_shared_addressbooks" value="#{msg.LINK_LOGIN_SHARED_ADDRESS_BOOKS}" />
+                               </li>
                        </ul>
 
                        <div class="menu_header">
diff --git a/web/login/login_shared_addressbooks.xhtml b/web/login/login_shared_addressbooks.xhtml
new file mode 100644 (file)
index 0000000..1d50a5f
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+         xmlns:ui="http://java.sun.com/jsf/facelets"
+         xmlns:h="http://xmlns.jcp.org/jsf/html"
+         xmlns:f="http://xmlns.jcp.org/jsf/core"
+         >
+
+       <ui:composition template="/WEB-INF/templates/login/login_base.tpl">
+               <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_SHARED_ADDRESSBOOKS}</ui:define>
+
+               <ui:define name="content_header">
+                       #{msg.CONTENT_TITLE_LOGIN_SHARED_ADDRESSBOOKS}
+               </ui:define>
+
+               <ui:define name="content">
+                       <div class="table">
+                               <div class="table_header">
+                                       <h:dataTable id="sharedAddressbooks" summary="#{msg.TABLE_SUMMARY_SHARED_ADDRESSBOOKS}" var="shares" value="#{addressbookController.allShares()}" rendered="#{shareController.isSharingAddressbooks()}">
+                                       </h:dataTable>
+                               </div>
+                       </div>
+               </ui:define>
+       </ui:composition>
+</html>