Fix for support Ticket #708

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@81203 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-09-10 10:05:29 +00:00
parent 6f3d3d3b15
commit f285ce1e14
5 changed files with 67 additions and 43 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/news-feed-1.1.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/news-feed-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -31,5 +31,5 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/news-feed-1.1.1-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/news-feed-1.2.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -1,6 +1,5 @@
#Thu Jul 11 11:44:03 CEST 2013
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
lastWarOutDir=/Users/massi/Documents/workspace/news-feed/target/news-feed-1.1.0-SNAPSHOT
lastWarOutDir=/Users/massi/Documents/workspace/news-feed/target/news-feed-1.2.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -1,6 +1,13 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets.user.NewsFeed.1-1-0" date="2013-07-08">
<Change>Open single feed separately enhancement implemeented #1818</Change>
<Changeset component="org.gcube.portlets.user.NewsFeed.1-2-0"
date="2013-07-08">
<Change>Fix for support Ticket #708</Change>
<Change>Fix for support Ticket #636</Change>
</Changeset>
<Changeset component="org.gcube.portlets.user.NewsFeed.1-1-0"
date="2013-07-08">
<Change>Open single feed separately enhancement implemeented #1818
</Change>
<Change>links redirects correctly to user profiles</Change>
</Changeset>
<Changeset component="org.gcube.portlets.user.NewsFeed.1-0-0"
@ -8,7 +15,8 @@
<Change>Mavenized</Change>
<Change>Smart Refresh Support Added #1539</Change>
<Change>Show HTTP URL in replies as HTML anchor links #1542</Change>
<Change>Replies on App Feed exception fixed #580 prod. support</Change>
<Change>Replies on App Feed exception fixed #580 prod. support
</Change>
<Change>Add Tag people in News Feed Portlet #1535</Change>
<Change>Notify people involved in post thread #1576</Change>
<Change>Scope Dependent News Feed #1561</Change>

View File

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>news-feed</artifactId>
<packaging>war</packaging>
<version>1.1.1-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<name>gCube News Feed Portlet</name>
<description>

View File

@ -39,6 +39,7 @@ import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.NoSuchUserException;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.WebKeys;
@ -95,8 +96,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
if (user == null) {
_log.warn("USER IS NULL setting testing user and Running OUTSIDE PORTAL");
user = "test.user";
// user = "massimiliano.assante";
// SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
// user = "massimiliano.assante";
// SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
}
else {
withinPortal = true;
@ -150,7 +151,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
return getASLSession().getScope().isInfrastructure();
}
@Override
public ArrayList<EnhancedFeed> getAllUpdateUserFeeds(int feedsNoPerCategory) {
@ -210,7 +211,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
}
//sort the feeds in reverse chronological order
Collections.sort(toMerge, Collections.reverseOrder());
ArrayList<Feed> toReturn = new ArrayList<Feed>();
//return only <MAX_FEEDS_NO> feeds
if (toMerge.size() > MAX_FEEDS_NO)
@ -471,13 +472,20 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
private ArrayList<EnhancedFeed> enhanceFeeds(ArrayList<Feed> toEnhance, int commentsNumberPerFeed) {
ArrayList<EnhancedFeed> toReturn = new ArrayList<EnhancedFeed>();
String username = getASLSession().getUsername();
ArrayList<String> likedFeeds = (ArrayList<String>) store.getAllLikedFeedIdsByUser(getASLSession().getUsername());
boolean skip = false;
for (Feed feed : toEnhance) {
skip = false;
feed.setDescription(replaceAmpersand(feed.getDescription()));
if (! feed.isApplicationFeed())
feed.setThumbnailURL(getUserImagePortraitUrlLocal(feed.getEntityId()));
if (! feed.isApplicationFeed()) {
String thumb = getUserImagePortraitUrlLocal(feed.getEntityId());
if (thumb == null) {
_log.warn(feed.getEntityId() + " is not avaialble on this portal, skipping this feed: " + feed.getKey());
skip = true;
} else
feed.setThumbnailURL(thumb);
}
//if likedFeeds contains this feed key it means the user already Liked it
boolean liked = likedFeeds.contains(feed.getKey());
int commentsNo = 0;
@ -488,33 +496,35 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
commentsNo = 0;
_log.error("NumberFormatException while reading comments number " + e.getMessage());
}
if (commentsNo == 0) {
EnhancedFeed toAdd = null;
//create the enhanced feed
if (feed.isApplicationFeed()) {
toAdd = new EnhancedFeed(feed, liked, checkisAdminUser());
} else
toAdd = new EnhancedFeed(feed, liked, isUsers(feed, username));
toReturn.add(toAdd);
} else {
ArrayList<Comment> comments = getAllCommentsByFeed(feed.getKey());
//sort in chronological order
Collections.sort(comments);
int currCommentsNumber = comments.size();
//if comments are less than $commentsNumberPerFeed they are the more recent, -1 return all the comments
if (currCommentsNumber < commentsNumberPerFeed || commentsNumberPerFeed == -1) {
EnhancedFeed toAdd = new EnhancedFeed(feed, liked, isUsers(feed, username), comments);
if (!skip) {
if (commentsNo == 0) {
EnhancedFeed toAdd = null;
//create the enhanced feed
if (feed.isApplicationFeed()) {
toAdd = new EnhancedFeed(feed, liked, checkisAdminUser());
} else
toAdd = new EnhancedFeed(feed, liked, isUsers(feed, username));
toReturn.add(toAdd);
} else {
//need to get the last two
ArrayList<Comment> comments2Attach = new ArrayList<Comment>();
for (int i = currCommentsNumber -commentsNumberPerFeed; i < currCommentsNumber; i++) {
comments2Attach.add(comments.get(i));
ArrayList<Comment> comments = getAllCommentsByFeed(feed.getKey());
//sort in chronological order
Collections.sort(comments);
int currCommentsNumber = comments.size();
//if comments are less than $commentsNumberPerFeed they are the more recent, -1 return all the comments
if (currCommentsNumber < commentsNumberPerFeed || commentsNumberPerFeed == -1) {
EnhancedFeed toAdd = new EnhancedFeed(feed, liked, isUsers(feed, username), comments);
toReturn.add(toAdd);
} else {
//need to get the last two
ArrayList<Comment> comments2Attach = new ArrayList<Comment>();
for (int i = currCommentsNumber -commentsNumberPerFeed; i < currCommentsNumber; i++) {
comments2Attach.add(comments.get(i));
}
EnhancedFeed toAdd = new EnhancedFeed(feed, liked, isUsers(feed, username), comments2Attach);
toReturn.add(toAdd);
}
EnhancedFeed toAdd = new EnhancedFeed(feed, liked, isUsers(feed, username), comments2Attach);
toReturn.add(toAdd);
}
}
}
}
@ -536,7 +546,11 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
User user = null;
try {
user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), screenName);
} catch (PortalException e) {
}
catch (com.liferay.portal.NoSuchUserException ex) {
return null;
}
catch (PortalException e) {
e.printStackTrace();
} catch (SystemException e) {
e.printStackTrace();
@ -552,7 +566,9 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
ArrayList<Like> toReturn = (ArrayList<Like>) store.getAllLikesByFeed(feedid);
_log.trace("Asking likes for " + feedid);
for (Like like : toReturn) {
like.setThumbnailURL(getUserImagePortraitUrlLocal(like.getUserid()));
String thumb = getUserImagePortraitUrlLocal(like.getUserid());
like.setThumbnailURL(thumb == null ? "" : thumb);
}
return toReturn;
}
@ -562,7 +578,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
_log.trace("Asking comments for " + feedid);
ArrayList<Comment> toReturn = (ArrayList<Comment>) store.getAllCommentByFeed(feedid);
for (Comment comment : toReturn) {
comment.setThumbnailURL(getUserImagePortraitUrlLocal(comment.getUserid()));
String thumb = getUserImagePortraitUrlLocal(comment.getUserid());
comment.setThumbnailURL(thumb == null ? "" : thumb);
}
Collections.sort(toReturn);
return toReturn;