diff --git a/pom.xml b/pom.xml index f7c9b88..983667b 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,7 @@ org.gcube.portal social-networking-library + provided org.gcube.dvos diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java index d5ce0a3..647fb40 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java @@ -29,6 +29,8 @@ import org.gcube.vomanagement.usermanagement.model.UserModel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.liferay.portal.kernel.util.Tuple; + /** * * @author Massimiliano Assante, ISTI-CNR @@ -815,21 +817,52 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen * {@inheritDoc} */ @Override - public boolean notifyTDMTabularResourceSharing(String userIdToNotify, - String tabularResourceName, String encodedTabularResourceParams) throws Exception { - // TODO Auto-generated method stub - return true; + public boolean notifyTDMTabularResourceSharing(String userIdToNotify, String tabularResourceName, String encodedTabularResourceParams) throws Exception { + Notification not = new Notification( + UUID.randomUUID().toString(), + NotificationType.TDM_TAB_RESOURCE_SHARE, + userIdToNotify, //user no notify + tabularResourceName, + new Date(), + getApplicationUrl()+"?"+encodedTabularResourceParams, + "shared the Tabular Resource \""+ tabularResourceName +"\" with you", + false, + aslSession.getUsername(), + aslSession.getUserFullName(), + aslSession.getUserAvatarId()); + + return saveNotification(not); } /** * {@inheritDoc} */ @Override - public boolean notifyTDMObjectSharing(String userIdToNotify, - NotificationType type, String tdmObjectName, - String encodedTabularResourceParams) - throws Exception { - // TODO Auto-generated method stub - return true; + public boolean notifyTDMObjectSharing(String userIdToNotify, NotificationType type, String tdmObjectName, String encodedTabularResourceParams) throws Exception { + if (type != NotificationType.TDM_RULE_SHARE || type != NotificationType.TDM_TEMPLATE_SHARE) + throw new IllegalArgumentException("Type must be either TDM_RULE_SHARE or TDM_TEMPLATE_SHARE"); + + String notificationText = "shared the Tabular Data Manager"; + notificationText += (type == NotificationType.TDM_RULE_SHARE) ? " Rule " : " Template "; + notificationText += tdmObjectName + " with you"; + + String url = getApplicationUrl(); + if (encodedTabularResourceParams != null && encodedTabularResourceParams.compareTo("") != 0) + url += "?"+encodedTabularResourceParams; + + Notification not = new Notification( + UUID.randomUUID().toString(), + type, + userIdToNotify, //user no notify + tdmObjectName, + new Date(), + url, + notificationText, + false, + aslSession.getUsername(), + aslSession.getUserFullName(), + aslSession.getUserAvatarId()); + + return saveNotification(not); } /** diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/mailing/EmailPlugin.java b/src/main/java/org/gcube/applicationsupportlayer/social/mailing/EmailPlugin.java index 6004369..fba6469 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/mailing/EmailPlugin.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/mailing/EmailPlugin.java @@ -316,6 +316,12 @@ public class EmailPlugin { return vreName +": Edited event in a shared calendar"; case CALENDAR_DELETED_EVENT: return vreName +": Deleted in a shared calendar"; + case TDM_TAB_RESOURCE_SHARE: + return notification2Save.getSenderFullName() + " shared a Tabular Resource with you on " + vreName; + case TDM_RULE_SHARE: + return notification2Save.getSenderFullName() + " shared a Tabular Data Manager Rule with you on " + vreName; + case TDM_TEMPLATE_SHARE: + return notification2Save.getSenderFullName() + " shared a Tabular Data Manager Template with you on " + vreName; default: return "You have a new Notification"; } @@ -408,6 +414,11 @@ public class EmailPlugin { case CALENDAR_DELETED_EVENT: actionLink.append("\">.").append(" Go to Calendar").append(""); break; + case TDM_TAB_RESOURCE_SHARE: + case TDM_RULE_SHARE: + case TDM_TEMPLATE_SHARE: + actionLink.append("\">.").append(" Go to Tabular Data Manager").append(""); + default: actionLink.append("\">.").append("").append(""); break; diff --git a/src/test/java/org/gcube/applicationsupportlayer/social/AppTest.java b/src/test/java/org/gcube/applicationsupportlayer/social/AppTest.java index 1f2acb3..20dbfc7 100644 --- a/src/test/java/org/gcube/applicationsupportlayer/social/AppTest.java +++ b/src/test/java/org/gcube/applicationsupportlayer/social/AppTest.java @@ -1,38 +1,35 @@ package org.gcube.applicationsupportlayer.social; -import org.gcube.application.framework.core.session.ASLSession; -import org.gcube.application.framework.core.session.SessionManager; -import org.gcube.applicationsupportlayer.social.mailing.EmailPlugin; -import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; -import org.gcube.portal.databook.shared.Notification; - import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; +import org.gcube.application.framework.core.session.ASLSession; +import org.gcube.application.framework.core.session.SessionManager; + /** * Unit test for simple App. */ public class AppTest - extends TestCase +extends TestCase { - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } /** @@ -40,19 +37,20 @@ public class AppTest * @return the session */ private ASLSession getTestSession() { - - ASLSession toReturn = SessionManager.getInstance().getASLSession("11", "test.user"); - toReturn.setScope("/gcube"); - toReturn.setUserFullName("Pico Pallino"); - toReturn.setUserEmailAddress("test@test123.com"); + + ASLSession toReturn = SessionManager.getInstance().getASLSession("11", "andrea.rossi"); + toReturn.setScope("/gcube/devsec/devVRE"); + toReturn.setUserFullName("Andrea Rossi"); + toReturn.setUserEmailAddress("m.assante@gmail.com"); toReturn.setGroupModelInfos("TheGroup", 123L); - + return toReturn; } - /** - * - */ - public void testApp() { - assertTrue( true ); - } + /** + * @throws Exception + * + */ + public void testApp() throws Exception { + + } }