Feature #16461, Invite member ... prevent the system from inviting people having an already registered email in VRE
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/invite-friends-widget@178904 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
fc88d1fe4e
commit
45f17e1153
2
pom.xml
2
pom.xml
|
@ -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.5.0-SNAPSHOT</version>
|
<version>1.6.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
|
||||||
|
|
|
@ -10,5 +10,6 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||||
*/
|
*/
|
||||||
@RemoteServiceRelativePath("greet")
|
@RemoteServiceRelativePath("greet")
|
||||||
public interface InviteService extends RemoteService {
|
public interface InviteService extends RemoteService {
|
||||||
|
Boolean accountExistInVRE(String email);
|
||||||
InviteOperationResult sendInvite(String name, String lastName, String email) throws IllegalArgumentException;
|
InviteOperationResult sendInvite(String name, String lastName, String email) throws IllegalArgumentException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,5 @@ public interface InviteServiceAsync {
|
||||||
|
|
||||||
void sendInvite(String name, String lastName, String email,
|
void sendInvite(String name, String lastName, String email,
|
||||||
AsyncCallback<InviteOperationResult> callback);
|
AsyncCallback<InviteOperationResult> callback);
|
||||||
|
void accountExistInVRE(String email, AsyncCallback<Boolean> callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.uibinder.client.UiHandler;
|
import com.google.gwt.uibinder.client.UiHandler;
|
||||||
import com.google.gwt.user.client.Timer;
|
import com.google.gwt.user.client.Timer;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
@ -94,6 +95,17 @@ public class FormViewImpl extends Composite implements FormView, Editor<FormView
|
||||||
@UiHandler("openModal")
|
@UiHandler("openModal")
|
||||||
void onUserClick(ClickEvent event) {
|
void onUserClick(ClickEvent event) {
|
||||||
if (!delegate.onSendClick()) {
|
if (!delegate.onSendClick()) {
|
||||||
|
service.accountExistInVRE(email.getText(), new AsyncCallback<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
Window.alert("Ops, There were problems communicating with the server, please retry later or report this issue to http://support.d4science.org");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Boolean userAccountExists) {
|
||||||
|
if (userAccountExists) {
|
||||||
|
Window.alert("A user with the same email already exists in this VRE, the invite cannot be sent.");
|
||||||
|
} else {
|
||||||
sendInvite.setEnabled(true);
|
sendInvite.setEnabled(true);
|
||||||
feedback.setText("This gateway will send the invitation email to: "+email.getText() + " and put you in cc. It will never email your contacts without your consent.");
|
feedback.setText("This gateway will send the invitation email to: "+email.getText() + " and put you in cc. It will never email your contacts without your consent.");
|
||||||
name.setText("");
|
name.setText("");
|
||||||
|
@ -107,6 +119,10 @@ public class FormViewImpl extends Composite implements FormView, Editor<FormView
|
||||||
t.schedule(1000);
|
t.schedule(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@UiHandler("sendInvite")
|
@UiHandler("sendInvite")
|
||||||
void onSendInviteClick(ClickEvent event) {
|
void onSendInviteClick(ClickEvent event) {
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
package org.gcube.portlets.widgets.inviteswidget.server;
|
package org.gcube.portlets.widgets.inviteswidget.server;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
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;
|
||||||
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||||
|
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||||
|
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -15,6 +24,8 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
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);
|
||||||
|
private final static GroupManager GM = new LiferayGroupManager();
|
||||||
|
private final static UserManager UM = new LiferayUserManager();
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -36,4 +47,33 @@ public class InviteServiceImpl extends RemoteServiceServlet implements InviteSer
|
||||||
return InvitesManager.getInstance().sendInvite(this.getThreadLocalRequest(), portalSenderEmail, portalUrl, name, lastName, lowercaseEmail, vreDescription);
|
return InvitesManager.getInstance().sendInvite(this.getThreadLocalRequest(), portalSenderEmail, portalUrl, name, lastName, lowercaseEmail, vreDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean accountExistInVRE(String email) {
|
||||||
|
long groupId = PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest());
|
||||||
|
try {
|
||||||
|
if (!GM.isVRE(groupId)) {
|
||||||
|
return false; //if deployed not in a VRE the check is not performed
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
GCubeUser theUser2Check = UM.getUserByEmail(email);
|
||||||
|
List<GCubeUser> theVREUsers = UM.listUsersByGroup(groupId, false);
|
||||||
|
for (GCubeUser vreUser : theVREUsers) {
|
||||||
|
if (vreUser.getUserId() == theUser2Check.getUserId()) {
|
||||||
|
_log.debug("User exists in this VRE, should not send the invite in VRE having id: " + groupId + " to " + theUser2Check.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (UserRetrievalFault e) {
|
||||||
|
_log.debug("User does not exist in this VRE, invite can be sent");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (UserManagementSystemException | GroupRetrievalFault e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue