From aa489f89cf2c8eb473522e1850e7d654fb2890d0 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 19 Oct 2015 11:06:02 +0200 Subject: [PATCH] =?utf8?q?Continued:=20-=20isAddressbookLoaded()=20also=20?= =?utf8?q?checks=20User=20instance=20+=20name=20-=20added=20check=20before?= =?utf8?q?=20start=20of=20sharing=20address=20books=20if=20the=20owner=20a?= =?utf8?q?nd=20sharee=20are=20both=20not=20invisible=20-=20added=20isUserN?= =?utf8?q?otInvisible().=20EL=20code=20seems=20not=20handle=20negative=20c?= =?utf8?q?heck=3F=20:-(=20-=20fixed=20check=20on=20user=20instance=20in=20?= =?utf8?q?template=20user=5Fprofile=5Flink.tpl=20-=20removed=20one=20ui:fr?= =?utf8?q?agment=20as=20it=20can=20be=20attached=20to=20h:panelGrid,=20too?= =?utf8?q?=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- nbproject/faces-config.NavData | 62 ++++++++--------- .../AddressbookWebSessionBean.java | 5 +- .../beans/login/UserLoginWebSessionBean.java | 8 +++ .../login/UserLoginWebSessionController.java | 7 ++ .../beans/shares/SharesWebSessionBean.java | 7 ++ .../templates/generic/user_profile_link.tpl | 2 +- .../login_start_sharing_addressbook.xhtml | 4 +- web/user/show_addressbook.xhtml | 68 +++++++++---------- 8 files changed, 93 insertions(+), 70 deletions(-) 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 - - - + + + -- 2.39.5