fixed the workspace notification rename problem, enhanced the notification subject to make them even more informative
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@95740 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
373a7a21cf
commit
ef2ba42c70
|
@ -11,16 +11,15 @@ import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
import org.gcube.applicationsupportlayer.social.mailing.EmailPlugin;
|
import org.gcube.applicationsupportlayer.social.mailing.EmailPlugin;
|
||||||
|
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||||
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
|
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
|
||||||
import org.gcube.portal.databook.shared.ApplicationProfile;
|
import org.gcube.portal.databook.shared.ApplicationProfile;
|
||||||
import org.gcube.portal.databook.shared.Notification;
|
import org.gcube.portal.databook.shared.Notification;
|
||||||
import org.gcube.portal.databook.shared.NotificationChannelType;
|
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||||
import org.gcube.portal.databook.shared.NotificationType;
|
import org.gcube.portal.databook.shared.NotificationType;
|
||||||
import org.gcube.portal.databook.shared.RunningJob;
|
import org.gcube.portal.databook.shared.RunningJob;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
|
||||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
|
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
|
||||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||||
|
@ -38,10 +37,10 @@ import org.slf4j.LoggerFactory;
|
||||||
*/
|
*/
|
||||||
public class ApplicationNotificationsManager extends SocialPortalBridge implements NotificationsManager {
|
public class ApplicationNotificationsManager extends SocialPortalBridge implements NotificationsManager {
|
||||||
private static final Logger _log = LoggerFactory.getLogger(ApplicationNotificationsManager.class);
|
private static final Logger _log = LoggerFactory.getLogger(ApplicationNotificationsManager.class);
|
||||||
|
|
||||||
private static final String SENDER_EMAIL = "notificationSenderEmail";
|
private static final String SENDER_EMAIL = "notificationSenderEmail";
|
||||||
private static final String GATEWAY_NAME = "portalinstancename";
|
private static final String GATEWAY_NAME = "portalinstancename";
|
||||||
|
|
||||||
private String portalName;
|
private String portalName;
|
||||||
private String senderEmail;
|
private String senderEmail;
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +121,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
* @throws InternalErrorException
|
* @throws InternalErrorException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyFolderSharing(String userIdToNotify, WorkspaceFolder sharedFolder) throws InternalErrorException {
|
public boolean notifyFolderSharing(String userIdToNotify, WorkspaceSharedFolder sharedFolder) throws InternalErrorException {
|
||||||
String sharedFolderName = sharedFolder.getName();
|
String sharedFolderName = sharedFolder.getName();
|
||||||
if (sharedFolder.isShared()) {
|
if (sharedFolder.isShared()) {
|
||||||
WorkspaceSharedFolder sharedWSFolder = (WorkspaceSharedFolder) sharedFolder;
|
WorkspaceSharedFolder sharedWSFolder = (WorkspaceSharedFolder) sharedFolder;
|
||||||
|
@ -172,7 +171,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
* @throws UserManagementSystemException
|
* @throws UserManagementSystemException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyFolderAddedUser(String userIdToNotify, WorkspaceFolder sharedFolder, String newAddedUserId) throws InternalErrorException, UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
|
public boolean notifyFolderAddedUser(String userIdToNotify, WorkspaceSharedFolder sharedFolder, String newAddedUserId) throws InternalErrorException, UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
|
||||||
UserManager um = new LiferayUserManager();
|
UserManager um = new LiferayUserManager();
|
||||||
UserModel user = um.getUserByScreenName(newAddedUserId);
|
UserModel user = um.getUserByScreenName(newAddedUserId);
|
||||||
Notification not = new Notification(
|
Notification not = new Notification(
|
||||||
|
@ -197,7 +196,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
* @throws UserManagementSystemException
|
* @throws UserManagementSystemException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyFolderAddedUsers(String userIdToNotify, WorkspaceFolder sharedFolder, List<String> newAddedUserIds) throws InternalErrorException, UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
|
public boolean notifyFolderAddedUsers(String userIdToNotify, WorkspaceSharedFolder sharedFolder, List<String> newAddedUserIds) throws InternalErrorException, UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
|
||||||
if (newAddedUserIds != null && newAddedUserIds.size() > 0) {
|
if (newAddedUserIds != null && newAddedUserIds.size() > 0) {
|
||||||
if (newAddedUserIds.size() == 1)
|
if (newAddedUserIds.size() == 1)
|
||||||
return notifyFolderAddedUser(userIdToNotify, sharedFolder, newAddedUserIds.get(0));
|
return notifyFolderAddedUser(userIdToNotify, sharedFolder, newAddedUserIds.get(0));
|
||||||
|
@ -228,7 +227,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyFolderRemovedUser(String userIdToNotify, WorkspaceFolder sharedFolder) throws InternalErrorException, UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
|
public boolean notifyFolderRemovedUser(String userIdToNotify, WorkspaceSharedFolder sharedFolder) throws InternalErrorException, UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
|
||||||
Notification not = new Notification(
|
Notification not = new Notification(
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
NotificationType.WP_FOLDER_REMOVEDUSER,
|
NotificationType.WP_FOLDER_REMOVEDUSER,
|
||||||
|
@ -249,15 +248,11 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
* @throws InternalErrorException
|
* @throws InternalErrorException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyAddedItem(String userIdToNotify, WorkspaceItem item, WorkspaceFolder sharedFolder) throws InternalErrorException {
|
public boolean notifyAddedItem(String userIdToNotify, WorkspaceItem item, WorkspaceSharedFolder sharedFolder) throws InternalErrorException {
|
||||||
String notifyText = "added "+ item.getName() +" to your workspace shared folder "+ item.getPath().substring(0,item.getPath().lastIndexOf('/'));
|
String notifyText = sharedFolder.isVreFolder() ?
|
||||||
if (sharedFolder.isShared()) {
|
"added "+ item.getName() +" to the workspace group folder " + sharedFolder.getDisplayName() :
|
||||||
WorkspaceSharedFolder sharedWSFolder = (WorkspaceSharedFolder) sharedFolder;
|
"added "+ item.getName() +" to your workspace shared folder "+ item.getPath().substring(0,item.getPath().lastIndexOf('/'));
|
||||||
if (sharedWSFolder.isVreFolder()) {
|
|
||||||
notifyText = "added "+ item.getName() +" to the workspace group folder " + sharedWSFolder.getDisplayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Notification not = new Notification(
|
Notification not = new Notification(
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
NotificationType.WP_ITEM_NEW,
|
NotificationType.WP_ITEM_NEW,
|
||||||
|
@ -278,14 +273,10 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
* @throws InternalErrorException
|
* @throws InternalErrorException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyMovedItem(String userIdToNotify, WorkspaceItem item, WorkspaceFolder sharedFolder) throws InternalErrorException {
|
public boolean notifyMovedItem(String userIdToNotify, WorkspaceItem item, WorkspaceSharedFolder sharedFolder) throws InternalErrorException {
|
||||||
String notifyText = "removed item "+ item.getName() +" from your workspace shared folder "+ sharedFolder.getName();
|
String notifyText = sharedFolder.isVreFolder() ? "removed item "+ item.getName() +" from the workspace group folder " + sharedFolder.getDisplayName():
|
||||||
if (sharedFolder.isShared()) {
|
"removed item "+ item.getName() +" from your workspace shared folder "+ sharedFolder.getName();
|
||||||
WorkspaceSharedFolder sharedWSFolder = (WorkspaceSharedFolder) sharedFolder;
|
|
||||||
if (sharedWSFolder.isVreFolder()) {
|
|
||||||
notifyText = "removed item "+ item.getName() +" from the workspace group folder " + sharedWSFolder.getDisplayName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Notification not = new Notification(
|
Notification not = new Notification(
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
NotificationType.WP_ITEM_DELETE,
|
NotificationType.WP_ITEM_DELETE,
|
||||||
|
@ -306,14 +297,10 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
* @throws InternalErrorException
|
* @throws InternalErrorException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyRemovedItem(String userIdToNotify, String itemName, WorkspaceFolder sharedFolder) throws InternalErrorException {
|
public boolean notifyRemovedItem(String userIdToNotify, String itemName, WorkspaceSharedFolder sharedFolder) throws InternalErrorException {
|
||||||
String notifyText = "deleted item "+ itemName +" from your workspace shared folder "+ sharedFolder.getName();
|
String notifyText = sharedFolder.isVreFolder() ? "deleted item "+ itemName +" from the workspace group folder " + sharedFolder.getDisplayName():
|
||||||
if (sharedFolder.isShared()) {
|
" deleted item "+ itemName +" from your workspace shared folder "+ sharedFolder.getName();
|
||||||
WorkspaceSharedFolder sharedWSFolder = (WorkspaceSharedFolder) sharedFolder;
|
|
||||||
if (sharedWSFolder.isVreFolder()) {
|
|
||||||
notifyText = "deleted item "+ itemName +" from the workspace group folder " + sharedWSFolder.getDisplayName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Notification not = new Notification(
|
Notification not = new Notification(
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
NotificationType.WP_ITEM_DELETE,
|
NotificationType.WP_ITEM_DELETE,
|
||||||
|
@ -334,14 +321,10 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
* @throws InternalErrorException
|
* @throws InternalErrorException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyUpdatedItem(String userIdToNotify, WorkspaceItem item, WorkspaceFolder sharedFolder) throws InternalErrorException {
|
public boolean notifyUpdatedItem(String userIdToNotify, WorkspaceItem item, WorkspaceSharedFolder sharedFolder) throws InternalErrorException {
|
||||||
String notifyText = " updated "+ item.getName() +" to your workspace shared folder "+ item.getPath().substring(0,item.getPath().lastIndexOf('/'));
|
String notifyText = sharedFolder.isVreFolder() ? " updated "+ item.getName() +" from the workspace group folder " + sharedFolder.getDisplayName():
|
||||||
if (sharedFolder.isShared()) {
|
" updated "+ item.getName() +" to your workspace shared folder "+ item.getPath().substring(0,item.getPath().lastIndexOf('/'));
|
||||||
WorkspaceSharedFolder sharedWSFolder = (WorkspaceSharedFolder) sharedFolder;
|
|
||||||
if (sharedWSFolder.isVreFolder()) {
|
|
||||||
notifyText = " updated "+ item.getName() +" from the workspace group folder " + sharedWSFolder.getDisplayName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Notification not = new Notification(
|
Notification not = new Notification(
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
NotificationType.WP_ITEM_UPDATED,
|
NotificationType.WP_ITEM_UPDATED,
|
||||||
|
@ -362,15 +345,10 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
* @throws InternalErrorException
|
* @throws InternalErrorException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyItemRenaming(String userIdToNotify, String previousName, WorkspaceItem renamedItem, WorkspaceFolder rootSharedFolder) throws InternalErrorException {
|
public boolean notifyItemRenaming(String userIdToNotify, String previousName, WorkspaceItem renamedItem, WorkspaceSharedFolder rootSharedFolder) throws InternalErrorException {
|
||||||
String notifyText = "renamed " + previousName +" as " + renamedItem.getName() +" in your shared folder " + renamedItem.getPath().substring(0, renamedItem.getPath().lastIndexOf('/'));
|
String notifyText = rootSharedFolder.isVreFolder() ? "renamed "+ previousName +" as " + renamedItem.getName() +" in the workspace group folder " + rootSharedFolder.getDisplayName():
|
||||||
|
"renamed " + previousName +" as " + renamedItem.getName() +" in your shared folder " + renamedItem.getPath().substring(0, renamedItem.getPath().lastIndexOf('/'));
|
||||||
if (rootSharedFolder.isShared()) {
|
|
||||||
WorkspaceSharedFolder sharedWSFolder = (WorkspaceSharedFolder) renamedItem.getParent();
|
|
||||||
if (sharedWSFolder.isVreFolder()) {
|
|
||||||
notifyText = "renamed "+ previousName +" as " + renamedItem.getName() +" in the workspace group folder " + sharedWSFolder.getDisplayName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Notification not = new Notification(
|
Notification not = new Notification(
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
NotificationType.WP_ITEM_RENAMED,
|
NotificationType.WP_ITEM_RENAMED,
|
||||||
|
@ -411,12 +389,12 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyPost(String userIdToNotify, String feedid, String feedText) {
|
public boolean notifyPost(String userIdToNotify, String feedid, String feedText) {
|
||||||
|
|
||||||
StringBuilder notificationText = new StringBuilder();
|
StringBuilder notificationText = new StringBuilder();
|
||||||
notificationText.append("posted a news on <b>").append(aslSession.getGroupName()).append(":</b>") // has done something
|
notificationText.append("posted a news on <b>").append(aslSession.getGroupName()).append(":</b>") // has done something
|
||||||
.append("<br /><br /> ").append(escapeHtml(feedText)).append(". ")
|
.append("<br /><br /> ").append(escapeHtml(feedText)).append(". ")
|
||||||
.append("<br /><br />Follow the discussion and comment it. ");
|
.append("<br /><br />Follow the discussion and comment it. ");
|
||||||
|
|
||||||
Notification not = new Notification(
|
Notification not = new Notification(
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
NotificationType.POST_ALERT,
|
NotificationType.POST_ALERT,
|
||||||
|
@ -673,18 +651,18 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyNewCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate) {
|
public boolean notifyNewCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate) {
|
||||||
SimpleDateFormat spf = new SimpleDateFormat("EEE dd MMMMM, yyyy");
|
SimpleDateFormat spf = new SimpleDateFormat("EEE dd MMMMM, yyyy");
|
||||||
|
|
||||||
String endDateToDisplay="";
|
String endDateToDisplay="";
|
||||||
if (endingDate != null) {
|
if (endingDate != null) {
|
||||||
endDateToDisplay = " to " + spf.format(endingDate);
|
endDateToDisplay = " to " + spf.format(endingDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder notificationText = new StringBuilder();
|
StringBuilder notificationText = new StringBuilder();
|
||||||
notificationText.append("added the following event in the <b>").append(aslSession.getGroupName()).append("</b> shared calendar: ") // has done something
|
notificationText.append("added the following event in the <b>").append(aslSession.getGroupName()).append("</b> shared calendar: ") // has done something
|
||||||
.append("<strong>").append(eventTitle).append("</strong><br />")
|
.append("<strong>").append(eventTitle).append("</strong><br />")
|
||||||
.append("<br /><strong> Time:</strong> ").append(spf.format(startDate)).append(endDateToDisplay).append("<br />")
|
.append("<br /><strong> Time:</strong> ").append(spf.format(startDate)).append(endDateToDisplay).append("<br />")
|
||||||
.append("<br /><strong> Category: </strong> ").append(eventType);
|
.append("<br /><strong> Category: </strong> ").append(eventType);
|
||||||
|
|
||||||
Notification not = new Notification(
|
Notification not = new Notification(
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
NotificationType.CALENDAR_ADDED_EVENT,
|
NotificationType.CALENDAR_ADDED_EVENT,
|
||||||
|
@ -700,25 +678,25 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
|
|
||||||
return saveNotification(not);
|
return saveNotification(not);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyEditedCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate) {
|
public boolean notifyEditedCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate) {
|
||||||
SimpleDateFormat spf = new SimpleDateFormat("EEE dd MMMMM, yyyy");
|
SimpleDateFormat spf = new SimpleDateFormat("EEE dd MMMMM, yyyy");
|
||||||
|
|
||||||
String endDateToDisplay="";
|
String endDateToDisplay="";
|
||||||
if (endingDate != null) {
|
if (endingDate != null) {
|
||||||
endDateToDisplay = " to " + spf.format(endingDate);
|
endDateToDisplay = " to " + spf.format(endingDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder notificationText = new StringBuilder();
|
StringBuilder notificationText = new StringBuilder();
|
||||||
notificationText.append("edited the following event in the <b>").append(aslSession.getGroupName()).append("</b> shared calendar: ") // has done something
|
notificationText.append("edited the following event in the <b>").append(aslSession.getGroupName()).append("</b> shared calendar: ") // has done something
|
||||||
.append("<strong>").append(eventTitle).append("</strong><br />")
|
.append("<strong>").append(eventTitle).append("</strong><br />")
|
||||||
.append("<br /><strong> Time:</strong> ").append(spf.format(startDate)).append(endDateToDisplay).append("<br />")
|
.append("<br /><strong> Time:</strong> ").append(spf.format(startDate)).append(endDateToDisplay).append("<br />")
|
||||||
.append("<br /><strong> Category: </strong> ").append(eventType);
|
.append("<br /><strong> Category: </strong> ").append(eventType);
|
||||||
|
|
||||||
Notification not = new Notification(
|
Notification not = new Notification(
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
NotificationType.CALENDAR_UPDATED_EVENT,
|
NotificationType.CALENDAR_UPDATED_EVENT,
|
||||||
|
@ -734,25 +712,25 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
|
|
||||||
return saveNotification(not);
|
return saveNotification(not);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyDeletedCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate) {
|
public boolean notifyDeletedCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate) {
|
||||||
SimpleDateFormat spf = new SimpleDateFormat("EEE dd MMMMM, yyyy");
|
SimpleDateFormat spf = new SimpleDateFormat("EEE dd MMMMM, yyyy");
|
||||||
|
|
||||||
String endDateToDisplay="";
|
String endDateToDisplay="";
|
||||||
if (endingDate != null) {
|
if (endingDate != null) {
|
||||||
endDateToDisplay = " to " + spf.format(endingDate);
|
endDateToDisplay = " to " + spf.format(endingDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder notificationText = new StringBuilder();
|
StringBuilder notificationText = new StringBuilder();
|
||||||
notificationText.append("deleted the following event in the <b>").append(aslSession.getGroupName()).append("</b> shared calendar: ") // has done something
|
notificationText.append("deleted the following event in the <b>").append(aslSession.getGroupName()).append("</b> shared calendar: ") // has done something
|
||||||
.append("<strong>").append(eventTitle).append("</strong><br />")
|
.append("<strong>").append(eventTitle).append("</strong><br />")
|
||||||
.append("<br /><strong> Was planned:</strong> ").append(spf.format(startDate)).append(endDateToDisplay).append("<br />")
|
.append("<br /><strong> Was planned:</strong> ").append(spf.format(startDate)).append(endDateToDisplay).append("<br />")
|
||||||
.append("<br /><strong> Category: </strong> ").append(eventType);
|
.append("<br /><strong> Category: </strong> ").append(eventType);
|
||||||
|
|
||||||
Notification not = new Notification(
|
Notification not = new Notification(
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
NotificationType.CALENDAR_DELETED_EVENT,
|
NotificationType.CALENDAR_DELETED_EVENT,
|
||||||
|
@ -768,7 +746,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
|
|
||||||
return saveNotification(not);
|
return saveNotification(not);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read the portal instance name from a property file and returns it
|
* read the portal instance name from a property file and returns it
|
||||||
*/
|
*/
|
||||||
|
@ -793,7 +771,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
_log.debug("Returning Gateway Name: " + toReturn );
|
_log.debug("Returning Gateway Name: " + toReturn );
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read the sender email for notifications name from a property file and returns it
|
* read the sender email for notifications name from a property file and returns it
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,6 +7,7 @@ import org.gcube.portal.databook.shared.ApplicationProfile;
|
||||||
import org.gcube.portal.databook.shared.RunningJob;
|
import org.gcube.portal.databook.shared.RunningJob;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Massimiliano Assante, ISTI-CNR
|
* @author Massimiliano Assante, ISTI-CNR
|
||||||
|
@ -17,10 +18,10 @@ public interface NotificationsManager {
|
||||||
* use to notify a user he got a workspace folder shared
|
* use to notify a user he got a workspace folder shared
|
||||||
*
|
*
|
||||||
* @param userIdToNotify the user you want to notify
|
* @param userIdToNotify the user you want to notify
|
||||||
* @param sharedFolder the shared {@link WorkspaceFolder}
|
* @param sharedFolder the shared {@link WorkspaceSharedFolder}
|
||||||
* @return true if the notification is correctly delivered, false otherwise
|
* @return true if the notification is correctly delivered, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean notifyFolderSharing(String userIdToNotify, WorkspaceFolder sharedFolder) throws Exception;
|
boolean notifyFolderSharing(String userIdToNotify, WorkspaceSharedFolder sharedFolder) throws Exception;
|
||||||
/**
|
/**
|
||||||
* use to notify a user he got a workspace folder renamed
|
* use to notify a user he got a workspace folder renamed
|
||||||
*
|
*
|
||||||
|
@ -35,52 +36,52 @@ public interface NotificationsManager {
|
||||||
* use to notify a user that a new user was added in on of his workspace shared folder
|
* use to notify a user that a new user was added in on of his workspace shared folder
|
||||||
*
|
*
|
||||||
* @param userIdToNotify the user you want to notify
|
* @param userIdToNotify the user you want to notify
|
||||||
* @param sharedFolder the shared {@link WorkspaceFolder}
|
* @param sharedFolder the shared {@link WorkspaceSharedFolder}
|
||||||
* @param newAddedUserId the new user that was added
|
* @param newAddedUserId the new user that was added
|
||||||
* @return true if the notification is correctly delivered, false otherwise
|
* @return true if the notification is correctly delivered, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean notifyFolderAddedUser(String userIdToNotify, WorkspaceFolder sharedFolder, String newAddedUserId) throws Exception;
|
boolean notifyFolderAddedUser(String userIdToNotify, WorkspaceSharedFolder sharedFolder, String newAddedUserId) throws Exception;
|
||||||
/**
|
/**
|
||||||
* use to notify a user that a new user was added in on of his workspace shared folder
|
* use to notify a user that a new user was added in on of his workspace shared folder
|
||||||
*
|
*
|
||||||
* @param userIdToNotify the user you want to notify
|
* @param userIdToNotify the user you want to notify
|
||||||
* @param sharedFolder the shared {@link WorkspaceFolder}
|
* @param sharedFolder the shared {@link WorkspaceSharedFolder}
|
||||||
* @param newAddedUserIds List of new users that were added
|
* @param newAddedUserIds List of new users that were added
|
||||||
* @return true if the notification is correctly delivered, false otherwise
|
* @return true if the notification is correctly delivered, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean notifyFolderAddedUsers(String userIdToNotify, WorkspaceFolder sharedFolder, List<String> newAddedUserIds) throws Exception;
|
boolean notifyFolderAddedUsers(String userIdToNotify, WorkspaceSharedFolder sharedFolder, List<String> newAddedUserIds) throws Exception;
|
||||||
/**
|
/**
|
||||||
* use to notify a user that an existing user was removed from one of his workspace shared folder
|
* use to notify a user that an existing user was removed from one of his workspace shared folder
|
||||||
*
|
*
|
||||||
* @param userIdToNotify the user you want to notify
|
* @param userIdToNotify the user you want to notify
|
||||||
* @param sharedFolder the shared {@link WorkspaceFolder}
|
* @param sharedFolder the shared {@link WorkspaceSharedFolder}
|
||||||
* @return true if the notification is correctly delivered, false otherwise
|
* @return true if the notification is correctly delivered, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean notifyFolderRemovedUser(String userIdToNotify, WorkspaceFolder sharedFolder) throws Exception;
|
boolean notifyFolderRemovedUser(String userIdToNotify, WorkspaceSharedFolder sharedFolder) throws Exception;
|
||||||
/**
|
/**
|
||||||
* use to notify a user he got a workspace item new in some of his workspace shared folder
|
* use to notify a user he got a workspace item new in some of his workspace shared folder
|
||||||
* @param userIdToNotify the user you want to notify
|
* @param userIdToNotify the user you want to notify
|
||||||
* @param newItem the new shared {@link WorkspaceItem}
|
* @param newItem the new shared {@link WorkspaceItem}
|
||||||
* @param sharedFolder the shared folder {@link WorkspaceFolder}
|
* @param sharedFolder the shared folder {@link WorkspaceSharedFolder}
|
||||||
* @return true if the notification is correctly delivered, false otherwise
|
* @return true if the notification is correctly delivered, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean notifyAddedItem(String userIdToNotify, WorkspaceItem item, WorkspaceFolder sharedFolder) throws Exception;
|
boolean notifyAddedItem(String userIdToNotify, WorkspaceItem item, WorkspaceSharedFolder sharedFolder) throws Exception;
|
||||||
/**
|
/**
|
||||||
* use to notify a user he got a workspace item deleted from one of his workspace shared folder
|
* use to notify a user he got a workspace item deleted from one of his workspace shared folder
|
||||||
* @param userIdToNotify the user you want to notify
|
* @param userIdToNotify the user you want to notify
|
||||||
* @param removedItem the removed {@link WorkspaceItem}
|
* @param removedItem the removed {@link WorkspaceItem}
|
||||||
* @param sharedFolder the shared folder {@link WorkspaceFolder}
|
* @param sharedFolder the shared folder {@link WorkspaceSharedFolder}
|
||||||
* @return true if the notification is correctly delivered, false otherwise
|
* @return true if the notification is correctly delivered, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean notifyMovedItem(String userIdToNotify, WorkspaceItem item, WorkspaceFolder sharedFolder) throws Exception;
|
boolean notifyMovedItem(String userIdToNotify, WorkspaceItem item, WorkspaceSharedFolder sharedFolder) throws Exception;
|
||||||
/**
|
/**
|
||||||
* use to notify a user he got a workspace item deleted from one of his workspace shared folder
|
* use to notify a user he got a workspace item deleted from one of his workspace shared folder
|
||||||
* @param userIdToNotify the user you want to notify
|
* @param userIdToNotify the user you want to notify
|
||||||
* @param removedItem the removed {@link WorkspaceItem}
|
* @param removedItem the removed {@link WorkspaceItem}
|
||||||
* @param sharedFolder the shared folder {@link WorkspaceFolder}
|
* @param sharedFolder the shared folder {@link WorkspaceSharedFolder}
|
||||||
* @return true if the notification is correctly delivered, false otherwise
|
* @return true if the notification is correctly delivered, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean notifyRemovedItem(String userIdToNotify, String item, WorkspaceFolder sharedFolder) throws Exception;
|
boolean notifyRemovedItem(String userIdToNotify, String item, WorkspaceSharedFolder sharedFolder) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* use to notify a user he got a workspace item updated from one of his workspace shared folder
|
* use to notify a user he got a workspace item updated from one of his workspace shared folder
|
||||||
|
@ -89,17 +90,17 @@ public interface NotificationsManager {
|
||||||
* @param sharedFolder the shared folder {@link WorkspaceFolder}
|
* @param sharedFolder the shared folder {@link WorkspaceFolder}
|
||||||
* @return true if the notification is correctly delivered, false otherwise
|
* @return true if the notification is correctly delivered, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean notifyUpdatedItem(String userIdToNotify, WorkspaceItem item, WorkspaceFolder sharedFolder) throws Exception;
|
boolean notifyUpdatedItem(String userIdToNotify, WorkspaceItem item, WorkspaceSharedFolder sharedFolder) throws Exception;
|
||||||
/**
|
/**
|
||||||
* use to notify a user he got a workspace item renamed
|
* use to notify a user he got a workspace item renamed
|
||||||
*
|
*
|
||||||
* @param userIdToNotify the user you want to notify
|
* @param userIdToNotify the user you want to notify
|
||||||
* @param previousName the previous name of the folder
|
* @param previousName the previous name of the folder
|
||||||
* @param renamedItem the renamed {@link WorkspaceItem}
|
* @param renamedItem the renamed {@link WorkspaceItem}
|
||||||
* @param rootSharedFolder the root shared {@link WorkspaceFolder} of the {@link WorkspaceItem}
|
* @param rootSharedFolder the root shared {@link WorkspaceSharedFolder} of the {@link WorkspaceItem}
|
||||||
* @return true if the notification is correctly delivered, false otherwise
|
* @return true if the notification is correctly delivered, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean notifyItemRenaming(String userIdToNotify, String previousName, WorkspaceItem renamedItem, WorkspaceFolder rootSharedFolder) throws Exception;
|
boolean notifyItemRenaming(String userIdToNotify, String previousName, WorkspaceItem renamedItem, WorkspaceSharedFolder rootSharedFolder) throws Exception;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param userIdToNotify the user you want to notify
|
* @param userIdToNotify the user you want to notify
|
||||||
|
|
|
@ -8,10 +8,13 @@ import java.util.Properties;
|
||||||
|
|
||||||
import javax.mail.Address;
|
import javax.mail.Address;
|
||||||
import javax.mail.Message;
|
import javax.mail.Message;
|
||||||
|
import javax.mail.Multipart;
|
||||||
import javax.mail.Session;
|
import javax.mail.Session;
|
||||||
import javax.mail.Transport;
|
import javax.mail.Transport;
|
||||||
import javax.mail.internet.InternetAddress;
|
import javax.mail.internet.InternetAddress;
|
||||||
|
import javax.mail.internet.MimeBodyPart;
|
||||||
import javax.mail.internet.MimeMessage;
|
import javax.mail.internet.MimeMessage;
|
||||||
|
import javax.mail.internet.MimeMultipart;
|
||||||
|
|
||||||
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
|
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
|
||||||
import org.gcube.portal.databook.shared.Notification;
|
import org.gcube.portal.databook.shared.Notification;
|
||||||
|
@ -72,6 +75,36 @@ public class EmailPlugin {
|
||||||
return body.toString();
|
return body.toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getTextEmail(Notification notification2Save, String userFirstName, String portalURL, String email) {
|
||||||
|
|
||||||
|
String removedMarkup = notification2Save.getDescription().replaceAll("&", "&");
|
||||||
|
removedMarkup = removedMarkup.replaceAll(">", ">");
|
||||||
|
removedMarkup = removedMarkup.replaceAll("<", "<");
|
||||||
|
|
||||||
|
String sender = notification2Save.getSenderFullName();
|
||||||
|
if (notification2Save.getType() == NotificationType.DOCUMENT_WORKFLOW_STEP_REQUEST_TASK)
|
||||||
|
sender = "";
|
||||||
|
|
||||||
|
String portalHost = portalURL.replaceAll("https://", "");
|
||||||
|
portalHost = portalHost.replaceAll("http://", "");
|
||||||
|
|
||||||
|
StringBuilder body = new StringBuilder();
|
||||||
|
|
||||||
|
body.append("Dear ").append(userFirstName).append(",") //dear <user>
|
||||||
|
.append("\n").append(sender).append(" ").append(removedMarkup) // has done something
|
||||||
|
.append("\nsee: ").append(portalURL).append(notification2Save.getUri())
|
||||||
|
.append("\n\n\n----\n")
|
||||||
|
.append("This message was sent to ")
|
||||||
|
.append(email)
|
||||||
|
.append(" by ")
|
||||||
|
.append(portalHost)
|
||||||
|
.append(" If you don't want to receive these emails in the future, please unsubscribe here: ")
|
||||||
|
.append(portalURL).append("/group/data-e-infrastructure-gateway/notifications .");
|
||||||
|
|
||||||
|
return body.toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static String getActionLink(Notification notification2Save, String portalURL) {
|
private static String getActionLink(Notification notification2Save, String portalURL) {
|
||||||
StringBuilder actionLink = new StringBuilder("<a style=\"color:#3B5998; text-decoration:none\" target=\"_blank\" href=\"");
|
StringBuilder actionLink = new StringBuilder("<a style=\"color:#3B5998; text-decoration:none\" target=\"_blank\" href=\"");
|
||||||
|
@ -101,14 +134,24 @@ public class EmailPlugin {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// EMAIL SENDER
|
// EMAIL SENDER
|
||||||
Address from = new InternetAddress(senderEmail, portalName);
|
|
||||||
mimeMessage.setHeader("Content-Type", "text/html; charset=UTF-8");
|
mimeMessage.setHeader("Content-Type", "text/html; charset=UTF-8");
|
||||||
mimeMessage.setFrom(from);
|
mimeMessage.setFrom(new InternetAddress(senderEmail, portalName));
|
||||||
Address address = new InternetAddress(email);
|
mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
|
||||||
mimeMessage.addRecipient(Message.RecipientType.TO, address);
|
|
||||||
|
|
||||||
mimeMessage.setSubject(getSubjectByNotificationType(notification2Save, portalUrl, vreName, user.getFirstName()));
|
mimeMessage.setSubject(getSubjectByNotificationType(notification2Save, portalUrl, vreName, user.getFirstName()));
|
||||||
mimeMessage.setContent(getHTMLEmail(notification2Save, user.getFirstName(), portalUrl, email), "text/html; charset=UTF-8");
|
|
||||||
|
final MimeBodyPart textPart = new MimeBodyPart();
|
||||||
|
textPart.setContent(getTextEmail(notification2Save, user.getFirstName(), portalUrl, email), "text/plain");
|
||||||
|
|
||||||
|
final MimeBodyPart htmlPart = new MimeBodyPart();
|
||||||
|
htmlPart.setContent(getHTMLEmail(notification2Save, user.getFirstName(), portalUrl, email), "text/html; charset=UTF-8");
|
||||||
|
|
||||||
|
final Multipart mp = new MimeMultipart("alternative");
|
||||||
|
mp.addBodyPart(textPart);
|
||||||
|
mp.addBodyPart(htmlPart);
|
||||||
|
// Set Multipart as the message's content
|
||||||
|
mimeMessage.setContent(mp);
|
||||||
|
|
||||||
mimeMessage.setSentDate(new Date());
|
mimeMessage.setSentDate(new Date());
|
||||||
Transport.send(mimeMessage);
|
Transport.send(mimeMessage);
|
||||||
_log.trace("notification email sent successfully");
|
_log.trace("notification email sent successfully");
|
||||||
|
@ -117,6 +160,7 @@ public class EmailPlugin {
|
||||||
_log.error("While sending the notification email:", e);
|
_log.error("While sending the notification email:", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* construct the subjec of the email
|
* construct the subjec of the email
|
||||||
* @param notification2Save
|
* @param notification2Save
|
||||||
|
@ -137,13 +181,15 @@ public class EmailPlugin {
|
||||||
case WP_FOLDER_REMOVEDUSER:
|
case WP_FOLDER_REMOVEDUSER:
|
||||||
return "Removed user in a shared folder";
|
return "Removed user in a shared folder";
|
||||||
case WP_FOLDER_SHARE:
|
case WP_FOLDER_SHARE:
|
||||||
return "Folder sharing notification";
|
return notification2Save.getSenderFullName()+ " shared a folder with you";
|
||||||
case WP_ITEM_NEW:
|
case WP_ITEM_NEW:
|
||||||
return "New item in a shared folder";
|
return notification2Save.getSenderFullName()+ " added an item in a shared folder";
|
||||||
case WP_ITEM_DELETE:
|
case WP_ITEM_DELETE:
|
||||||
return "Deleted item in a shared folder";
|
return notification2Save.getSenderFullName()+ " deleted an item in a shared folder";
|
||||||
case WP_ITEM_UPDATED:
|
case WP_ITEM_UPDATED:
|
||||||
return "Updated item in a shared folder";
|
return notification2Save.getSenderFullName()+ " updated an item in a shared folder";
|
||||||
|
case WP_ITEM_RENAMED:
|
||||||
|
return notification2Save.getSenderFullName()+ " renamed an item in a shared folder";
|
||||||
case OWN_COMMENT:
|
case OWN_COMMENT:
|
||||||
return notification2Save.getSenderFullName() + " commented on your post";
|
return notification2Save.getSenderFullName() + " commented on your post";
|
||||||
case MENTION:
|
case MENTION:
|
||||||
|
|
Loading…
Reference in New Issue