]> git.mxchange.org Git - addressbook-war.git/commitdiff
Continued:
authorRoland Haeder <roland@mxchange.org>
Mon, 19 Oct 2015 09:06:02 +0000 (11:06 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 19 Oct 2015 09:06:02 +0000 (11:06 +0200)
- isAddressbookLoaded() also checks User instance + name
- added check before start of sharing address books if the owner and sharee are both not invisible
- added isUserNotInvisible(). EL code seems not handle negative check? :-(
- fixed check on user instance in template user_profile_link.tpl
- removed one ui:fragment as it can be attached to h:panelGrid, too
Signed-off-by:Roland Häder <roland@mxchange.org>

nbproject/faces-config.NavData
src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java
src/java/org/mxchange/addressbook/beans/login/UserLoginWebSessionBean.java
src/java/org/mxchange/addressbook/beans/login/UserLoginWebSessionController.java
src/java/org/mxchange/addressbook/beans/shares/SharesWebSessionBean.java
web/WEB-INF/templates/generic/user_profile_link.tpl
web/login/login_start_sharing_addressbook.xhtml
web/user/show_addressbook.xhtml

index 4ef739c7d1024129acc22ad6160fadaba6cb5d51..9d6df15b2638555a59709ce212499c6e453ec1fa 100644 (file)
@@ -1,60 +1,60 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scene Scope="Project" version="2">
     <Scope Scope="Faces Configuration Only">
+        <Node id="admin/admin_logout.xhtml" x="650" y="150" zoom="true"/>
+        <Node id="user/login.xhtml" x="150" y="300" zoom="true"/>
+        <Node id="admin/index.xhtml" x="400" y="300" zoom="true"/>
+        <Node id="user/lost_passwd.xhtml" x="400" y="450" zoom="true"/>
+        <Node id="*" x="1150" y="150" zoom="true"/>
+        <Node id="terms.xhtml" x="400" y="150" zoom="true"/>
         <Node id="bye.xhtml" x="150" y="450" zoom="true"/>
-        <Node id="index.xhtml" x="900" y="150" zoom="true"/>
         <Node id="privacy.xhtml" x="650" y="300" zoom="true"/>
-        <Node id="*" x="1150" y="150" zoom="true"/>
+        <Node id="index.xhtml" x="900" y="150" zoom="true"/>
         <Node id="imprint.xhtml" x="150" y="600" zoom="true"/>
         <Node id="admin/category.xhtml" x="650" y="450" zoom="true"/>
-        <Node id="admin/index.xhtml" x="400" y="300" zoom="true"/>
         <Node id="user/register.xhtml" x="150" y="150" zoom="true"/>
-        <Node id="admin/admin_logout.xhtml" x="650" y="150" zoom="true"/>
-        <Node id="terms.xhtml" x="400" y="150" zoom="true"/>
         <Node id="admin/product.xhtml" x="900" y="300" zoom="true"/>
-        <Node id="user/lost_passwd.xhtml" x="400" y="450" zoom="true"/>
-        <Node id="user/login.xhtml" x="150" y="300" zoom="true"/>
     </Scope>
     <Scope Scope="Project">
-        <Node id="login/login_shared_addressbooks.xhtml" x="400" y="150" zoom="true"/>
-        <Node id="login/login_edit_address.xhtml" x="1400" y="300" zoom="true"/>
+        <Node id="user/user_list.xhtml" x="900" y="450" zoom="true"/>
+        <Node id="user/login.xhtml" x="900" y="600" zoom="true"/>
+        <Node id="login/login_other_addressbooks.xhtml" x="1150" y="300" zoom="true"/>
+        <Node id="user/login_error.xhtml" x="150" y="450" zoom="true"/>
         <Node id="privacy.xhtml" x="1400" y="150" zoom="true"/>
+        <Node id="admin/admin_index.xhtml" x="400" y="300" zoom="true"/>
         <Node id="login/login_start_sharing_addressbook.xhtml" x="400" y="450" zoom="true"/>
-        <Node id="user/register.xhtml" x="900" y="300" zoom="true"/>
-        <Node id="login/login_index.xhtml" x="150" y="150" zoom="true"/>
+        <Node id="user/user_profile.xhtml" x="150" y="900" zoom="true"/>
+        <Node id="login/login_list_sharing_addressbooks.xhtml" x="150" y="600" zoom="true"/>
+        <Node id="admin/admin_logout.xhtml" x="400" y="750" zoom="true"/>
         <Node id="login/login_add_addressbook.xhtml" x="1150" y="150" zoom="true"/>
-        <Node id="user/resend_link.xhtml" x="1150" y="450" zoom="true"/>
+        <Node id="login/login_edit_address.xhtml" x="1400" y="300" zoom="true"/>
+        <Node id="login/login_edit_user_data.xhtml" x="1650" y="150" zoom="true"/>
+        <Node id="user/lost_passwd.xhtml" x="400" y="900" zoom="true"/>
+        <Node id="*" x="900" y="150" zoom="true"/>
         <Node id="login/login_own_addressbooks.xhtml" x="650" y="450" zoom="true"/>
-        <Node id="admin/admin_logout.xhtml" x="400" y="750" zoom="true"/>
         <Node id="terms.xhtml" x="400" y="600" zoom="true"/>
-        <Node id="user/user_list.xhtml" x="900" y="450" zoom="true"/>
+        <Node id="user/register_done.xhtml" x="150" y="300" zoom="true"/>
+        <Node id="login/login_shared_addressbooks.xhtml" x="400" y="150" zoom="true"/>
         <Node id="bye.xhtml" x="650" y="600" zoom="true"/>
         <Node id="index.xhtml" x="650" y="150" zoom="true"/>
-        <Node id="user/register_done.xhtml" x="150" y="300" zoom="true"/>
-        <Node id="user/user_profile.xhtml" x="150" y="900" zoom="true"/>
         <Node id="imprint.xhtml" x="650" y="750" zoom="true"/>
-        <Node id="*" x="900" y="150" zoom="true"/>
-        <Node id="user/login_error.xhtml" x="150" y="450" zoom="true"/>
-        <Node id="login/login_other_addressbooks.xhtml" x="1150" y="300" zoom="true"/>
-        <Node id="admin/admin_index.xhtml" x="400" y="300" zoom="true"/>
-        <Node id="user/lost_passwd.xhtml" x="400" y="900" zoom="true"/>
-        <Node id="user/login.xhtml" x="900" y="600" zoom="true"/>
-        <Node id="login/login_list_sharing_addressbooks.xhtml" x="150" y="600" zoom="true"/>
-        <Node id="login/login_edit_user_data.xhtml" x="1650" y="150" zoom="true"/>
+        <Node id="login/login_index.xhtml" x="150" y="150" zoom="true"/>
+        <Node id="user/register.xhtml" x="900" y="300" zoom="true"/>
+        <Node id="user/resend_link.xhtml" x="1150" y="450" zoom="true"/>
     </Scope>
     <Scope Scope="All Faces Configurations">
+        <Node id="admin/admin_logout.xhtml" x="650" y="150" zoom="true"/>
+        <Node id="user/login.xhtml" x="150" y="300" zoom="true"/>
+        <Node id="admin/index.xhtml" x="400" y="300" zoom="true"/>
+        <Node id="user/lost_passwd.xhtml" x="400" y="450" zoom="true"/>
+        <Node id="*" x="1150" y="150" zoom="true"/>
+        <Node id="terms.xhtml" x="400" y="150" zoom="true"/>
         <Node id="bye.xhtml" x="150" y="450" zoom="true"/>
-        <Node id="index.xhtml" x="900" y="150" zoom="true"/>
         <Node id="privacy.xhtml" x="650" y="300" zoom="true"/>
-        <Node id="*" x="1150" y="150" zoom="true"/>
+        <Node id="index.xhtml" x="900" y="150" zoom="true"/>
         <Node id="imprint.xhtml" x="150" y="600" zoom="true"/>
         <Node id="admin/category.xhtml" x="650" y="450" zoom="true"/>
-        <Node id="admin/index.xhtml" x="400" y="300" zoom="true"/>
         <Node id="user/register.xhtml" x="150" y="150" zoom="true"/>
-        <Node id="admin/admin_logout.xhtml" x="650" y="150" zoom="true"/>
-        <Node id="terms.xhtml" x="400" y="150" zoom="true"/>
         <Node id="admin/product.xhtml" x="900" y="300" zoom="true"/>
-        <Node id="user/lost_passwd.xhtml" x="400" y="450" zoom="true"/>
-        <Node id="user/login.xhtml" x="150" y="300" zoom="true"/>
     </Scope>
 </Scene>
index 18334615b6c338689ed538cef3614ec49439c08f..cfc167ddd32dfecd25c14b262feca1217298a17d 100644 (file)
@@ -406,7 +406,10 @@ public class AddressbookWebSessionBean implements AddressbookWebSessionControlle
 
        @Override
        public boolean isAddressbookLoaded () {
-               return (this.getAddressbookId() instanceof Long);
+               return ((this.getAddressbookId() instanceof Long)
+                               && (this.getAddressbookName() instanceof String)
+                               && (!this.getAddressbookName().isEmpty())
+                               && (this.getAddressbookUser() instanceof User));
        }
 
        /**
index 564184c0853ebe8dc914872eaac6ad7eeace78bf..8854311ace7dfbece806f1475c8f882eb5b6dfc2 100644 (file)
@@ -37,6 +37,7 @@ import org.mxchange.jusercore.exceptions.UserStatusLockedException;
 import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
 import org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote;
 import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
 
 /**
@@ -167,7 +168,14 @@ public class UserLoginWebSessionBean implements UserLoginWebSessionController {
 
                // Trace message
                // NOISY: System.out.println(MessageFormat.format("UserLoginWebSessionBean:isUserLoggedIn: this.userLoggedIn={0} - EXIT!", this.userLoggedIn));
+
                // Return it
                return this.userLoggedIn;
        }
+
+       @Override
+       public boolean isNotInvisible () {
+               // Check logged-in first, then invisibility
+               return ((this.isUserLoggedIn()) && (!Objects.equals(this.getLoggedInUser().getUserProfileMode(), ProfileMode.INVISIBLE)));
+       }
 }
index a0641a10a7b44dd911206ec2af03bd3e12a056b1..680cdf2ef3b71b32842c2a748d9fafcf989c1782 100644 (file)
@@ -74,4 +74,11 @@ public interface UserLoginWebSessionController extends Serializable {
         * @return Whether the user is truly a guest
         */
        boolean isGuest ();
+
+       /**
+        * Whether the currently logged-in user is not invisible
+        * <p>
+        * @return Whether the currently logged-in user is not invisible
+        */
+       boolean isNotInvisible ();
 }
index b493921a6d6cb0a999a0aae3c1238f50a649f7d2..e14d89e56519a78c893bb9362026e311587b4c1a 100644 (file)
@@ -40,6 +40,7 @@ import org.mxchange.addressbook.model.addressbook.Addressbook;
 import org.mxchange.addressbook.model.addressbook.shared.ShareableAddressbook;
 import org.mxchange.addressbook.model.shared.SharedAddressbooksSessionBeanRemote;
 import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
 
 /**
  * A bean for sharing address books with other users
@@ -253,6 +254,12 @@ public class SharesWebSessionBean implements SharesWebSessionController {
                } else if (!Objects.equals(addressbook.getAddressbookUser(), this.loginController.getLoggedInUser())) {
                        // Not the same user!
                        throw new IllegalStateException(MessageFormat.format("Address book id {0} owner id {1} mismatching logged-in user id {2}", addressbook.getAddressbookId(), addressbook.getAddressbookUser().getUserId(), this.loginController.getLoggedInUser().getUserId())); //NOI18N
+               } else if (this.loginController.getLoggedInUser().getUserProfileMode() == ProfileMode.INVISIBLE) {
+                       // User is invisible
+                       throw new FaceletException(MessageFormat.format("user {0} is invisible and cannot start sharing address books.", this.loginController.getLoggedInUser().getUserId())); //NOI18N
+               } else if (user.getUserProfileMode() == ProfileMode.INVISIBLE) {
+                       // User is invisible
+                       throw new FaceletException(MessageFormat.format("user {0} is invisible and cannot be selected for sharing.", user.getUserId())); //NOI18N
                }
 
                try {
index 0bbe58a5a7dbcc53a4f1c2bba5100755d075287c..617a04967e9c0953a7bd3d6ec9d4dacaada3ad26 100644 (file)
@@ -7,7 +7,7 @@
        xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
 
        <c:choose>
-               <c:when test="#{profileController.isProfileLinkVisible(user)}">
+               <c:when test="#{user != null and profileController.isProfileLinkVisible(user)}">
                        <h:link id="userProfileLink" outcome="user_profile" title="#{msg.LINK_USER_PROFILE_TITLE}">
                                <h:outputText id="userName" value="#{user.userName}" />
                                <f:param name="userId" value="#{user.userId}" />
index 38660fcbf0e1251a54c95c453397809807a015b6..c25adf431307a1ce05b3d8becaba7f33719df9f8 100644 (file)
@@ -21,7 +21,7 @@
                                </div>
 
                                <div class="para">
-                                       <h:dataTable id="userList" headerClass="table_header_column" var="user" value="#{addressbookController.allUsersNotSharing()}">
+                                       <h:dataTable id="userList" headerClass="table_header_column" var="user" value="#{addressbookController.allUsersNotSharing()}" rendered="#{loginController.isNotInvisible()}">
                                                <h:column>
                                                        <f:facet name="header">#{msg.USER_ID}</f:facet>
                                                        <h:outputText value="#{user.userId}" />
@@ -36,7 +36,7 @@
 
                                                <h:column>
                                                        <f:facet name="header">#{msg.LOGIN_START_SHARING_TITLE}</f:facet>
-                                                       <h:form acceptcharset="utf-8" id="startSharing">
+                                                       <h:form acceptcharset="utf-8" id="startSharing" rendered="#{profileController.isProfileLinkVisible(user)}">
                                                                <h:commandButton class="submit" id="submit" value="#{msg.LOGIN_START_SHARING_BUTTON}" action="#{shareController.startSharing(user, addressbookController.addressbook)}" title="#{msg.LOGIN_START_SHARING_BUTTON_TITLE}" />
                                                        </h:form>
                                                </h:column>
index 0a73b4ad2754ea479927caffcb9e2195f14d09a1..8c2115fe9c7f74401d3d16ab039e2dea470abc09 100644 (file)
                </ui:define>
 
                <ui:define name="content">
-                       <ui:fragment rendered="#{addressbookController.isAddressbookLoaded()}">
-                               <h:panelGrid headerClass="table_header" styleClass="table" columns="2">
-                                       <f:facet name="header">#{msg.TABLE_HEADER_SHOW_ADDRESSBOOK}</f:facet>
-
-                                       <h:outputLabel for="addressbookId" class="table_label">#{msg.ADDRESSBOOK_ID}</h:outputLabel>
-                                       <h:outputText id="addressbookId" value="#{addressbookController.addressbookId}" />
-
-                                       <h:outputLabel for="addressbookName" class="table_label">#{msg.ADDRESSBOOK_NAME}</h:outputLabel>
-                                       <h:outputText id="addressbookName" value="#{addressbookController.addressbookName}" />
-
-                                       <h:outputLabel for="userProfileLink" class="table_label">#{msg.ADDRESSBOOK_OWNER}</h:outputLabel>
-                                       <ui:include src="/WEB-INF/templates/generic/user_profile_link.tpl">
-                                               <ui:param name="user" value="#{addressbookController.addressbookUser}" />
-                                       </ui:include>
-
-                                       <h:outputLabel for="addressbookCreated" class="table_label">#{msg.ADDRESSBOOK_CREATED}</h:outputLabel>
-                                       <h:outputFormat id="addressbookCreated" value="#{addressbookController.addressbook.addressbookCreated.time}" title="#{msg.ADDRESSBOOK_CREATED_TITLE}">
-                                               <f:convertDateTime for="addressbookCreated" type="both" timeStyle="short" dateStyle="medium" />
-                                       </h:outputFormat>
-
-                                       <h:outputLabel for="addressbookStatus" class="table_label">#{msg.ADDRESSBOOK_STATUS}</h:outputLabel>
-                                       <h:outputText id="addressbookStatus" value="#{msg[addressbookController.addressbook.addressbookStatus.messageKey]}" title="#{msg.ADDRESSBOOK_STATUS_TITLE}" />
-
-                                       <f:facet name="footer">
-                                               <ui:fragment rendered="#{loginController.isUserLoggedIn()}">
-                                                       <ui:fragment rendered="#{addressbookController.isOwnAddressbook()}">
-                                                               <h:link id="startSharing" outcome="login_start_sharing_addressbook" value="#{msg.LINK_LOGIN_START_SHARING_ADDRESSBOOK}" title="#{msg.LINK_LOGIN_START_SHARING_ADDRESSBOOK_TITLE}" />
-                                                       </ui:fragment>
-
-                                                       <ui:fragment rendered="#{addressbookController.isOtherAddressbook()}">
-                                                               Bla bla
-                                                       </ui:fragment>
+                       <h:panelGrid headerClass="table_header" styleClass="table" columns="2" rendered="#{addressbookController.isAddressbookLoaded()}">
+                               <f:facet name="header">#{msg.TABLE_HEADER_SHOW_ADDRESSBOOK}</f:facet>
+
+                               <h:outputLabel for="addressbookId" class="table_label">#{msg.ADDRESSBOOK_ID}</h:outputLabel>
+                               <h:outputText id="addressbookId" value="#{addressbookController.addressbookId}" />
+
+                               <h:outputLabel for="addressbookName" class="table_label">#{msg.ADDRESSBOOK_NAME}</h:outputLabel>
+                               <h:outputText id="addressbookName" value="#{addressbookController.addressbookName}" />
+
+                               <h:outputLabel for="userProfileLink" class="table_label">#{msg.ADDRESSBOOK_OWNER}</h:outputLabel>
+                               <ui:include src="/WEB-INF/templates/generic/user_profile_link.tpl">
+                                       <ui:param name="user" value="#{addressbookController.addressbookUser}" />
+                               </ui:include>
+
+                               <h:outputLabel for="addressbookCreated" class="table_label">#{msg.ADDRESSBOOK_CREATED}</h:outputLabel>
+                               <h:outputFormat id="addressbookCreated" value="#{addressbookController.addressbook.addressbookCreated.time}" title="#{msg.ADDRESSBOOK_CREATED_TITLE}">
+                                       <f:convertDateTime for="addressbookCreated" type="both" timeStyle="short" dateStyle="medium" />
+                               </h:outputFormat>
+
+                               <h:outputLabel for="addressbookStatus" class="table_label">#{msg.ADDRESSBOOK_STATUS}</h:outputLabel>
+                               <h:outputText id="addressbookStatus" value="#{msg[addressbookController.addressbook.addressbookStatus.messageKey]}" title="#{msg.ADDRESSBOOK_STATUS_TITLE}" />
+
+                               <f:facet name="footer">
+                                       <ui:fragment rendered="#{loginController.isUserLoggedIn()}">
+                                               <ui:fragment rendered="#{addressbookController.isOwnAddressbook()}">
+                                                       <h:link id="startSharing" outcome="login_start_sharing_addressbook" value="#{msg.LINK_LOGIN_START_SHARING_ADDRESSBOOK}" title="#{msg.LINK_LOGIN_START_SHARING_ADDRESSBOOK_TITLE}" />
+                                               </ui:fragment>
+
+                                               <ui:fragment rendered="#{addressbookController.isOtherAddressbook()}">
+                                                       Bla bla
                                                </ui:fragment>
-                                       </f:facet>
-                               </h:panelGrid>
-                       </ui:fragment>
+                                       </ui:fragment>
+                               </f:facet>
+                       </h:panelGrid>
                </ui:define>
        </ui:composition>
 </html>