fix for hashtags' feeds filter per site
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@132179 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3141795b1c
commit
ef7215c895
|
@ -5,15 +5,6 @@
|
|||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<dependent-module archiveName="gcube-widgets-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module archiveName="social-util-library-1.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/social-util-library/social-util-library">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module archiveName="session-checker-1.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/session-checker/session-checker">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||
<property name="context-root" value="news-feed"/>
|
||||
</wb-module>
|
||||
|
|
|
@ -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>();
|
||||
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<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
|
||||
|
|
Loading…
Reference in New Issue