]> git.mxchange.org Git - addressbook-war.git/blobdiff - src/java/org/mxchange/addressbook/beans/profile/AddressbookUserProfileWebRequestBean.java
Updated copyright year
[addressbook-war.git] / src / java / org / mxchange / addressbook / beans / profile / AddressbookUserProfileWebRequestBean.java
index abedbba9e0ede5726cf15cabb0f17e10487dd02a..b37a4502ffa736a3bcfdb74a9783625040610720 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Roland Haeder
+ * Copyright (C) 2016 - 2024 Free Software Foundation
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
@@ -18,11 +18,12 @@ package org.mxchange.addressbook.beans.profile;
 
 import java.text.MessageFormat;
 import javax.enterprise.context.RequestScoped;
-import javax.faces.view.facelets.FaceletException;
+import javax.faces.FacesException;
 import javax.inject.Inject;
 import javax.inject.Named;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
-import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController;
+import org.mxchange.addressbook.beans.BaseAddressbookBean;
+import org.mxchange.addressbook.beans.user.list.AddressbookUserListWebViewController;
+import org.mxchange.addressbook.beans.user.login.AddressbookUserLoginWebSessionController;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.model.user.User;
 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
@@ -30,11 +31,11 @@ import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
 /**
  * A web request bean for user profiles
  * <p>
- * @author Roland Haeder<roland@mxchange.org>
+ * @author Roland Hรคder<roland@mxchange.org>
  */
 @Named (value = "profileController")
 @RequestScoped
-public class AddressbookUserProfileWebRequestBean implements AddressbookUserProfileWebRequestController {
+public class AddressbookUserProfileWebRequestBean extends BaseAddressbookBean implements AddressbookUserProfileWebRequestController {
 
        /**
         * Serial number
@@ -42,38 +43,46 @@ public class AddressbookUserProfileWebRequestBean implements AddressbookUserProf
        private static final long serialVersionUID = 187_687_145_286_710L;
 
        /**
-        * Login controller
+        * User list controller
         */
        @Inject
-       private AddressbookUserLoginWebSessionController loginController;
+       private AddressbookUserListWebViewController userListController;
 
        /**
-        * User controller
+        * Login controller
         */
        @Inject
-       private AddressbookUserWebSessionController userController;
+       private AddressbookUserLoginWebSessionController userLoginController;
+
+       /**
+        * Default constructor
+        */
+       public AddressbookUserProfileWebRequestBean () {
+               // Call super constructor
+               super();
+       }
 
        @Override
        public boolean isProfileLinkVisibleById (final Long userId) {
                // Init user instance
-               User u = null;
+               User user = null;
 
                try {
                        // Try to get it
-                       u = this.userController.lookupUserById(userId);
+                       user = this.userListController.lookupUserById(userId);
                } catch (final UserNotFoundException ex) {
                        // Throw again
-                       throw new FaceletException(ex);
+                       throw new FacesException(ex);
                }
 
                // Is it null?
-               if (null == u) {
+               if (null == user) {
                        // Not found, not visible.
                        return false;
                }
 
                // Ask other method
-               return this.isProfileLinkVisibleByUser(u);
+               return this.isProfileLinkVisibleByUser(user);
        }
 
        @Override
@@ -106,12 +115,11 @@ public class AddressbookUserProfileWebRequestBean implements AddressbookUserProf
                }
 
                // Get profile mode from user instance (safe now)
-               ProfileMode profileMode = user.getUserProfileMode();
+               final ProfileMode profileMode = user.getUserProfileMode();
 
                // Check all conditions (except for admin)
-               // TODO: Add admin role somehow?
                return ((profileMode.equals(ProfileMode.PUBLIC)) ||
-                               (this.loginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS)));
+                               (this.userLoginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS)));
        }
 
 }