ready to release
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/invite-friends-vre@114601 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e8901917c5
commit
4af42f13c4
|
@ -1,18 +1,18 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/invite-friends-vre-0.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
<classpathentry kind="src" output="target/invite-friends-vre-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" output="target/invite-friends-vre-0.1.0-SNAPSHOT/WEB-INF/classes" path="target/generated-sources/gwt">
|
<classpathentry kind="src" output="target/invite-friends-vre-1.0.0-SNAPSHOT/WEB-INF/classes" path="target/generated-sources/gwt">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/invite-friends-vre-0.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
<classpathentry excluding="**" kind="src" output="target/invite-friends-vre-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
@ -39,5 +39,5 @@
|
||||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/invite-friends-vre-0.1.0-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/invite-friends-vre-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>invite-friends-vre</artifactId>
|
<artifactId>invite-friends-vre</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<name>Invite Friends to VRE</name>
|
<name>Invite Friends to VRE</name>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</connection>
|
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</connection>
|
||||||
|
|
|
@ -16,7 +16,7 @@ import com.google.gwt.user.client.ui.Widget;
|
||||||
*/
|
*/
|
||||||
public class InviteWidget extends Composite{
|
public class InviteWidget extends Composite{
|
||||||
|
|
||||||
public static final String DISPLAY_NAME = "Invite people to this VRE";
|
public static final String DISPLAY_NAME = "Invite whoever's missing";
|
||||||
|
|
||||||
private static InviteWidgetUiBinder uiBinder = GWT.create(InviteWidgetUiBinder.class);
|
private static InviteWidgetUiBinder uiBinder = GWT.create(InviteWidgetUiBinder.class);
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,11 @@ import org.gcube.portlets.user.invitefriends.client.InviteServiceAsync;
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||||
import com.github.gwtbootstrap.client.ui.HelpBlock;
|
import com.github.gwtbootstrap.client.ui.HelpBlock;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Icon;
|
||||||
import com.github.gwtbootstrap.client.ui.Modal;
|
import com.github.gwtbootstrap.client.ui.Modal;
|
||||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.editor.client.Editor;
|
import com.google.gwt.editor.client.Editor;
|
||||||
import com.google.gwt.editor.client.EditorDriver;
|
import com.google.gwt.editor.client.EditorDriver;
|
||||||
|
@ -36,10 +38,10 @@ public class FormViewImpl extends Composite implements FormView, Editor<FormView
|
||||||
* Create a remote service proxy to talk to the server-side service
|
* Create a remote service proxy to talk to the server-side service
|
||||||
*/
|
*/
|
||||||
private final InviteServiceAsync service = GWT.create(InviteService.class);
|
private final InviteServiceAsync service = GWT.create(InviteService.class);
|
||||||
|
|
||||||
interface Binder extends UiBinder<Widget, FormViewImpl> {}
|
interface Binder extends UiBinder<Widget, FormViewImpl> {}
|
||||||
private static Binder uiBinder = GWT.create(Binder.class);
|
private static Binder uiBinder = GWT.create(Binder.class);
|
||||||
|
|
||||||
interface Driver extends SimpleBeanEditorDriver<FormView.UserDetails, FormViewImpl> { }
|
interface Driver extends SimpleBeanEditorDriver<FormView.UserDetails, FormViewImpl> { }
|
||||||
private Driver driver = GWT.create(Driver.class);
|
private Driver driver = GWT.create(Driver.class);
|
||||||
|
|
||||||
|
@ -48,16 +50,18 @@ public class FormViewImpl extends Composite implements FormView, Editor<FormView
|
||||||
@UiField TextBox email;
|
@UiField TextBox email;
|
||||||
@UiField TextBox name;
|
@UiField TextBox name;
|
||||||
@UiField TextBox lastName;
|
@UiField TextBox lastName;
|
||||||
//
|
//
|
||||||
@UiField Button openModal;
|
@UiField Button openModal;
|
||||||
@UiField Button cancelInvite;
|
@UiField Button cancelInvite;
|
||||||
@UiField Button sendInvite;
|
@UiField Button sendInvite;
|
||||||
@UiField Modal modalWindow;
|
@UiField Modal modalWindow;
|
||||||
@UiField HelpBlock nameErrors;
|
@UiField HelpBlock nameErrors;
|
||||||
@UiField HelpBlock helpBlock;
|
@UiField HelpBlock feedback;
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
ControlGroup nameGroup;
|
ControlGroup nameGroup;
|
||||||
|
@UiField
|
||||||
|
ControlGroup feedbackGroup;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -68,46 +72,54 @@ public class FormViewImpl extends Composite implements FormView, Editor<FormView
|
||||||
driver.initialize(this);
|
driver.initialize(this);
|
||||||
driver.edit(new UserDetails());
|
driver.edit(new UserDetails());
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiHandler("openModal")
|
@UiHandler("openModal")
|
||||||
void onUserClick(ClickEvent event) {
|
void onUserClick(ClickEvent event) {
|
||||||
if (!delegate.onSendClick()) {
|
if (!delegate.onSendClick()) {
|
||||||
helpBlock.setText("We will send the invitation email to: "+email.getText());
|
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.");
|
||||||
modalWindow.show();
|
modalWindow.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiHandler("sendInvite")
|
@UiHandler("sendInvite")
|
||||||
void onSendInviteClick(ClickEvent event) {
|
void onSendInviteClick(ClickEvent event) {
|
||||||
if (delegate.onEmailSendInviteClick()) {
|
if (delegate.onEmailSendInviteClick()) {
|
||||||
nameGroup.setType(ControlGroupType.ERROR);
|
nameGroup.setType(ControlGroupType.ERROR);
|
||||||
nameErrors.setText("Please fill both name and last name");
|
nameErrors.setText("Please fill both name and last name");
|
||||||
} else {
|
} else {
|
||||||
nameGroup.setType(ControlGroupType.SUCCESS);
|
nameGroup.setType(ControlGroupType.NONE);
|
||||||
nameErrors.setText("");
|
nameErrors.setText("");
|
||||||
service.sendInviteEmail(name.getText(), lastName.getText(), email.getText(), new AsyncCallback<Boolean>() {
|
service.sendInviteEmail(name.getText(), lastName.getText(), email.getText(), new AsyncCallback<Boolean>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Boolean result) {
|
public void onSuccess(Boolean result) {
|
||||||
helpBlock.setText("Send OK");
|
feedback.setText("Thanks for inviting, we sent the email correctly.");
|
||||||
|
feedbackGroup.setType(ControlGroupType.SUCCESS);
|
||||||
|
sendInvite.removeFromParent();
|
||||||
|
cancelInvite.setText("Close");
|
||||||
|
email.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
helpBlock.setText("Message send error");
|
feedback.setText("Sorry, an error occurred and we could not send the invite, please try again later");
|
||||||
|
feedbackGroup.setType(ControlGroupType.ERROR);
|
||||||
|
sendInvite.removeFromParent();
|
||||||
|
email.setText("");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiHandler("cancelInvite")
|
@UiHandler("cancelInvite")
|
||||||
public void onCancelClick(ClickEvent e) {
|
public void onCancelClick(ClickEvent e) {
|
||||||
modalWindow.hide();
|
modalWindow.hide();
|
||||||
|
email.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditorDriver<FormView.UserDetails> getEditorDriver() {
|
public EditorDriver<FormView.UserDetails> getEditorDriver() {
|
||||||
return driver;
|
return driver;
|
||||||
|
|
|
@ -7,8 +7,9 @@
|
||||||
controlGroup="{emailGroup}" errorLabel="{emailErrors}" />
|
controlGroup="{emailGroup}" errorLabel="{emailErrors}" />
|
||||||
<b:HelpBlock ui:field="emailErrors"></b:HelpBlock>
|
<b:HelpBlock ui:field="emailErrors"></b:HelpBlock>
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
<b:Button ui:field="openModal">Send Invite</b:Button>
|
<b:Button ui:field="openModal">Send Invite</b:Button>
|
||||||
<b:Modal ui:field="modalWindow" title="Invite Friend"
|
|
||||||
|
<b:Modal ui:field="modalWindow" title="Invite whoever's missing"
|
||||||
backdrop="STATIC" keyboard="true" animation="true">
|
backdrop="STATIC" keyboard="true" animation="true">
|
||||||
<b:Form type="VERTICAL">
|
<b:Form type="VERTICAL">
|
||||||
<b:ControlGroup ui:field="nameGroup">
|
<b:ControlGroup ui:field="nameGroup">
|
||||||
|
@ -20,7 +21,10 @@
|
||||||
<b:TextBox placeholder="name" ui:field="name"></b:TextBox>
|
<b:TextBox placeholder="name" ui:field="name"></b:TextBox>
|
||||||
<b:TextBox placeholder="last name" ui:field="lastName"></b:TextBox>
|
<b:TextBox placeholder="last name" ui:field="lastName"></b:TextBox>
|
||||||
<b:HelpBlock ui:field="nameErrors"></b:HelpBlock>
|
<b:HelpBlock ui:field="nameErrors"></b:HelpBlock>
|
||||||
<b:HelpBlock ui:field="helpBlock" styleName="helpFontSize"></b:HelpBlock>
|
|
||||||
|
</b:ControlGroup>
|
||||||
|
<b:ControlGroup ui:field="feedbackGroup">
|
||||||
|
<b:HelpBlock ui:field="feedback"></b:HelpBlock>
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
</b:Form>
|
</b:Form>
|
||||||
<b:ModalFooter>
|
<b:ModalFooter>
|
||||||
|
|
|
@ -65,6 +65,7 @@ public class InviteServiceImpl extends RemoteServiceServlet implements InviteSer
|
||||||
String vreName = aslSession.getGroupName();
|
String vreName = aslSession.getGroupName();
|
||||||
String fromFullName = aslSession.getUserFullName();
|
String fromFullName = aslSession.getUserFullName();
|
||||||
|
|
||||||
|
|
||||||
Properties props = System.getProperties();
|
Properties props = System.getProperties();
|
||||||
Session session = null;
|
Session session = null;
|
||||||
props.put("mail.smtp.host", MAIL_SERVICE_HOST);
|
props.put("mail.smtp.host", MAIL_SERVICE_HOST);
|
||||||
|
@ -76,11 +77,12 @@ public class InviteServiceImpl extends RemoteServiceServlet implements InviteSer
|
||||||
MimeMessage message = new MimeMessage(session);
|
MimeMessage message = new MimeMessage(session);
|
||||||
message.setHeader("Content-Type", "text/plain; charset=UTF-8");
|
message.setHeader("Content-Type", "text/plain; charset=UTF-8");
|
||||||
// Set From: header field of the header.
|
// Set From: header field of the header.
|
||||||
message.setFrom(new InternetAddress(getSenderEmail(), getPortalInstanceName()));
|
message.setFrom(new InternetAddress(getSenderEmail(), fromFullName));
|
||||||
message.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
|
message.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
|
||||||
|
message.addRecipient(Message.RecipientType.CC, new InternetAddress(aslSession.getUserEmailAddress()));
|
||||||
|
|
||||||
// Set Subject: header field
|
// Set Subject: header field
|
||||||
message.setSubject(name + ", " + fromFullName + " would like you to try " + vreName);
|
message.setSubject("Join me on " + vreName);
|
||||||
|
|
||||||
// Now set the actual message
|
// Now set the actual message
|
||||||
message.setText(getTextEmail(name, lastName, email, fromFullName, vreName));
|
message.setText(getTextEmail(name, lastName, email, fromFullName, vreName));
|
||||||
|
@ -100,7 +102,7 @@ public class InviteServiceImpl extends RemoteServiceServlet implements InviteSer
|
||||||
private String getTextEmail(String name, String lastName, String email, String fromFullName, String vreName) {
|
private String getTextEmail(String name, String lastName, String email, String fromFullName, String vreName) {
|
||||||
String username = getASLSession().getUsername();
|
String username = getASLSession().getUsername();
|
||||||
String portalUrl = null;
|
String portalUrl = null;
|
||||||
|
long orgId = getASLSession().getGroupId();
|
||||||
try {
|
try {
|
||||||
portalUrl = PortalUtil.getPortalURL(OrganizationsUtil.getCompany().getVirtualHost(), PortalUtil.getPortalPort(), true);
|
portalUrl = PortalUtil.getPortalURL(OrganizationsUtil.getCompany().getVirtualHost(), PortalUtil.getPortalPort(), true);
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
|
@ -108,16 +110,19 @@ public class InviteServiceImpl extends RemoteServiceServlet implements InviteSer
|
||||||
_log.warn("While trying to send email for invitation to " + email);
|
_log.warn("While trying to send email for invitation to " + email);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String portalHost = portalUrl.replaceAll("https://", "");
|
|
||||||
portalHost = portalHost.replaceAll("http://", "");
|
|
||||||
|
|
||||||
StringBuilder body = new StringBuilder();
|
StringBuilder body = new StringBuilder();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
body.append("Dear " + name)
|
body.append("Dear " + name)
|
||||||
|
.append(",\n")
|
||||||
|
.append(fromFullName).append(" has invited you to the " + vreName + " Virtual Research Environment.")
|
||||||
.append("\n\n")
|
.append("\n\n")
|
||||||
.append(fromFullName).append("\n")
|
.append("To accept the invite just follow this link: " + portalUrl + "/group/data-e-infrastructure-gateway/join-new?orgid="+orgId)
|
||||||
.append("would like you to try the " + vreName + " Virtual Research Environment")
|
|
||||||
.append("\n\n")
|
.append("\n\n")
|
||||||
|
.append("Please note: if you do not have an account yet, please sign up first: " + portalUrl + "/web/guest/home?p_p_id=58&_58_struts_action=%2Flogin%2Fcreate_account")
|
||||||
|
.append("\n\n\n\n")
|
||||||
.append("WARNING / LEGAL TEXT: This message is intended only for the use of the individual or entity to which it is addressed and may contain")
|
.append("WARNING / LEGAL TEXT: This message is intended only for the use of the individual or entity to which it is addressed and may contain")
|
||||||
.append("information which is privileged, confidential, proprietary, or exempt from disclosure under applicable law. "
|
.append("information which is privileged, confidential, proprietary, or exempt from disclosure under applicable law. "
|
||||||
+ "If you are not the intended recipient or the person responsible for delivering the message to the intended recipient, "
|
+ "If you are not the intended recipient or the person responsible for delivering the message to the intended recipient, "
|
||||||
|
|
Loading…
Reference in New Issue