From 6c813d5e0b7563066a838d9dbc96da78841091e4 Mon Sep 17 00:00:00 2001 From: "massimiliano.assante" Date: Mon, 26 Sep 2016 10:14:27 +0000 Subject: [PATCH] revised some notificaiton text (removed favorite in like) git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@131776 82a268e6-3cf1-43bd-a215-b396298e98cf --- distro/changelog.xml | 4 + pom.xml | 3 +- .../ApplicationNotificationsManager.java | 146 ++---------------- .../social/NotificationsManager.java | 79 ++-------- .../social/SocialPortalBridge.java | 1 + .../social/mailing/SocialMailingUtil.java | 12 +- .../social/shared/SocialNetworkingSite.java | 40 ++++- 7 files changed, 75 insertions(+), 210 deletions(-) diff --git a/distro/changelog.xml b/distro/changelog.xml index 0afeafb..9653503 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,4 +1,8 @@ + + Revised notification text + Vre's name is now reported in email's subject + Added original discussion in email's body diff --git a/pom.xml b/pom.xml index 77e1d2a..a589481 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.gcube.applicationsupportlayer aslsocial - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT jar Social Portal ASL Extension @@ -131,7 +131,6 @@ javax.servlet javax.servlet-api - 3.0.1 provided diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java index 01c3b8b..c604507 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java @@ -81,6 +81,10 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen portalName = site.getName(); senderEmail = site.getSenderEmail(); portalURL = site.getSiteURL(); + _log.info("ApplicationNotificationsManager setContext for Site: " + portalURL); + _log.info("siteLandingPagePath: " + siteLandingPagePath); + _log.info("senderEmail: " + senderEmail); + _log.info("portalName: " + senderEmail); } /** * actually save the notification to the store @@ -485,7 +489,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen @Override public boolean notifyPost(String userIdToNotify, String feedid, String feedText, String ... hashtags) { StringBuilder notificationText = new StringBuilder(); - notificationText.append("posted a news on ").append(currGroupName).append(":") // has done something + notificationText.append("posted on ").append(currGroupName).append(":") // has done something .append("

").append(feedText).append(" ") .append("

"); @@ -559,6 +563,13 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen */ @Override public boolean notifyCommentOnFavorite(String userIdToNotify, String feedid, String commentText, String commentKey) { + return notifyCommentOnLike(userIdToNotify, feedid, commentText, commentKey); + } + /** + * {@inheritDoc} + */ + @Override + public boolean notifyCommentOnLike(String userIdToNotify, String feedid, String commentText, String commentKey) { Notification not = new Notification( UUID.randomUUID().toString(), NotificationType.COMMENT, @@ -566,7 +577,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen feedid, //the post new Date(), getApplicationUrl()+"?oid="+feedid, - "commented on one of your favorite posts: " + "commented on one of your liked posts: " + "
\"" + commentText +"\"
", false, @@ -610,7 +621,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen feedid, //the post new Date(), getApplicationUrl()+"?oid="+feedid, - "favorited/subscribed to one of your post", + "liked/subscribed to one of your post", false, currUser.getUsername(), currUser.getFullname(), @@ -625,134 +636,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen //TODO: missing implementation return false; } - /** - * {@inheritDoc} - */ - @Override - public boolean notifyDocumentWorkflowView(String userIdToNotify, String documentWorkflowId, String documentName) { - Notification not = new Notification( - UUID.randomUUID().toString(), - NotificationType.DOCUMENT_WORKFLOW_VIEW, - userIdToNotify, //user no notify - documentWorkflowId, //the workflowid - new Date(), - getApplicationUrl()+"?oid="+documentWorkflowId, - "viewed document workflow " + escapeHtml(documentName), - false, - currUser.getUsername(), - currUser.getFullname(), - currUser.getUserAvatarId()); - return saveNotification(not); - } - /** - * {@inheritDoc} - */ - @Override - public boolean notifyDocumentWorkflowUpdate(String userIdToNotify, String documentWorkflowId, String documentName) { - - Notification not = new Notification( - UUID.randomUUID().toString(), - NotificationType.DOCUMENT_WORKFLOW_EDIT, - userIdToNotify, //user no notify - documentWorkflowId, //the workflowid - new Date(), - getApplicationUrl()+"?oid="+documentWorkflowId, - "updated document workflow " + escapeHtml(documentName), - false, - currUser.getUsername(), - currUser.getFullname(), - currUser.getUserAvatarId()); - return saveNotification(not); - } - /** - * {@inheritDoc} - */ - @Override - public boolean notifyDocumentWorkflowTaskRequest(String userIdToNotify, String documentWorkflowId, String documentName, String assignedRoleName) { - String notificationText = "in " + currGroupName + " you are requested to perform a new task in the Document Workflow titled: " - + escapeHtml(documentName) + ". Your role is: " + assignedRoleName; - - Notification not = new Notification( - UUID.randomUUID().toString(), - NotificationType.DOCUMENT_WORKFLOW_STEP_REQUEST_TASK, - userIdToNotify, //user no notify - documentWorkflowId, //the workflowid - new Date(), - getApplicationUrl()+"?oid="+documentWorkflowId, - notificationText, - false, - currUser.getUsername(), - currUser.getFullname(), - currUser.getUserAvatarId()); - - return saveNotification(not); - - } - /** - * {@inheritDoc} - */ - @Override - public boolean notifyDocumentWorkflowUserForward(String userIdToNotify, String documentWorkflowId, String documentName, String fromStepName, String toStepName){ - Notification not = new Notification( - UUID.randomUUID().toString(), - NotificationType.DOCUMENT_WORKFLOW_USER_FORWARD_TO_OWNER, - userIdToNotify, //user no notify - documentWorkflowId, //the workflowid - new Date(), - getApplicationUrl()+"?oid="+documentWorkflowId, - - "forwarded the Document Workflow titled: " + escapeHtml(documentName) + - " from status \"" + fromStepName + "\" to status \"" + toStepName +"\". In " + currGroupName, - false, - currUser.getUsername(), - currUser.getFullname(), - currUser.getUserAvatarId()); - - return saveNotification(not); - } - /** - * {@inheritDoc} - */ - @Override - public boolean notifyDocumentWorkflowStepForwardComplete(String userIdToNotify, String documentWorkflowId, String documentName, String fromStepName, String toStepName) { - Notification not = new Notification( - UUID.randomUUID().toString(), - NotificationType.DOCUMENT_WORKFLOW_FORWARD_STEP_COMPLETED_OWNER, - userIdToNotify, //user no notify - documentWorkflowId, //the workflowid - new Date(), - getApplicationUrl()+"?oid="+documentWorkflowId, - "has performed the last needed forward on a Document Workflow titled: " + escapeHtml(documentName) + ". " + - "Step \"" + fromStepName + "\" is now complete. The next step is \"" + toStepName +"\". In " + currGroupName, - false, - currUser.getUsername(), - currUser.getFullname(), - currUser.getUserAvatarId()); - - return saveNotification(not); - } - /** - * {@inheritDoc} - */ - @Override - public boolean notifyDocumentWorkflowFirstStepRequest(String userIdToNotify, String documentWorkflowId, String documentName, String assignedRole) { - String notificationText = "involved you in the Document Workflow titled: " + escapeHtml(documentName) + ". " + - "You are requested to perform a task. Your role is: " + assignedRole+""; - Notification not = new Notification( - UUID.randomUUID().toString(), - NotificationType.DOCUMENT_WORKFLOW_FIRST_STEP_REQUEST_INVOLVMENT, - userIdToNotify, //user no notify - documentWorkflowId, //the workflowid - new Date(), - getApplicationUrl()+"?oid="+documentWorkflowId, - notificationText, - false, - currUser.getUsername(), - currUser.getFullname(), - currUser.getUserAvatarId()); - - return saveNotification(not); - } + /** * {@inheritDoc} */ diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java index 42ebe0e..3d8f7c6 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java @@ -198,7 +198,8 @@ public interface NotificationsManager { */ boolean notifyCommentReply(String userIdToNotify, String feedid, String feedText, String feedOwnerFullName, String feedOwnerId, String commentKey); /** - * use to notify a user that someone commented on one of his favorite posts + * @deprecated use notifyCommentOnLike + * use to notify a user that someone commented on one of his liked posts * * @param userIdToNotify the user you want to notify * @param feedid the liked feedid @@ -207,6 +208,15 @@ public interface NotificationsManager { * @return true if the notification is correctly delivered, false otherwise */ boolean notifyCommentOnFavorite(String userIdToNotify, String feedid, String commentText, String commentKey); + /** + * + * @param userIdToNotify the user you want to notify + * @param feedid the liked feedid + * @param commentText the commentText + * @param commentKey when sending email, stop the shown discussion at that comment + * @return true if the notification is correctly delivered, false otherwise + */ + boolean notifyCommentOnLike(String userIdToNotify, String feedid, String commentText, String commentKey); /** * use to notify a user that he was mentioned (tagged) on a post * @@ -234,72 +244,7 @@ public interface NotificationsManager { * @return true if the notification is correctly delivered, false otherwise */ boolean notifyJobStatus(String userIdToNotify, ApplicationProfile executingJobApId, RunningJob job); - /** - * use to notify a document workflow owner that someone - * has viewed a document involved in a worflow he created - * @param userIdToNotify the user you want to notify - * @param documentName the document title - * @param documentid the id of the document workflow - * @return true if the notification is correctly delivered, false otherwise - */ - boolean notifyDocumentWorkflowView(String userIdToNotify, String documentWorkflowId, String documentName); - /** - * use to notify a document workflow owner that someone - * has updated a document involved in a worflow he created - * @param userIdToNotify the user you want to notify - * @param documentName the document title - * @param documentid the id of the document workflow - * @return true if the notification is correctly delivered, false otherwise - */ - boolean notifyDocumentWorkflowUpdate(String userIdToNotify, String documentWorkflowId, String documentName); - /** - * use to notify a document workflow user (user that in the same document workflow) - * that he is requested to do a task - * @param userIdToNotify the user you want to notify - * @param documentName the document title - * @param documentid the id of the document workflow - * @param isStartStep set to true is the document worflow was just created - * @return true if the notification is correctly delivered, false otherwise - */ - boolean notifyDocumentWorkflowTaskRequest(String userIdToNotify, String documentWorkflowId, String documentName, String assignedRole); - /** - * use to notify a document workflow user that a new Document Workflow was created and he is involved in the first step - * and he is requested to do a task - * @param userIdToNotify the user you want to notify - * @param documentName the document title - * @param documentid the id of the document workflow - * @param isStartStep set to true is the document worflow was just created - * @return true if the notification is correctly delivered, false otherwise - */ - boolean notifyDocumentWorkflowFirstStepRequest(String userIdToNotify, String documentWorkflowId, String documentName, String assignedRole); - /** - * use to notify a document workflow owner that a user performed a forward action to another step a document worflow he created - * @param userIdToNotify the owner of this document workflow - * @param documentWorkflowId - * @param documentName - * @param fromStepName the name of the step from which the user performed the forward - * @param toStepName the name of the step to which the user performed the forward - * @return true if the notification is correctly delivered, false otherwise - */ - boolean notifyDocumentWorkflowUserForward(String userIdToNotify, String documentWorkflowId, String documentName, String fromStepName, String toStepName); - /** - * use to notify a document workflow owner that someone forwarded and the workflow moved to another step a document worflow he created - * @param userIdToNotify the owner of this document workflow - * @param documentWorkflowId - * @param documentName - * @param fromStepName the name of the step from which the user performed the forward - * @param toStepName the name of the step to which the user performed the forward - * @return true if the notification is correctly delivered, false otherwise - */ - boolean notifyDocumentWorkflowStepForwardComplete(String userIdToNotify, String documentWorkflowId, String documentName, String fromStepName, String toStepName); - /** - * use to notify a user he got a Tabular Data Resource shared - * - * @param userIdToNotify the user you want to notify - * @param tabularResourceName the shared tabular resource name - * @param encodedTabularResourceParams the parameters to be placed in the HTTP GET Request (must be encoded) - * @return true if the notification is correctly delivered, false otherwise - */ + boolean notifyTDMTabularResourceSharing(String userIdToNotify, String tabularResourceName, String encodedTabularResourceParams) throws Exception; /** * use to notify a user he got a Tabular Data Resource shared diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/SocialPortalBridge.java b/src/main/java/org/gcube/applicationsupportlayer/social/SocialPortalBridge.java index ebf70e0..8dba217 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/SocialPortalBridge.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/SocialPortalBridge.java @@ -63,6 +63,7 @@ public class SocialPortalBridge { public SocialPortalBridge(String scope, SocialNetworkingUser currUser, String portletClassName) { this(scope, currUser); this.applicationProfile = getProfileFromInfrastrucure(portletClassName); + _log.debug("ASLSocial called on " + portletClassName); } /** 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 71b86e6..5bf00b4 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/mailing/SocialMailingUtil.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/mailing/SocialMailingUtil.java @@ -61,9 +61,7 @@ public class SocialMailingUtil { } String sender = notification2Save.getSenderFullName(); - if (notification2Save.getType() == NotificationType.DOCUMENT_WORKFLOW_STEP_REQUEST_TASK) - sender = ""; - + String portalHost = portalURL.replaceAll("https://", ""); portalHost = portalHost.replaceAll("http://", ""); @@ -147,9 +145,7 @@ public class SocialMailingUtil { } } String sender = notification2Save.getSenderFullName(); - if (notification2Save.getType() == NotificationType.DOCUMENT_WORKFLOW_STEP_REQUEST_TASK) - sender = ""; - + String portalHost = portalURL.replaceAll("https://", ""); portalHost = portalHost.replaceAll("http://", ""); @@ -307,7 +303,7 @@ public class SocialMailingUtil { actionLink.append("\">").append(" Open Post").append(""); break; case POST_ALERT: - actionLink.append("\">").append("See this News").append(""); + actionLink.append("\">").append("See this Post").append(""); break; case REQUEST_CONNECTION: actionLink.append("\">").append(" Go to Contacts Center").append(""); @@ -499,7 +495,7 @@ public class SocialMailingUtil { + "[" + formatter.format(feed.getTime()) + "] " + feed.getFullName() + ": " - + (feedTextNoHtml.length() > 30 ? feedTextNoHtml.substring(0, 30) + " ..." : feedTextNoHtml) + + (feedTextNoHtml.length() > 200 ? feedTextNoHtml.substring(0, 200) + " ..." : feedTextNoHtml) + "\n"; diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/shared/SocialNetworkingSite.java b/src/main/java/org/gcube/applicationsupportlayer/social/shared/SocialNetworkingSite.java index 41c9735..435c47c 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/shared/SocialNetworkingSite.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/shared/SocialNetworkingSite.java @@ -5,15 +5,25 @@ import java.io.Serializable; import javax.servlet.http.HttpServletRequest; import org.gcube.common.portal.PortalContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.liferay.portal.kernel.util.Http; +import com.liferay.portal.kernel.util.PropsKeys; +import com.liferay.portal.kernel.util.StringUtil; +import com.liferay.portal.util.PortalUtil; @SuppressWarnings("serial") public class SocialNetworkingSite implements Serializable{ - + private static final Logger _log = LoggerFactory.getLogger(SocialNetworkingSite.class); private String siteName; private String senderEmail; private String siteURL; private String siteLandingPagePath; - + /** + * + * @param request make sure that is not expired when you call it + */ public SocialNetworkingSite(HttpServletRequest request) { super(); PortalContext context = PortalContext.getConfiguration(); @@ -22,6 +32,26 @@ public class SocialNetworkingSite implements Serializable{ senderEmail = context.getSenderEmail(request); siteURL = context.getGatewayURL(request); } + /** + * + * @param serverName e.g. myportal.mydomain.org + */ + public SocialNetworkingSite(final String serverName) { + super(); + PortalContext context = PortalContext.getConfiguration(); + siteLandingPagePath = context.getSiteLandingPagePath(serverName); + siteName = context.getGatewayName(serverName); + senderEmail = context.getSenderEmail(serverName); + boolean https = false; + if (StringUtil.equalsIgnoreCase( + Http.HTTPS, PortalUtil.getPortalProperties().get(PropsKeys.WEB_SERVER_PROTOCOL).toString())) { + https = true; + } + int port = (Integer) PortalUtil.getPortalProperties().get(PropsKeys.WEB_SERVER_HTTPS_PORT); + siteURL = context.getGatewayURL(serverName, port, https); + _log.debug("SocialNetworkingSite by serverName instantiated = " + this.toString()); + } + public SocialNetworkingSite(String siteName, String senderEmail, String siteURL, String siteLandingPagePath) { super(); @@ -62,6 +92,12 @@ public class SocialNetworkingSite implements Serializable{ public void setSiteLandingPagePath(String siteLandingPagePath) { this.siteLandingPagePath = siteLandingPagePath; } + @Override + public String toString() { + return "SocialNetworkingSite [siteName=" + siteName + ", senderEmail=" + + senderEmail + ", siteURL=" + siteURL + + ", siteLandingPagePath=" + siteLandingPagePath + "]"; + } }