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:
Massimiliano Assante 2016-08-24 15:59:55 +00:00
parent 6d03bbc55e
commit b0fbde6943
4 changed files with 13 additions and 66 deletions

View File

@ -24,27 +24,11 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</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">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</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"/>
</classpath>

View File

@ -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="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="context-root" value="create-users"/>
</wb-module>

27
pom.xml
View File

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.admin</groupId>
<artifactId>create-users</artifactId>
<packaging>war</packaging>
<version>2.0.0-SNAPSHOT</version>
<version>2.1.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.
@ -94,7 +94,6 @@
<dependency>
<groupId>com.github.gwtbootstrap</groupId>
<artifactId>gwt-bootstrap</artifactId>
<version>2.3.2.0</version>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
@ -104,7 +103,6 @@
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>${liferayVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -131,27 +129,6 @@
<artifactId>social-networking-library</artifactId>
<scope>provided</scope>
</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>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@ -216,7 +193,7 @@
<version>2.2</version>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
<descriptor>distro/descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>

View File

@ -13,7 +13,6 @@ import javax.mail.internet.InternetAddress;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.portal.PortalContext;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
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.service.CompanyLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.util.PortalUtil;
/**
* The server side implementation of the RPC service.
@ -222,7 +220,7 @@ public class CreateUsersImpl extends RemoteServiceServlet implements HandleUsers
InternetAddress from = new InternetAddress(emailSender);
LiferayUserManager userManager = new LiferayUserManager();
String portalUrl = PortalUtil.getPortalURL(getCompany().getVirtualHostname(), 443, true);
String portalUrl = context.getGatewayURL(getThreadLocalRequest());
String username = userManager.getFullNameFromEmail(email);
MailMessage mailMessage = new MailMessage();
@ -230,11 +228,11 @@ public class CreateUsersImpl extends RemoteServiceServlet implements HandleUsers
mailMessage.setTo(to);
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 />" +
gatewayName + "<br />" +
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.setSubject(subject);
@ -328,15 +326,14 @@ public class CreateUsersImpl extends RemoteServiceServlet implements HandleUsers
isMale,
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
// adding to the current VRE
userManager.assignUserToGroup(getCurrentGroupID(), userManager.getUserId(user.getUsername()));
//adding to the HL
addUserToHLGroup(user.getUsername(), session.getScope());
if (sendEmail)
sendEmailToUser(email);
}catch(Exception e){
// 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;
}
/**
* 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
*