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>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>invites-common-library</artifactId>
|
<artifactId>invites-common-library</artifactId>
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
<version>1.3.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>
|
<description>
|
||||||
gCube Invites Common Library is a common library containing shared code for Inviting external users to portal VREs.
|
gCube Invites Common Library is a common library containing shared code for Inviting external users to portal VREs.
|
||||||
|
@ -44,8 +44,8 @@
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>custom-portal-handler</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -68,22 +68,11 @@
|
||||||
<artifactId>jsoup</artifactId>
|
<artifactId>jsoup</artifactId>
|
||||||
<version>1.6.2</version>
|
<version>1.6.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
|
||||||
<artifactId>aslcore</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>social-networking-library</artifactId>
|
<artifactId>social-networking-library</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>servlet-api</artifactId>
|
|
||||||
<version>2.4</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.mail</groupId>
|
<groupId>com.sun.mail</groupId>
|
||||||
<artifactId>javax.mail</artifactId>
|
<artifactId>javax.mail</artifactId>
|
||||||
|
|
|
@ -10,7 +10,6 @@ import java.util.UUID;
|
||||||
import javax.mail.internet.AddressException;
|
import javax.mail.internet.AddressException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.portal.mailing.EmailNotification;
|
import org.gcube.common.portal.mailing.EmailNotification;
|
||||||
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
||||||
|
@ -64,7 +63,6 @@ public class InvitesManager {
|
||||||
|
|
||||||
public InviteOperationResult sendInvite(
|
public InviteOperationResult sendInvite(
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
ASLSession aslSession,
|
|
||||||
String portalSenderEmail,
|
String portalSenderEmail,
|
||||||
String portalURL,
|
String portalURL,
|
||||||
String name,
|
String name,
|
||||||
|
@ -72,18 +70,20 @@ public class InvitesManager {
|
||||||
String email,
|
String email,
|
||||||
String vreDescription) {
|
String vreDescription) {
|
||||||
|
|
||||||
String username = aslSession.getUsername();
|
GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(request);
|
||||||
String fromFullName = aslSession.getUserFullName();
|
String username = currUser.getUsername();
|
||||||
|
String fromFullName = currUser.getFullname();
|
||||||
String controlcode = UUID.randomUUID().toString();
|
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;
|
InviteOperationResult result = null;
|
||||||
boolean emailResult = false;
|
boolean emailResult = false;
|
||||||
try {
|
try {
|
||||||
String vreName = aslSession.getGroupName();
|
String vreName = PortalContext.getConfiguration().getCurrentGroupName(request);
|
||||||
result = store.saveInvite(invite);
|
result = store.saveInvite(invite);
|
||||||
emailResult = sendInviteEmail(request, aslSession, portalSenderEmail, portalURL, name, lastName, email, vreDescription);
|
emailResult = sendInviteEmail(request, vreName, portalSenderEmail, portalURL, name, lastName, email, vreDescription);
|
||||||
notifyInviteSent(request, username, aslSession.getScopeName(), invite, vreName);
|
notifyInviteSent(request, username, currScope, invite, vreName);
|
||||||
|
|
||||||
} catch (AddressException e) {
|
} catch (AddressException e) {
|
||||||
_log.error("Email not valid " + e.getMessage());
|
_log.error("Email not valid " + e.getMessage());
|
||||||
|
@ -96,7 +96,7 @@ public class InvitesManager {
|
||||||
|
|
||||||
private Boolean sendInviteEmail(
|
private Boolean sendInviteEmail(
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
ASLSession aslSession,
|
String vreName,
|
||||||
String portalSenderEmail,
|
String portalSenderEmail,
|
||||||
String portalURL,
|
String portalURL,
|
||||||
String name,
|
String name,
|
||||||
|
@ -104,21 +104,20 @@ public class InvitesManager {
|
||||||
String email,
|
String email,
|
||||||
String vreDescription) {
|
String vreDescription) {
|
||||||
|
|
||||||
String vreName = aslSession.getGroupName();
|
GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(request);
|
||||||
String fromFullName = aslSession.getUserFullName();
|
String fromFullName = currUser.getFullname();
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String subject = "Join me on " + vreName;
|
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 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";
|
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(
|
EmailNotification mailToAdmin = new EmailNotification(
|
||||||
email ,
|
email ,
|
||||||
subject,
|
subject,
|
||||||
getHTMLEmail(aslSession, name, lastName, email, fromFullName, vreName, vreDescription, linkToAcceptInvite, linkToCreateAccount),
|
getHTMLEmail(name, lastName, email, fromFullName, vreName, vreDescription, linkToAcceptInvite, linkToCreateAccount),
|
||||||
request);
|
request);
|
||||||
mailToAdmin.sendEmail();
|
mailToAdmin.sendEmail();
|
||||||
_log.debug("Sent message successfully to " + email );
|
_log.debug("Sent message successfully to " + email );
|
||||||
|
@ -143,7 +142,6 @@ public class InvitesManager {
|
||||||
* @return the email text
|
* @return the email text
|
||||||
*/
|
*/
|
||||||
private String getHTMLEmail(
|
private String getHTMLEmail(
|
||||||
ASLSession aslSession,
|
|
||||||
String name,
|
String name,
|
||||||
String lastName,
|
String lastName,
|
||||||
String email,
|
String email,
|
||||||
|
|
Loading…
Reference in New Issue