integrated widget for invitations
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/invite-friends-vre@115801 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0b0a814e99
commit
7d84397969
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/invite-friends-vre-1.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/invite-friends-vre-1.1.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/invite-friends-vre-1.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<classpathentry excluding="**" kind="src" output="target/invite-friends-vre-1.1.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -33,5 +33,6 @@
|
|||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/invite-friends-vre-1.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
|
||||
<classpathentry kind="output" path="target/invite-friends-vre-1.1.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
#Thu Jun 16 11:14:17 CEST 2011
|
||||
eclipse.preferences.version=1
|
||||
entryPointModules=
|
||||
filesCopiedToWebInfLib=gwt-servlet.jar
|
||||
gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBWy13YXIgc3JjL21haW4vd2ViYXBwXV0+PC9leHRyYS1hcmdzPjx2bS1hcmdzPjwhW0NEQVRBWy1YbXg1MTJtXV0+PC92bS1hcmdzPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLmNvbXBhbnkuU29tZU1vZHVsZTwvZW50cnktcG9pbnQtbW9kdWxlPjwvZ3d0LWNvbXBpbGUtc2V0dGluZ3M+
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<dependent-module archiveName="invite-friends-widget-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/invite-friends-widget/invite-friends-widget">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module archiveName="invites-common-library-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/invites-common-library/invites-common-library">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
|
|
9
pom.xml
9
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>invite-friends-vre</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>1.1.1-SNAPSHOT</version>
|
||||
<name>Invite Friends to VRE</name>
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</connection>
|
||||
|
@ -74,10 +74,15 @@
|
|||
<version>${gwtVersion}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>invite-friends-widget</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>invites-common-library</artifactId>
|
||||
<version>[0.1.0-SNAPSHOT,)</version>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.gcube.portlets.user.invitefriends.client;
|
||||
|
||||
import org.gcube.portlets.user.invitefriends.client.ui.InviteWidget;
|
||||
import org.gcube.portlets.widgets.inviteswidget.client.ui.InviteWidget;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
|
@ -14,6 +14,6 @@ public class InviteFriends implements EntryPoint {
|
|||
* This is the entry point method.
|
||||
*/
|
||||
public void onModuleLoad() {
|
||||
RootPanel.get("invite-friends-DIV").add(new InviteWidget());
|
||||
RootPanel.get("invite-friends-DIV").add(new InviteWidget("Invite whoever's missing"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package org.gcube.portlets.user.invitefriends.client;
|
||||
|
||||
import org.gcube.portal.databook.shared.InviteOperationResult;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||
|
||||
/**
|
||||
* The client side stub for the RPC service.
|
||||
*/
|
||||
@RemoteServiceRelativePath("greet")
|
||||
public interface InviteService extends RemoteService {
|
||||
InviteOperationResult sendInvite(String name, String lastName, String email) throws IllegalArgumentException;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package org.gcube.portlets.user.invitefriends.client;
|
||||
|
||||
import org.gcube.portal.databook.shared.InviteOperationResult;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
public interface InviteServiceAsync {
|
||||
|
||||
void sendInvite(String name, String lastName, String email,
|
||||
AsyncCallback<InviteOperationResult> callback);
|
||||
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.invitefriends.client.ui;
|
||||
|
||||
import org.gcube.portal.databook.shared.InviteOperationResult;
|
||||
import org.gcube.portlets.user.invitefriends.client.InviteService;
|
||||
import org.gcube.portlets.user.invitefriends.client.InviteServiceAsync;
|
||||
import org.gcube.portlets.user.invitefriends.client.validation.FormView;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||
import com.github.gwtbootstrap.client.ui.HelpBlock;
|
||||
import com.github.gwtbootstrap.client.ui.Modal;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.editor.client.Editor;
|
||||
import com.google.gwt.editor.client.EditorDriver;
|
||||
import com.google.gwt.editor.client.SimpleBeanEditorDriver;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.KeyCodes;
|
||||
import com.google.gwt.event.dom.client.KeyDownEvent;
|
||||
import com.google.gwt.event.dom.client.KeyDownHandler;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.uibinder.client.UiHandler;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
*
|
||||
*/
|
||||
public class FormViewImpl extends Composite implements FormView, Editor<FormView.UserDetails> {
|
||||
|
||||
/**
|
||||
* Create a remote service proxy to talk to the server-side service
|
||||
*/
|
||||
private final InviteServiceAsync service = GWT.create(InviteService.class);
|
||||
|
||||
interface Binder extends UiBinder<Widget, FormViewImpl> {}
|
||||
private static Binder uiBinder = GWT.create(Binder.class);
|
||||
|
||||
interface Driver extends SimpleBeanEditorDriver<FormView.UserDetails, FormViewImpl> { }
|
||||
private Driver driver = GWT.create(Driver.class);
|
||||
|
||||
private final Delegate delegate;
|
||||
|
||||
@UiField TextBox email;
|
||||
@UiField TextBox name;
|
||||
|
||||
@UiField Button openModal;
|
||||
@UiField Button cancelInvite;
|
||||
@UiField Button sendInvite;
|
||||
@UiField Modal modalWindow;
|
||||
@UiField HelpBlock nameErrors;
|
||||
@UiField HelpBlock feedback;
|
||||
|
||||
@UiField
|
||||
ControlGroup nameGroup;
|
||||
@UiField
|
||||
ControlGroup feedbackGroup;
|
||||
|
||||
public FormViewImpl(Delegate delegate) {
|
||||
super();
|
||||
this.delegate = delegate;
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
driver.initialize(this);
|
||||
driver.edit(new UserDetails());
|
||||
|
||||
email.addKeyDownHandler(new KeyDownHandler() {
|
||||
@Override
|
||||
public void onKeyDown(KeyDownEvent event) {
|
||||
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
|
||||
openModal.click();
|
||||
}
|
||||
});
|
||||
|
||||
name.addKeyDownHandler(new KeyDownHandler() {
|
||||
@Override
|
||||
public void onKeyDown(KeyDownEvent event) {
|
||||
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
|
||||
sendInvite.click();
|
||||
}
|
||||
});
|
||||
|
||||
sendInvite.setEnabled(true);
|
||||
}
|
||||
|
||||
@UiHandler("openModal")
|
||||
void onUserClick(ClickEvent event) {
|
||||
if (!delegate.onSendClick()) {
|
||||
sendInvite.setEnabled(true);
|
||||
feedback.setText("We will send the invitation email to: "+email.getText() + " and put you in cc, we'll never email your contacts without your say so.");
|
||||
name.setText("");
|
||||
modalWindow.show();
|
||||
Timer t = new Timer() {
|
||||
@Override
|
||||
public void run() {
|
||||
name.setFocus(true);
|
||||
}
|
||||
};
|
||||
t.schedule(1000);
|
||||
}
|
||||
}
|
||||
|
||||
@UiHandler("sendInvite")
|
||||
void onSendInviteClick(ClickEvent event) {
|
||||
if (delegate.onEmailSendInviteClick()) {
|
||||
nameGroup.setType(ControlGroupType.ERROR);
|
||||
nameErrors.setText("Name must not be null");
|
||||
} else {
|
||||
nameGroup.setType(ControlGroupType.NONE);
|
||||
nameErrors.setText("");
|
||||
service.sendInvite(name.getText(), "", email.getText(), new AsyncCallback<InviteOperationResult>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(InviteOperationResult result) {
|
||||
switch (result) {
|
||||
case SUCCESS:
|
||||
feedback.setText("Thanks for inviting, we sent the email correctly.");
|
||||
feedbackGroup.setType(ControlGroupType.SUCCESS);
|
||||
break;
|
||||
case ALREADY_INVITED:
|
||||
feedback.setText("Thanks for inviting, however the user was already invited.");
|
||||
feedbackGroup.setType(ControlGroupType.WARNING);
|
||||
break;
|
||||
case FAILED:
|
||||
feedback.setText("Sorry, an error occurred in the server and we could not send the invite, please try again later.");
|
||||
feedbackGroup.setType(ControlGroupType.ERROR);
|
||||
break;
|
||||
}
|
||||
sendInvite.setEnabled(false);
|
||||
cancelInvite.setText("Close");
|
||||
email.setText("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
feedback.setText("Sorry, an error occurred and we could not send the invite, please try again later.");
|
||||
feedbackGroup.setType(ControlGroupType.ERROR);
|
||||
sendInvite.setEnabled(false);
|
||||
email.setText("");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@UiHandler("cancelInvite")
|
||||
public void onCancelClick(ClickEvent e) {
|
||||
modalWindow.hide();
|
||||
email.setText("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditorDriver<FormView.UserDetails> getEditorDriver() {
|
||||
return driver;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
|
||||
xmlns:g='urn:import:com.google.gwt.user.client.ui' xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
|
||||
<b:Form type="VERTICAL">
|
||||
<b:ControlGroup ui:field="emailGroup">
|
||||
<b:TextBox placeholder="e-mail address" ui:field="email"
|
||||
controlGroup="{emailGroup}" errorLabel="{emailErrors}" />
|
||||
<b:HelpBlock ui:field="emailErrors"></b:HelpBlock>
|
||||
</b:ControlGroup>
|
||||
<b:Button ui:field="openModal">Send Invite</b:Button>
|
||||
|
||||
<b:Modal ui:field="modalWindow" title="Invite whoever's missing"
|
||||
backdrop="STATIC" keyboard="true" animation="true">
|
||||
<b:Form type="VERTICAL">
|
||||
<b:ControlGroup ui:field="nameGroup">
|
||||
<b:TextBox placeholder="enter your friend's name" ui:field="name"></b:TextBox>
|
||||
<b:HelpBlock ui:field="nameErrors"></b:HelpBlock>
|
||||
|
||||
</b:ControlGroup>
|
||||
<b:ControlGroup ui:field="feedbackGroup">
|
||||
<b:HelpBlock ui:field="feedback"></b:HelpBlock>
|
||||
</b:ControlGroup>
|
||||
</b:Form>
|
||||
<b:ModalFooter>
|
||||
<b:Button ui:field="cancelInvite">Cancel</b:Button>
|
||||
<b:Button ui:field="sendInvite" type="PRIMARY">Send Invite</b:Button>
|
||||
</b:ModalFooter>
|
||||
</b:Modal>
|
||||
</b:Form>
|
||||
</ui:UiBinder>
|
|
@ -1,35 +0,0 @@
|
|||
package org.gcube.portlets.user.invitefriends.client.ui;
|
||||
|
||||
import org.gcube.portlets.user.invitefriends.client.validation.FormErrorsValidation;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
*
|
||||
*/
|
||||
public class InviteWidget extends Composite{
|
||||
|
||||
public static final String DISPLAY_NAME = "Invite whoever's missing";
|
||||
|
||||
private static InviteWidgetUiBinder uiBinder = GWT.create(InviteWidgetUiBinder.class);
|
||||
|
||||
interface InviteWidgetUiBinder extends UiBinder<Widget, InviteWidget> { }
|
||||
|
||||
@UiField HTML header;
|
||||
@UiField SimplePanel validationErrorsFormPanel;
|
||||
|
||||
public InviteWidget() {
|
||||
super();
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
header.setText(DISPLAY_NAME);
|
||||
new FormErrorsValidation().start(validationErrorsFormPanel, null);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
|
||||
<g:HTMLPanel styleName="invites-frame">
|
||||
<g:HTML ui:field="header" styleName="invites-title"></g:HTML>
|
||||
<g:SimplePanel ui:field="validationErrorsFormPanel" />
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
|
@ -1,178 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.invitefriends.client.validation;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.Path;
|
||||
import javax.validation.metadata.ConstraintDescriptor;
|
||||
|
||||
import org.gcube.portlets.user.invitefriends.client.ui.FormViewImpl;
|
||||
import org.gcube.portlets.user.invitefriends.client.validation.FormView.UserDetails;
|
||||
|
||||
import com.google.gwt.activity.shared.AbstractActivity;
|
||||
import com.google.gwt.editor.client.EditorDriver;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.user.client.ui.AcceptsOneWidget;
|
||||
import com.google.gwt.validation.client.impl.PathImpl;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
*
|
||||
*/
|
||||
public class FormErrorsValidation extends AbstractActivity implements FormView.Delegate {
|
||||
|
||||
private FormView view;
|
||||
/**
|
||||
* @see com.google.gwt.activity.shared.Activity#start(com.google.gwt.user.client.ui.AcceptsOneWidget, com.google.gwt.event.shared.EventBus)
|
||||
*/
|
||||
@Override
|
||||
public void start(AcceptsOneWidget panel, EventBus eventBus) {
|
||||
view = new FormViewImpl(this);
|
||||
panel.setWidget(view);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public boolean onSendClick() {
|
||||
EditorDriver<UserDetails> editorDriver = view.getEditorDriver();
|
||||
UserDetails details = editorDriver.flush();
|
||||
Set<ConstraintViolation<UserDetails>> violations = validateEmailTextBox(details);
|
||||
//decorate widgets implementing HasEditorErrors with validation messages
|
||||
return editorDriver.setConstraintViolations( (Set) violations);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public boolean onEmailSendInviteClick() {
|
||||
EditorDriver<UserDetails> editorDriver = view.getEditorDriver();
|
||||
UserDetails details = editorDriver.flush();
|
||||
Set<ConstraintViolation<UserDetails>> violations = validateName(details);
|
||||
return !violations.isEmpty();
|
||||
}
|
||||
|
||||
private Set<ConstraintViolation<UserDetails>> validateName(UserDetails user2InviteBean) {
|
||||
Set<ConstraintViolation<UserDetails>> violations = new HashSet<ConstraintViolation<UserDetails>>();
|
||||
if(user2InviteBean.getName() == null || "".equals(user2InviteBean.getName().trim())) {
|
||||
violations.add(buildNotNullConstraintViolation(user2InviteBean, "name"));
|
||||
}
|
||||
return violations;
|
||||
}
|
||||
|
||||
private Set<ConstraintViolation<UserDetails>> validateEmailTextBox(UserDetails user2InviteBean){
|
||||
Set<ConstraintViolation<UserDetails>> violations = new HashSet<ConstraintViolation<UserDetails>>();
|
||||
if(user2InviteBean.getEmail() == null || "".equals(user2InviteBean.getEmail().trim())) {
|
||||
violations.add(buildNotNullConstraintViolation(user2InviteBean, "email"));
|
||||
}
|
||||
else if (!isValidEmailAddress(user2InviteBean.getEmail())) {
|
||||
violations.add(buildInvalidEmailAddressConstraintViolation(user2InviteBean, "email"));
|
||||
}
|
||||
|
||||
return violations;
|
||||
}
|
||||
|
||||
|
||||
private ConstraintViolation<UserDetails> buildNotNullConstraintViolation(final UserDetails bean, final String path) {
|
||||
return new ConstraintViolation<UserDetails>() {
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "must not be empty";
|
||||
}
|
||||
@Override
|
||||
public String getMessageTemplate() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public UserDetails getRootBean() {
|
||||
return bean;
|
||||
}
|
||||
@Override
|
||||
public Class<UserDetails> getRootBeanClass() {
|
||||
return UserDetails.class;
|
||||
}
|
||||
@Override
|
||||
public Object getLeafBean() {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getPropertyPath() {
|
||||
return new PathImpl().append(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInvalidValue() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ConstraintDescriptor<?> getConstraintDescriptor() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private ConstraintViolation<UserDetails> buildInvalidEmailAddressConstraintViolation(final UserDetails bean, final String path) {
|
||||
return new ConstraintViolation<UserDetails>() {
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "email address must be valid";
|
||||
}
|
||||
@Override
|
||||
public String getMessageTemplate() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public UserDetails getRootBean() {
|
||||
return bean;
|
||||
}
|
||||
@Override
|
||||
public Class<UserDetails> getRootBeanClass() {
|
||||
return UserDetails.class;
|
||||
}
|
||||
@Override
|
||||
public Object getLeafBean() {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getPropertyPath() {
|
||||
return new PathImpl().append(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInvalidValue() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ConstraintDescriptor<?> getConstraintDescriptor() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param emailValue
|
||||
* @return
|
||||
*/
|
||||
private boolean isValidEmailAddress(String emailValue) {
|
||||
if(emailValue == null) return true;
|
||||
|
||||
String emailPattern = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.(?:[a-zA-Z]{2,6})$";
|
||||
|
||||
boolean valid = false;
|
||||
|
||||
if(emailValue.getClass().toString().equals(String.class.toString())) {
|
||||
valid = ((String)emailValue).matches(emailPattern);
|
||||
} else {
|
||||
valid = ((Object)emailValue).toString().matches(emailPattern);
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.invitefriends.client.validation;
|
||||
|
||||
import com.google.gwt.editor.client.EditorDriver;
|
||||
import com.google.gwt.user.client.ui.IsWidget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
*
|
||||
*/
|
||||
public interface FormView extends IsWidget {
|
||||
|
||||
public static class UserDetails {
|
||||
String email;
|
||||
String name;
|
||||
String lastName;
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserDetails [email=" + email + ", name=" + name
|
||||
+ ", lastName=" + lastName + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public interface Delegate {
|
||||
boolean onSendClick();
|
||||
|
||||
boolean onEmailSendInviteClick();
|
||||
}
|
||||
|
||||
|
||||
|
||||
EditorDriver<UserDetails> getEditorDriver();
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package org.gcube.portlets.user.invitefriends.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.portal.custom.communitymanager.OrganizationsUtil;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.portal.databook.shared.InviteOperationResult;
|
||||
import org.gcube.portal.invites.InvitesManager;
|
||||
import org.gcube.portlets.user.invitefriends.client.InviteService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
||||
import com.liferay.portal.util.PortalUtil;
|
||||
|
||||
/**
|
||||
* The server side implementation of the RPC service.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class InviteServiceImpl extends RemoteServiceServlet implements InviteService {
|
||||
|
||||
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
|
||||
public InviteOperationResult sendInvite(String name, String lastName, String email) throws IllegalArgumentException {
|
||||
ASLSession aslSession = getASLSession();
|
||||
|
||||
String portalUrl = null;
|
||||
String vreDescription = null;
|
||||
long organizationId = getASLSession().getGroupId();
|
||||
try {
|
||||
portalUrl = PortalUtil.getPortalURL(OrganizationsUtil.getCompany().getVirtualHost(), PortalUtil.getPortalPort(), true);
|
||||
vreDescription = OrganizationLocalServiceUtil.getOrganization(organizationId).getComments();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
_log.warn("While trying to send email for invitation to " + email);
|
||||
return null;
|
||||
}
|
||||
String portalSenderEmail = PortalContext.getConfiguration().getSenderEmail();
|
||||
return InvitesManager.getInstance().sendInvite(aslSession, portalSenderEmail, portalUrl, name, lastName, email, vreDescription);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
<inherits name='com.google.gwt.user.User' />
|
||||
<inherits name='com.google.gwt.activity.Activity' />
|
||||
<inherits name="com.github.gwtbootstrap.Bootstrap" />
|
||||
|
||||
<inherits name="org.gcube.portlets.widgets.inviteswidget.InvitesWidget"/>
|
||||
<!-- Other module inherits -->
|
||||
<inherits name="org.jsonmaker.gwt.Gwt_jsonmaker" />
|
||||
<inherits name='org.gcube.portal.databook.GCubeSocialNetworking' />
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
sendButton = Envoyer
|
||||
nameField = Entrez votre nom
|
|
@ -8,7 +8,7 @@
|
|||
<!-- Servlets -->
|
||||
<servlet>
|
||||
<servlet-name>greetServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.invitefriends.server.InviteServiceImpl</servlet-class>
|
||||
<servlet-class>org.gcube.portlets.widgets.inviteswidget.server.InviteServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
|
|
Loading…
Reference in New Issue