2012-12-07 15:06:26 +01:00
|
|
|
package org.gcube.applicationsupportlayer.social;
|
|
|
|
|
2013-01-09 17:47:22 +01:00
|
|
|
import java.util.Date;
|
2013-01-30 18:41:39 +01:00
|
|
|
import java.util.List;
|
2013-01-09 17:47:22 +01:00
|
|
|
import java.util.UUID;
|
|
|
|
|
2012-12-07 15:06:26 +01:00
|
|
|
import org.gcube.application.framework.core.session.ASLSession;
|
2013-01-31 01:31:07 +01:00
|
|
|
import org.gcube.applicationsupportlayer.social.mailing.EmailPlugin;
|
2013-01-09 17:47:22 +01:00
|
|
|
import org.gcube.common.core.utils.logging.GCUBEClientLog;
|
2013-01-03 16:28:36 +01:00
|
|
|
import org.gcube.portal.databook.shared.ApplicationProfile;
|
2013-01-09 17:47:22 +01:00
|
|
|
import org.gcube.portal.databook.shared.Notification;
|
2013-01-30 18:41:39 +01:00
|
|
|
import org.gcube.portal.databook.shared.NotificationChannelType;
|
2013-01-09 17:47:22 +01:00
|
|
|
import org.gcube.portal.databook.shared.NotificationType;
|
2013-01-03 16:28:36 +01:00
|
|
|
import org.gcube.portal.databook.shared.RunningJob;
|
2013-01-11 12:36:44 +01:00
|
|
|
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
|
2012-12-07 15:06:26 +01:00
|
|
|
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder;
|
|
|
|
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem;
|
2013-01-11 12:36:44 +01:00
|
|
|
import org.gcube.vomanagement.usermanagement.UserManager;
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager;
|
|
|
|
import org.gcube.vomanagement.usermanagement.model.UserModel;
|
|
|
|
|
2012-12-07 15:06:26 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author Massimiliano Assante, ISTI-CNR
|
|
|
|
*
|
2012-12-07 18:06:40 +01:00
|
|
|
* use to notify users from within your application
|
2012-12-07 15:06:26 +01:00
|
|
|
*/
|
2013-01-03 16:28:36 +01:00
|
|
|
public class ApplicationNotificationsManager extends SocialPortalBridge implements NotificationsManager {
|
2013-01-09 17:47:22 +01:00
|
|
|
static GCUBEClientLog _log = new GCUBEClientLog(ApplicationNotificationsManager.class);
|
2013-01-03 16:28:36 +01:00
|
|
|
/**
|
2013-01-11 12:36:44 +01:00
|
|
|
* Use this constructor if you do not need notifications to point back to your applications
|
2013-01-03 16:28:36 +01:00
|
|
|
* @param aslSession the ASLSession instance
|
|
|
|
*/
|
2013-01-09 17:47:22 +01:00
|
|
|
public ApplicationNotificationsManager(ASLSession session) {
|
|
|
|
super(session);
|
2013-06-10 18:31:20 +02:00
|
|
|
_log.warn("Asked for Simple Notification (without redirect to creator)");
|
2012-12-07 15:06:26 +01:00
|
|
|
}
|
2013-01-11 12:36:44 +01:00
|
|
|
/**
|
|
|
|
* Use this constructor if you do need notifications to point back to your applications,
|
|
|
|
* make sure you create your application profile on the infrastructure.
|
|
|
|
*
|
|
|
|
* @see http://gcube.wiki.gcube-system.org/gcube/index.php/Social_Networking_Library#Create_Your_Application_Profile
|
|
|
|
*
|
|
|
|
* @param aslSession the ASLSession instance
|
|
|
|
* @param portletClassName your portlet class name will be used ad unique identifier for your applicationProfile
|
|
|
|
*/
|
|
|
|
public ApplicationNotificationsManager(ASLSession session, String portletClassName) {
|
|
|
|
super(session, portletClassName);
|
|
|
|
}
|
2013-01-28 23:30:54 +01:00
|
|
|
/**
|
|
|
|
* actually save the notification to the store
|
|
|
|
* @param notification2Save the notification instance to save
|
|
|
|
* @return true if the notification was sent ok
|
|
|
|
*/
|
|
|
|
private boolean saveNotification(Notification notification2Save) {
|
|
|
|
_log.trace("Trying to send notification to: " + notification2Save.getUserid() + " Type: " + notification2Save.getType());
|
2013-04-26 13:08:59 +02:00
|
|
|
if (notification2Save.getSenderid().compareTo(notification2Save.getUserid()) == 0) {
|
|
|
|
_log.trace("Sender and Receiver are the same " + notification2Save.getUserid() + " Notification Stopped");
|
|
|
|
return true; //I'm not sending notifications to the person who triggered it, pretend I sent it though
|
|
|
|
}
|
2013-01-30 18:41:39 +01:00
|
|
|
List<NotificationChannelType> channels = null;
|
|
|
|
try {
|
2013-06-03 18:13:46 +02:00
|
|
|
channels = getStoreInstance().getUserNotificationChannels(notification2Save.getUserid(), notification2Save.getType());
|
2013-06-06 18:52:03 +02:00
|
|
|
} catch (Exception e) {
|
2013-01-30 18:41:39 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
boolean result = false;
|
2013-01-31 01:31:07 +01:00
|
|
|
if (channels.contains(NotificationChannelType.PORTAL)) {
|
2013-01-30 18:41:39 +01:00
|
|
|
result = getStoreInstance().saveNotification(notification2Save);
|
2013-01-31 01:31:07 +01:00
|
|
|
if (result)
|
|
|
|
_log.trace("Notification Saved Successfully! ");
|
|
|
|
else
|
|
|
|
_log.error("Error While trying to save Notification");
|
|
|
|
}
|
|
|
|
if (channels.contains(NotificationChannelType.EMAIL))
|
2013-01-31 15:46:37 +01:00
|
|
|
EmailPlugin.sendNotification(notification2Save, aslSession.getGroupName());
|
2013-04-26 13:08:59 +02:00
|
|
|
|
2013-01-31 01:31:07 +01:00
|
|
|
if (channels.isEmpty()) {
|
|
|
|
_log.info("Notification was not needed as the user decided not to be notified");
|
|
|
|
result = true;
|
|
|
|
}
|
2013-01-28 23:30:54 +01:00
|
|
|
return result;
|
2013-04-26 13:08:59 +02:00
|
|
|
|
2013-01-28 23:30:54 +01:00
|
|
|
}
|
2013-01-29 02:09:00 +01:00
|
|
|
/**
|
|
|
|
* return the url of the application if exists in the profile
|
|
|
|
* @return .
|
|
|
|
*/
|
|
|
|
private String getApplicationUrl() {
|
|
|
|
if (applicationProfile != null && applicationProfile.getUrl() != null)
|
|
|
|
return applicationProfile.getUrl();
|
|
|
|
else return "";
|
|
|
|
}
|
2012-12-07 18:02:20 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
2013-01-11 12:36:44 +01:00
|
|
|
* @throws InternalErrorException
|
2012-12-07 18:02:20 +01:00
|
|
|
*/
|
2012-12-07 15:06:26 +01:00
|
|
|
@Override
|
2013-01-11 12:36:44 +01:00
|
|
|
public boolean notifyFolderSharing(String userIdToNotify, WorkspaceFolder sharedFolder) throws InternalErrorException {
|
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.WP_FOLDER_SHARE,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
sharedFolder.getId(), //the
|
|
|
|
new Date(),
|
2013-06-10 18:31:20 +02:00
|
|
|
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
|
2013-01-31 15:46:37 +01:00
|
|
|
"shared the workspace folder "+ sharedFolder.getName() +" with you",
|
2013-01-11 12:36:44 +01:00
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
|
|
|
|
2013-01-28 23:30:54 +01:00
|
|
|
return saveNotification(not);
|
2012-12-07 15:06:26 +01:00
|
|
|
}
|
2013-03-20 15:45:06 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
* @throws InternalErrorException
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean notifyFolderRenaming(String userIdToNotify, String previousName, String newName, String renamedFolderId) throws InternalErrorException {
|
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
2013-03-25 14:38:14 +01:00
|
|
|
NotificationType.WP_FOLDER_RENAMED,
|
2013-03-20 15:45:06 +01:00
|
|
|
userIdToNotify, //user no notify
|
|
|
|
renamedFolderId, //the
|
|
|
|
new Date(),
|
2013-06-10 18:31:20 +02:00
|
|
|
getApplicationUrl()+"?itemid="+renamedFolderId,
|
2013-03-20 15:45:06 +01:00
|
|
|
"renamed your shared folder "+ previousName +" as " + newName,
|
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
|
|
|
|
|
|
|
return saveNotification(not);
|
|
|
|
}
|
2012-12-07 18:02:20 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
2013-01-11 12:36:44 +01:00
|
|
|
* @throws UserManagementPortalException
|
|
|
|
* @throws UserRetrievalFault
|
|
|
|
* @throws UserManagementSystemException
|
2012-12-07 18:02:20 +01:00
|
|
|
*/
|
2012-12-07 15:06:26 +01:00
|
|
|
@Override
|
2013-01-11 12:36:44 +01:00
|
|
|
public boolean notifyFolderAddedUser(String userIdToNotify, WorkspaceFolder sharedFolder, String newAddedUserId) throws InternalErrorException, UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
|
|
|
|
UserManager um = new LiferayUserManager();
|
|
|
|
UserModel user = um.getUserByScreenName(newAddedUserId);
|
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.WP_FOLDER_ADDEDUSER,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
sharedFolder.getId(), //the
|
|
|
|
new Date(),
|
2013-06-10 18:31:20 +02:00
|
|
|
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
|
2013-01-31 15:46:37 +01:00
|
|
|
"added "+ user.getFullname() +" to your workspace shared folder "+ sharedFolder.getName(),
|
2013-01-11 12:36:44 +01:00
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
2013-01-29 02:09:00 +01:00
|
|
|
|
2013-01-28 23:30:54 +01:00
|
|
|
return saveNotification(not);
|
2012-12-07 15:06:26 +01:00
|
|
|
}
|
2013-03-25 12:08:25 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
* @throws UserManagementPortalException
|
|
|
|
* @throws UserRetrievalFault
|
|
|
|
* @throws UserManagementSystemException
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean notifyFolderAddedUsers(String userIdToNotify, WorkspaceFolder sharedFolder, List<String> newAddedUserIds) throws InternalErrorException, UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
|
|
|
|
if (newAddedUserIds != null && newAddedUserIds.size() > 0) {
|
|
|
|
if (newAddedUserIds.size() == 1)
|
|
|
|
return notifyFolderAddedUser(userIdToNotify, sharedFolder, newAddedUserIds.get(0));
|
|
|
|
StringBuilder addedUsersFullNames = new StringBuilder();
|
|
|
|
UserManager um = new LiferayUserManager();
|
|
|
|
for (String userId : newAddedUserIds)
|
|
|
|
addedUsersFullNames.append(um.getUserByScreenName(userId).getFullname()).append(" ");
|
2013-04-26 13:08:59 +02:00
|
|
|
|
2013-03-25 12:08:25 +01:00
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.WP_FOLDER_ADDEDUSER,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
sharedFolder.getId(), //the
|
|
|
|
new Date(),
|
2013-06-10 18:31:20 +02:00
|
|
|
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
|
2013-03-25 12:08:25 +01:00
|
|
|
"added "+ addedUsersFullNames +" to your workspace shared folder "+ sharedFolder.getName(),
|
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
|
|
|
|
|
|
|
return saveNotification(not);
|
|
|
|
}
|
2013-04-26 13:08:59 +02:00
|
|
|
|
2013-03-25 12:08:25 +01:00
|
|
|
return false;
|
|
|
|
}
|
2012-12-07 18:02:20 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2012-12-07 15:06:26 +01:00
|
|
|
@Override
|
2013-02-27 17:07:04 +01:00
|
|
|
public boolean notifyFolderRemovedUser(String userIdToNotify, WorkspaceFolder sharedFolder) throws InternalErrorException, UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
|
2013-01-11 12:36:44 +01:00
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.WP_FOLDER_REMOVEDUSER,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
sharedFolder.getId(), //the
|
|
|
|
new Date(),
|
2013-06-10 18:31:20 +02:00
|
|
|
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
|
2013-02-27 17:07:04 +01:00
|
|
|
"unshared his shared folder "+ sharedFolder.getName() + " from your workspace",
|
2013-01-11 12:36:44 +01:00
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
2013-01-29 02:09:00 +01:00
|
|
|
|
2013-01-28 23:30:54 +01:00
|
|
|
return saveNotification(not);
|
2012-12-07 15:06:26 +01:00
|
|
|
}
|
2012-12-07 18:02:20 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
2013-01-11 12:36:44 +01:00
|
|
|
* @throws InternalErrorException
|
2012-12-07 18:02:20 +01:00
|
|
|
*/
|
2012-12-07 15:06:26 +01:00
|
|
|
@Override
|
2013-02-27 12:22:00 +01:00
|
|
|
public boolean notifyAddedItem(String userIdToNotify, WorkspaceItem item, WorkspaceFolder sharedFolder) throws InternalErrorException {
|
2013-01-11 12:36:44 +01:00
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.WP_ITEM_NEW,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
item.getId(), //the
|
|
|
|
new Date(),
|
2013-06-10 18:31:20 +02:00
|
|
|
getApplicationUrl()+"?itemid="+item.getParent().getId(),
|
2013-02-27 12:22:00 +01:00
|
|
|
"added "+ item.getName() +" to your workspace shared folder "+ sharedFolder.getName(),
|
2013-01-11 12:36:44 +01:00
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
2013-01-29 02:09:00 +01:00
|
|
|
|
2013-01-28 23:30:54 +01:00
|
|
|
return saveNotification(not);
|
2012-12-07 15:06:26 +01:00
|
|
|
}
|
2012-12-07 18:02:20 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
2013-01-11 12:36:44 +01:00
|
|
|
* @throws InternalErrorException
|
2012-12-07 18:02:20 +01:00
|
|
|
*/
|
2012-12-07 15:06:26 +01:00
|
|
|
@Override
|
2013-06-14 15:24:42 +02:00
|
|
|
public boolean notifyMovedItem(String userIdToNotify, WorkspaceItem item, WorkspaceFolder sharedFolder) throws InternalErrorException {
|
2013-01-11 12:36:44 +01:00
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.WP_ITEM_DELETE,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
item.getId(), //the
|
|
|
|
new Date(),
|
2013-06-10 18:36:24 +02:00
|
|
|
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
|
2013-06-10 18:31:20 +02:00
|
|
|
"removed item "+ item.getName() +" from your workspace shared folder "+ sharedFolder.getName(),
|
2013-01-11 12:36:44 +01:00
|
|
|
false,
|
2013-06-14 15:24:42 +02:00
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
|
|
|
|
|
|
|
return saveNotification(not);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
* @throws InternalErrorException
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean notifyRemovedItem(String userIdToNotify, String itemName, WorkspaceFolder sharedFolder) throws InternalErrorException {
|
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.WP_ITEM_DELETE,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
sharedFolder.getId(), //the
|
|
|
|
new Date(),
|
|
|
|
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
|
|
|
|
"deleted item "+ itemName +" from your workspace shared folder "+ sharedFolder.getName(),
|
|
|
|
false,
|
2013-01-11 12:36:44 +01:00
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
2013-01-29 02:09:00 +01:00
|
|
|
|
2013-01-28 23:30:54 +01:00
|
|
|
return saveNotification(not);
|
2012-12-07 15:06:26 +01:00
|
|
|
}
|
2012-12-07 18:02:20 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
2013-01-11 12:36:44 +01:00
|
|
|
* @throws InternalErrorException
|
2012-12-07 18:02:20 +01:00
|
|
|
*/
|
2012-12-07 15:06:26 +01:00
|
|
|
@Override
|
2013-03-16 02:40:56 +01:00
|
|
|
public boolean notifyUpdatedItem(String userIdToNotify, WorkspaceItem item, WorkspaceFolder sharedFolder) throws InternalErrorException {
|
2013-01-11 12:36:44 +01:00
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.WP_ITEM_UPDATED,
|
|
|
|
userIdToNotify, //user no notify
|
2013-03-16 02:40:56 +01:00
|
|
|
item.getId(), //the
|
2013-01-11 12:36:44 +01:00
|
|
|
new Date(),
|
2013-06-10 18:31:20 +02:00
|
|
|
getApplicationUrl()+"?itemid="+item.getParent().getId(),
|
2013-01-31 15:46:37 +01:00
|
|
|
" updated "+ item.getName() +" to your workspace shared folder "+ item.getParent().getName(),
|
2013-01-11 12:36:44 +01:00
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
2013-01-29 02:09:00 +01:00
|
|
|
|
2013-01-28 23:30:54 +01:00
|
|
|
return saveNotification(not);
|
2012-12-07 15:06:26 +01:00
|
|
|
}
|
2013-03-25 14:38:14 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
* @throws InternalErrorException
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean notifyItemRenaming(String userIdToNotify, String previousName, WorkspaceItem renamedItem) throws InternalErrorException {
|
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.WP_ITEM_RENAMED,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
renamedItem.getId(), //the
|
|
|
|
new Date(),
|
2013-06-10 18:31:20 +02:00
|
|
|
getApplicationUrl()+"?itemid="+renamedItem.getParent().getId(),
|
2013-03-25 14:38:14 +01:00
|
|
|
"renamed " + previousName +" as " + renamedItem.getName() +" in your shared folder " + renamedItem.getParent().getName(),
|
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
|
|
|
|
|
|
|
return saveNotification(not);
|
|
|
|
}
|
2012-12-07 18:02:20 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2012-12-07 16:29:09 +01:00
|
|
|
@Override
|
2013-01-09 17:47:22 +01:00
|
|
|
public boolean notifyMessageReceived(String userIdToNotify, String subject) {
|
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.MESSAGE,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
"messageid_not_provided", //the
|
|
|
|
new Date(),
|
2013-02-01 10:06:17 +01:00
|
|
|
"/group/data-e-infrastructure-gateway/messages",
|
2013-01-31 15:46:37 +01:00
|
|
|
"sent you a message with subject: " + escapeHtml(subject),
|
2013-01-09 17:47:22 +01:00
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
2013-01-11 12:36:44 +01:00
|
|
|
|
2013-01-28 23:30:54 +01:00
|
|
|
return saveNotification(not);
|
2012-12-07 16:29:09 +01:00
|
|
|
}
|
2012-12-07 18:02:20 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2012-12-07 16:29:09 +01:00
|
|
|
@Override
|
2013-01-11 12:36:44 +01:00
|
|
|
public boolean notifyOwnCommentReply(String userIdToNotify, String feedid, String feedText) {
|
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.OWN_COMMENT,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
feedid, //the post
|
|
|
|
new Date(),
|
2013-02-01 10:06:17 +01:00
|
|
|
"/group/data-e-infrastructure-gateway?oid="+feedid,
|
2013-01-11 12:41:13 +01:00
|
|
|
"commented on your post: " + escapeHtml(feedText),
|
2013-01-11 12:36:44 +01:00
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
2013-01-28 23:30:54 +01:00
|
|
|
return saveNotification(not);
|
2012-12-07 16:29:09 +01:00
|
|
|
}
|
2012-12-07 18:02:20 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2012-12-07 16:29:09 +01:00
|
|
|
@Override
|
2013-04-18 17:32:04 +02:00
|
|
|
public boolean notifyCommentReply(String userIdToNotify, String feedid, String commentText, String feedOwnerFullName) {
|
2013-04-18 17:56:34 +02:00
|
|
|
String notificationText = (aslSession.getUserFullName().compareTo(feedOwnerFullName) == 0) ?
|
2013-04-26 13:08:59 +02:00
|
|
|
"also commented on his post: " + escapeHtml(commentText)
|
|
|
|
:
|
2013-04-18 17:56:34 +02:00
|
|
|
"also commented on " + feedOwnerFullName + "'s post: " + escapeHtml(commentText);
|
2013-04-26 13:08:59 +02:00
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.COMMENT,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
feedid, //the post
|
|
|
|
new Date(),
|
|
|
|
"/group/data-e-infrastructure-gateway?oid="+feedid,
|
|
|
|
notificationText,
|
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
|
|
|
return saveNotification(not);
|
2013-04-18 16:34:07 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2013-04-18 17:32:04 +02:00
|
|
|
public boolean notifyCommentOnFavorite(String userIdToNotify, String feedid, String commentText) {
|
2013-03-11 12:35:23 +01:00
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.COMMENT,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
feedid, //the post
|
|
|
|
new Date(),
|
|
|
|
"/group/data-e-infrastructure-gateway?oid="+feedid,
|
2013-04-18 17:32:04 +02:00
|
|
|
"commented on one of your favorite posts: " + escapeHtml(commentText),
|
2013-03-11 12:35:23 +01:00
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
|
|
|
return saveNotification(not);
|
2012-12-07 16:29:09 +01:00
|
|
|
}
|
2012-12-07 18:02:20 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2012-12-07 16:29:09 +01:00
|
|
|
@Override
|
2013-04-18 11:21:31 +02:00
|
|
|
public boolean notifyUserTag(String userIdToNotify, String feedid, String feedText) {
|
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.MENTION,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
feedid, //the post
|
|
|
|
new Date(),
|
|
|
|
"/group/data-e-infrastructure-gateway?oid="+feedid,
|
|
|
|
"mentioned you in his post: " + escapeHtml(feedText),
|
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
|
|
|
return saveNotification(not);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2013-01-11 12:36:44 +01:00
|
|
|
public boolean notifyLikedFeed(String userIdToNotify, String feedid, String feedText) {
|
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.LIKE,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
feedid, //the post
|
|
|
|
new Date(),
|
2013-02-01 10:06:17 +01:00
|
|
|
"/group/data-e-infrastructure-gateway?oid="+feedid,
|
2013-01-11 12:41:13 +01:00
|
|
|
"likes your post: " + escapeHtml(feedText),
|
2013-01-11 12:36:44 +01:00
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
2013-01-28 23:30:54 +01:00
|
|
|
return saveNotification(not);
|
2012-12-07 16:29:09 +01:00
|
|
|
}
|
2013-01-28 01:12:51 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2013-01-03 16:28:36 +01:00
|
|
|
@Override
|
2013-01-11 12:36:44 +01:00
|
|
|
public boolean notifyJobStatus(String userIdToNotify, ApplicationProfile executingJobApId, RunningJob job) {
|
|
|
|
//TODO: missing implementation
|
2013-01-03 16:28:36 +01:00
|
|
|
return false;
|
|
|
|
}
|
2013-01-28 01:12:51 +01:00
|
|
|
/**
|
|
|
|
* {@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(),
|
2013-01-29 02:09:00 +01:00
|
|
|
getApplicationUrl()+"?oid="+documentWorkflowId,
|
2013-01-31 15:46:37 +01:00
|
|
|
"viewed document workflow " + escapeHtml(documentName),
|
2013-01-28 01:12:51 +01:00
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
2013-01-28 23:30:54 +01:00
|
|
|
return saveNotification(not);
|
2013-01-28 01:12:51 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean notifyDocumentWorkflowUpdate(String userIdToNotify, String documentWorkflowId, String documentName) {
|
2013-01-29 02:09:00 +01:00
|
|
|
|
2013-01-28 01:12:51 +01:00
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.DOCUMENT_WORKFLOW_EDIT,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
documentWorkflowId, //the workflowid
|
|
|
|
new Date(),
|
2013-01-29 02:09:00 +01:00
|
|
|
getApplicationUrl()+"?oid="+documentWorkflowId,
|
2013-01-31 15:46:37 +01:00
|
|
|
"updated document workflow " + escapeHtml(documentName),
|
2013-01-28 01:12:51 +01:00
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
2013-01-28 23:30:54 +01:00
|
|
|
return saveNotification(not);
|
2013-01-28 01:12:51 +01:00
|
|
|
}
|
2013-01-28 23:30:54 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2013-01-28 18:38:43 +01:00
|
|
|
@Override
|
2013-01-29 19:25:43 +01:00
|
|
|
public boolean notifyDocumentWorkflowTaskRequest(String userIdToNotify, String documentWorkflowId, String documentName, String assignedRoleName) {
|
2013-04-26 13:08:59 +02:00
|
|
|
|
2013-01-31 15:46:37 +01:00
|
|
|
String notificationText = "in " + aslSession.getGroupName() + " you are requested to perform a new task in the Document Workflow titled: "
|
|
|
|
+ escapeHtml(documentName) + ". Your role is: " + assignedRoleName;
|
2013-04-26 13:08:59 +02:00
|
|
|
|
2013-01-28 18:38:43 +01:00
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
|
|
|
NotificationType.DOCUMENT_WORKFLOW_STEP_REQUEST_TASK,
|
|
|
|
userIdToNotify, //user no notify
|
|
|
|
documentWorkflowId, //the workflowid
|
|
|
|
new Date(),
|
2013-01-29 02:09:00 +01:00
|
|
|
getApplicationUrl()+"?oid="+documentWorkflowId,
|
2013-01-29 18:19:06 +01:00
|
|
|
notificationText,
|
2013-04-26 13:08:59 +02:00
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
2013-01-29 02:09:00 +01:00
|
|
|
|
2013-01-28 23:30:54 +01:00
|
|
|
return saveNotification(not);
|
|
|
|
|
2013-01-28 18:38:43 +01:00
|
|
|
}
|
2013-01-29 16:24:44 +01:00
|
|
|
/**
|
|
|
|
* {@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,
|
2013-01-31 15:46:37 +01:00
|
|
|
|
|
|
|
"forwarded the Document Workflow titled: " + escapeHtml(documentName) +
|
2013-04-26 13:08:59 +02:00
|
|
|
" from status \"" + fromStepName + "\" to status \"" + toStepName +"\". In " + aslSession.getGroupName(),
|
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
2013-01-29 16:24:44 +01:00
|
|
|
|
|
|
|
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,
|
2013-01-31 16:58:54 +01:00
|
|
|
"has performed the last needed forward on a Document Workflow titled: " + escapeHtml(documentName) + ". " +
|
|
|
|
"Step \"" + fromStepName + "\" is now complete. The next step is \"" + toStepName +"\". In " + aslSession.getGroupName(),
|
2013-01-29 16:24:44 +01:00
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
|
|
|
|
|
|
|
return saveNotification(not);
|
|
|
|
}
|
2013-01-29 19:25:43 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean notifyDocumentWorkflowFirstStepRequest(String userIdToNotify, String documentWorkflowId, String documentName, String assignedRole) {
|
2013-01-31 15:46:37 +01:00
|
|
|
String notificationText = "involved you in the Document Workflow titled: " + escapeHtml(documentName) + ". " +
|
2013-01-31 16:58:54 +01:00
|
|
|
"You are requested to perform a task. Your role is: " + assignedRole+"";
|
2013-01-29 19:25:43 +01:00
|
|
|
Notification not = new Notification(
|
|
|
|
UUID.randomUUID().toString(),
|
2013-01-29 19:49:12 +01:00
|
|
|
NotificationType.DOCUMENT_WORKFLOW_FIRST_STEP_REQUEST_INVOLVMENT,
|
2013-01-29 19:25:43 +01:00
|
|
|
userIdToNotify, //user no notify
|
|
|
|
documentWorkflowId, //the workflowid
|
|
|
|
new Date(),
|
|
|
|
getApplicationUrl()+"?oid="+documentWorkflowId,
|
|
|
|
notificationText,
|
2013-04-26 13:08:59 +02:00
|
|
|
false,
|
|
|
|
aslSession.getUsername(),
|
|
|
|
aslSession.getUserFullName(),
|
|
|
|
aslSession.getUserAvatarId());
|
2013-01-29 19:25:43 +01:00
|
|
|
|
|
|
|
return saveNotification(not);
|
2013-03-25 14:38:14 +01:00
|
|
|
}
|
2012-12-07 15:06:26 +01:00
|
|
|
}
|