Added support for template emails

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gcube-loggedin@148757 82a268e6-3cf1-43bd-a215-b396298e98cf
master
Massimiliano Assante 7 years ago
parent c3ddbdf85d
commit 0db87c477f

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/gcube-loggedin-3.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/gcube-loggedin-3.3.0-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/gcube-loggedin-3.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/gcube-loggedin-3.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -34,10 +34,10 @@
</attributes>
</classpathentry>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/gcube-loggedin-3.2.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/gcube-loggedin-3.3.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

@ -1,6 +1,6 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error

@ -4,7 +4,10 @@
<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="gcube-widgets-2.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
<dependent-module archiveName="gcube-widgets-2.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="email-templates-library-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/email-templates-library/email-templates-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>

@ -1,4 +1,9 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-user.gcube-loggedin-portlet.3-3-0"
date="2017-05-16">
<Change>Ported to Java8</Change>
<Change>Added support for template emails</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.gcube-loggedin-portlet.3-2-0"
date="2016-11-23">
<Change>Removed ASL Session dependency</Change>
@ -9,7 +14,8 @@
</Changeset>
<Changeset component="org.gcube.portlets-user.gcube-loggedin-portlet.3-0-0"
date="2016-07-15">
<Change>Added possibility for VRE Manager to edit VRE Abstract text</Change>
<Change>Added possibility for VRE Manager to edit VRE Abstract text
</Change>
<Change>Restyled and ported to Liferay 6.2</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.gcube-loggedin-portlet.2-7-0"
@ -22,7 +28,8 @@
<Change>Added show more option when VRE Description is too long
</Change>
<Change>Added client scope handler for preventing back button cache
problems</Change>
problems
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.gcube-loggedin-portlet.2-5-0"
date="2014-11-13">

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-loggedin</artifactId>
<packaging>war</packaging>
<version>3.2.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
<name>gCube Environment Home Portlet</name>
<description>
@ -28,9 +28,8 @@
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.7.0</gwtVersion>
<distroDirectory>distro</distroDirectory>
<!-- GWT needs at least java 1.6 -->
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.target>1.8</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<liferay.version>6.2.5</liferay.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -76,7 +75,7 @@
<dependency>
<groupId>com.github.gwtbootstrap</groupId>
<artifactId>gwt-bootstrap</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
@ -87,6 +86,11 @@
<artifactId>gcube-widgets</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal.mailing</groupId>
<artifactId>email-templates-library</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
@ -189,8 +193,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<!-- SA Plugin -->

@ -7,6 +7,9 @@ import java.util.Set;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.portal.mailing.EmailNotification;
import org.gcube.portal.mailing.message.Recipient;
import org.gcube.portal.mailing.service.EmailTemplateService;
import org.gcube.portal.mailing.templates.TemplateUserHasLeftVRE;
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService;
import org.gcube.portlets.user.gcubeloggedin.shared.VObject;
import org.gcube.portlets.user.gcubeloggedin.shared.VObject.UserBelongingClient;
@ -220,41 +223,31 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
}
/**
*
* @param scope .
* @param optionalMessage .
* @param username
* @param scope
* @param portalbasicurl
* @param gatewayName
*/
public void sendUserUnregisteredNotification(String username, String scope, String portalbasicurl, String gatewayName) {
ArrayList<String> adminEmails = getAdministratorsEmails(scope);
ArrayList<Recipient> recipients = new ArrayList<>();
for (String email : adminEmails) {
recipients.add(new Recipient(email));
}
UserManager um = new LiferayUserManager();
GCubeUser currUser = null;
try {
currUser = um.getUserByUsername(username);
} catch (Exception e) {
_log.trace("Error getUserByUsername", e);
}
String name = currUser.getFirstName();
String lastname = currUser.getLastName();
StringBuffer body = new StringBuffer();
body.append("<p>Dear manager of "+ scope +",<br />this email message was automatically generated by " + portalbasicurl +" to inform you that ");
body.append("</p>");
body.append("<p>");
body.append("<b>"+name + " " + lastname +"</b> has left the following environment: ");
body.append("<br /><br />");
body.append("<b>" + scope+"</b>");
body.append("<br />");
body.append("<br />");
body.append("<b>Username: </b>" + username);
body.append("<br />");
body.append("<b>e-mail: </b>" + currUser.getEmail());
body.append("</p>");
String[] allMails = new String[adminEmails.size()];
adminEmails.toArray(allMails);
EmailNotification mailToAdmin = new EmailNotification(allMails , "Unregistration from VRE", body.toString(), getThreadLocalRequest());
String selectedVRE = scope.substring(scope.lastIndexOf("/")+1, scope.length());
EmailTemplateService.send("Unregistration from VRE",
new TemplateUserHasLeftVRE(currUser, selectedVRE, gatewayName, portalbasicurl),
getThreadLocalRequest(),
recipients.toArray(new Recipient[recipients.size()]));
mailToAdmin.sendEmail();
}
}

Loading…
Cancel
Save