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
This commit is contained in:
Massimiliano Assante 2016-09-26 10:14:27 +00:00
parent 14a6f9f61b
commit 6c813d5e0b
7 changed files with 75 additions and 210 deletions

View File

@ -1,4 +1,8 @@
<ReleaseNotes>
<Changeset component="org.gcube.applicationsupportlayer.aslsocial.1-1-0" date="2016-09-29">
<Change>Revised notification text</Change>
<Change>Vre's name is now reported in email's subject</Change>
</Changeset>
<Changeset component="org.gcube.applicationsupportlayer.aslsocial.0-16-0"
date="2016-02-29">
<Change>Added original discussion in email's body</Change>

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslsocial</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Social Portal ASL Extension</name>
<description>
@ -131,7 +131,6 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -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 <b> ").append(currGroupName).append(":</b>") // has done something
notificationText.append("posted on <b> ").append(currGroupName).append(":</b>") // has done something
.append("<br /><br /> ").append(feedText).append(" ")
.append("<br /><br />");
@ -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: "
+ "<div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; border-left: 3px solid #ccc; font-style: italic;\">\""
+ commentText +"\"</div>",
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}
*/

View File

@ -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

View File

@ -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);
}
/**

View File

@ -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("</a>");
break;
case POST_ALERT:
actionLink.append("\">").append("See this News").append("</a>");
actionLink.append("\">").append("See this Post").append("</a>");
break;
case REQUEST_CONNECTION:
actionLink.append("\">").append(" Go to Contacts Center").append("</a>");
@ -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";

View File

@ -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 + "]";
}
}