From 3141795b1ccba7cf12ff5e1d5a9416814bc4f95a Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Fri, 30 Sep 2016 10:34:36 +0000 Subject: [PATCH] filter of the posts related to the statistics per site added git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@132170 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../user/newsfeed/server/NewsServiceImpl.java | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java b/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java index 3c55fac..741b299 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java @@ -146,7 +146,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService */ public String getDevelopmentUser() { String user = NewsConstants.TEST_USER; -// user = "costantino.perciante"; + // user = "costantino.perciante"; return user; } /** @@ -1135,7 +1135,9 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService public ArrayList getFeedsRelatedToUserStatistics( ShowUserStatisticAction action, int from, int quantity) { - String userid = getASLSession().getUsername(); + ASLSession session = getASLSession(); + String userid = session.getUsername(); + String scope = session.getScope(); if(userid == NewsConstants.TEST_USER) return null; @@ -1179,19 +1181,35 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService default : return new ArrayList(); } - // filter the feeds according the current context - Iterator iteratorScope = feeds.iterator(); + + List contexts = new ArrayList(); + if(isInfrastructureScope()){ - if(!isInfrastructureScope()){ + LiferayGroupManager groupManager = new LiferayGroupManager(); + long userIdLong = new LiferayUserManager().getUserId(userid); - String currentScope = getASLSession().getScope(); + // filter for site + Set vresInPortal = groupManager.listGroupsByUserAndSite(userIdLong, getThreadLocalRequest().getServerName()); + _log.debug("Contexts in this site are " + vresInPortal); - while (iteratorScope.hasNext()) { - Feed feed = (Feed) iteratorScope.next(); - if(!feed.getVreid().equals(currentScope)) - iteratorScope.remove(); + // get the scopes associated with such groups + for (GCubeGroup gCubeGroup : vresInPortal) { + contexts.add(groupManager.getInfrastructureScope(gCubeGroup.getGroupId())); } + }else{ + + // just the current scope + contexts.add(scope); + + } + + // filter + Iterator iteratorScope = feeds.iterator(); + while (iteratorScope.hasNext()) { + Feed feed = (Feed) iteratorScope.next(); + if(!contexts.contains(feed.getVreid())) + iteratorScope.remove(); } // sort the list, retrieve elements in the range and enhance the feeds