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="/WEB-INF/classes" source-path="/src/main/java"/>
<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="context-root" value="news-feed"/>
</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.util.Encoder;
import org.gcube.portal.databook.shared.Attachment;
import org.gcube.portal.databook.shared.ClientFeed;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
@ -562,11 +563,33 @@ public class NewsFeedPanel extends Composite {
* @param description
*/
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(),
cFeed.getEmail(), cFeed.getThumbnailURL(), cFeed.getLinkTitle(), cFeed.getLinkDescription(), cFeed.getLinkHost());
Feed feed = new Feed(cFeed.getKey(),
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
// 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);
if (isFirstTweet) {
newsPanel.clear();
@ -574,6 +597,7 @@ public class NewsFeedPanel extends Composite {
isFirstTweet = false;
}
newsPanel.insert(tt, 0);
Timer t = new Timer() {
@Override

View File

@ -70,7 +70,7 @@ public class TweetTemplate extends Composite {
private int totalComments = 0;
private HTML showAllComments = new HTML();
private boolean isAppFeed = false;
private TweetTemplate myInstance;
/**
@ -141,13 +141,15 @@ public class TweetTemplate extends Composite {
} else {
closeImage.removeFromParent();
}
GWT.log("# attachments: "+myFeed.getAttachments().size());
if (myFeed.getAttachments().size() > 0) {
for (Attachment a : myFeed.getAttachments()) {
GWT.log(a.toString());
if(myFeed.getAttachments() != null){
GWT.log("# attachments: "+myFeed.getAttachments().size());
if (myFeed.getAttachments().size() > 0) {
for (Attachment a : myFeed.getAttachments()) {
GWT.log(a.toString());
}
}
}
openImage.setStyleName("openImage");
openImage.setTitle("Open this feed separately");
//show if the user has already liked this or not
@ -157,7 +159,7 @@ public class TweetTemplate extends Composite {
String feedText = feed.getDescription();
String descWithoutHTML = new HTML(feedText).getText();
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;
feedText = feedText.substring(0, TEXT_TO_SHOW_LENGHT) + "...";
@ -461,35 +463,35 @@ public class TweetTemplate extends Composite {
}
public void addComment(SingleComment comment) {
commentsPanel.add(comment);
myComments.add(comment);
}
public void updateSingleComment(Comment edited, HTMLPanel commentPanel){
commentPanel.clear();
SingleComment sc = new SingleComment(edited, this, true);
commentPanel.add(sc);
// replace the new SingleComment in the list
int index = 0;
Iterator<SingleComment> iterator = this.myComments.iterator();
for (;iterator.hasNext();) {
SingleComment singleComment = (SingleComment) iterator.next();
if(singleComment.getCommentKey().equals(edited.getKey())){
iterator.remove();
this.myComments.add(index, sc);
break;
}
index ++;
}
}
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";
public static final String TEST_SCOPE = "/gcube/devsec/devVRE";
private String APP_ID;
/**
*
@ -124,7 +124,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
*/
public String getDevelopmentUser() {
String user = NewsConstants.TEST_USER;
// user = "andrea.rossi";
// user = "andrea.rossi";
return user;
}
/**
@ -611,7 +611,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
boolean commentCommitResult = false;
_log.trace("Trying to add this comment " + commentText);
UserInfo user = getUserSettings().getUserInfo();
if (user.getUsername().compareTo(NewsConstants.TEST_USER) == 0) {
return new OperationResult(false, "Session Expired", null);
}
@ -621,7 +621,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
//copy the set into a list
ArrayList<String> mentionedUserFullNamesList = new ArrayList<String>();
mentionedUserFullNamesList.addAll(mentionedUserFullNames);
ArrayList<ItemBean> mentionedUsers = null;
if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) {
mentionedUsers = getSelectedUserIds(mentionedUserFullNamesList);
@ -675,7 +675,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
if (user.getUsername().compareTo(NewsConstants.TEST_USER) == 0) {
return new OperationResult(false, "Session Expired", null);
}
String escapedCommentText = Utils.escapeHtmlAndTransformUrl(toEdit.getText());
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());
boolean skip = false;
for (Feed feed : toEnhance) {
boolean isMultiFileUpload = feed.isMultiFileUpload();
ArrayList<Attachment> attachments = new ArrayList<Attachment>();
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());
}
}
skip = false;
if (! feed.isApplicationFeed()) {
String thumb = getUserImagePortraitUrlLocal(feed.getEntityId());

View File

@ -4,14 +4,14 @@
<inherits name='com.google.gwt.user.User' />
<!-- To Comment out -->
<!-- <set-property name="user.agent" value="safari,gecko1_8" /> -->
<!-- <set-property name="user.agent" value="safari,gecko1_8" /> -->
<!-- Other module inherits -->
<inherits name="net.eliasbalasis.tibcopagebus4gwt.tibcopagebus4gwt" />
<inherits name="org.jsonmaker.gwt.Gwt_jsonmaker" />
<inherits
name="net.eliasbalasis.tibcopagebus4gwt.testsubscriber.TestSubscriber" />
<inherits name="com.github.gwtbootstrap.Bootstrap" />
<inherits name="com.github.gwtbootstrap.Bootstrap" />
<!-- inherits gCube Widgets Library -->
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
<inherits name='org.gcube.portlets.widgets.userselection.UserSelection' />