From fcd0bba5330867136d826a4cca01e5bd141e286d Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Thu, 12 May 2016 08:29:44 +0000 Subject: [PATCH] when the user is currently visiting a profile in a vre scope, the information show are the ones relative to the whole infrastructure git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/user-statistics@128565 82a268e6-3cf1-43bd-a215-b396298e98cf --- .settings/org.eclipse.wst.common.component | 3 --- .../server/UserStatisticsServiceImpl.java | 12 +++++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index d16397c..65eedd1 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,9 +4,6 @@ - - uses - diff --git a/src/main/java/org/gcube/portlet/user/userstatisticsportlet/server/UserStatisticsServiceImpl.java b/src/main/java/org/gcube/portlet/user/userstatisticsportlet/server/UserStatisticsServiceImpl.java index 3f7b852..c40ad71 100644 --- a/src/main/java/org/gcube/portlet/user/userstatisticsportlet/server/UserStatisticsServiceImpl.java +++ b/src/main/java/org/gcube/portlet/user/userstatisticsportlet/server/UserStatisticsServiceImpl.java @@ -99,14 +99,16 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U /** * Indicates whether the scope is the whole infrastructure. + * @param userid in case userid is not null, the user is visiting a profile page and + * the statistics to return are the ones available in the whole infrastructure * @return true if it is, false otherwise. */ - private boolean isInfrastructureScope() { + private boolean isInfrastructureScope(String userid) { boolean toReturn = false; try { GroupManager manager = new LiferayGroupManager(); long groupId = manager.getGroupIdFromInfrastructureScope(getASLSession().getScope()); - toReturn = !manager.isVRE(groupId); + toReturn = !manager.isVRE(groupId) || userid != null; return toReturn; } catch (Exception e) { @@ -278,9 +280,9 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U } if(isWithinPortal()){ - // If the user is in the root panel, we have to send him the overall number of posts made, comments/likes(received) and the space in use. + // If the user is in the root panel (or is visiting a profile page), we have to send him the overall number of posts made, comments/likes(received) and the space in use. // Otherwise we have to filter on the vre. - boolean isInfrastructure = isInfrastructureScope(); + boolean isInfrastructure = isInfrastructureScope(userid); _log.debug("User scope is " + (isInfrastructure ? " the whole infrastucture " : " a VRE")); // get path of the avatar @@ -363,7 +365,7 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U long totalFeeds = 0, totalLikes = 0, totalComments = 0; // check if the user is or not in a VRE - boolean isInfrastructure = isInfrastructureScope(); + boolean isInfrastructure = isInfrastructureScope(userid); // date corresponding to one year ago Calendar oneYearAgo = Calendar.getInstance();