Fixed ClientFeed exchange problem between this portlet and the share-updates one on posting.

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@122312 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-01-19 13:35:27 +00:00
parent 12726771ff
commit f663bfe58b
5 changed files with 56 additions and 39 deletions

View File

@ -4,15 +4,6 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<dependent-module archiveName="session-checker-0.5.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/session-checker/session-checker">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="pickitem-widget-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/pickitem-widget/pickitem-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="gcube-widgets-1.9.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/> <property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="news-feed"/> <property name="context-root" value="news-feed"/>
</wb-module> </wb-module>

View File

@ -6,6 +6,7 @@ import java.util.HashSet;
import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder; import org.gcube.portal.databook.client.util.Encoder;
import org.gcube.portal.databook.shared.Attachment;
import org.gcube.portal.databook.shared.ClientFeed; import org.gcube.portal.databook.shared.ClientFeed;
import org.gcube.portal.databook.shared.Comment; import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed; import org.gcube.portal.databook.shared.Feed;
@ -562,11 +563,33 @@ public class NewsFeedPanel extends Composite {
* @param description * @param description
*/ */
public void addJustAddedFeed(ClientFeed cFeed) { public void addJustAddedFeed(ClientFeed cFeed) {
Feed feed = new Feed(cFeed.getKey(), FeedType.SHARE, cFeed.getUserid(), cFeed.getTime(), "", cFeed.getUri(), cFeed.getLinkUrlThumbnail(),
cFeed.getDescription(), PrivacyLevel.CONNECTION, cFeed.getFullName(), Feed feed = new Feed(cFeed.getKey(),
cFeed.getEmail(), cFeed.getThumbnailURL(), cFeed.getLinkTitle(), cFeed.getLinkDescription(), cFeed.getLinkHost()); FeedType.SHARE,
cFeed.getUserid(),
cFeed.getTime(),
"",
cFeed.getUri(),
cFeed.getLinkUrlThumbnail(),
cFeed.getDescription(),
PrivacyLevel.CONNECTION,
cFeed.getFullName(),
cFeed.getEmail(),
cFeed.getThumbnailURL(),
cFeed.getLinkTitle(),
cFeed.getLinkDescription(),
cFeed.getLinkHost());
// set attachments property
boolean multiAttachments = cFeed.getAttachments() != null;
feed.setMultiFileUpload(multiAttachments);
EnhancedFeed toAdd = new EnhancedFeed(feed, false, true); //false cuz he could not have liked this yet and true because is the current user's EnhancedFeed toAdd = new EnhancedFeed(feed, false, true); //false cuz he could not have liked this yet and true because is the current user's
// be careful when converting from List<> to ArrayList<> ...
ArrayList<Attachment> attachments = cFeed.getAttachments() == null ? null : new ArrayList<Attachment>(cFeed.getAttachments());
toAdd.setAttachments(attachments);
final TweetTemplate tt = new TweetTemplate(myUserInfo, toAdd, eventBus, true); final TweetTemplate tt = new TweetTemplate(myUserInfo, toAdd, eventBus, true);
if (isFirstTweet) { if (isFirstTweet) {
newsPanel.clear(); newsPanel.clear();
@ -574,6 +597,7 @@ public class NewsFeedPanel extends Composite {
isFirstTweet = false; isFirstTweet = false;
} }
newsPanel.insert(tt, 0); newsPanel.insert(tt, 0);
Timer t = new Timer() { Timer t = new Timer() {
@Override @Override

View File

@ -70,7 +70,7 @@ public class TweetTemplate extends Composite {
private int totalComments = 0; private int totalComments = 0;
private HTML showAllComments = new HTML(); private HTML showAllComments = new HTML();
private boolean isAppFeed = false; private boolean isAppFeed = false;
private TweetTemplate myInstance; private TweetTemplate myInstance;
/** /**
@ -141,13 +141,15 @@ public class TweetTemplate extends Composite {
} else { } else {
closeImage.removeFromParent(); closeImage.removeFromParent();
} }
GWT.log("# attachments: "+myFeed.getAttachments().size()); if(myFeed.getAttachments() != null){
if (myFeed.getAttachments().size() > 0) { GWT.log("# attachments: "+myFeed.getAttachments().size());
for (Attachment a : myFeed.getAttachments()) { if (myFeed.getAttachments().size() > 0) {
GWT.log(a.toString()); for (Attachment a : myFeed.getAttachments()) {
GWT.log(a.toString());
}
} }
} }
openImage.setStyleName("openImage"); openImage.setStyleName("openImage");
openImage.setTitle("Open this feed separately"); openImage.setTitle("Open this feed separately");
//show if the user has already liked this or not //show if the user has already liked this or not
@ -157,7 +159,7 @@ public class TweetTemplate extends Composite {
String feedText = feed.getDescription(); String feedText = feed.getDescription();
String descWithoutHTML = new HTML(feedText).getText(); String descWithoutHTML = new HTML(feedText).getText();
if ( (! feedText.startsWith("<span")) && descWithoutHTML.length() > MAX_SHOWTEXT_LENGTH && !displaySingle) { if ( (! feedText.startsWith("<span")) && descWithoutHTML.length() > MAX_SHOWTEXT_LENGTH && !displaySingle) {
final int TEXT_TO_SHOW_LENGHT = (descWithoutHTML.length() < 500) ? (feedText.length() - (feedText.length() / 3)) : 500; final int TEXT_TO_SHOW_LENGHT = (descWithoutHTML.length() < 500) ? (feedText.length() - (feedText.length() / 3)) : 500;
feedText = feedText.substring(0, TEXT_TO_SHOW_LENGHT) + "..."; feedText = feedText.substring(0, TEXT_TO_SHOW_LENGHT) + "...";
@ -461,35 +463,35 @@ public class TweetTemplate extends Composite {
} }
public void addComment(SingleComment comment) { public void addComment(SingleComment comment) {
commentsPanel.add(comment); commentsPanel.add(comment);
myComments.add(comment); myComments.add(comment);
} }
public void updateSingleComment(Comment edited, HTMLPanel commentPanel){ public void updateSingleComment(Comment edited, HTMLPanel commentPanel){
commentPanel.clear(); commentPanel.clear();
SingleComment sc = new SingleComment(edited, this, true); SingleComment sc = new SingleComment(edited, this, true);
commentPanel.add(sc); commentPanel.add(sc);
// replace the new SingleComment in the list // replace the new SingleComment in the list
int index = 0; int index = 0;
Iterator<SingleComment> iterator = this.myComments.iterator(); Iterator<SingleComment> iterator = this.myComments.iterator();
for (;iterator.hasNext();) { for (;iterator.hasNext();) {
SingleComment singleComment = (SingleComment) iterator.next(); SingleComment singleComment = (SingleComment) iterator.next();
if(singleComment.getCommentKey().equals(edited.getKey())){ if(singleComment.getCommentKey().equals(edited.getKey())){
iterator.remove(); iterator.remove();
this.myComments.add(index, sc); this.myComments.add(index, sc);
break; break;
} }
index ++; index ++;
} }
} }
public void clearComments() { public void clearComments() {

View File

@ -84,9 +84,9 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
private static final String USER_SETTINGS_ATTR = "USER_SETTINGS_ATTR"; private static final String USER_SETTINGS_ATTR = "USER_SETTINGS_ATTR";
public static final String TEST_SCOPE = "/gcube/devsec/devVRE"; public static final String TEST_SCOPE = "/gcube/devsec/devVRE";
private String APP_ID; private String APP_ID;
/** /**
* *
@ -124,7 +124,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
*/ */
public String getDevelopmentUser() { public String getDevelopmentUser() {
String user = NewsConstants.TEST_USER; String user = NewsConstants.TEST_USER;
// user = "andrea.rossi"; // user = "andrea.rossi";
return user; return user;
} }
/** /**
@ -611,7 +611,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
boolean commentCommitResult = false; boolean commentCommitResult = false;
_log.trace("Trying to add this comment " + commentText); _log.trace("Trying to add this comment " + commentText);
UserInfo user = getUserSettings().getUserInfo(); UserInfo user = getUserSettings().getUserInfo();
if (user.getUsername().compareTo(NewsConstants.TEST_USER) == 0) { if (user.getUsername().compareTo(NewsConstants.TEST_USER) == 0) {
return new OperationResult(false, "Session Expired", null); return new OperationResult(false, "Session Expired", null);
} }
@ -621,7 +621,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
//copy the set into a list //copy the set into a list
ArrayList<String> mentionedUserFullNamesList = new ArrayList<String>(); ArrayList<String> mentionedUserFullNamesList = new ArrayList<String>();
mentionedUserFullNamesList.addAll(mentionedUserFullNames); mentionedUserFullNamesList.addAll(mentionedUserFullNames);
ArrayList<ItemBean> mentionedUsers = null; ArrayList<ItemBean> mentionedUsers = null;
if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) { if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) {
mentionedUsers = getSelectedUserIds(mentionedUserFullNamesList); mentionedUsers = getSelectedUserIds(mentionedUserFullNamesList);
@ -675,7 +675,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
if (user.getUsername().compareTo(NewsConstants.TEST_USER) == 0) { if (user.getUsername().compareTo(NewsConstants.TEST_USER) == 0) {
return new OperationResult(false, "Session Expired", null); return new OperationResult(false, "Session Expired", null);
} }
String escapedCommentText = Utils.escapeHtmlAndTransformUrl(toEdit.getText()); String escapedCommentText = Utils.escapeHtmlAndTransformUrl(toEdit.getText());
Comment edited = new Comment(toEdit.getKey(), toEdit.getUserid(), Comment edited = new Comment(toEdit.getKey(), toEdit.getUserid(),
@ -704,7 +704,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
ArrayList<String> likedFeeds = (ArrayList<String>) store.getAllLikedFeedIdsByUser(getASLSession().getUsername()); ArrayList<String> likedFeeds = (ArrayList<String>) store.getAllLikedFeedIdsByUser(getASLSession().getUsername());
boolean skip = false; boolean skip = false;
for (Feed feed : toEnhance) { for (Feed feed : toEnhance) {
boolean isMultiFileUpload = feed.isMultiFileUpload(); boolean isMultiFileUpload = feed.isMultiFileUpload();
ArrayList<Attachment> attachments = new ArrayList<Attachment>(); ArrayList<Attachment> attachments = new ArrayList<Attachment>();
if (isMultiFileUpload) { if (isMultiFileUpload) {
@ -714,7 +714,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
_log.error("It looks like sth wrong with this feedid having attachments, could not find feedId = " + feed.getKey() + "\n" + e.getMessage()); _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.isApplicationFeed()) {
String thumb = getUserImagePortraitUrlLocal(feed.getEntityId()); String thumb = getUserImagePortraitUrlLocal(feed.getEntityId());

View File

@ -4,14 +4,14 @@
<inherits name='com.google.gwt.user.User' /> <inherits name='com.google.gwt.user.User' />
<!-- To Comment out --> <!-- To Comment out -->
<!-- <set-property name="user.agent" value="safari,gecko1_8" /> --> <!-- <set-property name="user.agent" value="safari,gecko1_8" /> -->
<!-- Other module inherits --> <!-- Other module inherits -->
<inherits name="net.eliasbalasis.tibcopagebus4gwt.tibcopagebus4gwt" /> <inherits name="net.eliasbalasis.tibcopagebus4gwt.tibcopagebus4gwt" />
<inherits name="org.jsonmaker.gwt.Gwt_jsonmaker" /> <inherits name="org.jsonmaker.gwt.Gwt_jsonmaker" />
<inherits <inherits
name="net.eliasbalasis.tibcopagebus4gwt.testsubscriber.TestSubscriber" /> name="net.eliasbalasis.tibcopagebus4gwt.testsubscriber.TestSubscriber" />
<inherits name="com.github.gwtbootstrap.Bootstrap" /> <inherits name="com.github.gwtbootstrap.Bootstrap" />
<!-- inherits gCube Widgets Library --> <!-- inherits gCube Widgets Library -->
<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' />