Bug #17181, post editing leads to losing both formatting and mentions
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@181247 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4c6116947f
commit
241486383b
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/news-feed-2.8.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
<classpathentry kind="src" output="target/news-feed-2.8.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/news-feed-2.8.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
<classpathentry excluding="**" kind="src" output="target/news-feed-2.8.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
@ -41,5 +41,5 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/news-feed-2.8.0-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/news-feed-2.8.1-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
lastWarOutDir=/Users/massi/Documents/workspace/news-feed/target/news-feed-2.8.0-SNAPSHOT
|
lastWarOutDir=/Users/massi/Documents/workspace/news-feed/target/news-feed-2.8.1-SNAPSHOT
|
||||||
warSrcDir=src/main/webapp
|
warSrcDir=src/main/webapp
|
||||||
warSrcDirIsOutput=false
|
warSrcDirIsOutput=false
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
<dependent-module archiveName="gcube-widgets-2.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
|
<dependent-module archiveName="gcube-widgets-2.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
|
||||||
<dependency-type>uses</dependency-type>
|
<dependency-type>uses</dependency-type>
|
||||||
</dependent-module>
|
</dependent-module>
|
||||||
<dependent-module archiveName="social-util-library-1.6.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/social-util-library/social-util-library">
|
|
||||||
<dependency-type>uses</dependency-type>
|
|
||||||
</dependent-module>
|
|
||||||
<dependent-module archiveName="pickitem-widget-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/pickitem-widget/pickitem-widget">
|
<dependent-module archiveName="pickitem-widget-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/pickitem-widget/pickitem-widget">
|
||||||
<dependency-type>uses</dependency-type>
|
<dependency-type>uses</dependency-type>
|
||||||
</dependent-module>
|
</dependent-module>
|
||||||
|
|
|
@ -1,23 +1,32 @@
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
<Changeset component="org.gcube.portlets-user.news-feed.2-8-0"
|
<Changeset
|
||||||
date="2019-05-22">
|
component="org.gcube.portlets-user.news-feed.2-8-1" date="2019-07-17">
|
||||||
<Change>Bug #16724, Social networking: "See more" seems to reload a post with part of the old look and feel</Change>
|
<Change>Fixed Bug #17181, post editing leads to losing both formatting and mentions</Change>
|
||||||
<Change>Bug #16673, News Feed: comments with links between parenthesis not recognised</Change>
|
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.news-feed.2-7-2"
|
<Changeset
|
||||||
date="2019-01-25">
|
component="org.gcube.portlets-user.news-feed.2-8-0" date="2019-05-22">
|
||||||
<Change>Feature #16205: News Feed avoid refresh page when user is commenting</Change>
|
<Change>Fixed Bug #16724, Social networking: "See more" seems to reload a
|
||||||
|
post with part of the old look and feel</Change>
|
||||||
|
<Change>Fixed Bug #16673, News Feed: comments with links between parenthesis
|
||||||
|
not recognised</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.news-feed.2-7-2" date="2019-01-25">
|
||||||
|
<Change>Feature #16205: News Feed avoid refresh page when user is
|
||||||
|
commenting</Change>
|
||||||
<Change>Minor CSS fix for anchors links font size</Change>
|
<Change>Minor CSS fix for anchors links font size</Change>
|
||||||
<Change>Bug fix #16225 mentions and replies http links not working in some email notifications</Change>
|
<Change>Bug fix #16225 mentions and replies http links not working in
|
||||||
|
some email notifications</Change>
|
||||||
<Change>Feature #16452, Revise posts look and feel</Change>
|
<Change>Feature #16452, Revise posts look and feel</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.news-feed.2-6-1"
|
<Changeset
|
||||||
date="2018-04-12">
|
component="org.gcube.portlets-user.news-feed.2-6-1" date="2018-04-12">
|
||||||
<Change>Removed previous jquery js load script and useless deprecated
|
<Change>Removed previous jquery js load script and useless deprecated
|
||||||
pagebus</Change>
|
pagebus
|
||||||
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.news-feed.2-6-0"
|
<Changeset
|
||||||
date="2018-03-07">
|
component="org.gcube.portlets-user.news-feed.2-6-0" date="2018-03-07">
|
||||||
<Change>Ported to GWT 2.8.2</Change>
|
<Change>Ported to GWT 2.8.2</Change>
|
||||||
<Change>Fix for Incident #11187 citing a people (with '@') in comments
|
<Change>Fix for Incident #11187 citing a people (with '@') in comments
|
||||||
is not working anymore
|
is not working anymore
|
||||||
|
@ -29,13 +38,15 @@
|
||||||
<Change>Feature #10192 allow to sort feeds per recent comments
|
<Change>Feature #10192 allow to sort feeds per recent comments
|
||||||
</Change>
|
</Change>
|
||||||
<Change>Bug #7841 lack of blank space to separate the query term when
|
<Change>Bug #7841 lack of blank space to separate the query term when
|
||||||
hashtag is used</Change>
|
hashtag is used
|
||||||
|
</Change>
|
||||||
<Change>Support for ticket #11139</Change>
|
<Change>Support for ticket #11139</Change>
|
||||||
<Change>Enhanced efficiency when retrieving mentioned users or groups
|
<Change>Enhanced efficiency when retrieving mentioned users or groups
|
||||||
in comments</Change>
|
in comments
|
||||||
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.news-feed.2-5-0"
|
<Changeset
|
||||||
date="2017-11-13">
|
component="org.gcube.portlets-user.news-feed.2-5-0" date="2017-11-13">
|
||||||
<Change>fixes for Incident #10262: Cannot see who liked posts on VREs
|
<Change>fixes for Incident #10262: Cannot see who liked posts on VREs
|
||||||
of Parthenos
|
of Parthenos
|
||||||
</Change>
|
</Change>
|
||||||
|
@ -44,8 +55,8 @@
|
||||||
</Change>
|
</Change>
|
||||||
<Change>Ported to GWT 2.8.1</Change>
|
<Change>Ported to GWT 2.8.1</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.news-feed.2-3-0"
|
<Changeset
|
||||||
date="2017-02-20">
|
component="org.gcube.portlets-user.news-feed.2-3-0" date="2017-02-20">
|
||||||
<Change>fixes for changes to the underneath
|
<Change>fixes for changes to the underneath
|
||||||
common-notification-library
|
common-notification-library
|
||||||
</Change>
|
</Change>
|
||||||
|
@ -57,15 +68,15 @@
|
||||||
try to engage the user to post something.
|
try to engage the user to post something.
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.news-feed.2-2-0"
|
<Changeset
|
||||||
date="2016-12-02">
|
component="org.gcube.portlets-user.news-feed.2-2-0" date="2016-12-02">
|
||||||
<Change>removed asl session</Change>
|
<Change>removed asl session</Change>
|
||||||
<Change>Increased general performance and bugfixes</Change>
|
<Change>Increased general performance and bugfixes</Change>
|
||||||
<Change>fetching of users list to mention in comments loaded on demand
|
<Change>fetching of users list to mention in comments loaded on demand
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.news-feed.2-1-0"
|
<Changeset
|
||||||
date="2016-10-29">
|
component="org.gcube.portlets-user.news-feed.2-1-0" date="2016-10-29">
|
||||||
<Change>Support to show feeds related to user's statistics added
|
<Change>Support to show feeds related to user's statistics added
|
||||||
</Change>
|
</Change>
|
||||||
<Change>Fixed time for comments/posts: the year is present only if the
|
<Change>Fixed time for comments/posts: the year is present only if the
|
||||||
|
@ -73,34 +84,34 @@
|
||||||
was made before the current one
|
was made before the current one
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.news-feed.2-0-0"
|
<Changeset
|
||||||
date="2016-06-29">
|
component="org.gcube.portlets-user.news-feed.2-0-0" date="2016-06-29">
|
||||||
<Change>Updated for Liferay 6.2.5</Change>
|
<Change>Updated for Liferay 6.2.5</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.news-feed.1-13-1"
|
<Changeset
|
||||||
date="2016-02-29">
|
component="org.gcube.portlets-user.news-feed.1-13-1" date="2016-02-29">
|
||||||
<Change>Full-text search supported</Change>
|
<Change>Full-text search supported</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.news-feed.1-13-0"
|
<Changeset
|
||||||
date="2016-01-22">
|
component="org.gcube.portlets-user.news-feed.1-13-0" date="2016-01-22">
|
||||||
<Change>Multi-attachment supported</Change>
|
<Change>Multi-attachment supported</Change>
|
||||||
<Change>Image preview available</Change>
|
<Change>Image preview available</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.newsfeed.1-12-0"
|
<Changeset
|
||||||
date="2015-11-12">
|
component="org.gcube.portlets-user.newsfeed.1-12-0" date="2015-11-12">
|
||||||
<Change>Fix for Bug #246, editing changes comment "metadata" namely
|
<Change>Fix for Bug #246, editing changes comment "metadata" namely
|
||||||
data
|
data
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.newsfeed.1-11-0"
|
<Changeset
|
||||||
date="2015-10-12">
|
component="org.gcube.portlets-user.newsfeed.1-11-0" date="2015-10-12">
|
||||||
<Change>Integrated workspace explorer widget and replace light tree
|
<Change>Integrated workspace explorer widget and replace light tree
|
||||||
</Change>
|
</Change>
|
||||||
<Change>Fix for Bug #195, Post dates lack the year
|
<Change>Fix for Bug #195, Post dates lack the year
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.newsfeed.1-10-0"
|
<Changeset
|
||||||
date="2015-07-15">
|
component="org.gcube.portlets-user.newsfeed.1-10-0" date="2015-07-15">
|
||||||
<Change>Revised the way we shorten posts' text when this is very long,
|
<Change>Revised the way we shorten posts' text when this is very long,
|
||||||
better heuristic used
|
better heuristic used
|
||||||
</Change>
|
</Change>
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>news-feed</artifactId>
|
<artifactId>news-feed</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>2.8.0-SNAPSHOT</version>
|
<version>2.8.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>gCube News Feed Portlet</name>
|
<name>gCube News Feed Portlet</name>
|
||||||
<description>
|
<description>
|
||||||
|
|
|
@ -49,7 +49,7 @@ public interface NewsService extends RemoteService {
|
||||||
HashSet<MentionedDTO> mentionedUsers, String feedOwnerId,
|
HashSet<MentionedDTO> mentionedUsers, String feedOwnerId,
|
||||||
boolean isAppFeed);
|
boolean isAppFeed);
|
||||||
|
|
||||||
OperationResult editComment(Comment toEdit);
|
OperationResult editComment(String text, Comment toEdit, HashSet<MentionedDTO> mentionedUsers);
|
||||||
|
|
||||||
ArrayList<Like> getAllLikesByPost(String postid);
|
ArrayList<Like> getAllLikesByPost(String postid);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public interface NewsServiceAsync {
|
||||||
|
|
||||||
void deletePost(String feedid, AsyncCallback<Boolean> callback);
|
void deletePost(String feedid, AsyncCallback<Boolean> callback);
|
||||||
|
|
||||||
void editComment(Comment toEdit, 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<EnhancedFeed>> callback);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package org.gcube.portlets.user.newsfeed.client.event;
|
package org.gcube.portlets.user.newsfeed.client.event;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
import org.gcube.portal.databook.shared.Comment;
|
import org.gcube.portal.databook.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 com.google.gwt.event.shared.GwtEvent;
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||||
|
@ -13,7 +16,9 @@ public class EditCommentEvent extends GwtEvent<EditCommentEventHandler> {
|
||||||
|
|
||||||
private TweetTemplate owner;
|
private TweetTemplate owner;
|
||||||
private Comment edited;
|
private Comment edited;
|
||||||
|
private String text;
|
||||||
private HTMLPanel commentPanel;
|
private HTMLPanel commentPanel;
|
||||||
|
private HashSet<MentionedDTO> mentionedUsers;
|
||||||
|
|
||||||
public TweetTemplate getOwner() {
|
public TweetTemplate getOwner() {
|
||||||
return owner;
|
return owner;
|
||||||
|
@ -25,12 +30,21 @@ public class EditCommentEvent extends GwtEvent<EditCommentEventHandler> {
|
||||||
public HTMLPanel getCommentPanel() {
|
public HTMLPanel getCommentPanel() {
|
||||||
return commentPanel;
|
return commentPanel;
|
||||||
}
|
}
|
||||||
public EditCommentEvent(TweetTemplate owner, Comment editedComment, HTMLPanel commentPanel) {
|
public EditCommentEvent(TweetTemplate owner, String text, Comment editedComment, HTMLPanel commentPanel, HashSet<MentionedDTO> mentionedUsers) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
|
this.text = text;
|
||||||
this.edited = editedComment;
|
this.edited = editedComment;
|
||||||
this.commentPanel = commentPanel;
|
this.commentPanel = commentPanel;
|
||||||
|
this.mentionedUsers = mentionedUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashSet<MentionedDTO> getMentionedUsers() {
|
||||||
|
return mentionedUsers;
|
||||||
|
}
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type<EditCommentEventHandler> getAssociatedType() {
|
public Type<EditCommentEventHandler> getAssociatedType() {
|
||||||
return TYPE;
|
return TYPE;
|
||||||
|
|
|
@ -203,7 +203,7 @@ public class NewsFeedPanel extends Composite {
|
||||||
eventBus.addHandler(EditCommentEvent.TYPE, new EditCommentEventHandler() {
|
eventBus.addHandler(EditCommentEvent.TYPE, new EditCommentEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onEditComment(EditCommentEvent event) {
|
public void onEditComment(EditCommentEvent event) {
|
||||||
doEditComment(event.getOwner(), event.getCommentInstance(), event.getCommentPanel());
|
doEditComment(event.getOwner(), event.getText(), event.getCommentInstance(), event.getCommentPanel(), event.getMentionedUsers());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1361,15 +1361,6 @@ public class NewsFeedPanel extends Composite {
|
||||||
owner.setCommentingDisabled(false);
|
owner.setCommentingDisabled(false);
|
||||||
owner.updateCommentsNumberCount();
|
owner.updateCommentsNumberCount();
|
||||||
owner.showAddCommentForm(false);
|
owner.showAddCommentForm(false);
|
||||||
|
|
||||||
// if(owner.isUser()){
|
|
||||||
// // alert the User statistics portlet to increment the number of comments got
|
|
||||||
// try {
|
|
||||||
// NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.commentsIncrement, "", Defaults.STRING_JSONIZER);
|
|
||||||
// } catch (PageBusAdapterException e) {
|
|
||||||
// GWT.log(e.toString());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1379,8 +1370,8 @@ public class NewsFeedPanel extends Composite {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doEditComment(final TweetTemplate owner, Comment edited, final HTMLPanel commentPanel) {
|
private void doEditComment(final TweetTemplate owner, String text, Comment edited, final HTMLPanel commentPanel, HashSet<MentionedDTO> mentionedUsers) {
|
||||||
newsService.editComment(edited, new AsyncCallback<OperationResult>() {
|
newsService.editComment(text, edited, mentionedUsers, new AsyncCallback<OperationResult>() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
Window.alert("Could not edit this comment: " + caught.getMessage());
|
Window.alert("Could not edit this comment: " + caught.getMessage());
|
||||||
|
@ -1390,7 +1381,7 @@ public class NewsFeedPanel extends Composite {
|
||||||
public void onSuccess(OperationResult result) {
|
public void onSuccess(OperationResult result) {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
if (!result.isSuccess()) {
|
if (!result.isSuccess()) {
|
||||||
//CheckSession.showLogoutDialog();
|
Window.alert("Could not deliver this comment. Please try again in a short while.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Comment comment = (Comment) result.getComment();
|
Comment comment = (Comment) result.getComment();
|
||||||
|
|
|
@ -83,16 +83,17 @@ public class AddCommentTemplate extends Composite {
|
||||||
isEditing = true;
|
isEditing = true;
|
||||||
this.toEdit = toEdit;
|
this.toEdit = toEdit;
|
||||||
|
|
||||||
String commentText = new HTML(toEdit.getText()).getText();
|
String commentText = toEdit.getText().replaceAll("<br/>", "\n");
|
||||||
//replace the < & and >
|
commentText = commentText.replaceAll(" ", " ");
|
||||||
commentText = commentText.replaceAll("<","<").replaceAll(">",">");
|
commentText = new HTML(commentText).getText();
|
||||||
commentText = commentText.replaceAll("&","&");
|
|
||||||
|
|
||||||
owner = caller;
|
owner = caller;
|
||||||
commentTextArea.setContext(owner.getVREContext());
|
commentTextArea.setContext(owner.getVREContext());
|
||||||
avatarImage.setPixelSize(30, 30);
|
avatarImage.setPixelSize(30, 30);
|
||||||
avatarImage.setUrl(caller.getMyUserInfo().getAvatarId());
|
avatarImage.setUrl(caller.getMyUserInfo().getAvatarId());
|
||||||
commentTextArea.setText(commentText);
|
commentTextArea.setText(commentText);
|
||||||
|
|
||||||
|
|
||||||
mainPanel.removeStyleName("comment-hidden");
|
mainPanel.removeStyleName("comment-hidden");
|
||||||
mainPanel.setStyleName("single-comment");
|
mainPanel.setStyleName("single-comment");
|
||||||
commentTextArea.addStyleName("comment-dark-color");
|
commentTextArea.addStyleName("comment-dark-color");
|
||||||
|
@ -106,10 +107,10 @@ public class AddCommentTemplate extends Composite {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
handlerRegistration = Window.addWindowClosingHandler(closingHandler);
|
handlerRegistration = Window.addWindowClosingHandler(closingHandler);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Used by AddCommentTemplate to instantiate SuperPosedTextArea */
|
/** Used by AddCommentTemplate to instantiate SuperPosedTextArea */
|
||||||
@UiFactory SuperPosedTextArea build() {
|
@UiFactory SuperPosedTextArea build() {
|
||||||
|
@ -151,7 +152,7 @@ public class AddCommentTemplate extends Composite {
|
||||||
}
|
}
|
||||||
if (isEditing) {
|
if (isEditing) {
|
||||||
toEdit.setText(escapeHtml(commentTextArea.getText()));
|
toEdit.setText(escapeHtml(commentTextArea.getText()));
|
||||||
eventBus.fireEvent(new EditCommentEvent(owner, toEdit, commentPanel));
|
eventBus.fireEvent(new EditCommentEvent(owner, escapeHtml(commentTextArea.getText()), toEdit, commentPanel, commentTextArea.getMentionedUsers()));
|
||||||
}
|
}
|
||||||
else { //it is ok to add this comment
|
else { //it is ok to add this comment
|
||||||
eventBus.fireEvent(new AddCommentEvent(owner, escapeHtml(commentTextArea.getText()), commentTextArea.getMentionedUsers()));
|
eventBus.fireEvent(new AddCommentEvent(owner, escapeHtml(commentTextArea.getText()), commentTextArea.getMentionedUsers()));
|
||||||
|
@ -159,6 +160,7 @@ public class AddCommentTemplate extends Composite {
|
||||||
this.getWidget().setVisible(false);
|
this.getWidget().setVisible(false);
|
||||||
owner.setCommentingDisabled(false);
|
owner.setCommentingDisabled(false);
|
||||||
handlerRegistration.removeHandler();
|
handlerRegistration.removeHandler();
|
||||||
|
|
||||||
GWT.log(" handlerRegistration.removeHandler();");
|
GWT.log(" handlerRegistration.removeHandler();");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<div id="comment-supercontainer">
|
<div id="comment-supercontainer" style="background-color: #FFF;">
|
||||||
<div id="comment-highlighterContainer">
|
<div id="comment-highlighterContainer">
|
||||||
<w:Div styleName="comment-highlighter" ui:field="highlighterDIV"></w:Div>
|
<w:Div styleName="comment-highlighter" ui:field="highlighterDIV"></w:Div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -735,9 +735,11 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OperationResult editComment(Comment toEdit) {
|
public OperationResult editComment(String text, Comment toEdit, HashSet<MentionedDTO> mentionedItemsSet) {
|
||||||
Comment edited = null;
|
Comment edited = null;
|
||||||
|
boolean commentCommitResult = false;
|
||||||
try {
|
try {
|
||||||
|
_log.debug("in edit Comment ... ");
|
||||||
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);
|
||||||
|
@ -748,6 +750,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
// get old hashtags and delete them
|
// get old hashtags and delete them
|
||||||
String oldText = store.readCommentById(toEdit.getKey()).getText();
|
String oldText = store.readCommentById(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);
|
||||||
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());
|
||||||
|
@ -755,19 +758,94 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
_log.debug("deletedHashtag? " + deletedHashtag);
|
_log.debug("deletedHashtag? " + deletedHashtag);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get new hashtags
|
ArrayList<ItemBean> mentionedUsers = new ArrayList<>();
|
||||||
String escapedCommentText = Utils.escapeHtmlAndTransformUrl(toEdit.getText());
|
if (mentionedItemsSet != null && mentionedItemsSet.size() > 0) {
|
||||||
List<String> newHashtags = Utils.getHashTags(escapedCommentText);
|
//copy the set into a list
|
||||||
|
ArrayList<MentionedDTO> mentionedItems = new ArrayList<MentionedDTO>();
|
||||||
|
mentionedItems.addAll(mentionedItemsSet);
|
||||||
|
if (mentionedItemsSet != null && ! mentionedItemsSet.isEmpty()) {
|
||||||
|
mentionedUsers = getMentionsBean(mentionedItems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SocialMessageParser messageParser = new SocialMessageParser(text);
|
||||||
|
String siteLandingPagePath = PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest());
|
||||||
|
String escapedCommentText = messageParser.getParsedMessage(mentionedUsers, siteLandingPagePath);
|
||||||
|
List<String> newHashtags = messageParser.getHashtags();
|
||||||
|
|
||||||
if (newHashtags != null && !newHashtags.isEmpty())
|
if (newHashtags != null && !newHashtags.isEmpty())
|
||||||
escapedCommentText = Utils.convertHashtagsAnchorHTML(escapedCommentText, newHashtags);
|
store.saveHashTagsComment(toEdit.getKey(), vreIdFeed, newHashtags);
|
||||||
|
|
||||||
|
// // get new hashtags
|
||||||
|
// String escapedCommentText = Utils.escapeHtmlAndTransformUrl(toEdit.getText());
|
||||||
|
// List<String> newHashtags = Utils.getHashTags(escapedCommentText);
|
||||||
|
// if (newHashtags != null && !newHashtags.isEmpty())
|
||||||
|
// escapedCommentText = Utils.convertHashtagsAnchorHTML(escapedCommentText, 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.getFeedid(), escapedCommentText, user.getFullName(), user.getAvatarId(), true, new Date());
|
||||||
|
|
||||||
store.editComment(edited);
|
commentCommitResult = store.editComment(edited);
|
||||||
|
|
||||||
if (newHashtags != null && !newHashtags.isEmpty())
|
if (commentCommitResult) {
|
||||||
store.saveHashTagsComment(edited.getKey(), vreIdFeed, newHashtags);
|
PortalContext pContext = PortalContext.getConfiguration();
|
||||||
|
String currScope = pContext.getCurrentScope(getThreadLocalRequest());
|
||||||
|
NotificationsManager nm = new ApplicationNotificationsManager(
|
||||||
|
new SocialNetworkingSite(getThreadLocalRequest()),
|
||||||
|
currScope,
|
||||||
|
new SocialNetworkingUser(user.getUsername(), user.getEmailaddress(), user.getFullName(), user.getAvatarId()),
|
||||||
|
APP_ID);
|
||||||
|
|
||||||
|
|
||||||
|
//send the notification to the mentioned users, if any
|
||||||
|
if (mentionedUsers != null && mentionedUsers.size() > 0) {
|
||||||
|
ArrayList<GenericItemBean> toPass = new ArrayList<GenericItemBean>();
|
||||||
|
|
||||||
|
// among the mentionedUsers there could be groups of people
|
||||||
|
Map<String, ItemBean> uniqueUsersToNotify = new HashMap<>();
|
||||||
|
UserManager um = new LiferayUserManager();
|
||||||
|
for (ItemBean bean : mentionedUsers) {
|
||||||
|
if(bean.isItemGroup()){
|
||||||
|
// retrieve the users of this group
|
||||||
|
try {
|
||||||
|
List<GCubeUser> teamUsers = um.listUsersByTeam(Long.parseLong(bean.getId()));
|
||||||
|
|
||||||
|
for (GCubeUser userTeam : teamUsers) {
|
||||||
|
if(!uniqueUsersToNotify.containsKey(userTeam.getUsername()))
|
||||||
|
uniqueUsersToNotify.put(userTeam.getUsername(), new ItemBean(userTeam.getUserId()+"",
|
||||||
|
userTeam.getUsername(), userTeam.getFullname(), userTeam.getUserAvatarURL()));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (NumberFormatException
|
||||||
|
| UserManagementSystemException
|
||||||
|
| TeamRetrievalFault | UserRetrievalFault e) {
|
||||||
|
_log.error("Unable to retrieve team information", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
// it is a user, just add to the hashmap
|
||||||
|
if(!uniqueUsersToNotify.containsKey(bean.getName()))
|
||||||
|
uniqueUsersToNotify.put(bean.getName(), bean);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// iterate over the hashmap
|
||||||
|
Iterator<Entry<String, ItemBean>> userMapIterator = uniqueUsersToNotify.entrySet().iterator();
|
||||||
|
while (userMapIterator.hasNext()) {
|
||||||
|
Map.Entry<String, ItemBean> userEntry = (Map.Entry<String, ItemBean>) userMapIterator
|
||||||
|
.next();
|
||||||
|
ItemBean userBean = userEntry.getValue();
|
||||||
|
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.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return new OperationResult(false, "Exception on the server, could not deliver the edited comment to storage", null);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return new OperationResult(false, "Exception on the server: " + e.getMessage(), null);
|
return new OperationResult(false, "Exception on the server: " + e.getMessage(), null);
|
||||||
|
|
Loading…
Reference in New Issue