integrated with centralized email notification
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/join-vre@128318 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c3d2f0d456
commit
1e710f2430
6
pom.xml
6
pom.xml
|
@ -69,7 +69,6 @@
|
|||
<dependency>
|
||||
<groupId>com.github.gwtbootstrap</groupId>
|
||||
<artifactId>gwt-bootstrap</artifactId>
|
||||
<version>2.3.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
|
@ -115,9 +114,8 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>javax.mail-api</artifactId>
|
||||
<version>1.4.5</version>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -8,9 +8,7 @@ import java.util.List;
|
|||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
import org.gcube.common.portal.CustomAttributeKeys;
|
||||
import org.gcube.common.portal.GCubePortalConstants;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
||||
import org.gcube.portal.databook.server.DatabookStore;
|
||||
|
@ -29,6 +27,7 @@ import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemExcep
|
|||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeMembershipRequest;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
|
@ -375,7 +374,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
|||
if (optionalMessage == null || optionalMessage.compareTo("") == 0)
|
||||
optionalMessage = "none";
|
||||
try {
|
||||
LoginServiceUtil.addMembershipRequest(username, scope, optionalMessage, getPortalUrl(), PortalContext.getConfiguration().getGatewayName());
|
||||
LoginServiceUtil.addMembershipRequest(username, scope, optionalMessage, getThreadLocalRequest());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -395,7 +394,6 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
|||
try {
|
||||
ASLSession session = getASLSession();
|
||||
String username = session.getUsername();
|
||||
String gatewayURL = PortalContext.getConfiguration().getGatewayURL(getThreadLocalRequest());
|
||||
_log.debug("registerUser " +username + " to "+ scope);
|
||||
GCubeUser currUser = um.getUserByUsername(username);
|
||||
GroupManager gm = new LiferayGroupManager();
|
||||
|
@ -406,18 +404,17 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
|||
Thread.sleep(1000);
|
||||
um.acceptMembershipRequest(currUser.getUserId(), groupId, true, replierUsername, "Automatic acceptance request at " + new Date());
|
||||
_log.info("fakeRequest accepted");
|
||||
String gatewayName = PortalContext.getConfiguration().getGatewayName();
|
||||
if (isInvitation) {
|
||||
initStore();
|
||||
String inviteId = store.isExistingInvite(scope, session.getUserEmailAddress());
|
||||
if (inviteId != null) {
|
||||
Invite invite = store.readInvite(inviteId);
|
||||
store.setInviteStatus(scope, session.getUserEmailAddress(), InviteStatus.ACCEPTED);
|
||||
LoginServiceUtil.notifyUserAcceptedInvite(username, scope, gatewayURL, gatewayName, invite);
|
||||
LoginServiceUtil.notifyUserAcceptedInvite(username, scope, invite, getThreadLocalRequest());
|
||||
}
|
||||
}
|
||||
else {
|
||||
LoginServiceUtil.notifyUserSelfRegistration(username, scope, gatewayURL, gatewayName);
|
||||
LoginServiceUtil.notifyUserSelfRegistration(username, scope, getThreadLocalRequest());
|
||||
_log.info("notifyUserSelfRegistration sent");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.portal.mailing.EmailNotification;
|
||||
import org.gcube.portal.databook.shared.Invite;
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
|
@ -87,7 +90,10 @@ public class LoginServiceUtil {
|
|||
* @param scope .
|
||||
* @param optionalMessage .
|
||||
*/
|
||||
public static void addMembershipRequest(String username, String scope, String optionalMessage,String portalbasicurl, String gatewayName) throws Exception{
|
||||
public static void addMembershipRequest(String username, String scope, String optionalMessage, HttpServletRequest request) throws Exception{
|
||||
|
||||
String gatewayName = PortalContext.getConfiguration().getGatewayName(request);
|
||||
String portalbasicurl = PortalContext.getConfiguration().getGatewayURL(request);
|
||||
_log.info("gatewayName = " + gatewayName + " Message=" + optionalMessage);
|
||||
|
||||
|
||||
|
@ -130,7 +136,7 @@ public class LoginServiceUtil {
|
|||
|
||||
adminEmails.toArray(allMails);
|
||||
|
||||
EmailNotification mailToAdmin = new EmailNotification(allMails , "[" + gatewayName + "] - Join Request", body.toString());
|
||||
EmailNotification mailToAdmin = new EmailNotification(allMails , "[" + gatewayName + "] - Join Request", body.toString(), request);
|
||||
|
||||
mailToAdmin.sendEmail();
|
||||
}
|
||||
|
@ -140,15 +146,15 @@ public class LoginServiceUtil {
|
|||
* @param scope .
|
||||
* @param optionalMessage .
|
||||
*/
|
||||
public static void notifyUserSelfRegistration(String username, String scope, String portalbasicurl, String gatewayName) throws Exception {
|
||||
public static void notifyUserSelfRegistration(String username, String scope, HttpServletRequest request) throws Exception {
|
||||
|
||||
ArrayList<String> adminEmails = LoginServiceUtil.getAdministratorsEmails(scope);
|
||||
LiferayUserManager um = new LiferayUserManager();
|
||||
GCubeUser currUser = um.getUserByUsername(username);
|
||||
String name = currUser.getFirstName();
|
||||
String lastname = currUser.getLastName();
|
||||
|
||||
|
||||
String portalbasicurl = PortalContext.getConfiguration().getGatewayURL(request);
|
||||
String gatewayName = PortalContext.getConfiguration().getGatewayName(request);
|
||||
StringBuffer body = new StringBuffer();
|
||||
body.append("<p>Dear manager of "+ scope +",<br />this email message was automatically generated by " + portalbasicurl +" to inform you that ");
|
||||
body.append("</p>").append("<p>")
|
||||
|
@ -169,7 +175,7 @@ public class LoginServiceUtil {
|
|||
|
||||
adminEmails.toArray(allMails);
|
||||
|
||||
EmailNotification mailToAdmin = new EmailNotification(allMails , "[" + gatewayName + "] - Self Registration", body.toString());
|
||||
EmailNotification mailToAdmin = new EmailNotification(allMails , "[" + gatewayName + "] - Self Registration", body.toString(), request);
|
||||
|
||||
mailToAdmin.sendEmail();
|
||||
}
|
||||
|
@ -180,7 +186,10 @@ public class LoginServiceUtil {
|
|||
* @param scope .
|
||||
* @param optionalMessage .
|
||||
*/
|
||||
public static void notifyUserAcceptedInvite(String username, String scope, String portalbasicurl, String gatewayName, Invite invite) throws Exception {
|
||||
public static void notifyUserAcceptedInvite(String username, String scope, Invite invite, HttpServletRequest request) throws Exception {
|
||||
|
||||
String portalbasicurl = PortalContext.getConfiguration().getGatewayURL(request);
|
||||
String gatewayName = PortalContext.getConfiguration().getGatewayName(request);
|
||||
|
||||
ArrayList<String> adminEmails = LoginServiceUtil.getAdministratorsEmails(scope);
|
||||
|
||||
|
@ -212,7 +221,7 @@ public class LoginServiceUtil {
|
|||
|
||||
adminEmails.toArray(allMails);
|
||||
|
||||
EmailNotification mailToAdmin = new EmailNotification(allMails , "[" + gatewayName + "] - Accepted Invitation", body.toString());
|
||||
EmailNotification mailToAdmin = new EmailNotification(allMails , "[" + gatewayName + "] - Accepted Invitation", body.toString(), request);
|
||||
|
||||
mailToAdmin.sendEmail();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue