added template welcome message
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/create-users@148778 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
aeab0d7caf
commit
a00d6b05a4
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/create-users-2.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/create-users-2.4.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/create-users-2.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<classpathentry excluding="**" kind="src" output="target/create-users-2.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -17,7 +17,7 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<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>
|
||||
|
@ -34,5 +34,5 @@
|
|||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
|
||||
<classpathentry kind="output" path="target/create-users-2.3.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/create-users-2.4.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,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="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>
|
||||
<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>
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.portlets.admin.create-users.2-4-0"
|
||||
date="2017-05-17">
|
||||
<Change>Ported to Java8</Change>
|
||||
<Change>Adapted for template email welcome message</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlets.admin.create-users.2-2-0"
|
||||
date="2016-12-02">
|
||||
<Change>Removed ASLSession</Change>
|
||||
|
|
13
pom.xml
13
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.portlets.admin</groupId>
|
||||
<artifactId>create-users</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>2.3.0-SNAPSHOT</version>
|
||||
<version>2.4.0-SNAPSHOT</version>
|
||||
<name>Create users portlet</name>
|
||||
<description>
|
||||
Create users portlet allows a VRE-Manager to enter user's personal data and automatically register he/she in the portal.
|
||||
|
@ -32,7 +32,7 @@
|
|||
<liferayVersion>6.2.5</liferayVersion>
|
||||
<!-- 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>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -64,6 +64,11 @@
|
|||
<artifactId>portal-manager</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal.mailing</groupId>
|
||||
<artifactId>email-templates-library</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
|
@ -209,8 +214,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 -->
|
||||
|
|
|
@ -71,7 +71,7 @@ public class AddUserForm extends Composite{
|
|||
@UiField
|
||||
AlertBlock successBlock;
|
||||
|
||||
private static final String NAME_SURNAME_PATTERN = "^[a-zA-Z\\s]*$";
|
||||
private static final String NAME_SURNAME_PATTERN = "^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,.'-]+$";
|
||||
|
||||
private static final String EMAIL_PATTERN =
|
||||
"^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
|
||||
|
|
|
@ -12,17 +12,22 @@ import java.util.List;
|
|||
import javax.mail.internet.InternetAddress;
|
||||
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.portal.mailing.message.Recipient;
|
||||
import org.gcube.portal.mailing.service.EmailTemplateService;
|
||||
import org.gcube.portal.mailing.templates.TemplateWelcomeCreatedAccount;
|
||||
import org.gcube.portlets.admin.createusers.client.HandleUsersService;
|
||||
import org.gcube.portlets.admin.createusers.shared.VreUserBean;
|
||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
import com.liferay.mail.service.MailServiceUtil;
|
||||
import com.liferay.portal.kernel.dao.jdbc.DataAccess;
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
|
@ -156,37 +161,23 @@ public class CreateUsersImpl extends RemoteServiceServlet implements HandleUsers
|
|||
|
||||
@Override
|
||||
public void sendEmailToUser(String email) {
|
||||
|
||||
if(isWithinPortal()){
|
||||
try{
|
||||
logger.debug("Sending welcome message to user with email " + email);
|
||||
PortalContext context = PortalContext.getConfiguration();
|
||||
String gatewayName = context.getGatewayName(getThreadLocalRequest());
|
||||
String emailSender = context.getSenderEmail(getThreadLocalRequest());
|
||||
String gatewayURL = context.getGatewayURL(getThreadLocalRequest());
|
||||
long groupId = context.getCurrentGroupId(getThreadLocalRequest());
|
||||
GCubeGroup currVRE = new LiferayGroupManager().getGroup(groupId);
|
||||
UserManager um = new LiferayUserManager();
|
||||
GCubeUser theCreatedAccountUser = um.getUserByEmail(email);
|
||||
GCubeUser theManagerUser =context.getCurrentUser(getThreadLocalRequest());
|
||||
|
||||
InternetAddress to = new InternetAddress(email);
|
||||
InternetAddress from = new InternetAddress(emailSender);
|
||||
String subject = "Your user account for " + currVRE.getGroupName() + " VRE has been created";
|
||||
EmailTemplateService.send(
|
||||
subject,
|
||||
new TemplateWelcomeCreatedAccount(gatewayName, gatewayURL, theCreatedAccountUser, theManagerUser, currVRE), getThreadLocalRequest(), new Recipient(email));
|
||||
|
||||
LiferayUserManager userManager = new LiferayUserManager();
|
||||
String portalUrl = context.getGatewayURL(getThreadLocalRequest());
|
||||
String username = userManager.getFullNameFromEmail(email);
|
||||
|
||||
MailMessage mailMessage = new MailMessage();
|
||||
mailMessage.setFrom(from);
|
||||
mailMessage.setTo(to);
|
||||
|
||||
// TODO it would be nice to let the creator specify the message to be sent
|
||||
String body = "<p>Dear " + username + ",<br />" + "<br />" +
|
||||
"Welcome! Your new account at " + portalUrl + " is ready to be used. Your temporary password is training1, you will be asked to reset it at your first login.<br />" +
|
||||
"<br />" + "Sincerely,<br />" +
|
||||
gatewayName + "<br />" +
|
||||
emailSender + "<br />" + portalUrl;
|
||||
String subject = gatewayName + ": Your New Account was created successfully!";
|
||||
|
||||
mailMessage.setBody(body);
|
||||
mailMessage.setSubject(subject);
|
||||
mailMessage.setHTMLFormat(true);
|
||||
MailServiceUtil.sendEmail(mailMessage);
|
||||
}catch(Exception e){
|
||||
logger.error("Error while sending email to user " + email, e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue