removed ASL Session, ported to gCube Client Context
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portal/invites-common-library@134166 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
27d99c0ed6
commit
91079103f6
17
pom.xml
17
pom.xml
|
@ -12,7 +12,7 @@
|
|||
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>invites-common-library</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.3.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<description>
|
||||
gCube Invites Common Library is a common library containing shared code for Inviting external users to portal VREs.
|
||||
|
@ -44,8 +44,8 @@
|
|||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>custom-portal-handler</artifactId>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -68,22 +68,11 @@
|
|||
<artifactId>jsoup</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslcore</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>social-networking-library</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue