From: Roland Haeder Date: Mon, 19 Oct 2015 09:06:02 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=aa489f89cf2c8eb473522e1850e7d654fb2890d0;p=addressbook-war.git Continued: - 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 --- diff --git a/nbproject/faces-config.NavData b/nbproject/faces-config.NavData index 4ef739c7..9d6df15b 100644 --- a/nbproject/faces-config.NavData +++ b/nbproject/faces-config.NavData @@ -1,60 +1,60 @@ + + + + + + - - + - - - - - - - + + + + + - - + + + - + + + + - - + + - - - - - - - - - - + + + + + + + + + - - + - - - - - diff --git a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java index 18334615..cfc167dd 100644 --- a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java @@ -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)); } /** diff --git a/src/java/org/mxchange/addressbook/beans/login/UserLoginWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/login/UserLoginWebSessionBean.java index 564184c0..8854311a 100644 --- a/src/java/org/mxchange/addressbook/beans/login/UserLoginWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/login/UserLoginWebSessionBean.java @@ -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))); + } } diff --git a/src/java/org/mxchange/addressbook/beans/login/UserLoginWebSessionController.java b/src/java/org/mxchange/addressbook/beans/login/UserLoginWebSessionController.java index a0641a10..680cdf2e 100644 --- a/src/java/org/mxchange/addressbook/beans/login/UserLoginWebSessionController.java +++ b/src/java/org/mxchange/addressbook/beans/login/UserLoginWebSessionController.java @@ -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 + *

+ * @return Whether the currently logged-in user is not invisible + */ + boolean isNotInvisible (); } diff --git a/src/java/org/mxchange/addressbook/beans/shares/SharesWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/shares/SharesWebSessionBean.java index b493921a..e14d89e5 100644 --- a/src/java/org/mxchange/addressbook/beans/shares/SharesWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/shares/SharesWebSessionBean.java @@ -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 { diff --git a/web/WEB-INF/templates/generic/user_profile_link.tpl b/web/WEB-INF/templates/generic/user_profile_link.tpl index 0bbe58a5..617a0496 100644 --- a/web/WEB-INF/templates/generic/user_profile_link.tpl +++ b/web/WEB-INF/templates/generic/user_profile_link.tpl @@ -7,7 +7,7 @@ xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"> - + diff --git a/web/login/login_start_sharing_addressbook.xhtml b/web/login/login_start_sharing_addressbook.xhtml index 38660fcb..c25adf43 100644 --- a/web/login/login_start_sharing_addressbook.xhtml +++ b/web/login/login_start_sharing_addressbook.xhtml @@ -21,7 +21,7 @@

- + #{msg.USER_ID} @@ -36,7 +36,7 @@ #{msg.LOGIN_START_SHARING_TITLE} - + diff --git a/web/user/show_addressbook.xhtml b/web/user/show_addressbook.xhtml index 0a73b4ad..8c2115fe 100644 --- a/web/user/show_addressbook.xhtml +++ b/web/user/show_addressbook.xhtml @@ -22,42 +22,40 @@ - - - #{msg.TABLE_HEADER_SHOW_ADDRESSBOOK} - - #{msg.ADDRESSBOOK_ID} - - - #{msg.ADDRESSBOOK_NAME} - - - #{msg.ADDRESSBOOK_OWNER} - - - - - #{msg.ADDRESSBOOK_CREATED} - - - - - #{msg.ADDRESSBOOK_STATUS} - - - - - - - - - - Bla bla - + + #{msg.TABLE_HEADER_SHOW_ADDRESSBOOK} + + #{msg.ADDRESSBOOK_ID} + + + #{msg.ADDRESSBOOK_NAME} + + + #{msg.ADDRESSBOOK_OWNER} + + + + + #{msg.ADDRESSBOOK_CREATED} + + + + + #{msg.ADDRESSBOOK_STATUS} + + + + + + + + + + Bla bla - - - + + +