adapted to Liferay 6.2
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/create-users@131019 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6d03bbc55e
commit
b0fbde6943
18
.classpath
18
.classpath
|
@ -24,27 +24,11 @@
|
||||||
<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="lib" path="/home/costantino/Downloads/gwt-2.7.0/gwt-user.jar">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="javadoc_location" value="file:/home/costantino/Downloads/gwt-2.7.0/doc/javadoc/"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="lib" path="/home/costantino/Downloads/gwt-2.7.0/gwt-codeserver.jar">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="javadoc_location" value="file:/home/costantino/Downloads/gwt-2.7.0/doc/javadoc/"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="lib" path="/home/costantino/Downloads/gwt-2.7.0/gwt-dev.jar">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="javadoc_location" value="file:/home/costantino/Downloads/gwt-2.7.0/doc/javadoc/"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="lib" path="/home/costantino/Downloads/gwt-2.7.0/validation-api-1.0.0.GA-sources.jar"/>
|
|
||||||
<classpathentry kind="lib" path="/home/costantino/Downloads/gwt-2.7.0/validation-api-1.0.0.GA.jar" sourcepath="/home/costantino/Downloads/gwt-2.7.0/validation-api-1.0.0.GA-sources.jar"/>
|
|
||||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
|
||||||
<classpathentry kind="output" path="target/create-users-2.0.0-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/create-users-2.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
<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/java"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
|
<dependent-module archiveName="gcube-widgets-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
|
||||||
|
<dependency-type>uses</dependency-type>
|
||||||
|
</dependent-module>
|
||||||
<property name="java-output-path" value="/create-users/target/subscribe-users-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
<property name="java-output-path" value="/create-users/target/subscribe-users-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
<property name="context-root" value="create-users"/>
|
<property name="context-root" value="create-users"/>
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
27
pom.xml
27
pom.xml
|
@ -13,7 +13,7 @@
|
||||||
<groupId>org.gcube.portlets.admin</groupId>
|
<groupId>org.gcube.portlets.admin</groupId>
|
||||||
<artifactId>create-users</artifactId>
|
<artifactId>create-users</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.1.0-SNAPSHOT</version>
|
||||||
<name>Create users portlet</name>
|
<name>Create users portlet</name>
|
||||||
<description>
|
<description>
|
||||||
Create users portlet allows a VRE-Manager to enter user's personal data and automatically register he/she in the portal.
|
Create users portlet allows a VRE-Manager to enter user's personal data and automatically register he/she in the portal.
|
||||||
|
@ -94,7 +94,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.gwtbootstrap</groupId>
|
<groupId>com.github.gwtbootstrap</groupId>
|
||||||
<artifactId>gwt-bootstrap</artifactId>
|
<artifactId>gwt-bootstrap</artifactId>
|
||||||
<version>2.3.2.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.dvos</groupId>
|
<groupId>org.gcube.dvos</groupId>
|
||||||
|
@ -104,7 +103,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.liferay.portal</groupId>
|
<groupId>com.liferay.portal</groupId>
|
||||||
<artifactId>portal-service</artifactId>
|
<artifactId>portal-service</artifactId>
|
||||||
<version>${liferayVersion}</version>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -131,27 +129,6 @@
|
||||||
<artifactId>social-networking-library</artifactId>
|
<artifactId>social-networking-library</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.common</groupId>
|
|
||||||
<artifactId>home-library-model</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.common</groupId>
|
|
||||||
<artifactId>home-library</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>asm-all</artifactId>
|
|
||||||
<groupId>asm</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.common</groupId>
|
|
||||||
<artifactId>home-library-jcr</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
@ -216,7 +193,7 @@
|
||||||
<version>2.2</version>
|
<version>2.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<descriptors>
|
<descriptors>
|
||||||
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
|
<descriptor>distro/descriptor.xml</descriptor>
|
||||||
</descriptors>
|
</descriptors>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
|
|
|
@ -13,7 +13,6 @@ import javax.mail.internet.InternetAddress;
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
import org.gcube.application.framework.core.session.SessionManager;
|
import org.gcube.application.framework.core.session.SessionManager;
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||||
import org.gcube.portlets.admin.createusers.client.HandleUsersService;
|
import org.gcube.portlets.admin.createusers.client.HandleUsersService;
|
||||||
|
@ -38,7 +37,6 @@ import com.liferay.portal.kernel.util.PropsUtil;
|
||||||
import com.liferay.portal.model.Company;
|
import com.liferay.portal.model.Company;
|
||||||
import com.liferay.portal.service.CompanyLocalServiceUtil;
|
import com.liferay.portal.service.CompanyLocalServiceUtil;
|
||||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||||
import com.liferay.portal.util.PortalUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The server side implementation of the RPC service.
|
* The server side implementation of the RPC service.
|
||||||
|
@ -222,7 +220,7 @@ public class CreateUsersImpl extends RemoteServiceServlet implements HandleUsers
|
||||||
InternetAddress from = new InternetAddress(emailSender);
|
InternetAddress from = new InternetAddress(emailSender);
|
||||||
|
|
||||||
LiferayUserManager userManager = new LiferayUserManager();
|
LiferayUserManager userManager = new LiferayUserManager();
|
||||||
String portalUrl = PortalUtil.getPortalURL(getCompany().getVirtualHostname(), 443, true);
|
String portalUrl = context.getGatewayURL(getThreadLocalRequest());
|
||||||
String username = userManager.getFullNameFromEmail(email);
|
String username = userManager.getFullNameFromEmail(email);
|
||||||
|
|
||||||
MailMessage mailMessage = new MailMessage();
|
MailMessage mailMessage = new MailMessage();
|
||||||
|
@ -230,11 +228,11 @@ public class CreateUsersImpl extends RemoteServiceServlet implements HandleUsers
|
||||||
mailMessage.setTo(to);
|
mailMessage.setTo(to);
|
||||||
|
|
||||||
String body = "<p>Dear " + username + ",<br />" + "<br />" +
|
String body = "<p>Dear " + username + ",<br />" + "<br />" +
|
||||||
"Welcome! You recently created an account at " + portalUrl + ". Your password is not sent by email for security purposes.<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 />" +
|
"<br />" + "Sincerely,<br />" +
|
||||||
gatewayName + "<br />" +
|
gatewayName + "<br />" +
|
||||||
emailSender + "<br />" + portalUrl;
|
emailSender + "<br />" + portalUrl;
|
||||||
String subject = portalUrl + ": Your New Account was created successfully!";
|
String subject = gatewayName + ": Your New Account was created successfully!";
|
||||||
|
|
||||||
mailMessage.setBody(body);
|
mailMessage.setBody(body);
|
||||||
mailMessage.setSubject(subject);
|
mailMessage.setSubject(subject);
|
||||||
|
@ -328,15 +326,14 @@ public class CreateUsersImpl extends RemoteServiceServlet implements HandleUsers
|
||||||
isMale,
|
isMale,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
sendEmail, // determine if we need to send him/her an email
|
false, // determine if we need to send him/her an email
|
||||||
true); // force the password reset
|
true); // force the password reset
|
||||||
|
|
||||||
// adding to the current VRE
|
// adding to the current VRE
|
||||||
userManager.assignUserToGroup(getCurrentGroupID(), userManager.getUserId(user.getUsername()));
|
userManager.assignUserToGroup(getCurrentGroupID(), userManager.getUserId(user.getUsername()));
|
||||||
|
if (sendEmail)
|
||||||
//adding to the HL
|
sendEmailToUser(email);
|
||||||
addUserToHLGroup(user.getUsername(), session.getScope());
|
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
|
||||||
// unable to create.. we need to delete it from the list of users
|
// unable to create.. we need to delete it from the list of users
|
||||||
|
@ -500,20 +497,6 @@ public class CreateUsersImpl extends RemoteServiceServlet implements HandleUsers
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add user to Home Library Group
|
|
||||||
* @param username
|
|
||||||
* @param group
|
|
||||||
*/
|
|
||||||
private void addUserToHLGroup(String username, String group) {
|
|
||||||
try {
|
|
||||||
org.gcube.common.homelibrary.home.workspace.usermanager.UserManager um = HomeLibrary.getHomeManagerFactory().getUserManager();
|
|
||||||
um.associateUserToGroup(group, username);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Failed to get the usermanager from HL. Could not add user to the HL group");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current group ID
|
* Get the current group ID
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue