git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@179525 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
370b543326
commit
ed35f67885
|
@ -54,12 +54,18 @@ public class SocialMailingUtil {
|
||||||
List<Comment> comments,
|
List<Comment> comments,
|
||||||
String commentKey,
|
String commentKey,
|
||||||
String ... hashtags) {
|
String ... hashtags) {
|
||||||
|
|
||||||
String removedMarkup = notification2Save.getDescription().replaceAll("&", "&");
|
String removedMarkup = notification2Save.getDescription().replaceAll("&", "&");
|
||||||
removedMarkup = convertHTML2Text(removedMarkup);
|
|
||||||
removedMarkup = removedMarkup.replaceAll("(\r\n|\n)"," <br/> "); //preserve new lines
|
|
||||||
String sender = notification2Save.getSenderFullName();
|
|
||||||
|
|
||||||
|
//notification2Save uri contains the absoulte path to the feed in the correct channel, e.g. /group/ustore_vre?oid=f1637958-34d0-48fc-b5ad-13b1116e389d
|
||||||
|
String pathToVRE = siteLandingPagePath + "?";
|
||||||
|
if (notification2Save.getUri().split("\\?").length > 0) {
|
||||||
|
pathToVRE = notification2Save.getUri().split("\\?")[0];
|
||||||
|
}
|
||||||
|
_log.debug("editing hyperlinks for mail client");
|
||||||
|
removedMarkup = removedMarkup.replaceAll("href=\"/group/", "href=\""+portalURL + "/group/"); //because there is no indication of the portal (for mentions)
|
||||||
|
removedMarkup = removedMarkup.replace("href=\"?", "href=\""+portalURL + pathToVRE + "?"); //because there is no indication of the portal (for hashtags)
|
||||||
|
|
||||||
|
String sender = notification2Save.getSenderFullName();
|
||||||
String portalHost = portalURL.replaceAll("https://", "");
|
String portalHost = portalURL.replaceAll("https://", "");
|
||||||
portalHost = portalHost.replaceAll("http://", "");
|
portalHost = portalHost.replaceAll("http://", "");
|
||||||
|
|
||||||
|
@ -86,11 +92,9 @@ public class SocialMailingUtil {
|
||||||
|
|
||||||
body.append("<div style=\"color:#000; font-size:13px; font-family:'lucida grande',tahoma,verdana,arial,sans-serif;\">")
|
body.append("<div style=\"color:#000; font-size:13px; font-family:'lucida grande',tahoma,verdana,arial,sans-serif;\">")
|
||||||
.append("<p><a href=\"").append(userProfileLink).append("\">").append(sender).append("</a> ").append(removedMarkup) // has done something
|
.append("<p><a href=\"").append(userProfileLink).append("\">").append(sender).append("</a> ").append(removedMarkup) // has done something
|
||||||
.append("<p>")
|
|
||||||
.append(getActionLink(notification2Save, portalURL)) //Goto
|
.append(getActionLink(notification2Save, portalURL)) //Goto
|
||||||
.append("</p>")
|
|
||||||
.append(attachmentsNotice)
|
.append(attachmentsNotice)
|
||||||
.append(SocialMailingUtil.buildHtmlDiscussion(notification2Save, feed, comments, commentKey)) // the original discussion
|
.append(SocialMailingUtil.buildHtmlDiscussion(portalURL, pathToVRE, notification2Save, feed, comments, commentKey)) // the original discussion
|
||||||
.append("</p>")
|
.append("</p>")
|
||||||
.append("</div><br/>")
|
.append("</div><br/>")
|
||||||
.append("<p><div style=\"color:#999999; font-size:11px; font-family:'lucida grande',tahoma,verdana,arial,sans-serif;\">")
|
.append("<p><div style=\"color:#999999; font-size:11px; font-family:'lucida grande',tahoma,verdana,arial,sans-serif;\">")
|
||||||
|
@ -376,7 +380,7 @@ public class SocialMailingUtil {
|
||||||
if (node instanceof Element) {
|
if (node instanceof Element) {
|
||||||
Element element = (Element) node;
|
Element element = (Element) node;
|
||||||
if ("a".equals(element.tagName())) {
|
if ("a".equals(element.tagName())) {
|
||||||
buffer.append(" ");
|
buffer.append(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +397,7 @@ public class SocialMailingUtil {
|
||||||
Element element = (Element) node;
|
Element element = (Element) node;
|
||||||
String tagName = element.tagName();
|
String tagName = element.tagName();
|
||||||
if ("a".equals(element.tagName())) {
|
if ("a".equals(element.tagName())) {
|
||||||
buffer.append(" ");
|
buffer.append(" ");
|
||||||
}
|
}
|
||||||
if ("p".equals(tagName) || "br".equals(tagName)) {
|
if ("p".equals(tagName) || "br".equals(tagName)) {
|
||||||
buffer.append("\n");
|
buffer.append("\n");
|
||||||
|
@ -405,12 +409,12 @@ public class SocialMailingUtil {
|
||||||
/**
|
/**
|
||||||
* Build up a discussion given the feed and its comments.
|
* Build up a discussion given the feed and its comments.
|
||||||
* @param notification2Save
|
* @param notification2Save
|
||||||
* @param feed
|
* @param post
|
||||||
* @param comments
|
* @param comments
|
||||||
* @param commentKey if not null, when building the discussion stop at this comment.
|
* @param commentKey if not null, when building the discussion stop at this comment.
|
||||||
* @return an html string representing the discussion
|
* @return an html string representing the discussion
|
||||||
*/
|
*/
|
||||||
protected static String buildHtmlDiscussion(Notification notification2Save, Feed feed, List<Comment> comments, String commentKey){
|
protected static String buildHtmlDiscussion(String portalURL, String pathToVRE, Notification notification2Save, Feed post, List<Comment> comments, String commentKey){
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
|
||||||
|
@ -424,37 +428,40 @@ public class SocialMailingUtil {
|
||||||
Format formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm a");
|
Format formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm a");
|
||||||
|
|
||||||
// escape html
|
// escape html
|
||||||
String feedTextNoHtml = convertHTML2Text(feed.getDescription());
|
String postTextNoHtml = post.getDescription().replaceAll("&", "&");
|
||||||
feedTextNoHtml = feedTextNoHtml.replaceAll("(\r\n|\n)"," <br/> "); //preserve new lines
|
postTextNoHtml = postTextNoHtml.replaceAll("href=\"/group/", "href=\""+portalURL + "/group/"); //because there is no indication of the portal (for mentions)
|
||||||
|
postTextNoHtml = postTextNoHtml.replace("href=\"?", "href=\""+portalURL + pathToVRE + "?"); //because there is no indication of the portal (for hashtags)
|
||||||
|
|
||||||
|
|
||||||
// build up html post + comments
|
// build up html post + comments
|
||||||
if(notification2Save.getType() == NotificationType.POST_ALERT || (comments.size() == 0 && notification2Save.getType() == NotificationType.MENTION))
|
if(notification2Save.getType() == NotificationType.POST_ALERT || (comments.size() == 0 && notification2Save.getType() == NotificationType.MENTION))
|
||||||
htmlPost += "<div style=\"margin-top: 10px; margin-bottom: 10px;padding-left: 15px; "
|
htmlPost += "<div style=\"margin-top: 10px; margin-bottom: 10px;padding-left: 15px; "
|
||||||
+ "font-style: italic; font-weight:bold\">"
|
+ "font-style: italic; font-weight:bold\">"
|
||||||
+ feed.getFullName()
|
+ post.getFullName()
|
||||||
+ ": "
|
+ ": "
|
||||||
+ (feedTextNoHtml.length() > 100 ? feedTextNoHtml.substring(0, 100) + " ..." : feedTextNoHtml)
|
+ (postTextNoHtml.length() > 200 ? postTextNoHtml.substring(0, 200) + " ..." : postTextNoHtml)
|
||||||
+ "<p style=\"font-family:Lucida Grande,"
|
+ "<p style=\"font-family:Lucida Grande,"
|
||||||
+ "Verdana,Bitstream Vera Sans,Arial,sans-serif; "
|
+ "Verdana,Bitstream Vera Sans,Arial,sans-serif; "
|
||||||
+ "white-space: nowrap; font-size: smaller; color: #999;\">" + formatter.format(feed.getTime()) + "</p>"
|
+ "white-space: nowrap; font-size: smaller; color: #999;\">" + formatter.format(post.getTime()) + "</p>"
|
||||||
+"</div>";
|
+"</div>";
|
||||||
else
|
else
|
||||||
htmlPost += "<div style=\"margin-top: 10px; margin-bottom: 10px;padding-left: 15px; "
|
htmlPost += "<div style=\"margin-top: 10px; margin-bottom: 10px;padding-left: 15px; "
|
||||||
+ "font-style: italic\">"
|
+ "font-style: italic\">"
|
||||||
+ feed.getFullName()
|
+ post.getFullName()
|
||||||
+ ": "
|
+ ": "
|
||||||
+ (feedTextNoHtml.length() > 100 ? feedTextNoHtml.substring(0, 100) + " ..." : feedTextNoHtml)
|
+ (postTextNoHtml.length() > 200 ? postTextNoHtml.substring(0, 200) + " ..." : postTextNoHtml)
|
||||||
+ "<p style=\"font-family:Lucida Grande,"
|
+ "<p style=\"font-family:Lucida Grande,"
|
||||||
+ "Verdana,Bitstream Vera Sans,Arial,sans-serif; "
|
+ "Verdana,Bitstream Vera Sans,Arial,sans-serif; "
|
||||||
+ "white-space: nowrap; font-size: smaller; color: #999;\">" + formatter.format(feed.getTime()) + "</p>"
|
+ "white-space: nowrap; font-size: smaller; color: #999;\">" + formatter.format(post.getTime()) + "</p>"
|
||||||
+"</div>";
|
+"</div>";
|
||||||
|
|
||||||
if(comments != null)
|
if(comments != null)
|
||||||
for (int i = 0; i < comments.size(); i++) {
|
for (int i = 0; i < comments.size(); i++) {
|
||||||
|
|
||||||
String commentTextNoHtml = comments.get(i).getText().replaceAll("&", "&");
|
String commentTextNoHtml = comments.get(i).getText().replaceAll("&", "&");
|
||||||
commentTextNoHtml = convertHTML2Text(commentTextNoHtml);
|
commentTextNoHtml = commentTextNoHtml.replaceAll("href=\"/group/", "href=\""+portalURL + "/group/"); //because there is no indication of the portal (for mentions)
|
||||||
commentTextNoHtml = commentTextNoHtml.replaceAll("(\r\n|\n)"," <br/> "); //preserve new lines
|
commentTextNoHtml = commentTextNoHtml.replace("href=\"?", "href=\""+portalURL + pathToVRE + "?"); //because there is no indication of the portal (for hashtags)
|
||||||
|
|
||||||
if((commentKey != null && comments.get(i).getKey().equals(commentKey)) && !(notification2Save.getType() == NotificationType.POST_ALERT)){
|
if((commentKey != null && comments.get(i).getKey().equals(commentKey)) && !(notification2Save.getType() == NotificationType.POST_ALERT)){
|
||||||
htmlPost += "<div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; "
|
htmlPost += "<div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; "
|
||||||
+ "border-left: 3px solid #ccc; font-style: italic; font-weight:bold\">"
|
+ "border-left: 3px solid #ccc; font-style: italic; font-weight:bold\">"
|
||||||
|
|
Loading…
Reference in New Issue