use of com.liferay.portal.NoSuchTicketException 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