List of usage examples for com.liferay.portal.kernel.util PropsKeys ADMIN_EMAIL_VERIFICATION_SUBJECT
String ADMIN_EMAIL_VERIFICATION_SUBJECT
To view the source code for com.liferay.portal.kernel.util PropsKeys ADMIN_EMAIL_VERIFICATION_SUBJECT.
Click Source Link
From source file:org.opencps.util.MessageBusUtil.java
License:Open Source License
public static void sendEmailAddressVerification(String uuid, User user, String emailAddress, String type, ServiceContext serviceContext) throws PortalException, SystemException { if (user.isEmailAddressVerified() && StringUtil.equalsIgnoreCase(emailAddress, user.getEmailAddress())) { return;/*from ww w . j ava 2 s . c om*/ } Ticket ticket = TicketLocalServiceUtil.addDistinctTicket(user.getCompanyId(), User.class.getName(), user.getUserId(), TicketConstants.TYPE_EMAIL_ADDRESS, emailAddress, null, serviceContext); String verifyEmailAddressURL = serviceContext.getPortalURL() + "/opencps-portlet/verify/email?token=" + uuid + "&ticketKey=" + ticket.getKey() + "&type=" + type; long plid = serviceContext.getPlid(); if (plid > 0) { Layout layout = LayoutLocalServiceUtil.fetchLayout(plid); if (layout != null) { Group group = layout.getGroup(); if (!layout.isPrivateLayout() && !group.isUser()) { verifyEmailAddressURL += "&p_l_id=" + serviceContext.getPlid(); } } } String fromName = PrefsPropsUtil.getString(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME); String fromAddress = PrefsPropsUtil.getString(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS); String toName = user.getFullName(); String toAddress = emailAddress; String subject = PrefsPropsUtil.getContent(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_VERIFICATION_SUBJECT); String body = PrefsPropsUtil.getContent(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_VERIFICATION_BODY); SubscriptionSender subscriptionSender = new SubscriptionSender(); subscriptionSender.setBody(body); subscriptionSender.setCompanyId(user.getCompanyId()); subscriptionSender.setContextAttributes("[$EMAIL_VERIFICATION_CODE$]", ticket.getKey(), "[$EMAIL_VERIFICATION_URL$]", verifyEmailAddressURL, "[$REMOTE_ADDRESS$]", serviceContext.getRemoteAddr(), "[$REMOTE_HOST$]", serviceContext.getRemoteHost(), "[$USER_ID$]", user.getUserId(), "[$USER_SCREENNAME$]", user.getScreenName()); subscriptionSender.setFrom(fromAddress, fromName); subscriptionSender.setHtmlFormat(true); subscriptionSender.setMailId("user", user.getUserId(), System.currentTimeMillis(), PwdGenerator.getPassword()); subscriptionSender.setServiceContext(serviceContext); subscriptionSender.setSubject(subject); subscriptionSender.setUserId(user.getUserId()); subscriptionSender.addRuntimeSubscribers(toAddress, toName); subscriptionSender.flushNotificationsAsync(); }