added email subjects and redirect link for TDM

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@115375 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2015-06-15 09:10:43 +00:00
parent b200758ce6
commit 0a30c4474d
4 changed files with 88 additions and 45 deletions

View File

@ -60,6 +60,7 @@
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId> <artifactId>social-networking-library</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.dvos</groupId> <groupId>org.gcube.dvos</groupId>

View File

@ -29,6 +29,8 @@ import org.gcube.vomanagement.usermanagement.model.UserModel;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.liferay.portal.kernel.util.Tuple;
/** /**
* *
* @author Massimiliano Assante, ISTI-CNR * @author Massimiliano Assante, ISTI-CNR
@ -815,21 +817,52 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public boolean notifyTDMTabularResourceSharing(String userIdToNotify, public boolean notifyTDMTabularResourceSharing(String userIdToNotify, String tabularResourceName, String encodedTabularResourceParams) throws Exception {
String tabularResourceName, String encodedTabularResourceParams) throws Exception { Notification not = new Notification(
// TODO Auto-generated method stub UUID.randomUUID().toString(),
return true; 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} * {@inheritDoc}
*/ */
@Override @Override
public boolean notifyTDMObjectSharing(String userIdToNotify, public boolean notifyTDMObjectSharing(String userIdToNotify, NotificationType type, String tdmObjectName, String encodedTabularResourceParams) throws Exception {
NotificationType type, String tdmObjectName, if (type != NotificationType.TDM_RULE_SHARE || type != NotificationType.TDM_TEMPLATE_SHARE)
String encodedTabularResourceParams) throw new IllegalArgumentException("Type must be either TDM_RULE_SHARE or TDM_TEMPLATE_SHARE");
throws Exception {
// TODO Auto-generated method stub String notificationText = "shared the Tabular Data Manager";
return true; 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);
} }
/** /**

View File

@ -316,6 +316,12 @@ public class EmailPlugin {
return vreName +": Edited event in a shared calendar"; return vreName +": Edited event in a shared calendar";
case CALENDAR_DELETED_EVENT: case CALENDAR_DELETED_EVENT:
return vreName +": Deleted in a shared calendar"; 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: default:
return "You have a new Notification"; return "You have a new Notification";
} }
@ -408,6 +414,11 @@ public class EmailPlugin {
case CALENDAR_DELETED_EVENT: case CALENDAR_DELETED_EVENT:
actionLink.append("\">.").append(" Go to Calendar").append("</a>"); actionLink.append("\">.").append(" Go to Calendar").append("</a>");
break; break;
case TDM_TAB_RESOURCE_SHARE:
case TDM_RULE_SHARE:
case TDM_TEMPLATE_SHARE:
actionLink.append("\">.").append(" Go to Tabular Data Manager").append("</a>");
default: default:
actionLink.append("\">.").append("").append("</a>"); actionLink.append("\">.").append("").append("</a>");
break; break;

View File

@ -1,38 +1,35 @@
package org.gcube.applicationsupportlayer.social; 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.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import junit.framework.TestSuite; 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. * Unit test for simple App.
*/ */
public class AppTest public class AppTest
extends TestCase extends TestCase
{ {
/** /**
* Create the test case * Create the test case
* *
* @param testName name of the test case * @param testName name of the test case
*/ */
public AppTest( String testName ) public AppTest( String testName )
{ {
super( testName ); super( testName );
} }
/** /**
* @return the suite of tests being tested * @return the suite of tests being tested
*/ */
public static Test suite() public static Test suite()
{ {
return new TestSuite( AppTest.class ); return new TestSuite( AppTest.class );
} }
/** /**
@ -40,19 +37,20 @@ public class AppTest
* @return the session * @return the session
*/ */
private ASLSession getTestSession() { private ASLSession getTestSession() {
ASLSession toReturn = SessionManager.getInstance().getASLSession("11", "test.user"); ASLSession toReturn = SessionManager.getInstance().getASLSession("11", "andrea.rossi");
toReturn.setScope("/gcube"); toReturn.setScope("/gcube/devsec/devVRE");
toReturn.setUserFullName("Pico Pallino"); toReturn.setUserFullName("Andrea Rossi");
toReturn.setUserEmailAddress("test@test123.com"); toReturn.setUserEmailAddress("m.assante@gmail.com");
toReturn.setGroupModelInfos("TheGroup", 123L); toReturn.setGroupModelInfos("TheGroup", 123L);
return toReturn; return toReturn;
} }
/** /**
* * @throws Exception
*/ *
public void testApp() { */
assertTrue( true ); public void testApp() throws Exception {
}
}
} }