From 2ff8f3ad0cc89be27aa8a66e334e095c518dd509 Mon Sep 17 00:00:00 2001 From: "massimiliano.assante" Date: Mon, 25 Mar 2013 11:08:25 +0000 Subject: [PATCH] notifyFolderAddedUsers method added git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@71685 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../ApplicationNotificationsManager.java | 36 ++++++++++++++++++- .../social/NotificationsManager.java | 12 ++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java index d3bae15..5b3de43 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java @@ -157,6 +157,40 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen return saveNotification(not); } + /** + * {@inheritDoc} + * @throws UserManagementPortalException + * @throws UserRetrievalFault + * @throws UserManagementSystemException + */ + @Override + public boolean notifyFolderAddedUsers(String userIdToNotify, WorkspaceFolder sharedFolder, List 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(" "); + + Notification not = new Notification( + UUID.randomUUID().toString(), + NotificationType.WP_FOLDER_ADDEDUSER, + userIdToNotify, //user no notify + sharedFolder.getId(), //the + new Date(), + "?oid="+sharedFolder.getId(), + "added "+ addedUsersFullNames +" to your workspace shared folder "+ sharedFolder.getName(), + false, + aslSession.getUsername(), + aslSession.getUserFullName(), + aslSession.getUserAvatarId()); + + return saveNotification(not); + } + + return false; + } /** * {@inheritDoc} */ @@ -453,5 +487,5 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen aslSession.getUserAvatarId()); return saveNotification(not); - } + } } diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java index bc70c4b..3cb483a 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java @@ -1,5 +1,7 @@ package org.gcube.applicationsupportlayer.social; +import java.util.List; + import org.gcube.portal.databook.shared.ApplicationProfile; import org.gcube.portal.databook.shared.RunningJob; import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder; @@ -28,7 +30,6 @@ public interface NotificationsManager { * @return true if the notification is correctly delivered, false otherwise */ boolean notifyFolderRenaming(String userIdToNotify, String previousName, String newName, String renamedFolderId) throws Exception; - /** /** * use to notify a user that a new user was added in on of his workspace shared folder * @@ -38,6 +39,15 @@ public interface NotificationsManager { * @return true if the notification is correctly delivered, false otherwise */ boolean notifyFolderAddedUser(String userIdToNotify, WorkspaceFolder sharedFolder, String newAddedUserId) throws Exception; + /** + * 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 sharedFolder the shared {@link WorkspaceFolder} + * @param newAddedUserIds List of new users that were added + * @return true if the notification is correctly delivered, false otherwise + */ + boolean notifyFolderAddedUsers(String userIdToNotify, WorkspaceFolder sharedFolder, List newAddedUserIds) throws Exception; /** * use to notify a user that an existing user was removed from one of his workspace shared folder *