Event class renamed according to its name and completed implementation
This commit is contained in:
parent
93aed9dc6e
commit
6ffee51961
|
@ -1,44 +0,0 @@
|
|||
package org.gcube.portlets.user.acceptinvite;
|
||||
|
||||
import org.gcube.portal.event.publisher.lr62.PortalEvent;
|
||||
|
||||
import com.liferay.portal.security.auth.DefaultScreenNameGenerator;
|
||||
|
||||
public class CreateUserAccountEvent extends PortalEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String EVENT_NAME = "invitation-accepted";
|
||||
|
||||
private String firstname;
|
||||
private String surname;
|
||||
private String email;
|
||||
private String tempPwd;
|
||||
private String username;
|
||||
|
||||
public CreateUserAccountEvent(String username, String firstname, String surname, String email, String tempPwd) {
|
||||
super(EVENT_NAME);
|
||||
DefaultScreenNameGenerator gen = new DefaultScreenNameGenerator();
|
||||
// gen.generate(companyId, userId, emailAddress)
|
||||
this.username = username;
|
||||
this.firstname = firstname;
|
||||
this.surname = surname;
|
||||
this.email = email;
|
||||
this.tempPwd = tempPwd;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
public String getSurname() {
|
||||
return surname;
|
||||
}
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public String getTempPwd() {
|
||||
return tempPwd;
|
||||
}
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package org.gcube.portlets.user.acceptinvite;
|
||||
|
||||
import org.gcube.portal.event.publisher.lr62.PortalEvent;
|
||||
|
||||
import com.liferay.portal.security.auth.CompanyThreadLocal;
|
||||
import com.liferay.portal.security.auth.DefaultScreenNameGenerator;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
|
||||
public class InvitationAcceptedEvent extends PortalEvent {
|
||||
|
||||
private static final long serialVersionUID = 1499288552188273747L;
|
||||
|
||||
public static final String NAME = "invitation-accepted";
|
||||
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();
|
||||
|
||||
public InvitationAcceptedEvent(String firstname, String lastname, String email, String password) {
|
||||
super(NAME);
|
||||
setUser(computeUsername(email));
|
||||
setFirstname(firstname);
|
||||
setLastname(lastname);
|
||||
setEmail(email);
|
||||
setPassword(password);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue