diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index 4e48db0..3fad16f 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -5,15 +5,6 @@
-
- uses
-
-
- uses
-
-
- uses
-
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 741b299..07195b2 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
@@ -332,40 +332,48 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
public ArrayList getFeedsByHashtag(String hashtag) {
ASLSession session = getASLSession();
String userName = session.getUsername();
- ArrayList toMerge = new ArrayList();
- HashMap feedsMap = new HashMap();
- try {
- //in case the portal is restarted and you have the social home open it will get test.user (no callback to set session info)
- //this check just return nothing if that happens
- if (userName.compareTo("test.user") == 0) {
- _log.debug("Found " + userName + " returning nothing");
- return null;
- }
+ String currentScope = session.getScopeName();
+ //in case the portal is restarted and you have the social home open it will get test.user (no callback to set session info)
+ //this check just return nothing if that happens
+ if (userName.compareTo(NewsConstants.TEST_USER) == 0) {
+ _log.debug("Found " + userName + " returning nothing");
+ return null;
+ }
+
+ try {
+
+ ArrayList toMerge = new ArrayList();
+ HashMap feedsMap = new HashMap();
String lowerCaseHashtag = hashtag.toLowerCase();
- /**
- * this handles the case where the portlet is deployed outside of VREs (regular)
- */
+ // the contexts of the user
+ List contexts = new ArrayList();
+
+ //this handles the case where the portlet is deployed outside of VREs (regular)
if (isInfrastructureScope()) {
- UserManager um = new LiferayUserManager();
- GCubeUser currUser = um.getUserByUsername(userName);
- //VRE Feeds
+
GroupManager gm = new LiferayGroupManager();
- for (GCubeGroup group : gm.listGroupsByUser(currUser.getUserId())) {
- if (gm.isVRE(group.getGroupId())) {
- String vreid = gm.getInfrastructureScope(group.getGroupId()); //get the scope
- ArrayList feeds = (ArrayList) store.getVREFeedsByHashtag(vreid, lowerCaseHashtag);
- for (Feed feed : feeds) {
- feedsMap.put(feed.getKey(), feed);
- }
- }
+ UserManager um = new LiferayUserManager();
+ GCubeUser user = um.getUserByUsername(userName);
+ Set vresInPortal = gm.listGroupsByUserAndSite(user.getUserId(), getThreadLocalRequest().getServerName());
+ _log.debug("Contexts in this site are per user " + vresInPortal);
+
+ // get the scopes associated with such groups
+ for (GCubeGroup gCubeGroup : vresInPortal) {
+ contexts.add(gm.getInfrastructureScope(gCubeGroup.getGroupId()));
}
}
- //else must be in a VRE scope
else {
- String vreid = session.getScopeName();
- ArrayList feeds = (ArrayList) store.getVREFeedsByHashtag(vreid, lowerCaseHashtag);
+
+ contexts.add(currentScope);
+
+ }
+
+ _log.debug("Contexts for hashtags is " + contexts);
+
+ for (String context : contexts) {
+ ArrayList feeds = (ArrayList) store.getVREFeedsByHashtag(context, lowerCaseHashtag);
for (Feed feed : feeds) {
feedsMap.put(feed.getKey(), feed);
}
@@ -388,16 +396,13 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
}
return enhanceFeeds(toReturn, 2);
} catch (PrivacyLevelTypeNotFoundException e) {
- _log.error("Privacy Level not Found " + e.getMessage());
- e.printStackTrace();
+ _log.error("Privacy Level not Found ", e);
} catch (FeedTypeNotFoundException e) {
- _log.error("Feed Type not Found " + e.getMessage());
- e.printStackTrace();
+ _log.error("Feed Type not Found ", e);
} catch (ColumnNameNotFoundException e) {
- _log.error("Column name not Found " + e.getMessage());
- e.printStackTrace();
+ _log.error("Column name not Found ", e);
} catch (Exception e) {
- e.printStackTrace();
+ _log.error("Error while retrieving feeds for hashtag ", e);
}
return null;
}
@@ -408,17 +413,20 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
// TODO : check this error better
if(escl == null){
- _log.debug("There is no connection to elasticsearch, sorry.");
+ _log.warn("There is no connection to elasticsearch, sorry.");
return null;
}
ASLSession session = getASLSession();
String userName = session.getUsername();
+ String currentScope = session.getScopeName();
+
try {
+
//in case the portal is restarted and you have the social home open it will get test.user (no callback to set session info)
//this check just return nothing if that happens
- if (userName.compareTo("test.user") == 0) {
+ if (userName.compareTo(NewsConstants.TEST_USER) == 0) {
_log.debug("Found " + userName + " returning nothing");
return null;
}
@@ -440,7 +448,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
}
//else must be in a VRE scope
else {
- vres.add(session.getScopeName());
+ vres.add(currentScope);
}
// query elastic search
@@ -1181,7 +1189,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
default : return new ArrayList();
}
-
+
List contexts = new ArrayList();
if(isInfrastructureScope()){