]> git.mxchange.org Git - jjobs-war.git/blobdiff - src/java/org/mxchange/jjobs/beans/profile/JobsUserProfileWebRequestBean.java
Don't cherry-pick:
[jjobs-war.git] / src / java / org / mxchange / jjobs / beans / profile / JobsUserProfileWebRequestBean.java
index 735273050747ca2b50d13f59b644f10076c2c325..0b93f40cffe2c0208e55cf3788b7a38bdf7c9685 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Roland Haeder
+ * Copyright (C) 2016 - 2018 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
@@ -21,9 +21,9 @@ import javax.enterprise.context.RequestScoped;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
-import org.mxchange.jjobs.beans.login.JobsUserLoginWebSessionController;
-import org.mxchange.jjobs.beans.user.JobsAdminUserWebRequestController;
-import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
+import org.mxchange.jjobs.beans.BaseJobsBean;
+import org.mxchange.jjobs.beans.user.JobsUserWebRequestController;
+import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.model.user.User;
 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
@@ -31,28 +31,22 @@ 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 JobsUserProfileWebRequestBean implements JobsUserProfileWebRequestController {
+public class JobsUserProfileWebRequestBean extends BaseJobsBean implements JobsUserProfileWebRequestController {
 
        /**
         * Serial number
         */
        private static final long serialVersionUID = 187_687_145_286_710L;
 
-       /**
-        * Administrative user controller
-        */
-       @Inject
-       private JobsAdminUserWebRequestController adminUserController;
-
        /**
         * User controller
         */
        @Inject
-       private JobsUserWebSessionController userController;
+       private JobsUserWebRequestController userController;
 
        /**
         * Login controller
@@ -60,27 +54,35 @@ public class JobsUserProfileWebRequestBean implements JobsUserProfileWebRequestC
        @Inject
        private JobsUserLoginWebSessionController userLoginController;
 
+       /**
+        * Default constructor
+        */
+       public JobsUserProfileWebRequestBean () {
+               // 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.adminUserController.lookupUserById(userId);
+                       user = this.userController.lookupUserById(userId);
                } catch (final UserNotFoundException ex) {
                        // Throw again
                        throw new FaceletException(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
@@ -113,10 +115,9 @@ public class JobsUserProfileWebRequestBean implements JobsUserProfileWebRequestC
                }
 
                // 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.userLoginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS)));
        }