Massimiliano Assante 2016-11-15 11:14:43 +00:00
parent 732046f811
commit d0665914ed
2 changed files with 14 additions and 41 deletions

20
pom.xml
View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
<artifactId>invite-friends-widget</artifactId> <artifactId>invite-friends-widget</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.2.0-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<name>gCube Invites widget</name> <name>gCube Invites widget</name>
<description> <description>
gCube Invites widget Widget is a GWT Widget that can be used to automatically send invites to VRE users gCube Invites widget Widget is a GWT Widget that can be used to automatically send invites to VRE users
@ -83,16 +83,6 @@
<artifactId>gcube-widgets</artifactId> <artifactId>gcube-widgets</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>custom-portal-handler</artifactId>
<scope>provided</scope>
</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>invites-common-library</artifactId> <artifactId>invites-common-library</artifactId>
@ -130,6 +120,14 @@
<artifactId>portal-service</artifactId> <artifactId>portal-service</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
<!-- Generate compiled stuff in the folder used for developing mode --> <!-- Generate compiled stuff in the folder used for developing mode -->

View File

@ -1,10 +1,7 @@
package org.gcube.portlets.widgets.inviteswidget.server; package org.gcube.portlets.widgets.inviteswidget.server;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.portal.custom.communitymanager.SiteManagerUtil;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portal.databook.shared.InviteOperationResult; import org.gcube.portal.databook.shared.InviteOperationResult;
import org.gcube.portal.invites.InvitesManager; import org.gcube.portal.invites.InvitesManager;
import org.gcube.portlets.widgets.inviteswidget.client.InviteService; import org.gcube.portlets.widgets.inviteswidget.client.InviteService;
@ -13,44 +10,22 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.util.PortalUtil;
/**
* The server side implementation of the RPC service.
*/
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class InviteServiceImpl extends RemoteServiceServlet implements InviteService { public class InviteServiceImpl extends RemoteServiceServlet implements InviteService {
private final static Logger _log = LoggerFactory.getLogger(InviteServiceImpl.class); private final static Logger _log = LoggerFactory.getLogger(InviteServiceImpl.class);
/**
* the current ASLSession
* @return the session
*/
private ASLSession getASLSession() {
String sessionID = this.getThreadLocalRequest().getSession().getId();
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
if (user == null) {
_log.warn("USER IS NULL setting test.user");
user = "test.user";
}
else {
_log.info("LIFERAY PORTAL DETECTED user=" + user);
}
return SessionManager.getInstance().getASLSession(sessionID, user);
}
/** /**
* *
*/ */
@Override @Override
public InviteOperationResult sendInvite(String name, String lastName, String email) throws IllegalArgumentException { public InviteOperationResult sendInvite(String name, String lastName, String email) throws IllegalArgumentException {
ASLSession aslSession = getASLSession();
String lowercaseEmail = email.toLowerCase(); String lowercaseEmail = email.toLowerCase();
String portalUrl = null; String portalUrl = null;
String vreDescription = null; String vreDescription = null;
long groupId = getASLSession().getGroupId(); long groupId = PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest());
try { try {
portalUrl = PortalContext.getConfiguration().getGatewayURL(this.getThreadLocalRequest()); portalUrl = PortalContext.getConfiguration().getGatewayURL(this.getThreadLocalRequest());
vreDescription = new LiferayGroupManager().getGroup(groupId).getDescription(); vreDescription = new LiferayGroupManager().getGroup(groupId).getDescription();
@ -59,8 +34,8 @@ public class InviteServiceImpl extends RemoteServiceServlet implements InviteSer
_log.warn("While trying to send email for invitation to " + lowercaseEmail); _log.warn("While trying to send email for invitation to " + lowercaseEmail);
return null; return null;
} }
String portalSenderEmail = PortalContext.getConfiguration().getSenderEmail(); String portalSenderEmail = PortalContext.getConfiguration().getSenderEmail(getThreadLocalRequest());
return InvitesManager.getInstance().sendInvite(this.getThreadLocalRequest(), aslSession, portalSenderEmail, portalUrl, name, lastName, lowercaseEmail, vreDescription); return InvitesManager.getInstance().sendInvite(this.getThreadLocalRequest(), portalSenderEmail, portalUrl, name, lastName, lowercaseEmail, vreDescription);
} }