Added shared method for messaging notifications

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/register-vre-users@119661 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2015-10-13 10:07:44 +00:00
parent 0ea30bc695
commit 59610a35cc
4 changed files with 26 additions and 21 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/register-vre-users-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/register-vre-users-1.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -31,5 +31,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/register-vre-users-1.3.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/register-vre-users-1.4.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -5,6 +5,9 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="invites-common-library-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/invites-common-library/invites-common-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="register-vre-users"/>
</wb-module>

11
pom.xml
View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.admin</groupId>
<artifactId>register-vre-users</artifactId>
<packaging>war</packaging>
<version>1.3.0-SNAPSHOT</version>
<version>1.4.0-SNAPSHOT</version>
<name>Register VRE Users</name>
<description>
Rigister VRE Users Portlet allow to select a user from the portal and add her to the VRE.
@ -72,6 +72,11 @@
<artifactId>custom-portal-handler</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>notifications-common-library</artifactId>
<version>[1.1.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslsocial</artifactId>
@ -114,7 +119,7 @@
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId>
<artifactId>common-scope-maps</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
@ -130,7 +135,7 @@
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<artifactId>portal-service</artifactId>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -1,11 +1,7 @@
package org.gcube.portlets.admin.manageusers.server;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
@ -15,6 +11,7 @@ import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portal.notifications.thread.MessageNotificationsThread;
import org.gcube.portlets.admin.manageusers.client.ManageUsersService;
import org.gcube.portlets.admin.manageusers.shared.PortalUserDTO;
import org.gcube.vomanagement.usermanagement.GroupManager;
@ -42,8 +39,6 @@ public class ManageUsersServiceImpl extends RemoteServiceServlet implements Man
private GroupManager groupM = new LiferayGroupManager();
private UserManager userM = new LiferayUserManager();
//this prop is needed for expando attributes
private static final String ADMIN_USERNAME = "administratorUsername";
private final static String POSITION = "POSITION";
private final static String LABS = "LABS";
@ -102,7 +97,6 @@ public class ManageUsersServiceImpl extends RemoteServiceServlet implements Man
*
* @return A list with the username of the unregistered users
*/
@SuppressWarnings("unchecked")
public ArrayList<PortalUserDTO> getNonBelongingUsersForVRE() {
try {
@ -174,17 +168,20 @@ public class ManageUsersServiceImpl extends RemoteServiceServlet implements Man
private boolean sendNotificationToUser(PortalUserDTO addressee) throws Exception {
ASLSession session = getASLSession();
Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername());
ArrayList<String> toSend = new ArrayList<String>();
toSend.add(addressee.getId());
List<String> recipientIds = new ArrayList<String>();
recipientIds.add(addressee.getId());
String subject = "Registration to Group Notification";
String body = "Dear "+addressee.getName()+", \n\n" + session.getUserFullName() + " has registered you to the group " + getASLSession().getGroupName()+".";
workspace.getWorkspaceMessageManager().sendMessageToPortalLogins(subject, body, new ArrayList<String>(), toSend);
NotificationsManager nnm = new ApplicationNotificationsManager(getASLSession());
if (nnm.notifyMessageReceived(addressee.getId(), subject)) {
_log.trace("Sent Notification: " + subject + " OK");
return true;
}
return false;
String messageId = workspace.getWorkspaceMessageManager().sendMessageToPortalLogins(subject, body, new ArrayList<String>(), recipientIds);
_log.debug("Sending message notification to: " + recipientIds.toString());
NotificationsManager nm = new ApplicationNotificationsManager(getASLSession());
Thread thread = new Thread(new MessageNotificationsThread(recipientIds, messageId, subject, body, nm));
thread.start();
return (messageId != null);
}
/**