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"?>
|
||||
<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>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</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>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</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>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -39,5 +39,5 @@
|
|||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</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>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>invite-friends-vre</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-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>
|
||||
|
|
|
@ -16,7 +16,7 @@ import com.google.gwt.user.client.ui.Widget;
|
|||
*/
|
||||
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);
|
||||
|
||||
|
|
|
@ -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.ControlGroup;
|
||||
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.TextBox;
|
||||
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.editor.client.Editor;
|
||||
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
|
||||
*/
|
||||
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);
|
||||
|
||||
|
@ -48,16 +50,18 @@ public class FormViewImpl extends Composite implements FormView, Editor<FormView
|
|||
@UiField TextBox email;
|
||||
@UiField TextBox name;
|
||||
@UiField TextBox lastName;
|
||||
//
|
||||
//
|
||||
@UiField Button openModal;
|
||||
@UiField Button cancelInvite;
|
||||
@UiField Button sendInvite;
|
||||
@UiField Modal modalWindow;
|
||||
@UiField HelpBlock nameErrors;
|
||||
@UiField HelpBlock helpBlock;
|
||||
|
||||
@UiField HelpBlock feedback;
|
||||
|
||||
@UiField
|
||||
ControlGroup nameGroup;
|
||||
@UiField
|
||||
ControlGroup feedbackGroup;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -68,46 +72,54 @@ public class FormViewImpl extends Composite implements FormView, Editor<FormView
|
|||
driver.initialize(this);
|
||||
driver.edit(new UserDetails());
|
||||
}
|
||||
|
||||
|
||||
@UiHandler("openModal")
|
||||
void onUserClick(ClickEvent event) {
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@UiHandler("sendInvite")
|
||||
void onSendInviteClick(ClickEvent event) {
|
||||
if (delegate.onEmailSendInviteClick()) {
|
||||
nameGroup.setType(ControlGroupType.ERROR);
|
||||
nameErrors.setText("Please fill both name and last name");
|
||||
} else {
|
||||
nameGroup.setType(ControlGroupType.SUCCESS);
|
||||
nameGroup.setType(ControlGroupType.NONE);
|
||||
nameErrors.setText("");
|
||||
service.sendInviteEmail(name.getText(), lastName.getText(), email.getText(), new AsyncCallback<Boolean>() {
|
||||
|
||||
|
||||
@Override
|
||||
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
|
||||
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")
|
||||
public void onCancelClick(ClickEvent e) {
|
||||
modalWindow.hide();
|
||||
email.setText("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public EditorDriver<FormView.UserDetails> getEditorDriver() {
|
||||
return driver;
|
||||
|
|
|
@ -7,8 +7,9 @@
|
|||
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 Friend"
|
||||
<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">
|
||||
|
@ -20,7 +21,10 @@
|
|||
<b:TextBox placeholder="name" ui:field="name"></b:TextBox>
|
||||
<b:TextBox placeholder="last name" ui:field="lastName"></b:TextBox>
|
||||
<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:Form>
|
||||
<b:ModalFooter>
|
||||
|
|
|
@ -65,6 +65,7 @@ public class InviteServiceImpl extends RemoteServiceServlet implements InviteSer
|
|||
String vreName = aslSession.getGroupName();
|
||||
String fromFullName = aslSession.getUserFullName();
|
||||
|
||||
|
||||
Properties props = System.getProperties();
|
||||
Session session = null;
|
||||
props.put("mail.smtp.host", MAIL_SERVICE_HOST);
|
||||
|
@ -76,11 +77,12 @@ public class InviteServiceImpl extends RemoteServiceServlet implements InviteSer
|
|||
MimeMessage message = new MimeMessage(session);
|
||||
message.setHeader("Content-Type", "text/plain; charset=UTF-8");
|
||||
// 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.CC, new InternetAddress(aslSession.getUserEmailAddress()));
|
||||
|
||||
// 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
|
||||
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) {
|
||||
String username = getASLSession().getUsername();
|
||||
String portalUrl = null;
|
||||
|
||||
long orgId = getASLSession().getGroupId();
|
||||
try {
|
||||
portalUrl = PortalUtil.getPortalURL(OrganizationsUtil.getCompany().getVirtualHost(), PortalUtil.getPortalPort(), true);
|
||||
} 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);
|
||||
return null;
|
||||
}
|
||||
String portalHost = portalUrl.replaceAll("https://", "");
|
||||
portalHost = portalHost.replaceAll("http://", "");
|
||||
|
||||
|
||||
StringBuilder body = new StringBuilder();
|
||||
|
||||
|
||||
|
||||
body.append("Dear " + name)
|
||||
.append(",\n")
|
||||
.append(fromFullName).append(" has invited you to the " + vreName + " Virtual Research Environment.")
|
||||
.append("\n\n")
|
||||
.append(fromFullName).append("\n")
|
||||
.append("would like you to try the " + vreName + " Virtual Research Environment")
|
||||
.append("To accept the invite just follow this link: " + portalUrl + "/group/data-e-infrastructure-gateway/join-new?orgid="+orgId)
|
||||
.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("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, "
|
||||
|
|
Loading…
Reference in New Issue