From b6cc3f90329836b6f0cf1adde40174043bf6447e Mon Sep 17 00:00:00 2001 From: "massimiliano.assante" Date: Wed, 9 Jan 2013 16:47:22 +0000 Subject: [PATCH] removed portletXClassName for NotificationsManager why was even there? git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@67400 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../ApplicationNotificationsManager.java | 30 +++++++++++++++---- .../social/NotificationsManager.java | 4 +-- .../social/SocialPortalBridge.java | 8 +++++ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java index 34be3d3..1b2a073 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java @@ -1,9 +1,15 @@ package org.gcube.applicationsupportlayer.social; +import java.util.Date; +import java.util.UUID; + 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.workspace.WorkspaceFolder; import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; @@ -16,13 +22,14 @@ import org.gcube.portlets.user.homelibrary.home.workspace.sharing.WorkspaceMessa * use to notify users from within your application */ public class ApplicationNotificationsManager extends SocialPortalBridge implements NotificationsManager { + static GCUBEClientLog _log = new GCUBEClientLog(ApplicationNotificationsManager.class); /** * * @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); + public ApplicationNotificationsManager(ASLSession session) { + super(session); } /** * {@inheritDoc} @@ -70,8 +77,21 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen * {@inheritDoc} */ @Override - public boolean notifyMessageReceived(String userIdToNotify, WorkspaceMessage message) { - return true; + 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(), + "", + " has sent you a message with subject: " + subject, + false, + aslSession.getUsername(), + aslSession.getUserFullName(), + aslSession.getUserAvatarId()); + + return getStoreInstance().saveNotification(not); } /** * {@inheritDoc} @@ -101,6 +121,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen return false; } - + } diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java index 3e59aab..2ad9c27 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java @@ -64,10 +64,10 @@ public interface NotificationsManager { /** * * @param userIdToNotify the user you want to notify - * @param message the {@link WorkspaceMessage} sent + * @param subject the subject of the message sent * @return true if the notification is correctly delivered, false otherwise */ - boolean notifyMessageReceived(String userIdToNotify, WorkspaceMessage message); + boolean notifyMessageReceived(String userIdToNotify, String subject); /** * * @param userIdToNotify the user you want to notify diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/SocialPortalBridge.java b/src/main/java/org/gcube/applicationsupportlayer/social/SocialPortalBridge.java index 3d6d95a..70d05c4 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/SocialPortalBridge.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/SocialPortalBridge.java @@ -39,6 +39,14 @@ public class SocialPortalBridge { this.aslSession = session; this.applicationProfile = getProfileFromInfrastrucure(portletClassName); } + /** + * + * @param session + */ + public SocialPortalBridge(ASLSession session) { + this.aslSession = session; + this.applicationProfile = null; + } /** * * @return the unique instance of the store