diff --git a/.classpath b/.classpath index cfbe319..26b9e5f 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + @@ -31,5 +31,5 @@ - + diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 7aaf430..7f8bd6a 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -5,6 +5,9 @@ + + uses + diff --git a/pom.xml b/pom.xml index 8f0486d..fe44161 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.gcube.portlets.admin register-vre-users war - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT Register VRE Users Rigister VRE Users Portlet allow to select a user from the portal and add her to the VRE. @@ -72,6 +72,11 @@ custom-portal-handler provided + + org.gcube.portal + notifications-common-library + [1.1.0-SNAPSHOT, 2.0.0-SNAPSHOT) + org.gcube.applicationsupportlayer aslsocial @@ -114,7 +119,7 @@ org.gcube.core - common-scope-maps + common-scope-maps provided @@ -130,7 +135,7 @@ com.liferay.portal - portal-service + portal-service provided diff --git a/src/main/java/org/gcube/portlets/admin/manageusers/server/ManageUsersServiceImpl.java b/src/main/java/org/gcube/portlets/admin/manageusers/server/ManageUsersServiceImpl.java index 7f86069..39a7796 100644 --- a/src/main/java/org/gcube/portlets/admin/manageusers/server/ManageUsersServiceImpl.java +++ b/src/main/java/org/gcube/portlets/admin/manageusers/server/ManageUsersServiceImpl.java @@ -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 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 toSend = new ArrayList(); - toSend.add(addressee.getId()); + + List recipientIds = new ArrayList(); + 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(), 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(), 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); } /**