use of com.liferay.portal.DuplicateUserEmailAddressException in project liferay-ide by liferay.
the class UserLocalServiceImpl method validate.
protected void validate(long userId, String screenName, String emailAddress, String openId, String firstName, String middleName, String lastName, String smsSn) throws PortalException, SystemException {
User user = userPersistence.findByPrimaryKey(userId);
if (!StringUtil.equalsIgnoreCase(user.getScreenName(), screenName)) {
validateScreenName(user.getCompanyId(), userId, screenName);
}
validateEmailAddress(user.getCompanyId(), emailAddress);
validateOpenId(user.getCompanyId(), userId, openId);
if (!user.isDefaultUser()) {
if (Validator.isNotNull(emailAddress) && !StringUtil.equalsIgnoreCase(user.getEmailAddress(), emailAddress)) {
if (userPersistence.fetchByC_EA(user.getCompanyId(), emailAddress) != null) {
throw new DuplicateUserEmailAddressException("{userId=" + userId + "}");
}
}
validateFullName(user.getCompanyId(), firstName, middleName, lastName);
}
if (Validator.isNotNull(smsSn) && !Validator.isEmailAddress(smsSn)) {
throw new UserSmsException();
}
}
use of com.liferay.portal.DuplicateUserEmailAddressException in project liferay-ide by liferay.
the class UserLocalServiceImpl method validate.
protected void validate(long companyId, long userId, boolean autoPassword, String password1, String password2, boolean autoScreenName, String screenName, String emailAddress, String openId, String firstName, String middleName, String lastName, long[] organizationIds) throws PortalException, SystemException {
validateCompanyMaxUsers(companyId);
if (!autoScreenName) {
validateScreenName(companyId, userId, screenName);
}
if (!autoPassword) {
PasswordPolicy passwordPolicy = passwordPolicyLocalService.getDefaultPasswordPolicy(companyId);
PwdToolkitUtil.validate(companyId, 0, password1, password2, passwordPolicy);
}
validateEmailAddress(companyId, emailAddress);
if (Validator.isNotNull(emailAddress)) {
User user = userPersistence.fetchByC_EA(companyId, emailAddress);
if ((user != null) && (user.getUserId() != userId)) {
throw new DuplicateUserEmailAddressException("{userId=" + userId + "}");
}
}
validateOpenId(companyId, userId, openId);
validateFullName(companyId, firstName, middleName, lastName);
if (organizationIds != null) {
for (long organizationId : organizationIds) {
Organization organization = organizationPersistence.fetchByPrimaryKey(organizationId);
if (organization == null) {
throw new NoSuchOrganizationException("{organizationId=" + organizationId + "}");
}
}
}
}
use of com.liferay.portal.DuplicateUserEmailAddressException in project liferay-ide by liferay.
the class UserLocalServiceImpl method verifyEmailAddress.
/**
* Verifies the email address of the ticket.
*
* @param ticketKey the ticket key
* @throws PortalException if a ticket matching the ticket key could not be
* found, if the ticket has expired, if the ticket is an email
* address ticket, or if the email address is invalid
* @throws SystemException if a system exception occurred
*/
@Override
public void verifyEmailAddress(String ticketKey) throws PortalException, SystemException {
Ticket ticket = ticketLocalService.getTicket(ticketKey);
if (ticket.isExpired() || (ticket.getType() != TicketConstants.TYPE_EMAIL_ADDRESS)) {
throw new NoSuchTicketException("{ticketKey=" + ticketKey + "}");
}
User user = userPersistence.findByPrimaryKey(ticket.getClassPK());
String emailAddress = ticket.getExtraInfo();
emailAddress = StringUtil.toLowerCase(emailAddress).trim();
if (!emailAddress.equals(user.getEmailAddress())) {
if (userPersistence.fetchByC_EA(user.getCompanyId(), emailAddress) != null) {
throw new DuplicateUserEmailAddressException("{userId=" + user.getUserId() + "}");
}
setEmailAddress(user, StringPool.BLANK, user.getFirstName(), user.getMiddleName(), user.getLastName(), emailAddress);
Contact contact = user.getContact();
contact.setEmailAddress(user.getEmailAddress());
contactPersistence.update(contact);
}
user.setEmailAddressVerified(true);
userPersistence.update(user);
ticketLocalService.deleteTicket(ticket);
}
Aggregations