Merge pull request 'Added dependency to even-publisher modules and implemented specific event and publisher' (#1) from mauro.mugnaini/issue-19811:master into master
This commit is contained in:
commit
6529b999f1
17
pom.xml
17
pom.xml
|
@ -59,6 +59,23 @@
|
|||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>event-publisher-library</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>event-publisher-portal</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
<artifactId>portal-manager</artifactId>
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
package org.gcube.portlets.admin.createusers.orchestrator;
|
||||
|
||||
import org.gcube.portal.event.publisher.lr62.PortalEvent;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.model.Group;
|
||||
import com.liferay.portal.security.auth.CompanyThreadLocal;
|
||||
import com.liferay.portal.security.auth.DefaultScreenNameGenerator;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
|
||||
public class CreateUserAddToVre extends PortalEvent {
|
||||
|
||||
private static final long serialVersionUID = 1499288552188273747L;
|
||||
|
||||
public static final String NAME = "create-user-add-to-vre";
|
||||
public static final String FIRST_NAME_ENTRY = "first-name";
|
||||
public static final String LAST_NAME_ENTRY = "last-name";
|
||||
public static final String EMAIL_ENTRY = "email";
|
||||
public static final String PASSWORD_ENTRY = "password";
|
||||
|
||||
private static DefaultScreenNameGenerator defaultScreenNameGenerator = new DefaultScreenNameGenerator();
|
||||
|
||||
private CreateUserAddToVre(String firstname, String lastname, String email, String password, Group group)
|
||||
throws PortalException, SystemException {
|
||||
|
||||
super(NAME);
|
||||
setUser(computeUsername(email));
|
||||
setFirstname(firstname);
|
||||
setLastname(lastname);
|
||||
setEmail(email);
|
||||
setPassword(password);
|
||||
setGroup(group);
|
||||
}
|
||||
|
||||
public static CreateUserAddToVre newEvent(String firstname, String lastname, String email, String password,
|
||||
Group group) {
|
||||
|
||||
try {
|
||||
return new CreateUserAddToVre(firstname, lastname, email, password, group);
|
||||
} catch (PortalException | SystemException e) {
|
||||
log.error("Cannot create event from group model object", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected String computeUsername(String email) {
|
||||
try {
|
||||
Long companyId = CompanyThreadLocal.getCompanyId();
|
||||
Long defaultUserId = UserLocalServiceUtil.getDefaultUserId(companyId);
|
||||
return defaultScreenNameGenerator.generate(companyId, defaultUserId, email);
|
||||
} catch (Exception e) {
|
||||
log.error("Cannot generate username via screen name generator", e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
set(FIRST_NAME_ENTRY, firstname);
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return (String) get(FIRST_NAME_ENTRY);
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
set(LAST_NAME_ENTRY, lastname);
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return (String) get(LAST_NAME_ENTRY);
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
set(EMAIL_ENTRY, email);
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return (String) get(EMAIL_ENTRY);
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
set(PASSWORD_ENTRY, password);
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return (String) get(PASSWORD_ENTRY);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.gcube.portlets.admin.createusers.orchestrator;
|
||||
|
||||
import org.gcube.portal.event.publisher.lr62.AbstractLR62EventPublisher;
|
||||
|
||||
public class CreateUserAddToVrePublisher extends AbstractLR62EventPublisher {
|
||||
|
||||
public CreateUserAddToVrePublisher() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue