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
This commit is contained in:
Costantino Perciante 2016-09-30 10:34:36 +00:00
parent cf6d6425e0
commit 3141795b1c
1 changed files with 28 additions and 10 deletions

View File

@ -1135,7 +1135,9 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
public ArrayList<EnhancedFeed> getFeedsRelatedToUserStatistics( public ArrayList<EnhancedFeed> getFeedsRelatedToUserStatistics(
ShowUserStatisticAction action, int from, int quantity) { 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) if(userid == NewsConstants.TEST_USER)
return null; return null;
@ -1179,19 +1181,35 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
default : return new ArrayList<EnhancedFeed>(); default : return new ArrayList<EnhancedFeed>();
} }
// filter the feeds according the current context
Iterator<Feed> iteratorScope = feeds.iterator();
if(!isInfrastructureScope()){ List<String> contexts = new ArrayList<String>();
if(isInfrastructureScope()){
String currentScope = getASLSession().getScope(); LiferayGroupManager groupManager = new LiferayGroupManager();
long userIdLong = new LiferayUserManager().getUserId(userid);
while (iteratorScope.hasNext()) { // filter for site
Feed feed = (Feed) iteratorScope.next(); Set<GCubeGroup> vresInPortal = groupManager.listGroupsByUserAndSite(userIdLong, getThreadLocalRequest().getServerName());
if(!feed.getVreid().equals(currentScope)) _log.debug("Contexts in this site are " + vresInPortal);
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<Feed> 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 // sort the list, retrieve elements in the range and enhance the feeds