Bug #16673, News Feed: comments with links between parenthesis not recognised and Bug #16724

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@179511 82a268e6-3cf1-43bd-a215-b396298e98cf
Feature/26194
Massimiliano Assante 5 years ago
parent b643cbd792
commit e2e3549ddc

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/news-feed-2.7.2-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/news-feed-2.8.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/news-feed-2.7.2-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/news-feed-2.8.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -15,11 +15,13 @@
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
@ -39,5 +41,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/news-feed-2.7.2-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/news-feed-2.8.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

@ -40,6 +40,16 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.gwtplugins.gdt.eclipse.core.webAppProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.gwtplugins.gwt.eclipse.core.gwtProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
@ -56,5 +66,6 @@
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
<nature>com.liferay.ide.core.liferayNature</nature>
<nature>com.gwtplugins.gwt.eclipse.core.gwtNature</nature>
</natures>
</projectDescription>

@ -0,0 +1,4 @@
eclipse.preferences.version=1
lastWarOutDir=/Users/massi/Documents/workspace/news-feed/target/news-feed-2.8.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

@ -9,4 +9,5 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="news-feed-portlet">
<wb-module deploy-name="news-feed">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>

@ -6,4 +6,5 @@
<installed facet="jst.jaxrs" version="2.0"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="java" version="1.8"/>
<installed facet="com.gwtplugins.gwt.facet" version="1.0"/>
</faceted-project>

@ -1,4 +1,9 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-user.news-feed.2-8-0"
date="2019-05-22">
<Change>Bug #16724, Social networking: "See more" seems to reload a post with part of the old look and feel</Change>
<Change>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>

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>news-feed</artifactId>
<packaging>war</packaging>
<version>2.7.2-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
<name>gCube News Feed Portlet</name>
<description>
@ -255,7 +255,6 @@
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.2</version>
<scope>provided</scope>
</dependency>
<dependency>

@ -144,10 +144,6 @@ public class AddCommentTemplate extends Composite {
@UiHandler("submitButton")
void onSubmitClick(ClickEvent e) {
String userComment = commentTextArea.getText().trim();
if (! checkTextLength(userComment)) {
Window.alert("We found a single word containing more than 50 chars and it's not a link, is it meaningful?");
return;
}
if (userComment.equals(COMMENT_TEXT) || userComment.equals(ERROR_UPDATE_TEXT) || userComment.equals("")) {
commentTextArea.addStyleName("nwfeed-error");
commentTextArea.setText(ERROR_UPDATE_TEXT);

@ -64,7 +64,7 @@ public class TweetTemplate extends Composite {
public static final String loading = GWT.getModuleBaseURL() + "../images/loading-comments.gif";
private static final int MAX_SHOWTEXT_LENGTH = 512;
private static final int MAX_SHOWTEXT_LENGTH = 612;
private EnhancedFeed myPost;
private UserInfo myUserInfo;
@ -148,7 +148,7 @@ public class TweetTemplate extends Composite {
this.separator.setVisible(false);
this.myPost = myPost;
isAppPost = myPost.getFeed().isApplicationFeed();
Feed feed = myPost.getFeed();
Feed post = myPost.getFeed();
this.eventBus = eventBus;
this.isUsers = myPost.isUsers();
this.carousel = new Carousel();
@ -162,24 +162,24 @@ public class TweetTemplate extends Composite {
}
// if there is one attachment or a link preview, maintain backward compatibility
if (feed.getUri() != null && feed.getUri().compareTo("") != 0 && feed.getLinkTitle() != null && feed.getLinkTitle().compareTo("") != 0 && !feed.isMultiFileUpload()) {
if (post.getUri() != null && post.getUri().compareTo("") != 0 && post.getLinkTitle() != null && post.getLinkTitle().compareTo("") != 0 && !post.isMultiFileUpload()) {
// hide the attachments panel
attachmentPreviewPanel.setVisible(false);
LinkPreviewer linkPreviewer = new LinkPreviewer(feed.getLinkTitle(), feed.getLinkDescription(), feed.getLinkHost(), feed.getUriThumbnail(), feed.getUri());
LinkPreviewer linkPreviewer = new LinkPreviewer(post.getLinkTitle(), post.getLinkDescription(), post.getLinkHost(), post.getUriThumbnail(), post.getUri());
// enable the image previewer if it is an image (mime)
if(feed.getLinkHost().contains("image/")){
if(post.getLinkHost().contains("image/")){
ArrayList<EnhancedImage> listOfEnhancedImages;
EnhancedImage enhancedImage = new EnhancedImage(
feed.getUri(),
feed.getLinkTitle() +
" (" + feed.getLinkDescription() + ", type:" + feed.getLinkHost() +")",
feed.getLinkTitle(),
feed.getUri()
post.getUri(),
post.getLinkTitle() +
" (" + post.getLinkDescription() + ", type:" + post.getLinkHost() +")",
post.getLinkTitle(),
post.getUri()
);
listOfEnhancedImages = new ArrayList<EnhancedImage>();
@ -200,7 +200,7 @@ public class TweetTemplate extends Composite {
}
// in case there are attachments, we have to fill attachmentPreviewPanel instead of the previewPanel
if(feed.isMultiFileUpload()){
if(post.isMultiFileUpload()){
// set style to the attachment container
attachmentPreviewPanel.setStyleName("attachment-preview-container");
@ -213,12 +213,12 @@ public class TweetTemplate extends Composite {
// remember that one attachment is stored in the fields: uri, uriThumbnail, linkTitle, linkDescription, linkHost
Attachment firstAttachment = new Attachment(
feed.getKey(), // it is meaningless but it's needed
feed.getUri(),
feed.getLinkTitle(),
feed.getLinkDescription(),
feed.getUriThumbnail(),
feed.getLinkHost());
post.getKey(), // it is meaningless but it's needed
post.getUri(),
post.getLinkTitle(),
post.getLinkDescription(),
post.getUriThumbnail(),
post.getLinkHost());
// create first attachment previewer and pass it the carousel
AttachmentPreviewer firstAttachmentPreviewer = new AttachmentPreviewer(firstAttachment);
@ -230,11 +230,11 @@ public class TweetTemplate extends Composite {
if(firstAttachment.getMimeType().contains("image/")){
EnhancedImage enhancedImage = new EnhancedImage(
feed.getUri(),
feed.getLinkTitle() +
" (" + feed.getLinkDescription() + ", type:" + feed.getLinkHost() +")",
feed.getLinkTitle(),
feed.getUri()
post.getUri(),
post.getLinkTitle() +
" (" + post.getLinkDescription() + ", type:" + post.getLinkHost() +")",
post.getLinkTitle(),
post.getUri()
);
listOfEnhancedImages.add(enhancedImage);
@ -258,7 +258,7 @@ public class TweetTemplate extends Composite {
EnhancedImage enhancedImage = new EnhancedImage(
otherAttachment.getUri(),
otherAttachment.getName() +
" (" + otherAttachment.getDescription() + ", type:" + feed.getLinkHost() +")",
" (" + otherAttachment.getDescription() + ", type:" + post.getLinkHost() +")",
otherAttachment.getName(),
otherAttachment.getUri()
);
@ -296,30 +296,30 @@ public class TweetTemplate extends Composite {
commentArea.setHTML("<a>" + NewsFeedPanel.COMMENT_LABEL + "</a>");
String feedText = feed.getDescription();
String descWithoutHTML = new HTML(feedText).getText();
String postText = post.getDescription();
String descWithoutHTML = new HTML(postText).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) + "...";
if ( (! postText.startsWith("<span")) && descWithoutHTML.length() > MAX_SHOWTEXT_LENGTH && !displaySingle) {
final int TEXT_TO_SHOW_LENGHT = (descWithoutHTML.length() < 600) ? (postText.length() - (postText.length() / 3)) : 600;
postText = postText.substring(0, TEXT_TO_SHOW_LENGHT) + "...";
seeMore.setHTML("<a class=\"seemore\"> See More </a>");
}
avatarImage.setUrl(feed.getThumbnailURL());
avatarImage.setUrl(post.getThumbnailURL());
avatarImage.setPixelSize(40, 40);
//replace the < & and >
feedText = feedText.replaceAll("&lt;","<").replaceAll("&gt;",">");
feedText = feedText.replaceAll("&amp;","&");
postText = postText.replaceAll("&lt;","<").replaceAll("&gt;",">");
postText = postText.replaceAll("&amp;","&");
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + NewsFeedPanel.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
if (showTimelineSource && feed.getVreid() != null && feed.getVreid().compareTo("") != 0) {
if (showTimelineSource && post.getVreid() != null && post.getVreid().compareTo("") != 0) {
this.vreSourceInMetadata.setVisible(true);
this.separator.setVisible(true);
String vreName = feed.getVreid().substring(feed.getVreid().lastIndexOf("/")+1);
String vreName = post.getVreid().substring(post.getVreid().lastIndexOf("/")+1);
vreSourceInMetadata.setText(vreName);
vreSourceInMetadata.addClickHandler(new ClickHandler() {
@Override
@ -334,32 +334,32 @@ public class TweetTemplate extends Composite {
postOwnerArea.setHTML("<a class=\"linkProfile\" href=\""+profilePageURL
+"?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(feed.getEntityId())+"\">"+feed.getFullName()+"</a>");
contentArea.setHTML(feedText);
Encoder.encode(post.getEntityId())+"\">"+post.getFullName()+"</a>");
contentArea.setHTML(postText);
//check if the user has his own avatar
if (feed.getThumbnailURL().contains("img_id=0") || !feed.getThumbnailURL().contains("?")) { //it means no avatar is set
if (post.getThumbnailURL().contains("img_id=0") || !post.getThumbnailURL().contains("?")) { //it means no avatar is set
avatarImage.setVisible(false);
String f = "A";
String s = "Z";
if (feed.getFullName() != null) {
String[] parts = feed.getFullName().split("\\s");
if (post.getFullName() != null) {
String[] parts = post.getFullName().split("\\s");
if (parts.length > 0) {
f = parts[0].toUpperCase();
s = parts[parts.length-1].toUpperCase();
} else {
f = feed.getFullName().substring(0,1);
s = feed.getFullName().substring(1,2);
f = post.getFullName().substring(0,1);
s = post.getFullName().substring(1,2);
}
}
avatarReplacement.setInitials(feed.getEntityId(), f, s);
avatarReplacement.setInitials(post.getEntityId(), f, s);
avatarReplacement.setVisible(true);
}
}
else {
// messageSeparator.setVisible(false);
postOwnerArea.setHTML("<a class=\"linkProfile\" href=\""+feed.getUri()+"\">"+feed.getFullName()+"</a>");
contentArea.setHTML(feedText);
postOwnerArea.setHTML("<a class=\"linkProfile\" href=\""+post.getUri()+"\">"+post.getFullName()+"</a>");
contentArea.setHTML(postText);
if (isAppPost) {
if (myUserInfo.isAdmin())
@ -374,25 +374,25 @@ public class TweetTemplate extends Composite {
Date now = new Date();
String formattedTime;
// TODO java.util.Calendar is not yet available in GWT
if(now.getYear() != feed.getTime().getYear())
formattedTime = DateTimeFormat.getFormat("MMMM dd yyyy, h:mm a").format(feed.getTime());
if(now.getYear() != post.getTime().getYear())
formattedTime = DateTimeFormat.getFormat("MMMM dd yyyy, h:mm a").format(post.getTime());
else
formattedTime = DateTimeFormat.getFormat("MMMM dd, h:mm a").format(feed.getTime());
formattedTime = DateTimeFormat.getFormat("MMMM dd, h:mm a").format(post.getTime());
timeArea.setText(formattedTime);
String formattedTimeWithYear = DateTimeFormat.getFormat("dd MMMM yyyy h:mm a ").format(feed.getTime());
String formattedTimeWithYear = DateTimeFormat.getFormat("dd MMMM yyyy h:mm a ").format(post.getTime());
timeArea.setTitle(formattedTimeWithYear);
if (! feed.getCommentsNo().equals("0")) {
if (! post.getCommentsNo().equals("0")) {
commentsNo.setVisible(true);
commentsNo.setText(feed.getCommentsNo());
commentsNo.setTitle(feed.getCommentsNo() + " people commented this.");
commentsNo.setText(post.getCommentsNo());
commentsNo.setTitle(post.getCommentsNo() + " people commented this.");
}
if (! feed.getLikesNo().equals("0")) {
if (! post.getLikesNo().equals("0")) {
likesNo.setVisible(true);
likesNo.setText(feed.getLikesNo());
likesNo.setText(post.getLikesNo());
likesNo.setTitle("Show People who have " + NewsFeedPanel.LIKED_LABEL + " this.");
}
totalComments = Integer.parseInt(feed.getCommentsNo());
totalComments = Integer.parseInt(post.getCommentsNo());
}
catch (NumberFormatException e) {
totalComments = 0;
@ -462,19 +462,12 @@ public class TweetTemplate extends Composite {
@UiHandler("seeMore")
void onSeeMoreClick(ClickEvent e) {
String feedText = myPost.getFeed().getDescription();
String postText = myPost.getFeed().getDescription();
//replace the < & and >
feedText = feedText.replaceAll("&lt;","<").replaceAll("&gt;",">");
feedText = feedText.replaceAll("&amp;","&");
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + NewsFeedPanel.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
contentArea.setHTML("<a class=\"link\"href=\"" + profilePageURL + "?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(myPost.getFeed().getEntityId())+"\">"+
myPost.getFeed().getFullName()+"</a> " + feedText);
postText = postText.replaceAll("&lt;","<").replaceAll("&gt;",">");
postText = postText.replaceAll("&amp;","&");
contentArea.setHTML(postText);
seeMore.setHTML("");
}

@ -55,6 +55,7 @@ import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import org.gcube.social_networking.socialutillibrary.Utils;
import org.gcube.socialnetworking.social_data_search_client.ElasticSearchClient;
import org.gcube.socialnetworking.social_data_search_client.ElasticSearchClientImpl;
import org.gcube.socialnetworking.socialtoken.SocialMessageParser;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.RoleManager;
import org.gcube.vomanagement.usermanagement.UserManager;
@ -390,7 +391,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
List<EnhancedFeed> enhancedFeeds = escl.search(query, vres, from, quantity);
// retrieve the ids of liked posts by the user
List<String> likedFeeds = store.getAllLikedFeedIdsByUser(userName);
List<String> likedPosts = store.getAllLikedFeedIdsByUser(userName);
// update fields "liked" and "isuser"
for (EnhancedFeed enhancedFeed : enhancedFeeds) {
@ -398,7 +399,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
if(isUsers(enhancedFeed.getFeed(), userName))
enhancedFeed.setUsers(true);
if(likedFeeds.contains(enhancedFeed.getFeed().getKey()))
if(likedPosts.contains(enhancedFeed.getFeed().getKey()))
enhancedFeed.setLiked(true);
}
@ -575,7 +576,12 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
currScope,
new SocialNetworkingUser(username, user.getEmailaddress(), user.getFullName(), user.getAvatarId()),
APP_ID);
boolean nResult = nm.notifyLikedPost(postOwnerId, postid, Utils.escapeHtml(postText));
ArrayList<ItemBean> mentionedUsers = new ArrayList<>();
SocialMessageParser messageParser = new SocialMessageParser(postText);
String siteLandingPagePath = PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest());
String escapedPostText = messageParser.getParsedMessage(mentionedUsers, siteLandingPagePath);
boolean nResult = nm.notifyLikedPost(postOwnerId, postid, escapedPostText);
_log.trace("Like Notification added? " + nResult);
}
}
@ -615,22 +621,20 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
return new OperationResult(false, "Session Expired", null);
}
String escapedCommentText = Utils.escapeHtmlAndTransformUrl(commentText);
// get hashtags
List<String> hashtags = Utils.getHashTags(escapedCommentText);
if (hashtags != null && !hashtags.isEmpty())
escapedCommentText = Utils.convertHashtagsAnchorHTML(escapedCommentText, hashtags);
//copy the set into a list
ArrayList<MentionedDTO> mentionedItems = new ArrayList<MentionedDTO>();
mentionedItems.addAll(mentionedItemsSet);
ArrayList<ItemBean> mentionedUsers = new ArrayList<>();
if (mentionedItemsSet != null && mentionedItemsSet.size() > 0) {
//copy the set into a list
ArrayList<MentionedDTO> mentionedItems = new ArrayList<MentionedDTO>();
mentionedItems.addAll(mentionedItemsSet);
if (mentionedItemsSet != null && ! mentionedItemsSet.isEmpty()) {
mentionedUsers = getMentionsBean(mentionedItems);
}
}
ArrayList<ItemBean> mentionedUsers = null;
if (mentionedItemsSet != null && ! mentionedItemsSet.isEmpty()) {
mentionedUsers = getMentionsBean(mentionedItems);
escapedCommentText = Utils.convertMentionPeopleAnchorHTML(escapedCommentText, mentionedUsers, getThreadLocalRequest());
}
SocialMessageParser messageParser = new SocialMessageParser(commentText);
String siteLandingPagePath = PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest());
String escapedCommentText = messageParser.getParsedMessage(mentionedUsers, siteLandingPagePath);
List<String> hashtags = messageParser.getHashtags();
Comment comment = new Comment(UUID.randomUUID().toString(), user.getUsername(),
new Date(), feedid, escapedCommentText, user.getFullName(), user.getAvatarId());

@ -26,6 +26,7 @@ log4j.logger.org.apache.jasper.compiler.TldLocationsCache.level=ERROR, CA
#AVOID LOGGING EHCACHE Hearbeat problem
log4j.logger.net.sf.ehcache.distribution.PayloadUtil=OFF, CA
log4j.logger.org.eclipse.jetty=ERROR, CA
log4j.logger.org.gcube.portal.notifications=INFO, CA
log4j.logger.org.gcube.common.scope.impl=INFO, CA
log4j.logger.org.gcube.common.core.utils.events=INFO, CA
@ -38,3 +39,4 @@ log4j.logger.com.couchbase.client=ERROR, CA
log4j.logger.org.gcube.smartgears.handlers=INFO, CA
log4j.logger.org.gcube.informationsystem.publisher=INFO, CA
log4j.logger.org.gcube.application.framework.core.session=INFO, CA

Loading…
Cancel
Save