diff --git a/pom.xml b/pom.xml
index bfc369a..4754db4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
org.gcube.portal
invites-common-library
- 1.4.0-SNAPSHOT
+ 1.5.0-SNAPSHOT
jar
gCube Invites Common Library is a common library containing shared code for Inviting external users to portal VREs.
diff --git a/src/main/java/org/gcube/portal/invites/InvitesManager.java b/src/main/java/org/gcube/portal/invites/InvitesManager.java
index a5356ec..1fb3fbd 100644
--- a/src/main/java/org/gcube/portal/invites/InvitesManager.java
+++ b/src/main/java/org/gcube/portal/invites/InvitesManager.java
@@ -10,7 +10,9 @@ import java.util.UUID;
import javax.mail.internet.AddressException;
import javax.servlet.http.HttpServletRequest;
+import org.apache.commons.codec.binary.Base64;
import org.gcube.common.portal.PortalContext;
+import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
import org.gcube.portal.databook.server.DatabookStore;
import org.gcube.portal.databook.shared.Invite;
@@ -39,6 +41,10 @@ import org.slf4j.LoggerFactory;
*/
public class InvitesManager {
private static final Logger _log = LoggerFactory.getLogger(InvitesManager.class);
+ private static final String SITEID_ATTR ="siteId";
+ private static final String INVITEID_ATTR ="inviteId";
+ private static final String INVITE_PAGE_ENDPOINT = "manage-invite";
+
private static InvitesManager instance;
private static DatabookStore store;
@@ -82,7 +88,7 @@ public class InvitesManager {
try {
String vreName = PortalContext.getConfiguration().getCurrentGroupName(request);
result = store.saveInvite(invite);
- emailResult = sendInviteEmail(request, currUser, vreName, name, email, vreDescription);
+ emailResult = sendInviteEmail(request, invite, currUser, vreName, name, email, vreDescription);
notifyInviteSent(request, currUser, currScope, invite, vreName);
} catch (AddressException e) {
@@ -96,31 +102,44 @@ public class InvitesManager {
private Boolean sendInviteEmail(
HttpServletRequest request,
+ Invite invite,
GCubeUser currUser,
String vreName,
String name,
String email,
String vreDescription) {
-
+
PortalContext pContext = PortalContext.getConfiguration();
String gatewayURL = pContext.getGatewayURL(request);
String gatewayName = pContext.getGatewayName(request);
-
+
try {
String subject = "Join me on " + vreName + " VRE";
long groupId = PortalContext.getConfiguration().getCurrentGroupId(request);
- final String linkToAcceptInvite = gatewayURL + PortalContext.getConfiguration().getSiteLandingPagePath(request)+"/explore?siteId="+groupId;
- final String linkToCreateAccount = gatewayURL + "/?p_p_id=58&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&saveLastPath=false&_58_struts_action=%2Flogin%2Fcreate_account";
-
+
+ StringBuilder getParamsEncoded = new StringBuilder(new String(Base64.encodeBase64(INVITEID_ATTR.getBytes())))
+ .append("=")
+ .append(new String(Base64.encodeBase64(invite.getKey().getBytes())))
+ .append("&")
+ .append(new String(Base64.encodeBase64(SITEID_ATTR.getBytes())))
+ .append("=")
+ .append(new String(Base64.encodeBase64((""+groupId).getBytes())));
+
+ StringBuilder linkToAcceptInvite = new StringBuilder(gatewayURL)
+ .append(PortalContext.getConfiguration().getSiteLandingPagePath(request))
+ .append(INVITE_PAGE_ENDPOINT)
+ .append("?")
+ .append(getParamsEncoded);
+
EmailTemplateService.send(
subject,
- new TemplatedJoinMeInvite(gatewayName, gatewayURL, currUser, name, vreName, vreDescription, linkToAcceptInvite, linkToCreateAccount),
+ new TemplatedJoinMeInvite(gatewayName, gatewayURL, currUser, name, vreName, vreDescription, linkToAcceptInvite.toString()),
request,
new Recipient(email), new Recipient(new EmailAddress(currUser.getEmail()), RecipientType.CC));
-
-
+
+
_log.debug("Join Me Invite email message sent successfully to " + email );
} catch (Exception mex) {
mex.printStackTrace();
@@ -154,7 +173,7 @@ public class InvitesManager {
adminRecipients.toArray(new Recipient[adminRecipients.size()]));
}
-
+
private static ArrayList getAdministratorsEmails(String scope) {
LiferayUserManager userManager = new LiferayUserManager();
LiferayGroupManager groupManager = new LiferayGroupManager();
@@ -197,5 +216,5 @@ public class InvitesManager {
return adminEmailsList;
}
-
+
}