implemented almost every method

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@67483 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-01-11 11:36:44 +00:00
parent 3099c03018
commit adb932d4de
2 changed files with 181 additions and 48 deletions

View File

@ -7,13 +7,19 @@ import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.portal.databook.shared.ApplicationProfile;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.portal.databook.shared.RunningJob;
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.portlets.user.homelibrary.home.workspace.sharing.WorkspaceMessage;
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;
/**
*
* @author Massimiliano Assante, ISTI-CNR
@ -24,54 +30,154 @@ import org.gcube.portlets.user.homelibrary.home.workspace.sharing.WorkspaceMessa
public class ApplicationNotificationsManager extends SocialPortalBridge implements NotificationsManager {
static GCUBEClientLog _log = new GCUBEClientLog(ApplicationNotificationsManager.class);
/**
*
* Use this constructor if you do not need notifications to point back to your applications
* @param aslSession the ASLSession instance
* @param portletClassName your portlet class name will be used ad unique identifier for your applicationProfile
*/
public ApplicationNotificationsManager(ASLSession session) {
super(session);
}
/**
* 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);
}
/**
* {@inheritDoc}
* @throws InternalErrorException
*/
@Override
public boolean notifyFolderSharing(String userIdToNotify, WorkspaceFolder sharedFolder) {
return true;
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(),
"?folder="+sharedFolder.getId(),
"has shared a workspace folder ("+ sharedFolder.getName() +") with you",
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
aslSession.getUserAvatarId());
return getStoreInstance().saveNotification(not);
}
/**
* {@inheritDoc}
* @throws UserManagementPortalException
* @throws UserRetrievalFault
* @throws UserManagementSystemException
*/
@Override
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(),
"?folder="+sharedFolder.getId(),
"has added a new user ("+ user.getFullname() +") on your workspace shared folder ("+ sharedFolder.getName() +")",
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
aslSession.getUserAvatarId());
return getStoreInstance().saveNotification(not);
}
/**
* {@inheritDoc}
*/
@Override
public boolean notifyFolderAddedUser(String userIdToNotify, WorkspaceFolder sharedFolder, String newAddedUserId) {
return true;
public boolean notifyFolderRemovedUser(String userIdToNotify, WorkspaceFolder sharedFolder, String removedUserId) throws InternalErrorException, UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
UserManager um = new LiferayUserManager();
UserModel user = um.getUserByScreenName(removedUserId);
Notification not = new Notification(
UUID.randomUUID().toString(),
NotificationType.WP_FOLDER_REMOVEDUSER,
userIdToNotify, //user no notify
sharedFolder.getId(), //the
new Date(),
"?folder="+sharedFolder.getId(),
"has removed a user ("+ user.getFullname() +") from your workspace shared folder ("+ sharedFolder.getName() +")",
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
aslSession.getUserAvatarId());
return getStoreInstance().saveNotification(not);
}
/**
* {@inheritDoc}
* @throws InternalErrorException
*/
@Override
public boolean notifyFolderRemovedUser(String userIdToNotify, WorkspaceFolder sharedFolder, String removedUserId) {
return true;
public boolean notifyAddedItem(String userIdToNotify, WorkspaceItem item) throws InternalErrorException {
Notification not = new Notification(
UUID.randomUUID().toString(),
NotificationType.WP_ITEM_NEW,
userIdToNotify, //user no notify
item.getId(), //the
new Date(),
"?folder="+item.getParent().getId()+"&item="+item.getId(),
"has added a new item ("+ item.getName() +") on your workspace shared folder ("+ item.getParent().getName() +")",
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
aslSession.getUserAvatarId());
return getStoreInstance().saveNotification(not);
}
/**
* {@inheritDoc}
* @throws InternalErrorException
*/
@Override
public boolean notifyAddedItem(String userIdToNotify, WorkspaceItem newItem) {
return true;
public boolean notifyRemovedItem(String userIdToNotify, WorkspaceItem item) throws InternalErrorException {
Notification not = new Notification(
UUID.randomUUID().toString(),
NotificationType.WP_ITEM_DELETE,
userIdToNotify, //user no notify
item.getId(), //the
new Date(),
"?folder="+item.getParent().getId()+"&item="+item.getId(),
"has removed an item ("+ item.getName() +") from your workspace shared folder ("+ item.getParent().getName() +")",
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
aslSession.getUserAvatarId());
return getStoreInstance().saveNotification(not);
}
/**
* {@inheritDoc}
* @throws InternalErrorException
*/
@Override
public boolean notifyRemovedItem(String userIdToNotify, WorkspaceItem removedItem) {
return true;
}
/**
* {@inheritDoc}
*/
@Override
public boolean notifyUpdatedItem(String userIdToNotify, WorkspaceItem updatedItem) {
return true;
public boolean notifyUpdatedItem(String userIdToNotify, WorkspaceItem item) throws InternalErrorException {
Notification not = new Notification(
UUID.randomUUID().toString(),
NotificationType.WP_ITEM_UPDATED,
userIdToNotify, //user no notify
item.getId(), //the
new Date(),
"?folder="+item.getParent().getId()+"&item="+item.getId(),
"has updated an item ("+ item.getName() +") on your workspace shared folder ("+ item.getParent().getName() +")",
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
aslSession.getUserAvatarId());
return getStoreInstance().saveNotification(not);
}
/**
* {@inheritDoc}
@ -85,39 +191,63 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
"messageid_not_provided", //the
new Date(),
"",
" has sent you a message with subject: " + subject,
"has sent you a message with subject: " + subject,
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
aslSession.getUserAvatarId());
return getStoreInstance().saveNotification(not);
}
/**
* {@inheritDoc}
*/
@Override
public boolean notifyOwnCommentReply(String userIdToNotify, Comment comment) {
return true;
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(),
"?feedid="+feedid,
"commented on your post: " + feedText,
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
aslSession.getUserAvatarId());
return getStoreInstance().saveNotification(not);
}
/**
* {@inheritDoc}
*/
@Override
public boolean notifyCommentReply(String userIdToNotify, Comment comment) {
return true;
public boolean notifyCommentReply(String userIdToNotify, String feedid, String feedText) {
//TODO: missing implementation
return false;
}
/**
* {@inheritDoc}
*/
@Override
public boolean notifyLikedFeed(String userIdToNotify, Feed likedFeed) {
return true;
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(),
"?feedid="+feedid,
"likes your post: " + feedText,
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
aslSession.getUserAvatarId());
return getStoreInstance().saveNotification(not);
}
@Override
public boolean notifyJobStatus(String userIdToNotify,
ApplicationProfile executingJobApId, RunningJob job) {
// TODO Auto-generated method stub
public boolean notifyJobStatus(String userIdToNotify, ApplicationProfile executingJobApId, RunningJob job) {
//TODO: missing implementation
return false;
}

View File

@ -6,7 +6,6 @@ import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.RunningJob;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.portlets.user.homelibrary.home.workspace.sharing.WorkspaceMessage;
/**
*
* @author Massimiliano Assante, ISTI-CNR
@ -21,7 +20,7 @@ public interface NotificationsManager {
* @param sharedFolder the shared {@link WorkspaceFolder}
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyFolderSharing(String userIdToNotify, WorkspaceFolder sharedFolder);
boolean notifyFolderSharing(String userIdToNotify, WorkspaceFolder sharedFolder) throws Exception;
/**
* use to notify a user that a new user was added in on of his workspace shared folder
*
@ -30,7 +29,7 @@ public interface NotificationsManager {
* @param newAddedUserId the new user that was added
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyFolderAddedUser(String userIdToNotify, WorkspaceFolder sharedFolder, String newAddedUserId);
boolean notifyFolderAddedUser(String userIdToNotify, WorkspaceFolder sharedFolder, String newAddedUserId) throws Exception;
/**
* use to notify a user that an existing user was removed from one of his workspace shared folder
*
@ -39,28 +38,28 @@ public interface NotificationsManager {
* @param removedUserId the new user that was removed
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyFolderRemovedUser(String userIdToNotify, WorkspaceFolder sharedFolder, String removedUserId);
boolean notifyFolderRemovedUser(String userIdToNotify, WorkspaceFolder sharedFolder, String removedUserId) throws Exception;
/**
* 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 newItem the new shared {@link WorkspaceItem}
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyAddedItem(String userIdToNotify, WorkspaceItem newItem);
boolean notifyAddedItem(String userIdToNotify, WorkspaceItem item) throws Exception;
/**
* 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 removedItem the removed {@link WorkspaceItem}
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyRemovedItem(String userIdToNotify, WorkspaceItem removedItem);
boolean notifyRemovedItem(String userIdToNotify, WorkspaceItem item) throws Exception;
/**
* use to notify a user he got a workspace item updated from one of his workspace shared folder
* @param userIdToNotify the user you want to notify
* @param updatedItem the updated shared {@link WorkspaceItem}
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyUpdatedItem(String userIdToNotify, WorkspaceItem updatedItem);
boolean notifyUpdatedItem(String userIdToNotify, WorkspaceItem item) throws Exception;
/**
*
* @param userIdToNotify the user you want to notify
@ -69,30 +68,34 @@ public interface NotificationsManager {
*/
boolean notifyMessageReceived(String userIdToNotify, String subject);
/**
* use to notify a user that someone commented on his post
*
* @param userIdToNotify the user you want to notify
* @param comment the {@link Comment} instance to which someone replied to
* @param feedid the liked feedid
* @param feedText the liked feed text or a portion of it
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyOwnCommentReply(String userIdToNotify, Comment comment);
boolean notifyOwnCommentReply(String userIdToNotify, String feedid, String feedText);
/**
* use to notify a user that commented on a feed (Not his) that someone commented too
* use to notify a user that commented on a post (Not his) that someone commented too
*
* @param userIdToNotify the user you want to notify
* @param comment the {@link Comment} instance to which someone replied to
* @param feedid the liked feedid
* @param feedText the liked feed text or a portion of it
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyCommentReply(String userIdToNotify, Comment comment);
boolean notifyCommentReply(String userIdToNotify, String feedid, String feedText);
/**
* use to notify a user he got one of his feed liked
* use to notify a user he got one of his post liked
*
* @param userIdToNotify the user you want to notify
* @param likedFeed the {@link Feed} instance someone liked
* @param feedid the liked feedid
* @param feedText the liked feed text or a portion of it
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyLikedFeed(String userIdToNotify, Feed likedFeed);
boolean notifyLikedFeed(String userIdToNotify, String feedid, String feedText);
/**
* use to notify a user he got one of his feed liked
* use to notify a user he got one of his job finished
*
* @param userIdToNotify the user you want to notify
* @param executingApp the {@link ApplicationProfile} of the application from which the job was executed/lauched