comments = null;
String commentKey = null;
String vreNameFromFeed = null;
@@ -113,13 +113,13 @@ public class NotificationMail {
notification2Send.getType() == NotificationType.MENTION) {
try{
String feedId = notification2Send.getSubjectid();
- feed = store.readFeed(feedId);
+ post = store.readFeed(feedId);
comments = store.getAllCommentByFeed(feedId);
Collections.sort(comments); // sort them
commentKey = notification2Send.getCommentKey();
// try to set vreName when notification is created in infrastructure scope
- String[] splittedVREName = feed.getVreid().split("/");
+ String[] splittedVREName = post.getVreid().split("/");
if(vreName == null)
vreName = splittedVREName[splittedVREName.length - 1];
@@ -140,24 +140,25 @@ public class NotificationMail {
_log.debug("VRE Name for the email's subject is going to be "
+ vreNameToUse + "[vreNameFromFeed is " + vreNameFromFeed + ", vreName is " + vreName + "]");
-
- // set subject
- msg2Return.setSubject(SocialMailingUtil.getSubjectByNotificationType(notification2Send, vreNameToUse, user.getFirstName(), mentionedVReGroups, hashtags));
-
- final MimeBodyPart textPart = new MimeBodyPart();
- textPart.setContent(SocialMailingUtil.getTextEmail(notification2Send, user.getFirstName(), portalURL, siteLandingPagePath, email, feed, comments, commentKey, hashtags), "text/plain; charset=UTF-8");
-
- final MimeBodyPart htmlPart = new MimeBodyPart();
- htmlPart.setContent(SocialMailingUtil.getHTMLEmail(vreNameToUse, notification2Send, user.getFirstName(), portalURL, siteLandingPagePath, email, feed, comments, commentKey, hashtags), "text/html; charset=UTF-8");
-
- final Multipart mp = new MimeMultipart("alternative");
- mp.addBodyPart(textPart);
- mp.addBodyPart(htmlPart);
- // Set Multipart as the message's content
- msg2Return.setContent(mp);
-
- msg2Return.setSentDate(new Date());
-
+ try{
+ // set subject
+ msg2Return.setSubject(SocialMailingUtil.getSubjectByNotificationType(notification2Send, vreNameToUse, user.getFirstName(), mentionedVReGroups, hashtags));
+ _log.debug("message subject set");
+ final MimeBodyPart textPart = new MimeBodyPart();
+ textPart.setContent(SocialMailingUtil.getTextEmail(notification2Send, user.getFirstName(), portalURL, siteLandingPagePath, email, post, comments, commentKey, hashtags), "text/plain; charset=UTF-8");
+ final MimeBodyPart htmlPart = new MimeBodyPart();
+ htmlPart.setContent(SocialMailingUtil.getHTMLEmail(vreNameToUse, notification2Send, user.getFirstName(), portalURL, siteLandingPagePath, email, post, comments, commentKey, hashtags), "text/html; charset=UTF-8");
+ final Multipart mp = new MimeMultipart("alternative");
+ mp.addBodyPart(textPart);
+ mp.addBodyPart(htmlPart);
+ _log.debug("message added body parts");
+ // Set Multipart as the message's content
+ msg2Return.setContent(mp);
+ _log.debug("message setContent DONE");
+ msg2Return.setSentDate(new Date());
+ } catch(Exception e){
+ e.printStackTrace();
+ }
return msg2Return;
}
diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/mailing/SocialMailingUtil.java b/src/main/java/org/gcube/applicationsupportlayer/social/mailing/SocialMailingUtil.java
index e1e7878..8c902dd 100644
--- a/src/main/java/org/gcube/applicationsupportlayer/social/mailing/SocialMailingUtil.java
+++ b/src/main/java/org/gcube/applicationsupportlayer/social/mailing/SocialMailingUtil.java
@@ -58,13 +58,15 @@ public class SocialMailingUtil {
//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];
- }
+ if (notification2Save.getUri() != null) {
+ 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://", "");
portalHost = portalHost.replaceAll("http://", "");
@@ -86,7 +88,7 @@ public class SocialMailingUtil {
body.append("").append(WRITE_ABOVE_MESSAGE_REPLY).append("
");
attachmentsNotice = "
Please note that email replies do not support attachments.
";
}
-
+
String userProfileLink = new StringBuffer(getVREUrl(portalURL, vreName))
.append("/").append(getUserProfileLink(notification2Save.getSenderid())).toString();
@@ -207,7 +209,7 @@ public class SocialMailingUtil {
case MESSAGE:
String messageSubject = (optionalParams != null && optionalParams.length > 0) ?
optionalParams[0] : notification2Save.getSenderFullName()+" sent you a message";
- return messageSubject;
+ return messageSubject;
case WP_FOLDER_ADDEDUSER:
return "New user in a shared folder";
case WP_FOLDER_REMOVEDUSER:
@@ -371,7 +373,7 @@ public class SocialMailingUtil {
buffer.append(" ");
}
}
-
+
if (node instanceof TextNode) {
TextNode textNode = (TextNode) node;
buffer.append(textNode.text().trim());
@@ -408,8 +410,8 @@ public class SocialMailingUtil {
if (notification2Save.getType() == NotificationType.COMMENT ||
notification2Save.getType() == NotificationType.OWN_COMMENT ||
- notification2Save.getType() == NotificationType.LIKE ||
- notification2Save.getType() == NotificationType.MENTION){
+ notification2Save.getType() == NotificationType.LIKE ||
+ notification2Save.getType() == NotificationType.MENTION){
String htmlPost = "
" + "
----Original post:
";
// data formatter
@@ -419,8 +421,8 @@ public class SocialMailingUtil {
String postTextNoHtml = post.getDescription().replaceAll("&", "&");
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
if(notification2Save.getType() == NotificationType.POST_ALERT || (comments.size() == 0 && notification2Save.getType() == NotificationType.MENTION))
htmlPost += "