Compare commits

...

2 Commits

16 changed files with 288 additions and 338 deletions

View File

@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [v3.0.0] - 2023-12-15 ## [v3.0.0] - 2023-12-15
- Feature #26194: News Feed portlet: remove elastic search client - Feature #26194: News Feed portlet: remove elastic search client
- Feature #26515: Removed SNL dependency
## [v2.8.4] - 2022-05-15 ## [v2.8.4] - 2022-05-15

14
pom.xml
View File

@ -86,23 +86,17 @@
<artifactId>xml-apis</artifactId> <artifactId>xml-apis</artifactId>
<version>1.4.01</version> <version>1.4.01</version>
</dependency> </dependency>
<!--needs to be provided -->
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.social-networking</groupId>
<artifactId>social-library-stubs</artifactId> <artifactId>social-service-model</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0)</version> <version>[1.2.0-SNAPSHOT, 2.0.0)</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.social-networking</groupId> <groupId>org.gcube.social-networking</groupId>
<artifactId>social-service-client</artifactId> <artifactId>social-service-client</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0)</version> <version>[2.0.0-SNAPSHOT, 3.0.0)</version>
<scope>provided</scope> <scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.socialnetworking</groupId> <groupId>org.gcube.socialnetworking</groupId>

View File

@ -1,7 +1,7 @@
package org.gcube.portlets.user.newsfeed.client; package org.gcube.portlets.user.newsfeed.client;
import org.gcube.portal.databook.shared.ClientPost; import org.gcube.social_networking.socialnetworking.model.shared.ClientPost;
import org.gcube.portal.databook.shared.JSON; import org.gcube.social_networking.socialnetworking.model.shared.JSON;
import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel; import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel;

View File

@ -3,10 +3,10 @@ package org.gcube.portlets.user.newsfeed.client;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import org.gcube.portal.databook.shared.Comment; import org.gcube.social_networking.socialnetworking.model.shared.Comment;
import org.gcube.portal.databook.shared.EnhancedFeed; import org.gcube.social_networking.socialnetworking.model.shared.EnhancedPost;
import org.gcube.portal.databook.shared.Like; import org.gcube.social_networking.socialnetworking.model.shared.Like;
import org.gcube.portal.databook.shared.ShowUserStatisticAction; import org.gcube.social_networking.socialnetworking.model.shared.ShowUserStatisticAction;
import org.gcube.portlets.user.newsfeed.shared.MentionedDTO; import org.gcube.portlets.user.newsfeed.shared.MentionedDTO;
import org.gcube.portlets.user.newsfeed.shared.MorePostsBean; import org.gcube.portlets.user.newsfeed.shared.MorePostsBean;
import org.gcube.portlets.user.newsfeed.shared.OperationResult; import org.gcube.portlets.user.newsfeed.shared.OperationResult;
@ -21,19 +21,19 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
*/ */
@RemoteServiceRelativePath("newsServlet") @RemoteServiceRelativePath("newsServlet")
public interface NewsService extends RemoteService { public interface NewsService extends RemoteService {
ArrayList<EnhancedFeed> getAllUpdateUserFeeds(int feedsNoPerCategory); ArrayList<EnhancedPost> getAllUpdateUserFeeds(int feedsNoPerCategory);
ArrayList<EnhancedFeed> getOnlyConnectionsUserPosts(); ArrayList<EnhancedPost> getOnlyConnectionsUserPosts();
ArrayList<EnhancedFeed> getOnlyMyUserPosts(); ArrayList<EnhancedPost> getOnlyMyUserPosts();
ArrayList<EnhancedFeed> getOnlyLikedPosts(); ArrayList<EnhancedPost> getOnlyLikedPosts();
ArrayList<EnhancedFeed> getPostsByHashtag(String hashtag); ArrayList<EnhancedPost> getPostsByHashtag(String hashtag);
ArrayList<EnhancedFeed> getPostsByQuery(String query, int from, int quantity); ArrayList<EnhancedPost> getPostsByQuery(String query, int from, int quantity);
ArrayList<EnhancedFeed> getPostsRelatedToUserStatistics(ShowUserStatisticAction action, int from, int quantity); ArrayList<EnhancedPost> getPostsRelatedToUserStatistics(ShowUserStatisticAction action, int from, int quantity);
MorePostsBean getMorePosts(int from, int quantity); MorePostsBean getMorePosts(int from, int quantity);
@ -57,7 +57,7 @@ public interface NewsService extends RemoteService {
UserSettings getUserSettings(); UserSettings getUserSettings();
EnhancedFeed getSinglePost(String postKey); EnhancedPost getSinglePost(String postKey);
ArrayList<ItemBean> getOrganizationUsers(); ArrayList<ItemBean> getOrganizationUsers();
} }

View File

@ -3,10 +3,10 @@ package org.gcube.portlets.user.newsfeed.client;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import org.gcube.portal.databook.shared.Comment; import org.gcube.social_networking.socialnetworking.model.shared.Comment;
import org.gcube.portal.databook.shared.EnhancedFeed; import org.gcube.social_networking.socialnetworking.model.shared.EnhancedPost;
import org.gcube.portal.databook.shared.Like; import org.gcube.social_networking.socialnetworking.model.shared.Like;
import org.gcube.portal.databook.shared.ShowUserStatisticAction; import org.gcube.social_networking.socialnetworking.model.shared.ShowUserStatisticAction;
import org.gcube.portlets.user.newsfeed.shared.MentionedDTO; import org.gcube.portlets.user.newsfeed.shared.MentionedDTO;
import org.gcube.portlets.user.newsfeed.shared.MorePostsBean; import org.gcube.portlets.user.newsfeed.shared.MorePostsBean;
import org.gcube.portlets.user.newsfeed.shared.OperationResult; import org.gcube.portlets.user.newsfeed.shared.OperationResult;
@ -21,10 +21,10 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
public interface NewsServiceAsync { public interface NewsServiceAsync {
void getAllUpdateUserFeeds(int feedsNoPerCategory, void getAllUpdateUserFeeds(int feedsNoPerCategory,
AsyncCallback<ArrayList<EnhancedFeed>> callback); AsyncCallback<ArrayList<EnhancedPost>> callback);
void getOnlyConnectionsUserPosts( void getOnlyConnectionsUserPosts(
AsyncCallback<ArrayList<EnhancedFeed>> callback); AsyncCallback<ArrayList<EnhancedPost>> callback);
void like(String postid, String postText, String postOwnerId, void like(String postid, String postText, String postOwnerId,
AsyncCallback<Boolean> callback); AsyncCallback<Boolean> callback);
@ -32,7 +32,7 @@ public interface NewsServiceAsync {
void getAllLikesByPost(String postid, void getAllLikesByPost(String postid,
AsyncCallback<ArrayList<Like>> callback); AsyncCallback<ArrayList<Like>> callback);
void getOnlyMyUserPosts(AsyncCallback<ArrayList<EnhancedFeed>> callback); void getOnlyMyUserPosts(AsyncCallback<ArrayList<EnhancedPost>> callback);
void getUserSettings(AsyncCallback<UserSettings> callback); void getUserSettings(AsyncCallback<UserSettings> callback);
@ -50,9 +50,9 @@ public interface NewsServiceAsync {
void editComment(String text, Comment toEdit, HashSet<MentionedDTO> mentionedUsers, AsyncCallback<OperationResult> callback); void editComment(String text, Comment toEdit, HashSet<MentionedDTO> mentionedUsers, AsyncCallback<OperationResult> callback);
void getOnlyLikedPosts(AsyncCallback<ArrayList<EnhancedFeed>> callback); void getOnlyLikedPosts(AsyncCallback<ArrayList<EnhancedPost>> callback);
void getSinglePost(String postKey, AsyncCallback<EnhancedFeed> callback); void getSinglePost(String postKey, AsyncCallback<EnhancedPost> callback);
void getMorePosts(int from, int quantity, void getMorePosts(int from, int quantity,
AsyncCallback<MorePostsBean> callback); AsyncCallback<MorePostsBean> callback);
@ -63,12 +63,12 @@ public interface NewsServiceAsync {
void getOrganizationUsers(AsyncCallback<ArrayList<ItemBean>> callback); void getOrganizationUsers(AsyncCallback<ArrayList<ItemBean>> callback);
void getPostsByHashtag(String hashtag, void getPostsByHashtag(String hashtag,
AsyncCallback<ArrayList<EnhancedFeed>> callback); AsyncCallback<ArrayList<EnhancedPost>> callback);
void getPostsByQuery(String query, int from, int quantity, void getPostsByQuery(String query, int from, int quantity,
AsyncCallback<ArrayList<EnhancedFeed>> callback); AsyncCallback<ArrayList<EnhancedPost>> callback);
void getPostsRelatedToUserStatistics(ShowUserStatisticAction action, int from, int quantity, void getPostsRelatedToUserStatistics(ShowUserStatisticAction action, int from, int quantity,
AsyncCallback<ArrayList<EnhancedFeed>> callback); AsyncCallback<ArrayList<EnhancedPost>> callback);
} }

View File

@ -2,7 +2,7 @@ package org.gcube.portlets.user.newsfeed.client.event;
import java.util.HashSet; import java.util.HashSet;
import org.gcube.portal.databook.shared.Comment; import org.gcube.social_networking.socialnetworking.model.shared.Comment;
import org.gcube.portlets.user.newsfeed.client.ui.TweetTemplate; import org.gcube.portlets.user.newsfeed.client.ui.TweetTemplate;
import org.gcube.portlets.user.newsfeed.shared.MentionedDTO; import org.gcube.portlets.user.newsfeed.shared.MentionedDTO;

View File

@ -7,19 +7,20 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import org.gcube.common.portal.GCubePortalConstants; import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.social_networking.socialnetworking.model.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder; import org.gcube.social_networking.socialnetworking.model.client.util.Encoder;
import org.gcube.portal.databook.shared.Attachment; import org.gcube.social_networking.socialnetworking.model.shared.Attachment;
import org.gcube.portal.databook.shared.ClientAttachment; import org.gcube.social_networking.socialnetworking.model.shared.ClientAttachment;
import org.gcube.portal.databook.shared.ClientPost; import org.gcube.social_networking.socialnetworking.model.shared.ClientPost;
import org.gcube.portal.databook.shared.Comment; import org.gcube.social_networking.socialnetworking.model.shared.Comment;
import org.gcube.portal.databook.shared.EnhancedFeed; import org.gcube.social_networking.socialnetworking.model.shared.EnhancedPost;
import org.gcube.portal.databook.shared.Feed; import org.gcube.social_networking.socialnetworking.model.shared.Post;
import org.gcube.portal.databook.shared.FeedType; import org.gcube.social_networking.socialnetworking.model.shared.PostType;
import org.gcube.portal.databook.shared.Like; import org.gcube.social_networking.socialnetworking.model.shared.Like;
import org.gcube.portal.databook.shared.PrivacyLevel; import org.gcube.social_networking.socialnetworking.model.shared.PrivacyLevel;
import org.gcube.portal.databook.shared.ShowUserStatisticAction; import org.gcube.social_networking.socialnetworking.model.shared.ShowUserStatisticAction;
import org.gcube.portal.databook.shared.UserInfo; import org.gcube.social_networking.socialnetworking.model.shared.UserInfo;
import org.gcube.portlets.user.newsfeed.client.FilterType; import org.gcube.portlets.user.newsfeed.client.FilterType;
import org.gcube.portlets.user.newsfeed.client.NewsService; import org.gcube.portlets.user.newsfeed.client.NewsService;
import org.gcube.portlets.user.newsfeed.client.NewsServiceAsync; import org.gcube.portlets.user.newsfeed.client.NewsServiceAsync;
@ -156,9 +157,9 @@ public class NewsFeedPanel extends Composite {
//needed to know the next range start //needed to know the next range start
private Integer fromStartingPoint; private Integer fromStartingPoint;
private ArrayList<EnhancedFeed> allUpdates = new ArrayList<EnhancedFeed>(); private ArrayList<EnhancedPost> allUpdates = new ArrayList<EnhancedPost>();
private ArrayList<EnhancedFeed> tempCacheNewUpdates = new ArrayList<EnhancedFeed>(); private ArrayList<EnhancedPost> tempCacheNewUpdates = new ArrayList<EnhancedPost>();
/** /**
* events binder * events binder
@ -447,14 +448,14 @@ public class NewsFeedPanel extends Composite {
*/ */
private void showSinglePost(String postKey) { private void showSinglePost(String postKey) {
newsPanel.clear(); newsPanel.clear();
newsService.getSinglePost(postKey, new AsyncCallback<EnhancedFeed>() { newsService.getSinglePost(postKey, new AsyncCallback<EnhancedPost>() {
@Override @Override
public void onSuccess(EnhancedFeed result) { public void onSuccess(EnhancedPost result) {
if (result.getFeed().getType() == FeedType.DISABLED) { if (result.getPost().getType() == PostType.DISABLED) {
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
String usrLink = "<a class=\"link\" href=\""+profilePageURL+"?"+ String usrLink = "<a class=\"link\" href=\""+profilePageURL+"?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+ Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(result.getFeed().getEntityId())+"\">"+result.getFeed().getFullName()+ Encoder.encode(result.getPost().getEntityId())+"\">"+result.getPost().getFullName()+
"</a> "; "</a> ";
newsPanel.add(new HTML("<div class=\"nofeed-message\"><div style=\"padding-top: 90px;\">" + newsPanel.add(new HTML("<div class=\"nofeed-message\"><div style=\"padding-top: 90px;\">" +
"We're sorry, "+ usrLink +" removed the post in the meantime!</div></div>")); "We're sorry, "+ usrLink +" removed the post in the meantime!</div></div>"));
@ -495,23 +496,23 @@ public class NewsFeedPanel extends Composite {
* is open at infra level the first tab stops checking for updates * is open at infra level the first tab stops checking for updates
*/ */
if (result.getCurrentScope().compareTo(currentScope) == 0) { if (result.getCurrentScope().compareTo(currentScope) == 0) {
newsService.getAllUpdateUserFeeds(NewsConstants.FEEDS_NO_PER_CATEGORY, new AsyncCallback<ArrayList<EnhancedFeed>>() { newsService.getAllUpdateUserFeeds(NewsConstants.FEEDS_NO_PER_CATEGORY, new AsyncCallback<ArrayList<EnhancedPost>>() {
@Override @Override
public void onSuccess(ArrayList<EnhancedFeed> feeds) { public void onSuccess(ArrayList<EnhancedPost> feeds) {
if (feeds != null && allUpdates.size() > 0) { if (feeds != null && allUpdates.size() > 0) {
Date myLastUpdateTime = allUpdates.get(0).getFeed().getTime(); //this is the last update in the View Date myLastUpdateTime = allUpdates.get(0).getPost().getTime(); //this is the last update in the View
GWT.log("Last Mine: "+allUpdates.get(0).getFeed().getDescription()); GWT.log("Last Mine: "+allUpdates.get(0).getPost().getDescription());
GWT.log("Last Retr.: "+feeds.get(0).getFeed().getDescription()); GWT.log("Last Retr.: "+feeds.get(0).getPost().getDescription());
tempCacheNewUpdates = new ArrayList<EnhancedFeed>(); //need to clear it everytime i check (in case someone deleted the updated in the meanwhile) tempCacheNewUpdates = new ArrayList<EnhancedPost>(); //need to clear it everytime i check (in case someone deleted the updated in the meanwhile)
//check if there are new updates (enter the while) and put them in a temporary cache for displaying on user click //check if there are new updates (enter the while) and put them in a temporary cache for displaying on user click
int i = 0; int i = 0;
while (i < feeds.size() && feeds.get(i).getFeed().getTime().after(myLastUpdateTime)) { while (i < feeds.size() && feeds.get(i).getPost().getTime().after(myLastUpdateTime)) {
tempCacheNewUpdates.add(feeds.get(i)); tempCacheNewUpdates.add(feeds.get(i));
i++; i++;
} }
@ -562,9 +563,9 @@ public class NewsFeedPanel extends Composite {
* is open at infra level the first tab stops checking for updates * is open at infra level the first tab stops checking for updates
*/ */
if (result.getCurrentScope().compareTo(currentScope) == 0) { if (result.getCurrentScope().compareTo(currentScope) == 0) {
newsService.getPostsByHashtag(hashtag, new AsyncCallback<ArrayList<EnhancedFeed>>() { newsService.getPostsByHashtag(hashtag, new AsyncCallback<ArrayList<EnhancedPost>>() {
@Override @Override
public void onSuccess(ArrayList<EnhancedFeed> posts) { public void onSuccess(ArrayList<EnhancedPost> posts) {
filterPanelWrapper.setVisible(false); filterPanelWrapper.setVisible(false);
newsPanel.clear(); newsPanel.clear();
if (posts != null) { if (posts != null) {
@ -579,7 +580,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT); newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
newsPanel.add(new ResultsFor("results for", hashtag)); newsPanel.add(new ResultsFor("results for", hashtag));
for (EnhancedFeed feed : posts) { for (EnhancedPost feed : posts) {
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
} }
if (posts.size() < 5) { if (posts.size() < 5) {
@ -629,10 +630,10 @@ public class NewsFeedPanel extends Composite {
* is open at infra level the first tab stops checking for updates * is open at infra level the first tab stops checking for updates
*/ */
if (result.getCurrentScope().compareTo(currentScope) == 0) { if (result.getCurrentScope().compareTo(currentScope) == 0) {
newsService.getPostsRelatedToUserStatistics(relatedFeedsToUserStatisticsToShow, from, to, new AsyncCallback<ArrayList<EnhancedFeed>>() { newsService.getPostsRelatedToUserStatistics(relatedFeedsToUserStatisticsToShow, from, to, new AsyncCallback<ArrayList<EnhancedPost>>() {
@Override @Override
public void onSuccess(ArrayList<EnhancedFeed> posts) { public void onSuccess(ArrayList<EnhancedPost> posts) {
filterPanelWrapper.setVisible(false); filterPanelWrapper.setVisible(false);
newsPanel.clear(); newsPanel.clear();
@ -649,7 +650,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT); newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
newsPanel.add(new ResultsFor("", actionToPrint)); newsPanel.add(new ResultsFor("", actionToPrint));
for (EnhancedFeed feed : posts) { for (EnhancedPost feed : posts) {
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
// save them (they will be used when asking more feeds) // save them (they will be used when asking more feeds)
allUpdates.add(feed); allUpdates.add(feed);
@ -706,9 +707,9 @@ public class NewsFeedPanel extends Composite {
* is open at infra level the first tab stops checking for updates * is open at infra level the first tab stops checking for updates
*/ */
if (result.getCurrentScope().compareTo(currentScope) == 0) { if (result.getCurrentScope().compareTo(currentScope) == 0) {
newsService.getPostsByQuery(query, from, to, new AsyncCallback<ArrayList<EnhancedFeed>>() { newsService.getPostsByQuery(query, from, to, new AsyncCallback<ArrayList<EnhancedPost>>() {
@Override @Override
public void onSuccess(ArrayList<EnhancedFeed> posts) { public void onSuccess(ArrayList<EnhancedPost> posts) {
filterPanelWrapper.setVisible(false); filterPanelWrapper.setVisible(false);
newsPanel.clear(); newsPanel.clear();
if (posts != null) { if (posts != null) {
@ -724,7 +725,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT); newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
newsPanel.add(new ResultsFor("Results for query: ", query)); newsPanel.add(new ResultsFor("Results for query: ", query));
for (EnhancedFeed feed : posts) { for (EnhancedPost feed : posts) {
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
// save them (they will be used when asking more feeds) // save them (they will be used when asking more feeds)
allUpdates.add(feed); allUpdates.add(feed);
@ -766,7 +767,7 @@ public class NewsFeedPanel extends Composite {
//need to put them in reverse order; //need to put them in reverse order;
for (int i = tempCacheNewUpdates.size(); i > 0; i--) { for (int i = tempCacheNewUpdates.size(); i > 0; i--) {
EnhancedFeed feed = tempCacheNewUpdates.get(i-1); EnhancedPost feed = tempCacheNewUpdates.get(i-1);
final TweetTemplate tt = new TweetTemplate(myUserInfo, feed, eventBus, true); final TweetTemplate tt = new TweetTemplate(myUserInfo, feed, eventBus, true);
newsPanel.insert(tt, 0); //insert in the view newsPanel.insert(tt, 0); //insert in the view
allUpdates.add(0, feed); //insert in the model allUpdates.add(0, feed); //insert in the model
@ -787,17 +788,13 @@ public class NewsFeedPanel extends Composite {
/** /**
* used when adding directly a feed from the UI (IPC) * used when adding directly a feed from the UI (IPC)
* @param userid
* @param fullName
* @param thumbURL
* @param description
*/ */
public void addJustAddedFeed(ClientPost cFeed) { public void addJustAddedFeed(ClientPost cFeed) {
// build up the feed // build up the feed
Feed feed = new Feed( Post feed = new Post(
cFeed.key, cFeed.key,
FeedType.SHARE, PostType.SHARE,
cFeed.userid, cFeed.userid,
cFeed.time, cFeed.time,
"", "",
@ -817,7 +814,7 @@ public class NewsFeedPanel extends Composite {
feed.setMultiFileUpload(multiAttachments); feed.setMultiFileUpload(multiAttachments);
//false because he could not have liked this yet and true because is the current user's //false because he could not have liked this yet and true because is the current user's
EnhancedFeed toAdd = new EnhancedFeed(feed, false, true); EnhancedPost toAdd = new EnhancedPost(feed, false, true);
ArrayList<Attachment> attachments = null; ArrayList<Attachment> attachments = null;
if (multiAttachments) { if (multiAttachments) {
@ -861,9 +858,9 @@ public class NewsFeedPanel extends Composite {
*/ */
public void showAllUpdatesFeeds() { public void showAllUpdatesFeeds() {
showLoader(); showLoader();
newsService.getAllUpdateUserFeeds(NewsConstants.FEEDS_NO_PER_CATEGORY, new AsyncCallback<ArrayList<EnhancedFeed>>() { newsService.getAllUpdateUserFeeds(NewsConstants.FEEDS_NO_PER_CATEGORY, new AsyncCallback<ArrayList<EnhancedPost>>() {
@Override @Override
public void onSuccess(ArrayList<EnhancedFeed> feeds) { public void onSuccess(ArrayList<EnhancedPost> feeds) {
newsPanel.clear(); newsPanel.clear();
if (feeds != null) { if (feeds != null) {
if (feeds.size() == 0) { if (feeds.size() == 0) {
@ -884,7 +881,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT); newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
for (EnhancedFeed feed : feeds) { for (EnhancedPost feed : feeds) {
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
allUpdates.add(feed); //in the model allUpdates.add(feed); //in the model
} }
@ -932,14 +929,14 @@ public class NewsFeedPanel extends Composite {
int start = allUpdates.size(); int start = allUpdates.size();
GWT.log("StartingPoint = " + start); GWT.log("StartingPoint = " + start);
newsService.getPostsByQuery(currentQuery, start, SEARCHED_FEEDS_TO_SHOW , new AsyncCallback<ArrayList<EnhancedFeed>>() { newsService.getPostsByQuery(currentQuery, start, SEARCHED_FEEDS_TO_SHOW , new AsyncCallback<ArrayList<EnhancedPost>>() {
@Override @Override
public void onSuccess(ArrayList<EnhancedFeed> posts){ public void onSuccess(ArrayList<EnhancedPost> posts){
newsPanel.remove(showMoreUpdatesPanel); newsPanel.remove(showMoreUpdatesPanel);
if (posts != null) { if (posts != null) {
GWT.log("There are " + posts.size() + " more feeds"); GWT.log("There are " + posts.size() + " more feeds");
for (EnhancedFeed feed : posts) { for (EnhancedPost feed : posts) {
// avoid to insert same data // avoid to insert same data
if(!isFeedPresent(feed)){ if(!isFeedPresent(feed)){
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
@ -976,14 +973,14 @@ public class NewsFeedPanel extends Composite {
int start = allUpdates.size(); int start = allUpdates.size();
GWT.log("StartingPoint = " + start); GWT.log("StartingPoint = " + start);
newsService.getPostsRelatedToUserStatistics(relatedFeedsToUserStatisticsToShow, start, FEEDS_RELATED_TO_USER_STATISTICS_TO_SHOW , new AsyncCallback<ArrayList<EnhancedFeed>>() { newsService.getPostsRelatedToUserStatistics(relatedFeedsToUserStatisticsToShow, start, FEEDS_RELATED_TO_USER_STATISTICS_TO_SHOW , new AsyncCallback<ArrayList<EnhancedPost>>() {
@Override @Override
public void onSuccess(ArrayList<EnhancedFeed> posts){ public void onSuccess(ArrayList<EnhancedPost> posts){
newsPanel.remove(showMoreUpdatesPanel); newsPanel.remove(showMoreUpdatesPanel);
if (posts != null) { if (posts != null) {
GWT.log("There are " + posts.size() + " more feeds"); GWT.log("There are " + posts.size() + " more feeds");
for (EnhancedFeed feed : posts) { for (EnhancedPost feed : posts) {
// avoid to insert same data // avoid to insert same data
if(!isFeedPresent(feed)){ if(!isFeedPresent(feed)){
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
@ -1039,7 +1036,7 @@ public class NewsFeedPanel extends Composite {
if (rangeFeeds.getPosts() != null) { if (rangeFeeds.getPosts() != null) {
fromStartingPoint = rangeFeeds.getLastReturnedFeedTimelineIndex(); fromStartingPoint = rangeFeeds.getLastReturnedFeedTimelineIndex();
int c = 1; int c = 1;
for (EnhancedFeed post : rangeFeeds.getPosts()) { for (EnhancedPost post : rangeFeeds.getPosts()) {
if (!isFeedPresent(post)) { //avoid possible duplicates if (!isFeedPresent(post)) { //avoid possible duplicates
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, post, eventBus)); //in the view newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, post, eventBus)); //in the view
allUpdates.add(post); //in the model allUpdates.add(post); //in the model
@ -1086,9 +1083,9 @@ public class NewsFeedPanel extends Composite {
return false; return false;
} }
private boolean isFeedPresent(EnhancedFeed toCheck) { private boolean isFeedPresent(EnhancedPost toCheck) {
for (EnhancedFeed feed : allUpdates) { for (EnhancedPost feed : allUpdates) {
if (feed.getFeed().getKey().compareTo(toCheck.getFeed().getKey()) == 0) if (feed.getPost().getKey().compareTo(toCheck.getPost().getKey()) == 0)
return true; return true;
} }
return false; return false;
@ -1098,9 +1095,9 @@ public class NewsFeedPanel extends Composite {
*/ */
public void showOnlyConnectionsFeeds() { public void showOnlyConnectionsFeeds() {
showLoader(); showLoader();
newsService.getOnlyConnectionsUserPosts(new AsyncCallback<ArrayList<EnhancedFeed>>() { newsService.getOnlyConnectionsUserPosts(new AsyncCallback<ArrayList<EnhancedPost>>() {
@Override @Override
public void onSuccess(ArrayList<EnhancedFeed> feeds) { public void onSuccess(ArrayList<EnhancedPost> feeds) {
if (feeds != null) { if (feeds != null) {
newsPanel.clear(); newsPanel.clear();
if (feeds.size() == 0) { if (feeds.size() == 0) {
@ -1114,7 +1111,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.setHeight(""); newsPanel.setHeight("");
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT); newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
for (EnhancedFeed feed : feeds) for (EnhancedPost feed : feeds)
newsPanel.add(new TweetTemplate(false, false, myUserInfo, feed, eventBus)); newsPanel.add(new TweetTemplate(false, false, myUserInfo, feed, eventBus));
if (feeds.size() < 5) { if (feeds.size() < 5) {
newsPanel.add(new Image(spacer)); newsPanel.add(new Image(spacer));
@ -1138,9 +1135,9 @@ public class NewsFeedPanel extends Composite {
*/ */
public void showOnlyMyPosts() { public void showOnlyMyPosts() {
showLoader(); showLoader();
newsService.getOnlyMyUserPosts(new AsyncCallback<ArrayList<EnhancedFeed>>() { newsService.getOnlyMyUserPosts(new AsyncCallback<ArrayList<EnhancedPost>>() {
@Override @Override
public void onSuccess(ArrayList<EnhancedFeed> posts) { public void onSuccess(ArrayList<EnhancedPost> posts) {
if (posts != null) { if (posts != null) {
newsPanel.clear(); newsPanel.clear();
if (posts.size() == 0) { if (posts.size() == 0) {
@ -1153,7 +1150,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.setHeight(""); newsPanel.setHeight("");
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT); newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
for (EnhancedFeed feed : posts) for (EnhancedPost feed : posts)
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus));
if (posts.size() < 5) { if (posts.size() < 5) {
newsPanel.add(new Image(spacer)); newsPanel.add(new Image(spacer));
@ -1177,9 +1174,9 @@ public class NewsFeedPanel extends Composite {
*/ */
public void showOnlyLikedPosts() { public void showOnlyLikedPosts() {
showLoader(); showLoader();
newsService.getOnlyLikedPosts(new AsyncCallback<ArrayList<EnhancedFeed>>() { newsService.getOnlyLikedPosts(new AsyncCallback<ArrayList<EnhancedPost>>() {
@Override @Override
public void onSuccess(ArrayList<EnhancedFeed> posts) { public void onSuccess(ArrayList<EnhancedPost> posts) {
if (posts != null) { if (posts != null) {
newsPanel.clear(); newsPanel.clear();
if (posts.size() == 0) { if (posts.size() == 0) {
@ -1192,7 +1189,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.setHeight(""); newsPanel.setHeight("");
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT); newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
for (EnhancedFeed feed : posts) for (EnhancedPost feed : posts)
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus));
if (posts.size() < 5) { if (posts.size() < 5) {
newsPanel.add(new Image(spacer)); newsPanel.add(new Image(spacer));
@ -1219,22 +1216,22 @@ public class NewsFeedPanel extends Composite {
GWT.log(" number of posts " + allUpdates.size()); GWT.log(" number of posts " + allUpdates.size());
ArrayList<Comment> latestComments = new ArrayList<>(); ArrayList<Comment> latestComments = new ArrayList<>();
//thePostsMap is need so that later it is faster to get the post by id //thePostsMap is need so that later it is faster to get the post by id
HashMap<String, EnhancedFeed> theCommentedPostsMap = new HashMap<>(); HashMap<String, EnhancedPost> theCommentedPostsMap = new HashMap<>();
for (EnhancedFeed post : allUpdates) { for (EnhancedPost post : allUpdates) {
ArrayList<Comment> postComments = post.getComments(); ArrayList<Comment> postComments = post.getComments();
if (postComments != null && !postComments.isEmpty()) { if (postComments != null && !postComments.isEmpty()) {
theCommentedPostsMap.put(post.getFeed().getKey(), post); theCommentedPostsMap.put(post.getPost().getKey(), post);
Comment latest = postComments.get(postComments.size()-1); Comment latest = postComments.get(postComments.size()-1);
latestComments.add(latest); //get the latest latestComments.add(latest); //get the latest
} }
} }
//sort the comments //sort the comments
Collections.sort(latestComments, Collections.reverseOrder()); Collections.sort(latestComments, Collections.reverseOrder());
ArrayList<EnhancedFeed> sortedPostsByLatestComment = new ArrayList<>(); ArrayList<EnhancedPost> sortedPostsByLatestComment = new ArrayList<>();
// evaluate unique posts' ids // evaluate unique posts' ids
HashSet<String> postIds = new HashSet<String>(); HashSet<String> postIds = new HashSet<String>();
for (Comment comment : latestComments) { for (Comment comment : latestComments) {
String postId = comment.getFeedid(); String postId = comment.getPostid();
if(!postIds.contains(postId)){ if(!postIds.contains(postId)){
postIds.add(postId); postIds.add(postId);
sortedPostsByLatestComment.add(theCommentedPostsMap.get(postId)); sortedPostsByLatestComment.add(theCommentedPostsMap.get(postId));
@ -1242,8 +1239,8 @@ public class NewsFeedPanel extends Composite {
} }
//at this point the sortedPostsByLatestComment list contains only the commented posts in the right order //at this point the sortedPostsByLatestComment list contains only the commented posts in the right order
//we need to add the remaining posts of the page in the latest post order //we need to add the remaining posts of the page in the latest post order
for (EnhancedFeed post : allUpdates) { for (EnhancedPost post : allUpdates) {
if (!theCommentedPostsMap.containsKey(post.getFeed().getKey())) if (!theCommentedPostsMap.containsKey(post.getPost().getKey()))
sortedPostsByLatestComment.add(post); sortedPostsByLatestComment.add(post);
} }
newsPanel.clear(); newsPanel.clear();
@ -1257,7 +1254,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.setHeight(""); newsPanel.setHeight("");
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT); newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
for (EnhancedFeed feed : sortedPostsByLatestComment) for (EnhancedPost feed : sortedPostsByLatestComment)
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus));
if (sortedPostsByLatestComment.size() < 5) { if (sortedPostsByLatestComment.size() < 5) {
newsPanel.add(new Image(spacer)); newsPanel.add(new Image(spacer));

View File

@ -1,8 +1,8 @@
package org.gcube.portlets.user.newsfeed.client.ui; package org.gcube.portlets.user.newsfeed.client.ui;
import org.gcube.portal.databook.shared.Comment; import org.gcube.social_networking.socialnetworking.model.shared.Comment;
import org.gcube.portal.databook.shared.UserInfo; import org.gcube.social_networking.socialnetworking.model.shared.UserInfo;
import org.gcube.portlets.user.gcubewidgets.client.elements.Div; import org.gcube.portlets.user.gcubewidgets.client.elements.Div;
import org.gcube.portlets.user.newsfeed.client.event.AddCommentEvent; import org.gcube.portlets.user.newsfeed.client.event.AddCommentEvent;
import org.gcube.portlets.user.newsfeed.client.event.EditCommentEvent; import org.gcube.portlets.user.newsfeed.client.event.EditCommentEvent;
@ -74,7 +74,7 @@ public class AddCommentTemplate extends Composite {
/** /**
* called on edit comment * called on edit comment
* @param caller * @param caller
* @param editText * @param toEdit
*/ */
public AddCommentTemplate(TweetTemplate caller, Comment toEdit, HTMLPanel commentPanel) { public AddCommentTemplate(TweetTemplate caller, Comment toEdit, HTMLPanel commentPanel) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
@ -166,7 +166,7 @@ public class AddCommentTemplate extends Composite {
/** /**
* called when pasting. it tries to avoid pasting long non spaced strings * called when pasting. it tries to avoid pasting long non spaced strings
* @param linkToCheck * @param textToCheck
*/ */
private boolean checkTextLength(String textToCheck) { private boolean checkTextLength(String textToCheck) {

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.newsfeed.client.ui; package org.gcube.portlets.user.newsfeed.client.ui;
import org.gcube.portal.databook.shared.Attachment; import org.gcube.social_networking.socialnetworking.model.shared.Attachment;
import org.gcube.portlets.widgets.imagepreviewerwidget.client.EnhancedImage; import org.gcube.portlets.widgets.imagepreviewerwidget.client.EnhancedImage;
import org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel; import org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel;

View File

@ -3,9 +3,9 @@ package org.gcube.portlets.user.newsfeed.client.ui;
import java.util.Date; import java.util.Date;
import org.gcube.common.portal.GCubePortalConstants; import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.social_networking.socialnetworking.model.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder; import org.gcube.social_networking.socialnetworking.model.client.util.Encoder;
import org.gcube.portal.databook.shared.Comment; import org.gcube.social_networking.socialnetworking.model.shared.Comment;
import org.gcube.portlets.user.newsfeed.client.event.DeleteCommentEvent; import org.gcube.portlets.user.newsfeed.client.event.DeleteCommentEvent;
import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel; import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel;

View File

@ -8,13 +8,13 @@ import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import org.gcube.common.portal.GCubePortalConstants; import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.social_networking.socialnetworking.model.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder; import org.gcube.social_networking.socialnetworking.model.client.util.Encoder;
import org.gcube.portal.databook.shared.Attachment; import org.gcube.social_networking.socialnetworking.model.shared.Attachment;
import org.gcube.portal.databook.shared.Comment; import org.gcube.social_networking.socialnetworking.model.shared.Comment;
import org.gcube.portal.databook.shared.EnhancedFeed; import org.gcube.social_networking.socialnetworking.model.shared.EnhancedPost;
import org.gcube.portal.databook.shared.Feed; import org.gcube.social_networking.socialnetworking.model.shared.Post;
import org.gcube.portal.databook.shared.UserInfo; import org.gcube.social_networking.socialnetworking.model.shared.UserInfo;
import org.gcube.portlets.user.newsfeed.client.event.AddLikeEvent; import org.gcube.portlets.user.newsfeed.client.event.AddLikeEvent;
import org.gcube.portlets.user.newsfeed.client.event.DeletePostEvent; import org.gcube.portlets.user.newsfeed.client.event.DeletePostEvent;
import org.gcube.portlets.user.newsfeed.client.event.OpenPostEvent; import org.gcube.portlets.user.newsfeed.client.event.OpenPostEvent;
@ -66,7 +66,7 @@ public class TweetTemplate extends Composite {
private static final int MAX_SHOWTEXT_LENGTH = 612; private static final int MAX_SHOWTEXT_LENGTH = 612;
private EnhancedFeed myPost; private EnhancedPost myPost;
private UserInfo myUserInfo; private UserInfo myUserInfo;
private HandlerManager eventBus; private HandlerManager eventBus;
@ -129,12 +129,11 @@ public class TweetTemplate extends Composite {
* used when fetching tweets from server * used when fetching tweets from server
* @param myUserInfo * @param myUserInfo
* @param myPost * @param myPost
* @param isUsers
* @param displaySingle tells if you're displaying a single fedd or not * @param displaySingle tells if you're displaying a single fedd or not
* @param eventBus * @param eventBus
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public TweetTemplate(boolean displaySingle, boolean showTimelineSource, UserInfo myUserInfo, EnhancedFeed myPost, HandlerManager eventBus) { public TweetTemplate(boolean displaySingle, boolean showTimelineSource, UserInfo myUserInfo, EnhancedPost myPost, HandlerManager eventBus) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
commentsNo.getElement().getStyle().setPaddingTop(0, Unit.PX); commentsNo.getElement().getStyle().setPaddingTop(0, Unit.PX);
likesNo.getElement().getStyle().setPaddingTop(0, Unit.PX); likesNo.getElement().getStyle().setPaddingTop(0, Unit.PX);
@ -147,8 +146,8 @@ public class TweetTemplate extends Composite {
this.vreSourceInMetadata.setVisible(false); this.vreSourceInMetadata.setVisible(false);
this.separator.setVisible(false); this.separator.setVisible(false);
this.myPost = myPost; this.myPost = myPost;
isAppPost = myPost.getFeed().isApplicationFeed(); isAppPost = myPost.getPost().isApplicationPost();
Feed post = myPost.getFeed(); Post post = myPost.getPost();
this.eventBus = eventBus; this.eventBus = eventBus;
this.isUsers = myPost.isUsers(); this.isUsers = myPost.isUsers();
this.carousel = new Carousel(); this.carousel = new Carousel();
@ -417,12 +416,12 @@ public class TweetTemplate extends Composite {
/** /**
* used when getting tweets from the client * used when getting tweets from the client
* @param myUserInfo * @param myUserInfo
* @param feed * @param post
* @param eventBus * @param eventBus
* @param hidden * @param hidden
*/ */
public TweetTemplate(UserInfo myUserInfo, EnhancedFeed feed, HandlerManager eventBus, boolean hidden) { public TweetTemplate(UserInfo myUserInfo, EnhancedPost post, HandlerManager eventBus, boolean hidden) {
this(false, false, myUserInfo, feed, eventBus); this(false, false, myUserInfo, post, eventBus);
contentArea.getElement().getParentElement().getParentElement().setClassName("div-table-col content hidden"); contentArea.getElement().getParentElement().getParentElement().setClassName("div-table-col content hidden");
} }
@ -462,7 +461,7 @@ public class TweetTemplate extends Composite {
@UiHandler("seeMore") @UiHandler("seeMore")
void onSeeMoreClick(ClickEvent e) { void onSeeMoreClick(ClickEvent e) {
String postText = myPost.getFeed().getDescription(); String postText = myPost.getPost().getDescription();
postText = postText.replaceAll("&amp;","&"); postText = postText.replaceAll("&amp;","&");
contentArea.setHTML(postText); contentArea.setHTML(postText);
@ -486,19 +485,19 @@ public class TweetTemplate extends Composite {
//if is not liked //if is not liked
if (!likeArea.getText().equals(NewsFeedPanel.LIKED_LABEL)) { if (!likeArea.getText().equals(NewsFeedPanel.LIKED_LABEL)) {
try { try {
int cur = Integer.parseInt(myPost.getFeed().getLikesNo()); int cur = Integer.parseInt(myPost.getPost().getLikesNo());
cur++; cur++;
if (cur == 1) { if (cur == 1) {
myPost.getFeed().setLikesNo("1"); myPost.getPost().setLikesNo("1");
likesNo.setText("1"); likesNo.setText("1");
likesNo.setTitle("People who have " + NewsFeedPanel.LIKED_LABEL + " this"); likesNo.setTitle("People who have " + NewsFeedPanel.LIKED_LABEL + " this");
likesNo.setVisible(true); likesNo.setVisible(true);
} else { } else {
myPost.getFeed().setLikesNo(""+cur); myPost.getPost().setLikesNo(""+cur);
likesNo.setText(""+cur); likesNo.setText(""+cur);
likesNo.setVisible(true); likesNo.setVisible(true);
} }
eventBus.fireEvent(new AddLikeEvent(this, myPost.getFeed().getKey())); eventBus.fireEvent(new AddLikeEvent(this, myPost.getPost().getKey()));
setFavoritedUI(true); setFavoritedUI(true);
} }
catch (NumberFormatException ex) { catch (NumberFormatException ex) {
@ -506,19 +505,19 @@ public class TweetTemplate extends Composite {
} }
} else { } else {
//it is liked //it is liked
int cur = Integer.parseInt(myPost.getFeed().getLikesNo()); int cur = Integer.parseInt(myPost.getPost().getLikesNo());
cur--; cur--;
if (cur == 0) { if (cur == 0) {
myPost.getFeed().setLikesNo("0"); myPost.getPost().setLikesNo("0");
likesNo.setText(""); likesNo.setText("");
likesNo.setVisible(false); likesNo.setVisible(false);
likesNo.setTitle(""); likesNo.setTitle("");
} else { } else {
myPost.getFeed().setLikesNo(""+cur); myPost.getPost().setLikesNo(""+cur);
likesNo.setText(""+cur); likesNo.setText(""+cur);
likesNo.setVisible(true); likesNo.setVisible(true);
} }
eventBus.fireEvent(new UnLikeEvent(this, myPost.getFeed().getKey())); eventBus.fireEvent(new UnLikeEvent(this, myPost.getPost().getKey()));
setFavoritedUI(false); setFavoritedUI(false);
} }
} }
@ -569,7 +568,7 @@ public class TweetTemplate extends Composite {
@UiHandler("likesNo") @UiHandler("likesNo")
void onSeeLikes(ClickEvent e) { void onSeeLikes(ClickEvent e) {
eventBus.fireEvent(new SeeLikesEvent(myPost.getFeed().getKey())); eventBus.fireEvent(new SeeLikesEvent(myPost.getPost().getKey()));
} }
@UiHandler("commentsNo") @UiHandler("commentsNo")
@ -589,7 +588,7 @@ public class TweetTemplate extends Composite {
this.commentingDisabled = commenting; this.commentingDisabled = commenting;
} }
public String getFeedKey() { public String getFeedKey() {
return myPost.getFeed().getKey(); return myPost.getPost().getKey();
} }
public void remove(Widget w) { public void remove(Widget w) {
@ -671,11 +670,11 @@ public class TweetTemplate extends Composite {
} }
public String getMyFeedUserId() { public String getMyFeedUserId() {
return myPost.getFeed().getEntityId(); return myPost.getPost().getEntityId();
} }
public String getMyFeedText() { public String getMyFeedText() {
return myPost.getFeed().getDescription(); return myPost.getPost().getDescription();
} }
public boolean isAppFeed() { public boolean isAppFeed() {
@ -698,7 +697,7 @@ public class TweetTemplate extends Composite {
* @return the context (scope) of the Post * @return the context (scope) of the Post
*/ */
public String getVREContext() { public String getVREContext() {
return this.myPost.getFeed().getVreid(); return this.myPost.getPost().getVreid();
} }
/** /**

View File

@ -25,22 +25,15 @@ import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
import org.gcube.common.portal.GCubePortalConstants; import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl; import org.gcube.social_networking.social_networking_client_library.LibClient;
import org.gcube.portal.databook.server.DatabookStore; import org.gcube.social_networking.socialnetworking.model.shared.Attachment;
import org.gcube.portal.databook.shared.Attachment; import org.gcube.social_networking.socialnetworking.model.shared.Comment;
import org.gcube.portal.databook.shared.Comment; import org.gcube.social_networking.socialnetworking.model.shared.EnhancedPost;
import org.gcube.portal.databook.shared.EnhancedFeed; import org.gcube.social_networking.socialnetworking.model.shared.Post;
import org.gcube.portal.databook.shared.Feed; import org.gcube.social_networking.socialnetworking.model.shared.Like;
import org.gcube.portal.databook.shared.Like; import org.gcube.social_networking.socialnetworking.model.shared.RangePosts;
import org.gcube.portal.databook.shared.RangeFeeds; import org.gcube.social_networking.socialnetworking.model.shared.ShowUserStatisticAction;
import org.gcube.portal.databook.shared.ShowUserStatisticAction; import org.gcube.social_networking.socialnetworking.model.shared.UserInfo;
import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portal.databook.shared.ex.ColumnNameNotFoundException;
import org.gcube.portal.databook.shared.ex.CommentIDNotFoundException;
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
import org.gcube.portal.databook.shared.ex.FeedTypeNotFoundException;
import org.gcube.portal.databook.shared.ex.LikeIDNotFoundException;
import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
import org.gcube.portal.notifications.bean.GenericItemBean; import org.gcube.portal.notifications.bean.GenericItemBean;
import org.gcube.portal.notifications.thread.CommentNotificationsThread; import org.gcube.portal.notifications.thread.CommentNotificationsThread;
import org.gcube.portal.notifications.thread.LikeNotificationsThread; import org.gcube.portal.notifications.thread.LikeNotificationsThread;
@ -98,20 +91,24 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
/** /**
* Cassandra client * Cassandra client
*/ */
private DatabookStore store; private LibClient libClient;
private final static int MAX_POSTS_NO = 30; private final static int MAX_POSTS_NO = 30;
public void init() { public void init() {
store = new DBCassandraAstyanaxImpl(); try {
libClient = new LibClient();
} catch (Exception e) {
throw new RuntimeException(e);
}
APP_ID = this.getClass().getName(); APP_ID = this.getClass().getName();
} }
public void destroy() { /*public void destroy() {
store.closeConnection(); store.closeConnection();
} }*/
/** /**
* *
* @return true if you're running into the portal, false if in development * @return true if you're running into the portal, false if in development
@ -177,10 +174,10 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
} }
@Override @Override
public ArrayList<EnhancedFeed> getAllUpdateUserFeeds(int postsNoPerCategory) { public ArrayList<EnhancedPost> getAllUpdateUserFeeds(int postsNoPerCategory) {
ArrayList<Feed> toMerge = new ArrayList<Feed>(); ArrayList<Post> toMerge = new ArrayList<Post>();
HashMap<String, Feed> feedsMap = new HashMap<String, Feed>(); HashMap<String, Post> feedsMap = new HashMap<String, Post>();
try { try {
GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest()); GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest());
_log.info("****** retrieving posts for user: " + currUser.getUsername()); _log.info("****** retrieving posts for user: " + currUser.getUsername());
@ -195,16 +192,16 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
if (gm.isVRE(group.getGroupId())) { if (gm.isVRE(group.getGroupId())) {
String vreid = gm.getInfrastructureScope(group.getGroupId()); //get the scope String vreid = gm.getInfrastructureScope(group.getGroupId()); //get the scope
_log.debug("Reading posts for VRE: " + vreid); _log.debug("Reading posts for VRE: " + vreid);
ArrayList<Feed> OrganizationFeeds = (ArrayList<Feed>) store.getRecentFeedsByVRE(vreid, postsNoPerCategory); ArrayList<Post> OrganizationFeeds = (ArrayList<Post>) libClient.getRecentPostsByVRELib(vreid, postsNoPerCategory);
for (Feed post : OrganizationFeeds) { for (Post post : OrganizationFeeds) {
feedsMap.put(post.getKey(), post); feedsMap.put(post.getKey(), post);
} }
} }
} }
//Portal Feeds //Portal Feeds
ArrayList<Feed> portalFeeds = (ArrayList<Feed>) store.getAllPortalPrivacyLevelFeeds(); ArrayList<Post> portalFeeds = (ArrayList<Post>) libClient.getAllPortalPrivacyLevelPostsLib();
for (Feed post : portalFeeds) { for (Post post : portalFeeds) {
feedsMap.put(post.getKey(), post); feedsMap.put(post.getKey(), post);
} }
} }
@ -213,8 +210,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
PortalContext context = PortalContext.getConfiguration(); PortalContext context = PortalContext.getConfiguration();
String vreid = context.getCurrentScope(getThreadLocalRequest()); String vreid = context.getCurrentScope(getThreadLocalRequest());
_log.trace("News Feed in VRE, Reading posts for VRE: " + vreid); _log.trace("News Feed in VRE, Reading posts for VRE: " + vreid);
ArrayList<Feed> OrganizationFeeds = (ArrayList<Feed>) store.getRecentFeedsByVRE(vreid, (NewsConstants.FEEDS_MAX_PER_CATEGORY)); ArrayList<Post> OrganizationFeeds = (ArrayList<Post>) libClient.getRecentPostsByVRELib(vreid, (NewsConstants.FEEDS_MAX_PER_CATEGORY));
for (Feed post : OrganizationFeeds) { for (Post post : OrganizationFeeds) {
feedsMap.put(post.getKey(), post); feedsMap.put(post.getKey(), post);
} }
} }
@ -226,21 +223,15 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
//sort the posts in reverse chronological order //sort the posts in reverse chronological order
Collections.sort(toMerge, Collections.reverseOrder()); Collections.sort(toMerge, Collections.reverseOrder());
ArrayList<Feed> toReturn = new ArrayList<Feed>(); ArrayList<Post> toReturn = new ArrayList<Post>();
//return only <MAX_FEEDS_NO> posts //return only <MAX_FEEDS_NO> posts
if (toMerge.size() > MAX_POSTS_NO) if (toMerge.size() > MAX_POSTS_NO)
for (int i = 0; i < MAX_POSTS_NO; i++) for (int i = 0; i < MAX_POSTS_NO; i++)
toReturn.add(toMerge.get(i)); toReturn.add(toMerge.get(i));
else { else {
return enhanceFeeds(toMerge, 2); return enhancePosts(toMerge, 2);
} }
return enhanceFeeds(toReturn, 2); return enhancePosts(toReturn, 2);
} catch (PrivacyLevelTypeNotFoundException e) {
_log.error("Privacy Level not Found " + e.getMessage());
} catch (FeedTypeNotFoundException e) {
_log.error("Feed Type not Found " + e.getMessage());
} catch (ColumnNameNotFoundException e) {
_log.error("Column name not Found " + e.getMessage());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -252,7 +243,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
* @param hashtag the hashtag to look for including '#' * @param hashtag the hashtag to look for including '#'
*/ */
@Override @Override
public ArrayList<EnhancedFeed> getPostsByHashtag(String hashtag) { public ArrayList<EnhancedPost> getPostsByHashtag(String hashtag) {
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername(); String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername();
String currentScope = pContext.getCurrentScope(getThreadLocalRequest()); String currentScope = pContext.getCurrentScope(getThreadLocalRequest());
@ -266,8 +257,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
try { try {
ArrayList<Feed> toMerge = new ArrayList<Feed>(); ArrayList<Post> toMerge = new ArrayList<Post>();
HashMap<String, Feed> feedsMap = new HashMap<String, Feed>(); HashMap<String, Post> feedsMap = new HashMap<String, Post>();
String lowerCaseHashtag = hashtag.toLowerCase(); String lowerCaseHashtag = hashtag.toLowerCase();
// the contexts of the user // the contexts of the user
@ -296,8 +287,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
_log.debug("Contexts for hashtags is " + contexts); _log.debug("Contexts for hashtags is " + contexts);
for (String context : contexts) { for (String context : contexts) {
ArrayList<Feed> posts = (ArrayList<Feed>) store.getVREFeedsByHashtag(context, lowerCaseHashtag); ArrayList<Post> posts = (ArrayList<Post>) libClient.getVREPostsByHashtagLib(context, lowerCaseHashtag);
for (Feed post : posts) { for (Post post : posts) {
feedsMap.put(post.getKey(), post); feedsMap.put(post.getKey(), post);
} }
} }
@ -309,21 +300,15 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
//sort the posts in reverse chronological order //sort the posts in reverse chronological order
Collections.sort(toMerge, Collections.reverseOrder()); Collections.sort(toMerge, Collections.reverseOrder());
ArrayList<Feed> toReturn = new ArrayList<Feed>(); ArrayList<Post> toReturn = new ArrayList<Post>();
//return only <MAX_FEEDS_NO> posts //return only <MAX_FEEDS_NO> posts
if (toMerge.size() > MAX_POSTS_NO) if (toMerge.size() > MAX_POSTS_NO)
for (int i = 0; i < MAX_POSTS_NO; i++) for (int i = 0; i < MAX_POSTS_NO; i++)
toReturn.add(toMerge.get(i)); toReturn.add(toMerge.get(i));
else { else {
return enhanceFeeds(toMerge, 2); return enhancePosts(toMerge, 2);
} }
return enhanceFeeds(toReturn, 2); return enhancePosts(toReturn, 2);
} catch (PrivacyLevelTypeNotFoundException e) {
_log.error("Privacy Level not Found ", e);
} catch (FeedTypeNotFoundException e) {
_log.error("Feed Type not Found ", e);
} catch (ColumnNameNotFoundException e) {
_log.error("Column name not Found ", e);
} catch (Exception e) { } catch (Exception e) {
_log.error("Error while retrieving posts for hashtag ", e); _log.error("Error while retrieving posts for hashtag ", e);
} }
@ -331,7 +316,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
} }
@Override @Override
public ArrayList<EnhancedFeed> getPostsByQuery(String query, int from, int quantity) { public ArrayList<EnhancedPost> getPostsByQuery(String query, int from, int quantity) {
_log.debug("\n\n IN getPostsByQuery "); _log.debug("\n\n IN getPostsByQuery ");
@ -369,26 +354,26 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
} }
FullTextSearchClient sClient = new FullTextSearchClient(); FullTextSearchClient sClient = new FullTextSearchClient();
List<EnhancedFeed> enhancedFeeds = sClient.search(query, from, quantity); List<EnhancedPost> enhancedFeeds = sClient.search(query, from, quantity);
// query elastic search // query elastic search
//escl.search(query, vres, from, quantity); //escl.search(query, vres, from, quantity);
// retrieve the ids of liked posts by the user // retrieve the ids of liked posts by the user
List<String> likedPosts = store.getAllLikedPostIdsByUser(userName); List<String> likedPosts = libClient.getAllLikedPostIdsByUserLib(userName);
// update fields "liked" and "isuser" // update fields "liked" and "isuser"
for (EnhancedFeed enhancedFeed : enhancedFeeds) { for (EnhancedPost enhancedFeed : enhancedFeeds) {
if(isUsers(enhancedFeed.getFeed(), userName)) if(isUsers(enhancedFeed.getPost(), userName))
enhancedFeed.setUsers(true); enhancedFeed.setUsers(true);
if(likedPosts.contains(enhancedFeed.getFeed().getKey())) if(likedPosts.contains(enhancedFeed.getPost().getKey()))
enhancedFeed.setLiked(true); enhancedFeed.setLiked(true);
} }
return (ArrayList<EnhancedFeed>) enhancedFeeds; return (ArrayList<EnhancedPost>) enhancedFeeds;
}catch (Exception e) { }catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -401,17 +386,18 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
* return only the user connection posts * return only the user connection posts
*/ */
@Override @Override
public ArrayList<EnhancedFeed> getOnlyConnectionsUserPosts() { public ArrayList<EnhancedPost> getOnlyConnectionsUserPosts() {
ArrayList<Feed> toMerge = new ArrayList<Feed>(); /*ArrayList<Post> toMerge = new ArrayList<Post>();
HashMap<String, Feed> feedsMap = new HashMap<String, Feed>(); HashMap<String, Post> feedsMap = new HashMap<String, Post>();
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername(); String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername();
try { try {
//UserFriends Feeds //UserFriends Feeds
ArrayList<String> userFriendsIds = (ArrayList<String>)store.getFriends(userName); //implement in client and ws
ArrayList<String> userFriendsIds = (ArrayList<String>)libClient.getFriendsLib(userName);
for (String userid : userFriendsIds) { for (String userid : userFriendsIds) {
for (Feed post : store.getRecentFeedsByUser(userid, NewsConstants.FEEDS_NO_PER_CATEGORY)) { for (Post post : libClient.getRecentPostsByUserLib(userid, NewsConstants.FEEDS_NO_PER_CATEGORY)) {
feedsMap.put(post.getKey(), post); feedsMap.put(post.getKey(), post);
} }
} }
@ -419,23 +405,23 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
toMerge.add(feedsMap.get(key)); toMerge.add(feedsMap.get(key));
} }
Collections.sort(toMerge, Collections.reverseOrder()); Collections.sort(toMerge, Collections.reverseOrder());
ArrayList<Feed> toReturn = new ArrayList<Feed>(); ArrayList<Post> toReturn = new ArrayList<Post>();
//return only <MAX_FEEDS_NO> posts //return only <MAX_FEEDS_NO> posts
if (toMerge.size() > MAX_POSTS_NO) if (toMerge.size() > MAX_POSTS_NO)
for (int i = 0; i < MAX_POSTS_NO; i++) for (int i = 0; i < MAX_POSTS_NO; i++)
toReturn.add(toMerge.get(i)); toReturn.add(toMerge.get(i));
else else
return enhanceFeeds(toMerge, 2); return enhancePosts(toMerge, 2);
} catch (PrivacyLevelTypeNotFoundException e) { } catch (PrivacyLevelTypeNotFoundException e) {
_log.error("Privacy Level not Found " + e.getMessage()); _log.error("Privacy Level not Found " + e.getMessage());
} catch (FeedTypeNotFoundException e) { } catch (PostTypeNotFoundException e) {
_log.error("Feed Type not Found " + e.getMessage()); _log.error("Feed Type not Found " + e.getMessage());
} catch (ColumnNameNotFoundException e) { } catch (ColumnNameNotFoundException e) {
_log.error("Column name not Found " + e.getMessage()); _log.error("Column name not Found " + e.getMessage());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }*/
return null; return null;
} }
@ -443,43 +429,42 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
* return only one post with all the comments * return only one post with all the comments
*/ */
@Override @Override
public EnhancedFeed getSinglePost(String postKey) { public EnhancedPost getSinglePost(String postKey) {
Feed post = null; Post post = null;
try { try {
if (postKey != null) { if (postKey != null) {
post = store.readFeed(postKey); post = libClient.readPostLib(postKey);
if (post != null) { if (post != null) {
ArrayList<Feed> toEnhance = new ArrayList<Feed>(); ArrayList<Post> toEnhance = new ArrayList<Post>();
toEnhance.add(post); toEnhance.add(post);
return enhanceFeeds(toEnhance, -1).get(0); //-1 all the comments return enhancePosts(toEnhance, -1).get(0); //-1 all the comments
} }
} }
} catch (Exception e) { } catch (Exception e) {
_log.debug("Error while trying to fetch post with key " + postKey + " returning nothing"); _log.debug("Error while trying to fetch post with key " + postKey + " returning nothing");
return new EnhancedFeed(); return new EnhancedPost();
} }
return new EnhancedFeed(); return new EnhancedPost();
} }
/** /**
* MorePostsBean contains the timeline index of the last returned valid post (because if you delete a feed is stays on in the timeline and is marked deleted) * MorePostsBean contains the timeline index of the last returned valid post (because if you delete a feed is stays on in the timeline and is marked deleted)
* and contains the Feeds * and contains the Feeds
* @param strat the range start (most recent posts for this vre) has to be greater than 0
* @param quantity the number of most recent posts for this vre starting from "start" param * @param quantity the number of most recent posts for this vre starting from "start" param
*/ */
@Override @Override
public MorePostsBean getMorePosts(int start, int quantity) { public MorePostsBean getMorePosts(int start, int quantity) {
ArrayList<Feed> toMerge = new ArrayList<Feed>(); ArrayList<Post> toMerge = new ArrayList<Post>();
HashMap<String, Feed> feedsMap = new HashMap<String, Feed>(); HashMap<String, Post> feedsMap = new HashMap<String, Post>();
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
String vreid = pContext.getCurrentScope(getThreadLocalRequest()); String vreid = pContext.getCurrentScope(getThreadLocalRequest());
_log.debug("\n\nAsking more post for Timeline " + vreid + " from " + start + " get other " + quantity); _log.debug("\n\nAsking more post for Timeline " + vreid + " from " + start + " get other " + quantity);
ArrayList<Feed> organizationFeeds; ArrayList<Post> organizationFeeds;
RangeFeeds rangeFeeds = null; RangePosts rangeFeeds = null;
try { try {
rangeFeeds = store.getRecentFeedsByVREAndRange(vreid, start, quantity); rangeFeeds = libClient.getRecentPostsByVREAndRangeLib(vreid, start, quantity);
organizationFeeds = rangeFeeds.getFeeds(); organizationFeeds = rangeFeeds.getPosts();
if (organizationFeeds != null) { if (organizationFeeds != null) {
for (Feed post : organizationFeeds) { for (Post post : organizationFeeds) {
feedsMap.put(post.getKey(), post); feedsMap.put(post.getKey(), post);
} }
} }
@ -494,38 +479,39 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
} }
//sort the posts in reverse chronological order //sort the posts in reverse chronological order
Collections.sort(toMerge, Collections.reverseOrder()); Collections.sort(toMerge, Collections.reverseOrder());
ArrayList<EnhancedFeed> toReturn = enhanceFeeds(toMerge, 2); ArrayList<EnhancedPost> toReturn = enhancePosts(toMerge, 2);
return new MorePostsBean(rangeFeeds.getLastReturnedFeedTimelineIndex(), toReturn); return new MorePostsBean(rangeFeeds.getLastReturnedPostTimelineIndex(), toReturn);
} }
@Override @Override
public ArrayList<EnhancedFeed> getOnlyMyUserPosts() { public ArrayList<EnhancedPost> getOnlyMyUserPosts() {
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername(); String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername();
_log.trace("getOnly UserFeeds for " + userName); _log.trace("getOnly UserFeeds for " + userName);
ArrayList<Feed> userFeeds = null; ArrayList<Post> userFeeds = null;
try { try {
userFeeds = (ArrayList<Feed>) store.getRecentFeedsByUser(userName, 15); userFeeds = (ArrayList<Post>) libClient.getRecentPostsByUserLib(userName, 15);
} catch (Exception e) { } catch (Exception e) {
_log.error("Could not read recent posts for this user " + userName); _log.error("Could not read recent posts for this user " + userName);
} }
Collections.sort(userFeeds, Collections.reverseOrder()); Collections.sort(userFeeds, Collections.reverseOrder());
return enhanceFeeds(userFeeds, 2); return enhancePosts(userFeeds, 2);
} }
@Override @Override
public ArrayList<EnhancedFeed> getOnlyLikedPosts() { public ArrayList<EnhancedPost> getOnlyLikedPosts() {
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername(); String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername();
_log.trace("getLiked Feeds for " + userName); _log.trace("getLiked Feeds for " + userName);
ArrayList<Feed> userFeeds = null; ArrayList<Post> userFeeds = null;
try { try {
userFeeds = (ArrayList<Feed>) store.getAllLikedFeedsByUser(userName, 25); //need to define this function and endpoint in ws and client
userFeeds = (ArrayList<Post>) libClient.getAllLikedPostsByUserLib(userName, 25);
} catch (Exception e) { } catch (Exception e) {
_log.error("Could not read liked posts for this user " + userName); _log.error("Could not read liked posts for this user " + userName);
} }
Collections.sort(userFeeds, Collections.reverseOrder()); Collections.sort(userFeeds, Collections.reverseOrder());
return enhanceFeeds(userFeeds, 2); return enhancePosts(userFeeds, 2);
} }
@Override @Override
@ -539,12 +525,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
Like toLike = new Like(UUID.randomUUID().toString(), user.getUsername(), Like toLike = new Like(UUID.randomUUID().toString(), user.getUsername(),
new Date(), postid, user.getFullName(), user.getAvatarId()); new Date(), postid, user.getFullName(), user.getAvatarId());
try { likeCommitResult = libClient.likeLib(toLike);
likeCommitResult = store.like(toLike);
} catch (FeedIDNotFoundException e) {
_log.error("Post not Found for this like " + e.getMessage());
return false;
}
//if the like was correctly delivered notify users involved //if the like was correctly delivered notify users involved
if (likeCommitResult) { if (likeCommitResult) {
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
@ -570,19 +551,14 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
@Override @Override
public boolean unlike(String postid, String postText, String postOwnerId) { public boolean unlike(String postid, String postText, String postOwnerId) {
UserInfo user = getUserSettings().getUserInfo(); UserInfo user = getUserSettings().getUserInfo();
try { for (Like like : libClient.getAllLikesByPostLib(postid)) {
for (Like like : store.getAllLikesByFeed(postid)) { if (like.getUserid().compareTo(user.getUsername()) == 0) {
if (like.getUserid().compareTo(user.getUsername()) == 0) { _log.trace("Trying unlike of " + postText + " for " + user.getFullName());
_log.trace("Trying unlike of " + postText + " for " + user.getFullName()); libClient.unlikeLib(user.getUsername(), like.getKey(), postid);
store.unlike(user.getUsername(), like.getKey(), postid); return true;
return true; }
} }
}
} catch (FeedIDNotFoundException | PrivacyLevelTypeNotFoundException | FeedTypeNotFoundException | ColumnNameNotFoundException | LikeIDNotFoundException e) {
_log.error("Either Post or Like not Found " + e.getMessage());
return false;
}
return false; return false;
} }
/** /**
@ -617,23 +593,11 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
Comment comment = new Comment(UUID.randomUUID().toString(), user.getUsername(), Comment comment = new Comment(UUID.randomUUID().toString(), user.getUsername(),
new Date(), feedid, escapedCommentText, user.getFullName(), user.getAvatarId()); new Date(), feedid, escapedCommentText, user.getFullName(), user.getAvatarId());
try { if (libClient.addCommentLib(comment))
if (store.addComment(comment)) commentCommitResult = true;
commentCommitResult = true;
} catch (FeedIDNotFoundException e) {
_log.error("Related post not found for this comment " + e.getMessage());
return new OperationResult(false, "Related post not found for this comment", comment);
}
try { if (hashtags != null && !hashtags.isEmpty())
if (hashtags != null && !hashtags.isEmpty()) libClient.saveHashTagsCommentLib(comment.getKey(), libClient.readPostLib(comment.getPostid()).getVreid(), hashtags);
store.saveHashTagsComment(comment.getKey(), store.readFeed(comment.getFeedid()).getVreid(), hashtags);
} catch (CommentIDNotFoundException
| PrivacyLevelTypeNotFoundException
| FeedTypeNotFoundException | FeedIDNotFoundException
| ColumnNameNotFoundException e1) {
_log.error("Unable to save hashtags for this comment " + e1.getMessage());
}
//if the comment was correctly delivered && is not an app feed notify users involved //if the comment was correctly delivered && is not an app feed notify users involved
if (commentCommitResult && isWithinPortal()) { if (commentCommitResult && isWithinPortal()) {
@ -656,7 +620,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
likesThread.start(); likesThread.start();
//notify the other users who commented this post (excluding the ones above) //notify the other users who commented this post (excluding the ones above)
Thread commentsNotificationthread = new Thread(new CommentNotificationsThread(store, new LiferayUserManager(), user.getUsername(), comment.getFeedid(), escapedCommentText, nm, feedOwnerId, comment.getKey(), favorites)); Thread commentsNotificationthread = new Thread(new CommentNotificationsThread(new LiferayUserManager(), user.getUsername(), comment.getPostid(), escapedCommentText, nm, feedOwnerId, comment.getKey(), favorites));
commentsNotificationthread.start(); commentsNotificationthread.start();
//send the notification to the mentioned users, if any //send the notification to the mentioned users, if any
@ -705,7 +669,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
toPass.add(new GenericItemBean(userBean.getId(), userBean.getName(), userBean.getAlternativeName(), userBean.getThumbnailURL())); toPass.add(new GenericItemBean(userBean.getId(), userBean.getName(), userBean.getAlternativeName(), userBean.getThumbnailURL()));
} }
Thread thread = new Thread(new MentionNotificationsThread(comment.getFeedid(), escapedCommentText, nm, null, toPass)); Thread thread = new Thread(new MentionNotificationsThread(comment.getPostid(), escapedCommentText, nm, null, toPass));
thread.start(); thread.start();
} }
} }
@ -723,16 +687,16 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
return new OperationResult(false, "Session Expired", null); return new OperationResult(false, "Session Expired", null);
} }
String vreIdFeed = store.readFeed(toEdit.getFeedid()).getVreid(); String vreIdFeed = libClient.readPostLib(toEdit.getPostid()).getVreid();
// get old hashtags and delete them // get old hashtags and delete them
String oldText = store.readCommentById(toEdit.getKey()).getText(); String oldText = libClient.readCommentByIdLib(toEdit.getKey()).getText();
_log.debug("Old text for this comment is " + oldText); _log.debug("Old text for this comment is " + oldText);
System.out.println("Old text for this comment is " + oldText); System.out.println("Old text for this comment is " + oldText);
List<String> oldHashtags = Utils.getHashTags(Utils.removeHTMLFromText(oldText)); List<String> oldHashtags = Utils.getHashTags(Utils.removeHTMLFromText(oldText));
if (oldHashtags != null && !oldHashtags.isEmpty()) { if (oldHashtags != null && !oldHashtags.isEmpty()) {
_log.debug("The comment has hashtags, attempting to delete them ... " + oldHashtags.toString()); _log.debug("The comment has hashtags, attempting to delete them ... " + oldHashtags.toString());
boolean deletedHashtag = store.deleteHashTagsComment(toEdit.getKey(), vreIdFeed, oldHashtags); boolean deletedHashtag = libClient.deleteHashTagsCommentLib(toEdit.getKey(), vreIdFeed, oldHashtags);
_log.debug("deletedHashtag? " + deletedHashtag); _log.debug("deletedHashtag? " + deletedHashtag);
} }
@ -752,12 +716,12 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
List<String> newHashtags = messageParser.getHashtags(); List<String> newHashtags = messageParser.getHashtags();
if (newHashtags != null && !newHashtags.isEmpty()) if (newHashtags != null && !newHashtags.isEmpty())
store.saveHashTagsComment(toEdit.getKey(), vreIdFeed, newHashtags); libClient.saveHashTagsCommentLib(toEdit.getKey(), vreIdFeed, newHashtags);
edited = new Comment(toEdit.getKey(), toEdit.getUserid(), edited = new Comment(toEdit.getKey(), toEdit.getUserid(),
toEdit.getTime(), toEdit.getFeedid(), escapedCommentText, user.getFullName(), user.getAvatarId(), true, new Date()); toEdit.getTime(), toEdit.getPostid(), escapedCommentText, user.getFullName(), user.getAvatarId(), true, new Date());
commentCommitResult = store.editComment(edited); commentCommitResult = libClient.editCommentLib(edited);
if (commentCommitResult) { if (commentCommitResult) {
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
@ -811,7 +775,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
toPass.add(new GenericItemBean(userBean.getId(), userBean.getName(), userBean.getAlternativeName(), userBean.getThumbnailURL())); toPass.add(new GenericItemBean(userBean.getId(), userBean.getName(), userBean.getAlternativeName(), userBean.getThumbnailURL()));
} }
Thread thread = new Thread(new MentionNotificationsThread(toEdit.getFeedid(), escapedCommentText, nm, null, toPass)); Thread thread = new Thread(new MentionNotificationsThread(toEdit.getPostid(), escapedCommentText, nm, null, toPass));
thread.start(); thread.start();
} }
} }
@ -831,8 +795,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
* *
* @return * @return
*/ */
private ArrayList<EnhancedFeed> enhanceFeeds(ArrayList<Feed> toEnhance, int commentsNumberPerFeed) { private ArrayList<EnhancedPost> enhancePosts(ArrayList<Post> toEnhance, int commentsNumberPerFeed) {
ArrayList<EnhancedFeed> toReturn = new ArrayList<EnhancedFeed>(); ArrayList<EnhancedPost> toReturn = new ArrayList<EnhancedPost>();
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername(); String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername();
@ -842,24 +806,20 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
String siteLandinPagePath = PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest()); String siteLandinPagePath = PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest());
String tokenTosubstitute = siteLandinPagePath.replace("/group/", ""); String tokenTosubstitute = siteLandinPagePath.replace("/group/", "");
ArrayList<String> likedFeeds = (ArrayList<String>) store.getAllLikedFeedIdsByUser(userName); ArrayList<String> likedFeeds = (ArrayList<String>) libClient.getAllLikedPostIdsByUserLib(userName);
boolean skip = false; boolean skip = false;
for (Feed feed : toEnhance) { for (Post feed : toEnhance) {
//patch needed for maintaining mention link backward compatibility (they point to /group/data-e-infrastructure-gateway/profile) //patch needed for maintaining mention link backward compatibility (they point to /group/data-e-infrastructure-gateway/profile)
String currPostText = feed.getDescription().replace(LINK_TO_REPLACE,tokenTosubstitute); String currPostText = feed.getDescription().replace(LINK_TO_REPLACE,tokenTosubstitute);
feed.setDescription(currPostText); feed.setDescription(currPostText);
boolean isMultiFileUpload = feed.isMultiFileUpload(); boolean isMultiFileUpload = feed.isMultiFileUpload();
ArrayList<Attachment> attachments = new ArrayList<Attachment>(); ArrayList<Attachment> attachments = new ArrayList<Attachment>();
if (isMultiFileUpload) { if (isMultiFileUpload) {
try { attachments = (ArrayList<Attachment>) libClient.getAttachmentsByPostIdLib(feed.getKey());
attachments = (ArrayList<Attachment>) store.getAttachmentsByFeedId(feed.getKey()); }
} catch (FeedIDNotFoundException e) {
_log.error("It looks like sth wrong with this feedid having attachments, could not find feedId = " + feed.getKey() + "\n" + e.getMessage());
}
}
skip = false; skip = false;
if (! feed.isApplicationFeed()) { if (! feed.isApplicationPost()) {
String thumb = getUserImagePortraitUrlLocal(feed.getEntityId()); String thumb = getUserImagePortraitUrlLocal(feed.getEntityId());
if (thumb == null) { if (thumb == null) {
_log.warn(feed.getEntityId() + " is not avaialble on this portal, skipping this feed: " + feed.getKey()); _log.warn(feed.getEntityId() + " is not avaialble on this portal, skipping this feed: " + feed.getKey());
@ -879,12 +839,12 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
} }
if (!skip) { if (!skip) {
if (commentsNo == 0) { if (commentsNo == 0) {
EnhancedFeed toAdd = null; EnhancedPost toAdd = null;
//create the enhanced feed //create the enhanced feed
if (feed.isApplicationFeed()) { if (feed.isApplicationPost()) {
toAdd = new EnhancedFeed(feed, liked, checkisAdminUser()); toAdd = new EnhancedPost(feed, liked, checkisAdminUser());
} else } else
toAdd = new EnhancedFeed(feed, liked, isUsers(feed, userName)); toAdd = new EnhancedPost(feed, liked, isUsers(feed, userName));
toAdd.setAttachments(attachments); toAdd.setAttachments(attachments);
toReturn.add(toAdd); toReturn.add(toAdd);
} else { } else {
@ -895,7 +855,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
int currCommentsNumber = comments.size(); int currCommentsNumber = comments.size();
//if comments are less than $commentsNumberPerFeed they are the more recent, -1 return all the comments //if comments are less than $commentsNumberPerFeed they are the more recent, -1 return all the comments
if (currCommentsNumber < commentsNumberPerFeed || commentsNumberPerFeed == -1) { if (currCommentsNumber < commentsNumberPerFeed || commentsNumberPerFeed == -1) {
EnhancedFeed toAdd = new EnhancedFeed(feed, liked, isUsers(feed, userName), comments, attachments); EnhancedPost toAdd = new EnhancedPost(feed, liked, isUsers(feed, userName), comments, attachments);
toReturn.add(toAdd); toReturn.add(toAdd);
} else { } else {
//need to get the last two //need to get the last two
@ -903,7 +863,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
for (int i = currCommentsNumber -commentsNumberPerFeed; i < currCommentsNumber; i++) { for (int i = currCommentsNumber -commentsNumberPerFeed; i < currCommentsNumber; i++) {
comments2Attach.add(comments.get(i)); comments2Attach.add(comments.get(i));
} }
EnhancedFeed toAdd = new EnhancedFeed(feed, liked, isUsers(feed, userName), comments2Attach, attachments); EnhancedPost toAdd = new EnhancedPost(feed, liked, isUsers(feed, userName), comments2Attach, attachments);
toReturn.add(toAdd); toReturn.add(toAdd);
} }
} }
@ -917,7 +877,6 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
/** /**
* this method is needed because user images portrait change id depending on the portal instance * this method is needed because user images portrait change id depending on the portal instance
* e.g. a post made from iMarine portal would not show the avatarIMage in D4Science.org * e.g. a post made from iMarine portal would not show the avatarIMage in D4Science.org
* @param screenname
* @return the url of the image portrait for this portal instance * @return the url of the image portrait for this portal instance
*/ */
private String getUserImagePortraitUrlLocal(String screenName) { private String getUserImagePortraitUrlLocal(String screenName) {
@ -935,7 +894,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
@Override @Override
public ArrayList<Like> getAllLikesByPost(String postid) { public ArrayList<Like> getAllLikesByPost(String postid) {
ArrayList<Like> toReturn = (ArrayList<Like>) store.getAllLikesByFeed(postid); ArrayList<Like> toReturn = (ArrayList<Like>) libClient.getAllLikesByPostLib(postid);
_log.trace("Asking likes for " + postid); _log.trace("Asking likes for " + postid);
for (Like like : toReturn) { for (Like like : toReturn) {
String thumb = getUserImagePortraitUrlLocal(like.getUserid()); String thumb = getUserImagePortraitUrlLocal(like.getUserid());
@ -948,7 +907,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
@Override @Override
public ArrayList<Comment> getAllCommentsByPost(String postid) { public ArrayList<Comment> getAllCommentsByPost(String postid) {
_log.trace("Asking comments for " + postid); _log.trace("Asking comments for " + postid);
ArrayList<Comment> toReturn = (ArrayList<Comment>) store.getAllCommentByFeed(postid); ArrayList<Comment> toReturn = (ArrayList<Comment>) libClient.getAllCommentsByPostIdLib(postid);
for (Comment comment : toReturn) { for (Comment comment : toReturn) {
String thumb = getUserImagePortraitUrlLocal(comment.getUserid()); String thumb = getUserImagePortraitUrlLocal(comment.getUserid());
comment.setThumbnailURL(thumb == null ? "" : thumb); comment.setThumbnailURL(thumb == null ? "" : thumb);
@ -961,16 +920,16 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
_log.trace("Attempting to delete comment " + commentid); _log.trace("Attempting to delete comment " + commentid);
try { try {
// get hashtags, if any, and delete them // get hashtags, if any, and delete them
Comment toDelete = store.readCommentById(commentid); Comment toDelete = libClient.readCommentByIdLib(commentid);
String vreIdFeed = store.readFeed(toDelete.getFeedid()).getVreid(); String vreIdFeed = libClient.readPostLib(toDelete.getPostid()).getVreid();
List<String> hashtags = Utils.getHashTags(Utils.removeHTMLFromText(toDelete.getText())); List<String> hashtags = Utils.getHashTags(Utils.removeHTMLFromText(toDelete.getText()));
if (hashtags != null && !hashtags.isEmpty()) { if (hashtags != null && !hashtags.isEmpty()) {
_log.debug("The comment has hashtags, attempting to delete them ... " + hashtags.toString()); _log.debug("The comment has hashtags, attempting to delete them ... " + hashtags.toString());
boolean deletedHashtag = store.deleteHashTagsComment(toDelete.getKey(), vreIdFeed, hashtags); boolean deletedHashtag = libClient.deleteHashTagsCommentLib(toDelete.getKey(), vreIdFeed, hashtags);
_log.debug("deletedHashtag? " + deletedHashtag); _log.debug("deletedHashtag? " + deletedHashtag);
} }
_log.debug("Attempting to delete comment " + commentid); _log.debug("Attempting to delete comment " + commentid);
return store.deleteComment(commentid, feedid); return libClient.deleteCommentLib(commentid, feedid);
} catch (Exception e) { } catch (Exception e) {
_log.error("Failed to delete comment " + commentid); _log.error("Failed to delete comment " + commentid);
return false; return false;
@ -980,14 +939,14 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
public boolean deletePost(String postid) { public boolean deletePost(String postid) {
_log.debug("Called delete post " + postid); _log.debug("Called delete post " + postid);
try { try {
Feed toDelete = store.readFeed(postid); Post toDelete = libClient.readPostLib(postid);
// delete comments and hastags as well // delete comments and hastags as well
boolean hasComments = Integer.parseInt(toDelete.getCommentsNo()) > 0; boolean hasComments = Integer.parseInt(toDelete.getCommentsNo()) > 0;
if(hasComments){ if(hasComments){
_log.debug("Deleting post comments and their hashtags"); _log.debug("Deleting post comments and their hashtags");
List<Comment> comments = store.getAllCommentByFeed(postid); List<Comment> comments = libClient.getAllCommentsByPostIdLib(postid);
for (Comment comment : comments) { for (Comment comment : comments) {
deleteComment(comment.getKey(), postid); deleteComment(comment.getKey(), postid);
} }
@ -996,11 +955,11 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
List<String> hashtags = Utils.getHashTags(Utils.removeHTMLFromText(toDelete.getDescription())); List<String> hashtags = Utils.getHashTags(Utils.removeHTMLFromText(toDelete.getDescription()));
if (hashtags != null && !hashtags.isEmpty()) { if (hashtags != null && !hashtags.isEmpty()) {
_log.debug("The post has hashtags, attempting to delete them ... " + hashtags.toString()); _log.debug("The post has hashtags, attempting to delete them ... " + hashtags.toString());
boolean deletedHashtag = store.deleteHashTags(postid, toDelete.getVreid(), hashtags); boolean deletedHashtag = libClient.deleteHashTagsLib(postid, toDelete.getVreid(), hashtags);
_log.debug("deletedHashtag? " + deletedHashtag); _log.debug("deletedHashtag? " + deletedHashtag);
} }
_log.debug("Attempting to delete post " + postid); _log.debug("Attempting to delete post " + postid);
return store.deleteFeed(postid); return libClient.deletePostLib(postid);
} catch (Exception e) { } catch (Exception e) {
_log.debug("Failed to delete post " + postid); _log.debug("Failed to delete post " + postid);
@ -1060,7 +1019,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
* @param username * @param username
* @return true if this feed is of the current user * @return true if this feed is of the current user
*/ */
private boolean isUsers(Feed tocheck, String username) { private boolean isUsers(Post tocheck, String username) {
return (tocheck.getEntityId().equals(username)); return (tocheck.getEntityId().equals(username));
} }
@ -1112,7 +1071,6 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
} }
/** /**
* tell if the user is a portal administrator or not * tell if the user is a portal administrator or not
* @param username
* @return true if is admin * @return true if is admin
* @throws SystemException * @throws SystemException
* @throws PortalException * @throws PortalException
@ -1185,7 +1143,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
} }
@Override @Override
public ArrayList<EnhancedFeed> getPostsRelatedToUserStatistics( public ArrayList<EnhancedPost> getPostsRelatedToUserStatistics(
ShowUserStatisticAction action, int from, int quantity) { ShowUserStatisticAction action, int from, int quantity) {
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
@ -1201,37 +1159,38 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
Calendar oneYearAgo = Calendar.getInstance(); Calendar oneYearAgo = Calendar.getInstance();
oneYearAgo.set(Calendar.YEAR, oneYearAgo.get(Calendar.YEAR) - 1); oneYearAgo.set(Calendar.YEAR, oneYearAgo.get(Calendar.YEAR) - 1);
ArrayList<Feed> feeds = null; ArrayList<Post> feeds = null;
switch(action){ switch(action){
case POSTS_MADE_BY_USER: case POSTS_MADE_BY_USER:
feeds = (ArrayList<Feed>) store.getRecentFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis()); feeds = (ArrayList<Post>) libClient.getRecentPostsByUserAndDateLib(userid, oneYearAgo.getTimeInMillis());
break; break;
case LIKES_MADE_BY_USER: case LIKES_MADE_BY_USER:
feeds = (ArrayList<Feed>) store.getRecentLikedFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis()); //need to implement it in client and ws
feeds = (ArrayList<Post>) libClient.getRecentLikedPostsByUserAndDateLib(userid, oneYearAgo.getTimeInMillis());
break; break;
case COMMENTS_MADE_BY_USER: case COMMENTS_MADE_BY_USER:
feeds = (ArrayList<Feed>) store.getRecentCommentedFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis()); feeds = (ArrayList<Post>) libClient.getRecentCommentedPostsByUserAndDateLib(userid, oneYearAgo.getTimeInMillis());
break; break;
case LIKES_GOT_BY_USER: case LIKES_GOT_BY_USER:
feeds = (ArrayList<Feed>) store.getRecentFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis()); feeds = (ArrayList<Post>) libClient.getRecentPostsByUserAndDateLib(userid, oneYearAgo.getTimeInMillis());
Iterator<Feed> feedsIteratorLikes = feeds.iterator(); Iterator<Post> feedsIteratorLikes = feeds.iterator();
while (feedsIteratorLikes.hasNext()) { while (feedsIteratorLikes.hasNext()) {
Feed feed = (Feed) feedsIteratorLikes.next(); Post feed = (Post) feedsIteratorLikes.next();
if(Integer.parseInt(feed.getLikesNo()) == 0) if(Integer.parseInt(feed.getLikesNo()) == 0)
feedsIteratorLikes.remove(); feedsIteratorLikes.remove();
} }
break; break;
case COMMENTS_GOT_BY_USER: case COMMENTS_GOT_BY_USER:
feeds = (ArrayList<Feed>) store.getRecentFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis()); feeds = (ArrayList<Post>) libClient.getRecentPostsByUserAndDateLib(userid, oneYearAgo.getTimeInMillis());
Iterator<Feed> feedsIteratorComments = feeds.iterator(); Iterator<Post> feedsIteratorComments = feeds.iterator();
while (feedsIteratorComments.hasNext()) { while (feedsIteratorComments.hasNext()) {
Feed feed = (Feed) feedsIteratorComments.next(); Post feed = (Post) feedsIteratorComments.next();
if(Integer.parseInt(feed.getCommentsNo()) == 0) if(Integer.parseInt(feed.getCommentsNo()) == 0)
feedsIteratorComments.remove(); feedsIteratorComments.remove();
} }
break; break;
default : return new ArrayList<EnhancedFeed>(); default : return new ArrayList<EnhancedPost>();
} }
@ -1258,9 +1217,9 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
} }
// filter // filter
Iterator<Feed> iteratorScope = feeds.iterator(); Iterator<Post> iteratorScope = feeds.iterator();
while (iteratorScope.hasNext()) { while (iteratorScope.hasNext()) {
Feed feed = (Feed) iteratorScope.next(); Post feed = (Post) iteratorScope.next();
if(!contexts.contains(feed.getVreid())) if(!contexts.contains(feed.getVreid()))
iteratorScope.remove(); iteratorScope.remove();
} }
@ -1268,8 +1227,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
// sort the list, retrieve elements in the range and enhance the feeds // sort the list, retrieve elements in the range and enhance the feeds
Collections.sort(feeds, Collections.reverseOrder()); Collections.sort(feeds, Collections.reverseOrder());
int upperIndex = (from + quantity) >= feeds.size() ? feeds.size() : from + quantity; int upperIndex = (from + quantity) >= feeds.size() ? feeds.size() : from + quantity;
feeds = new ArrayList<Feed>(feeds.subList(from, upperIndex)); feeds = new ArrayList<Post>(feeds.subList(from, upperIndex));
return enhanceFeeds(feeds, -1); return enhancePosts(feeds, -1);
}catch(Exception e){ }catch(Exception e){
_log.error("Error while retrieving feeds for user " + userid + " and action " + action.toString(), e); _log.error("Error while retrieving feeds for user " + userid + " and action " + action.toString(), e);

View File

@ -3,19 +3,19 @@ package org.gcube.portlets.user.newsfeed.shared;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portal.databook.shared.EnhancedFeed; import org.gcube.social_networking.socialnetworking.model.shared.EnhancedPost;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class MorePostsBean implements Serializable { public class MorePostsBean implements Serializable {
private int lastReturnedPostTimelineIndex; private int lastReturnedPostTimelineIndex;
private ArrayList<EnhancedFeed> posts; private ArrayList<EnhancedPost> posts;
public MorePostsBean() { public MorePostsBean() {
super(); super();
} }
public MorePostsBean(int lastReturnedFeedTimelineIndex, public MorePostsBean(int lastReturnedFeedTimelineIndex,
ArrayList<EnhancedFeed> feeds) { ArrayList<EnhancedPost> feeds) {
super(); super();
this.lastReturnedPostTimelineIndex = lastReturnedFeedTimelineIndex; this.lastReturnedPostTimelineIndex = lastReturnedFeedTimelineIndex;
this.posts = feeds; this.posts = feeds;
@ -27,10 +27,10 @@ public class MorePostsBean implements Serializable {
public void setLastReturnedFeedTimelineIndex(int lastReturnedFeedTimelineIndex) { public void setLastReturnedFeedTimelineIndex(int lastReturnedFeedTimelineIndex) {
this.lastReturnedPostTimelineIndex = lastReturnedFeedTimelineIndex; this.lastReturnedPostTimelineIndex = lastReturnedFeedTimelineIndex;
} }
public ArrayList<EnhancedFeed> getPosts() { public ArrayList<EnhancedPost> getPosts() {
return posts; return posts;
} }
public void setPosts(ArrayList<EnhancedFeed> posts) { public void setPosts(ArrayList<EnhancedPost> posts) {
this.posts = posts; this.posts = posts;
} }

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.newsfeed.shared; package org.gcube.portlets.user.newsfeed.shared;
import org.gcube.portal.databook.shared.Comment; import org.gcube.social_networking.socialnetworking.model.shared.Comment;
import com.google.gwt.user.client.rpc.IsSerializable; import com.google.gwt.user.client.rpc.IsSerializable;

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.newsfeed.shared; package org.gcube.portlets.user.newsfeed.shared;
import org.gcube.portal.databook.shared.UserInfo; import org.gcube.social_networking.socialnetworking.model.shared.UserInfo;
import com.google.gwt.user.client.rpc.IsSerializable; import com.google.gwt.user.client.rpc.IsSerializable;

View File

@ -15,7 +15,7 @@
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' /> <inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
<inherits name='org.gcube.portlets.widgets.userselection.UserSelection' /> <inherits name='org.gcube.portlets.widgets.userselection.UserSelection' />
<inherits name='org.gcube.portlets.widgets.pickitem.PickItem' /> <inherits name='org.gcube.portlets.widgets.pickitem.PickItem' />
<inherits name='org.gcube.portal.databook.GCubeSocialNetworking' /> <inherits name='org.gcube.social_networking.socialnetworking.model.GCubeSocialNetworking' />
<inherits name="org.gcube.portlets.widgets.imagepreviewerwidget.ImagePreviewer" /> <inherits name="org.gcube.portlets.widgets.imagepreviewerwidget.ImagePreviewer" />