2015-07-02 12:52:12 +02:00
|
|
|
package org.gcube.portlets.widgets.inviteswidget.server;
|
|
|
|
|
2016-11-15 12:14:43 +01:00
|
|
|
|
2016-03-23 16:38:42 +01:00
|
|
|
import org.gcube.common.portal.PortalContext;
|
2015-07-02 12:52:12 +02:00
|
|
|
import org.gcube.portal.databook.shared.InviteOperationResult;
|
|
|
|
import org.gcube.portal.invites.InvitesManager;
|
|
|
|
import org.gcube.portlets.widgets.inviteswidget.client.InviteService;
|
2016-03-23 17:03:19 +01:00
|
|
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
2015-07-02 12:52:12 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
2016-03-23 16:38:42 +01:00
|
|
|
|
2015-07-02 12:52:12 +02:00
|
|
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|
|
|
|
|
|
|
@SuppressWarnings("serial")
|
|
|
|
public class InviteServiceImpl extends RemoteServiceServlet implements InviteService {
|
|
|
|
|
|
|
|
private final static Logger _log = LoggerFactory.getLogger(InviteServiceImpl.class);
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public InviteOperationResult sendInvite(String name, String lastName, String email) throws IllegalArgumentException {
|
2016-11-15 12:14:43 +01:00
|
|
|
|
2015-07-02 12:52:12 +02:00
|
|
|
|
2015-09-02 11:13:07 +02:00
|
|
|
String lowercaseEmail = email.toLowerCase();
|
2016-03-23 19:02:54 +01:00
|
|
|
String portalUrl = null;
|
2015-07-02 12:52:12 +02:00
|
|
|
String vreDescription = null;
|
2016-11-15 12:14:43 +01:00
|
|
|
long groupId = PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest());
|
2015-07-02 12:52:12 +02:00
|
|
|
try {
|
2016-03-23 19:02:54 +01:00
|
|
|
portalUrl = PortalContext.getConfiguration().getGatewayURL(this.getThreadLocalRequest());
|
2016-03-23 17:03:19 +01:00
|
|
|
vreDescription = new LiferayGroupManager().getGroup(groupId).getDescription();
|
2015-07-02 12:52:12 +02:00
|
|
|
} catch (Exception e1) {
|
|
|
|
e1.printStackTrace();
|
2015-09-02 11:13:07 +02:00
|
|
|
_log.warn("While trying to send email for invitation to " + lowercaseEmail);
|
2015-07-02 12:52:12 +02:00
|
|
|
return null;
|
|
|
|
}
|
2016-11-15 12:14:43 +01:00
|
|
|
String portalSenderEmail = PortalContext.getConfiguration().getSenderEmail(getThreadLocalRequest());
|
|
|
|
return InvitesManager.getInstance().sendInvite(this.getThreadLocalRequest(), portalSenderEmail, portalUrl, name, lastName, lowercaseEmail, vreDescription);
|
2015-07-02 12:52:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|