|
|
|
@ -332,40 +332,48 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|
|
|
|
public ArrayList<EnhancedFeed> getFeedsByHashtag(String hashtag) {
|
|
|
|
|
ASLSession session = getASLSession();
|
|
|
|
|
String userName = session.getUsername();
|
|
|
|
|
ArrayList<Feed> toMerge = new ArrayList<Feed>();
|
|
|
|
|
HashMap<String, Feed> feedsMap = new HashMap<String, Feed>();
|
|
|
|
|
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 {
|
|
|
|
|
//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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ArrayList<Feed> toMerge = new ArrayList<Feed>();
|
|
|
|
|
HashMap<String, Feed> feedsMap = new HashMap<String, Feed>();
|
|
|
|
|
String lowerCaseHashtag = hashtag.toLowerCase();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this handles the case where the portlet is deployed outside of VREs (regular)
|
|
|
|
|
*/
|
|
|
|
|
// the contexts of the user
|
|
|
|
|
List<String> contexts = new ArrayList<String>();
|
|
|
|
|
|
|
|
|
|
//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<Feed> feeds = (ArrayList<Feed>) store.getVREFeedsByHashtag(vreid, lowerCaseHashtag);
|
|
|
|
|
for (Feed feed : feeds) {
|
|
|
|
|
feedsMap.put(feed.getKey(), feed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
UserManager um = new LiferayUserManager();
|
|
|
|
|
GCubeUser user = um.getUserByUsername(userName);
|
|
|
|
|
Set<GCubeGroup> 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<Feed> feeds = (ArrayList<Feed>) store.getVREFeedsByHashtag(vreid, lowerCaseHashtag);
|
|
|
|
|
|
|
|
|
|
contexts.add(currentScope);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_log.debug("Contexts for hashtags is " + contexts);
|
|
|
|
|
|
|
|
|
|
for (String context : contexts) {
|
|
|
|
|
ArrayList<Feed> feeds = (ArrayList<Feed>) 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<EnhancedFeed>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> contexts = new ArrayList<String>();
|
|
|
|
|
if(isInfrastructureScope()){
|
|
|
|
|
|
|
|
|
|