]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Continued:
authorRoland Haeder <roland@mxchange.org>
Thu, 15 Oct 2015 18:38:28 +0000 (20:38 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 15 Oct 2015 18:44:59 +0000 (20:44 +0200)
- 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)

lib/juser-core.jar
src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java
src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java
src/java/org/mxchange/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
web/WEB-INF/faces-config.xml
web/login/login_start_sharing_addressbook.xhtml [new file with mode: 0644]

index 94920473f0bd2dcfee1d99e5be9f16c81e3bd70d..c8486cff6d9b8b49ad3e85bc50a515a504837d72 100644 (file)
Binary files a/lib/juser-core.jar and b/lib/juser-core.jar differ
index 1c66acdff2feecc17a247aef388b5b1828586864..5593aa0af5598c2c03533f612c595c7ed1b89891 100644 (file)
@@ -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<User> 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());
        }
 }
index 285ce793377f527bbdb4789e7fcf8acbb969a401..97995957b3d63e3700634261e178e6858b214c26 100644 (file)
@@ -188,4 +188,25 @@ public interface AddressbookWebController extends Serializable {
         */
        boolean isOtherAddressbook ();
 
+       /**
+        * Getter for address book instance
+        * <p>
+        * @return Address book instance
+        */
+       Addressbook getAddressbook ();
+
+       /**
+        * Setter for address book instance
+        * <p>
+        * @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.
+        * <p>
+        * @return List of not sharing users
+        */
+       List<User> allUsersNotSharing ();
 }
index a088589226e50a9713d827ccd13fb31e932ffce2..e8dd33edbeae5ae600346b8200e88a865b22d635 100644 (file)
@@ -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.
index 8d59d3f9a3d755791be1545259b6fea3a77cd366..aabbaccb316e52f2444b33b59ef0dc01d9ed97d3 100644 (file)
@@ -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.
index 2c86702601468cd09605d9471103ff24a19d968c..af277878b4765a155b638680bef11af7ba812fb3 100644 (file)
                        <to-view-id>/login/login_list_sharing_addressbooks.xhtml</to-view-id>
                </navigation-case>
        </navigation-rule>
+       <navigation-rule>
+               <from-view-id>/login/login_show_addressbook.xhtml</from-view-id>
+               <navigation-case>
+                       <from-outcome>login_start_sharing_addressbook</from-outcome>
+                       <to-view-id>/login/login_start_sharing_addressbook.xhtml</to-view-id>
+               </navigation-case>
+       </navigation-rule>
 </faces-config>
diff --git a/web/login/login_start_sharing_addressbook.xhtml b/web/login/login_start_sharing_addressbook.xhtml
new file mode 100644 (file)
index 0000000..432dc7b
--- /dev/null
@@ -0,0 +1,62 @@
+<?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"
+         >
+
+       <f:metadata>
+               <f:viewParam id="addressbookId" name="addressbook_id" value="#{addressbookController.addressbookId}" required="true" requiredMessage="#{msg.PARAMETER_ADDRESSBOOK_ID_MISSING}" converterMessage="#{msg.PARAMETER_ADDRESSBOOK_ID_INVALID}" validatorMessage="#{msg.PARAMETER_ADDRESSBOOK_ID_NOT_FOUND}">
+                       <f:convertNumber for="addressbookId" type="number" minIntegerDigits="1" maxIntegerDigits="20" />
+                       <f:validator for="addressbookId" validatorId="AddressbookIdValidator" />
+               </f:viewParam>
+       </f:metadata>
+
+       <ui:composition template="/WEB-INF/templates/login/login_base.tpl">
+               <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_START_SHARING_ADDRESSBOOK}</ui:define>
+
+               <ui:define name="content_header">
+                       #{msg.CONTENT_TITLE_LOGIN_START_SHARING_ADDRESSBOOK}
+               </ui:define>
+
+               <ui:define name="content">
+                       <div class="table_big">
+
+                               <div class="table_header">
+                                       #{msg.TABLE_HEADER_CHOOSE_USER_FOR_SHARING}
+                               </div>
+
+                               <div class="para">
+                                       <h:dataTable id="userList" headerClass="table_header_column" var="user" value="#{addressbookController.allUsersNotSharing()}">
+                                               <h:column>
+                                                       <f:facet name="header">#{msg.USER_ID}</f:facet>
+                                                       <h:link outcome="user_profile" title="#{msg.LINK_USER_PROFILE_TITLE}" value="#{msg.LINK_USER_PROFILE}">
+                                                               <f:param id="userId" name="userId" value="#{user.userId}" />
+                                                       </h:link>
+                                               </h:column>
+
+                                               <h:column>
+                                                       <f:facet name="header">#{msg.USER_NAME}</f:facet>
+                                                       <h:outputText value="#{user.userName}" />
+                                               </h:column>
+
+                                               <h:column>
+                                                       <f:facet name="header">#{msg.LOGIN_START_SHARING_TITLE}</f:facet>
+                                                       <h:form acceptcharset="utf-8" id="startSharing">
+                                                               <h:commandButton class="submit" id="submit" value="#{msg.LOGIN_START_SHARING_BUTTON}" action="#{addressbookController.startSharing(user)}" title="#{msg.LOGIN_START_SHARING_BUTTON_TITLE}" />
+                                                       </h:form>
+                                               </h:column>
+                                       </h:dataTable>
+                               </div>
+
+                               <div class="table_footer">
+                                       <ul>
+                                               <li>#{msg.LOGIN_START_SHARING_NOTICE1}</li>
+                                               <li>#{msg.LOGIN_START_SHARING_NOTICE2}</li>
+                                       </ul>
+                               </div>
+                       </div>
+               </ui:define>
+       </ui:composition>
+</html>