|
|
|
@ -10,7 +10,6 @@ import java.util.UUID;
|
|
|
|
|
import javax.mail.internet.AddressException;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
|
|
import org.gcube.application.framework.core.session.ASLSession;
|
|
|
|
|
import org.gcube.common.portal.PortalContext;
|
|
|
|
|
import org.gcube.common.portal.mailing.EmailNotification;
|
|
|
|
|
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
|
|
|
@ -64,7 +63,6 @@ public class InvitesManager {
|
|
|
|
|
|
|
|
|
|
public InviteOperationResult sendInvite(
|
|
|
|
|
HttpServletRequest request,
|
|
|
|
|
ASLSession aslSession,
|
|
|
|
|
String portalSenderEmail,
|
|
|
|
|
String portalURL,
|
|
|
|
|
String name,
|
|
|
|
@ -72,18 +70,20 @@ public class InvitesManager {
|
|
|
|
|
String email,
|
|
|
|
|
String vreDescription) {
|
|
|
|
|
|
|
|
|
|
String username = aslSession.getUsername();
|
|
|
|
|
String fromFullName = aslSession.getUserFullName();
|
|
|
|
|
GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(request);
|
|
|
|
|
String username = currUser.getUsername();
|
|
|
|
|
String fromFullName = currUser.getFullname();
|
|
|
|
|
String controlcode = UUID.randomUUID().toString();
|
|
|
|
|
String currScope = PortalContext.getConfiguration().getCurrentScope(request);
|
|
|
|
|
|
|
|
|
|
Invite invite = new Invite(UUID.randomUUID().toString(), username, aslSession.getScopeName(), email, controlcode, InviteStatus.PENDING, new Date(), fromFullName);
|
|
|
|
|
Invite invite = new Invite(UUID.randomUUID().toString(), username, currScope, email, controlcode, InviteStatus.PENDING, new Date(), fromFullName);
|
|
|
|
|
InviteOperationResult result = null;
|
|
|
|
|
boolean emailResult = false;
|
|
|
|
|
try {
|
|
|
|
|
String vreName = aslSession.getGroupName();
|
|
|
|
|
String vreName = PortalContext.getConfiguration().getCurrentGroupName(request);
|
|
|
|
|
result = store.saveInvite(invite);
|
|
|
|
|
emailResult = sendInviteEmail(request, aslSession, portalSenderEmail, portalURL, name, lastName, email, vreDescription);
|
|
|
|
|
notifyInviteSent(request, username, aslSession.getScopeName(), invite, vreName);
|
|
|
|
|
emailResult = sendInviteEmail(request, vreName, portalSenderEmail, portalURL, name, lastName, email, vreDescription);
|
|
|
|
|
notifyInviteSent(request, username, currScope, invite, vreName);
|
|
|
|
|
|
|
|
|
|
} catch (AddressException e) {
|
|
|
|
|
_log.error("Email not valid " + e.getMessage());
|
|
|
|
@ -96,7 +96,7 @@ public class InvitesManager {
|
|
|
|
|
|
|
|
|
|
private Boolean sendInviteEmail(
|
|
|
|
|
HttpServletRequest request,
|
|
|
|
|
ASLSession aslSession,
|
|
|
|
|
String vreName,
|
|
|
|
|
String portalSenderEmail,
|
|
|
|
|
String portalURL,
|
|
|
|
|
String name,
|
|
|
|
@ -104,21 +104,20 @@ public class InvitesManager {
|
|
|
|
|
String email,
|
|
|
|
|
String vreDescription) {
|
|
|
|
|
|
|
|
|
|
String vreName = aslSession.getGroupName();
|
|
|
|
|
String fromFullName = aslSession.getUserFullName();
|
|
|
|
|
|
|
|
|
|
GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(request);
|
|
|
|
|
String fromFullName = currUser.getFullname();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String subject = "Join me on " + vreName;
|
|
|
|
|
|
|
|
|
|
long groupId = aslSession.getGroupId();
|
|
|
|
|
long groupId = PortalContext.getConfiguration().getCurrentGroupId(request);
|
|
|
|
|
final String linkToAcceptInvite = portalURL + PortalContext.getConfiguration().getSiteLandingPagePath(request)+"/explore?siteId="+groupId;
|
|
|
|
|
final String linkToCreateAccount = portalURL + "/?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";
|
|
|
|
|
|
|
|
|
|
EmailNotification mailToAdmin = new EmailNotification(
|
|
|
|
|
email ,
|
|
|
|
|
subject,
|
|
|
|
|
getHTMLEmail(aslSession, name, lastName, email, fromFullName, vreName, vreDescription, linkToAcceptInvite, linkToCreateAccount),
|
|
|
|
|
getHTMLEmail(name, lastName, email, fromFullName, vreName, vreDescription, linkToAcceptInvite, linkToCreateAccount),
|
|
|
|
|
request);
|
|
|
|
|
mailToAdmin.sendEmail();
|
|
|
|
|
_log.debug("Sent message successfully to " + email );
|
|
|
|
@ -143,7 +142,6 @@ public class InvitesManager {
|
|
|
|
|
* @return the email text
|
|
|
|
|
*/
|
|
|
|
|
private String getHTMLEmail(
|
|
|
|
|
ASLSession aslSession,
|
|
|
|
|
String name,
|
|
|
|
|
String lastName,
|
|
|
|
|
String email,
|
|
|
|
|