From 4af42f13c4372f852839bcae09e216bcc145cbf4 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Thu, 30 Apr 2015 10:42:59 +0000 Subject: [PATCH] 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 --- .classpath | 8 ++-- pom.xml | 2 +- .../invitefriends/client/ui/InviteWidget.java | 2 +- .../client/validation/FormViewImpl.java | 46 ++++++++++++------- .../client/validation/FormViewImpl.ui.xml | 10 ++-- .../server/InviteServiceImpl.java | 21 +++++---- 6 files changed, 55 insertions(+), 34 deletions(-) diff --git a/.classpath b/.classpath index 980bfe6..b162b09 100644 --- a/.classpath +++ b/.classpath @@ -1,18 +1,18 @@ - + - + - + @@ -39,5 +39,5 @@ - + diff --git a/pom.xml b/pom.xml index 9e3e6ca..e2f27f4 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.gcube.portlets.user invite-friends-vre war - 0.1.0-SNAPSHOT + 1.0.0-SNAPSHOT Invite Friends to VRE scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId} diff --git a/src/main/java/org/gcube/portlets/user/invitefriends/client/ui/InviteWidget.java b/src/main/java/org/gcube/portlets/user/invitefriends/client/ui/InviteWidget.java index 456a0fd..15c7883 100644 --- a/src/main/java/org/gcube/portlets/user/invitefriends/client/ui/InviteWidget.java +++ b/src/main/java/org/gcube/portlets/user/invitefriends/client/ui/InviteWidget.java @@ -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); diff --git a/src/main/java/org/gcube/portlets/user/invitefriends/client/validation/FormViewImpl.java b/src/main/java/org/gcube/portlets/user/invitefriends/client/validation/FormViewImpl.java index c05eaf5..55d786b 100644 --- a/src/main/java/org/gcube/portlets/user/invitefriends/client/validation/FormViewImpl.java +++ b/src/main/java/org/gcube/portlets/user/invitefriends/client/validation/FormViewImpl.java @@ -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 {} private static Binder uiBinder = GWT.create(Binder.class); - + interface Driver extends SimpleBeanEditorDriver { } private Driver driver = GWT.create(Driver.class); @@ -48,16 +50,18 @@ public class FormViewImpl extends Composite implements FormView, Editor() { - + @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 getEditorDriver() { return driver; diff --git a/src/main/java/org/gcube/portlets/user/invitefriends/client/validation/FormViewImpl.ui.xml b/src/main/java/org/gcube/portlets/user/invitefriends/client/validation/FormViewImpl.ui.xml index f50d4d9..40ef040 100644 --- a/src/main/java/org/gcube/portlets/user/invitefriends/client/validation/FormViewImpl.ui.xml +++ b/src/main/java/org/gcube/portlets/user/invitefriends/client/validation/FormViewImpl.ui.xml @@ -7,8 +7,9 @@ controlGroup="{emailGroup}" errorLabel="{emailErrors}" /> - Send Invite - Send Invite + + @@ -20,7 +21,10 @@ - + + + + diff --git a/src/main/java/org/gcube/portlets/user/invitefriends/server/InviteServiceImpl.java b/src/main/java/org/gcube/portlets/user/invitefriends/server/InviteServiceImpl.java index 3200425..a9878a1 100644 --- a/src/main/java/org/gcube/portlets/user/invitefriends/server/InviteServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/invitefriends/server/InviteServiceImpl.java @@ -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, "