List of usage examples for com.liferay.portal.kernel.util PropsKeys ADMIN_EMAIL_FROM_NAME
String ADMIN_EMAIL_FROM_NAME
To view the source code for com.liferay.portal.kernel.util PropsKeys ADMIN_EMAIL_FROM_NAME.
Click Source Link
From source file:com.liferay.portlet.flags.messaging.FlagsRequestMessageListener.java
License:Open Source License
@Override protected void doReceive(Message message) throws Exception { FlagsRequest flagsRequest = (FlagsRequest) message.getPayload(); // Service context ServiceContext serviceContext = flagsRequest.getServiceContext(); // Company//w ww . j a va 2 s. com long companyId = serviceContext.getCompanyId(); Company company = CompanyLocalServiceUtil.getCompany(serviceContext.getCompanyId()); // Group Layout layout = LayoutLocalServiceUtil.getLayout(serviceContext.getPlid()); Group group = layout.getGroup(); String groupName = HtmlUtil.escape(group.getDescriptiveName()); // Reporter user String reporterUserName = null; String reporterEmailAddress = null; User reporterUser = UserLocalServiceUtil.getUserById(serviceContext.getUserId()); Locale locale = LocaleUtil.getDefault(); if (reporterUser.isDefaultUser()) { reporterUserName = LanguageUtil.get(locale, "anonymous"); } else { reporterUserName = reporterUser.getFullName(); reporterEmailAddress = reporterUser.getEmailAddress(); } // Reported user String reportedUserName = StringPool.BLANK; String reportedEmailAddress = StringPool.BLANK; String reportedURL = StringPool.BLANK; User reportedUser = UserLocalServiceUtil.getUserById(flagsRequest.getReportedUserId()); if (reportedUser.isDefaultUser()) { reportedUserName = HtmlUtil.escape(group.getDescriptiveName()); } else { reportedUserName = HtmlUtil.escape(reportedUser.getFullName()); reportedEmailAddress = reportedUser.getEmailAddress(); reportedURL = reportedUser.getDisplayURL(serviceContext.getPortalURL(), serviceContext.getPathMain()); } // Content String contentType = ResourceActionsUtil.getModelResource(locale, flagsRequest.getClassName()); // Reason String reason = LanguageUtil.get(locale, flagsRequest.getReason()); // Email String fromName = PrefsPropsUtil.getStringFromNames(companyId, PropsKeys.FLAGS_EMAIL_FROM_NAME, PropsKeys.ADMIN_EMAIL_FROM_NAME); String fromAddress = PrefsPropsUtil.getStringFromNames(companyId, PropsKeys.FLAGS_EMAIL_FROM_ADDRESS, PropsKeys.ADMIN_EMAIL_FROM_ADDRESS); String subject = PrefsPropsUtil.getContent(companyId, PropsKeys.FLAGS_EMAIL_SUBJECT); String body = PrefsPropsUtil.getContent(companyId, PropsKeys.FLAGS_EMAIL_BODY); // Recipients List<User> recipients = getRecipients(companyId, serviceContext.getScopeGroupId()); for (User recipient : recipients) { try { notify(company, groupName, reporterEmailAddress, reporterUserName, reportedEmailAddress, reportedUserName, reportedURL, flagsRequest.getClassPK(), flagsRequest.getContentTitle(), contentType, flagsRequest.getContentURL(), reason, fromName, fromAddress, recipient.getFullName(), recipient.getEmailAddress(), subject, body, serviceContext); } catch (IOException ioe) { if (_log.isWarnEnabled()) { _log.warn(ioe); } } } }
From source file:com.liferay.portlet.messageboards.service.impl.MBMessageLocalServiceImpl.java
License:Open Source License
protected void notifyDiscussionSubscribers(MBMessage message, ServiceContext serviceContext) throws SystemException { if (!PrefsPropsUtil.getBoolean(message.getCompanyId(), PropsKeys.DISCUSSION_EMAIL_COMMENTS_ADDED_ENABLED)) { return;//from w ww . j a v a2 s . c o m } String contentURL = (String) serviceContext.getAttribute("contentURL"); String userAddress = StringPool.BLANK; String userName = (String) serviceContext.getAttribute("pingbackUserName"); if (Validator.isNull(userName)) { userAddress = PortalUtil.getUserEmailAddress(message.getUserId()); userName = PortalUtil.getUserName(message.getUserId(), StringPool.BLANK); } String fromName = PrefsPropsUtil.getString(message.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME); String fromAddress = PrefsPropsUtil.getString(message.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS); String subject = PrefsPropsUtil.getContent(message.getCompanyId(), PropsKeys.DISCUSSION_EMAIL_SUBJECT); String body = PrefsPropsUtil.getContent(message.getCompanyId(), PropsKeys.DISCUSSION_EMAIL_BODY); SubscriptionSender subscriptionSender = new SubscriptionSender(); subscriptionSender.setBody(body); subscriptionSender.setCompanyId(message.getCompanyId()); subscriptionSender.setContextAttributes("[$COMMENTS_BODY$]", message.getBody(true), "[$COMMENTS_USER_ADDRESS$]", userAddress, "[$COMMENTS_USER_NAME$]", userName, "[$CONTENT_URL$]", contentURL); subscriptionSender.setFrom(fromAddress, fromName); subscriptionSender.setHtmlFormat(true); subscriptionSender.setMailId("mb_discussion", message.getCategoryId(), message.getMessageId()); subscriptionSender.setScopeGroupId(message.getGroupId()); subscriptionSender.setServiceContext(serviceContext); subscriptionSender.setSubject(subject); subscriptionSender.setUserId(message.getUserId()); String className = (String) serviceContext.getAttribute("className"); long classPK = GetterUtil.getLong((String) serviceContext.getAttribute("classPK")); subscriptionSender.addPersistedSubscribers(className, classPK); subscriptionSender.flushNotificationsAsync(); }
From source file:com.liferay.socialnetworking.service.impl.WallEntryLocalServiceImpl.java
License:Open Source License
protected void sendEmail(WallEntry wallEntry, ThemeDisplay themeDisplay) throws Exception { long companyId = wallEntry.getCompanyId(); String portalURL = PortalUtil.getPortalURL(themeDisplay); String layoutURL = PortalUtil.getLayoutURL(themeDisplay); String wallEntryURL = portalURL + layoutURL; Group group = GroupLocalServiceUtil.getGroup(wallEntry.getGroupId()); User user = userLocalService.getUserById(group.getClassPK()); User wallEntryUser = userLocalService.getUserById(wallEntry.getUserId()); String fromName = PrefsPropsUtil.getString(companyId, PropsKeys.ADMIN_EMAIL_FROM_NAME); String fromAddress = PrefsPropsUtil.getString(companyId, PropsKeys.ADMIN_EMAIL_FROM_ADDRESS); String toName = user.getFullName(); String toAddress = user.getEmailAddress(); String subject = StringUtil.read(getClassLoader(), "com/liferay/socialnetworking/wall/dependencies/" + "wall_entry_added_subject.tmpl"); String body = StringUtil.read(getClassLoader(), "com/liferay/socialnetworking/wall/dependencies/" + "wall_entry_added_body.tmpl"); subject = StringUtil.replace(subject, new String[] { "[$FROM_ADDRESS$]", "[$FROM_NAME$]", "[$TO_ADDRESS$]", "[$TO_NAME$]", "[$WALL_ENTRY_URL$]", "[$WALL_ENTRY_USER_ADDRESS$]", "[$WALL_ENTRY_USER_NAME$]" }, new String[] { fromAddress, fromName, toAddress, toName, wallEntryURL, wallEntryUser.getEmailAddress(), wallEntryUser.getFullName() }); body = StringUtil.replace(body,/* w w w .java2 s .co m*/ new String[] { "[$FROM_ADDRESS$]", "[$FROM_NAME$]", "[$TO_ADDRESS$]", "[$TO_NAME$]", "[$WALL_ENTRY_URL$]", "[$WALL_ENTRY_USER_ADDRESS$]", "[$WALL_ENTRY_USER_NAME$]" }, new String[] { fromAddress, fromName, toAddress, toName, wallEntryURL, wallEntryUser.getEmailAddress(), wallEntryUser.getFullName() }); InternetAddress from = new InternetAddress(fromAddress, fromName); InternetAddress to = new InternetAddress(toAddress, toName); MailMessage mailMessage = new MailMessage(from, to, subject, body, true); MailServiceUtil.sendEmail(mailMessage); }
From source file:com.sympo.portlet.messageboards.service.MentionUsersMessageServiceImpl.java
License:Open Source License
private MBMessage notifyMentions(MBMessage message, ServiceContext serviceContext) throws PortalException, SystemException { if (!message.isDiscussion()) { return message; }/*from w w w . j a v a2 s . co m*/ ExpandoBridge expandoBridge = message.getExpandoBridge(); String mentionedUsers = GetterUtil.getString(expandoBridge.getAttribute("mentionedUsers")); if (Validator.isNull(mentionedUsers)) { return message; } long companyId = message.getCompanyId(); String contentURL = (String) serviceContext.getAttribute("contentURL"); String mailUserAddress = PortalUtil.getUserEmailAddress(message.getUserId()); String mailUserName = PortalUtil.getUserName(message.getUserId(), StringPool.BLANK); String fromName = PrefsPropsUtil.getString(message.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME); String fromAddress = PrefsPropsUtil.getString(message.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS); String mailSubject = ContentUtil.get(PropsUtil.get("discussion.mentioned.email.subject")); String mailBody = ContentUtil.get(PropsUtil.get("discussion.mentioned.email.body")); SubscriptionSender subscriptionSender = new SubscriptionSender(); subscriptionSender.setBody(mailBody); subscriptionSender.setCompanyId(companyId); subscriptionSender.setContextAttribute("[$COMMENTS_BODY$]", message.getBody(true), false); subscriptionSender.setContextAttributes("[$COMMENTS_USER_ADDRESS$]", mailUserAddress, "[$COMMENTS_USER_NAME$]", mailUserName, "[$CONTENT_URL$]", contentURL); subscriptionSender.setFrom(fromAddress, fromName); subscriptionSender.setHtmlFormat(true); subscriptionSender.setMailId("mb_discussion", message.getCategoryId(), message.getMessageId()); subscriptionSender.setScopeGroupId(message.getGroupId()); subscriptionSender.setServiceContext(serviceContext); subscriptionSender.setSubject(mailSubject); subscriptionSender.setUserId(message.getUserId()); String[] mentionedUsersArray = StringUtil.split(mentionedUsers); for (int i = 0; i < mentionedUsersArray.length; i++) { String screenName = mentionedUsersArray[i]; try { User mentionedUser = UserLocalServiceUtil.getUserByScreenName(companyId, screenName); subscriptionSender.addRuntimeSubscribers(mentionedUser.getEmailAddress(), mentionedUser.getFullName()); } catch (Exception e) { } } return message; }
From source file:it.sysdata.base.service.impl.UserHelper_1_1ServiceImpl.java
License:Open Source License
@Override @AccessControlled(guestAccessEnabled = true) @JSONWebService(value = "send-new-password", method = "POST") public User sendNewPassword(String emailAddress) throws PortalException, SystemException { ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); String adminEmailFromName = PrefsPropsUtil.getString(serviceContext.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME); String adminEmailFromAddress = PrefsPropsUtil.getString(serviceContext.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS); String adminEmailPasswordResetSubject = PrefsPropsUtil.getContent(serviceContext.getCompanyId(), PropsKeys.ADMIN_EMAIL_PASSWORD_RESET_SUBJECT); String adminEmailPasswordResetBody = PrefsPropsUtil.getContent(serviceContext.getCompanyId(), PropsKeys.ADMIN_EMAIL_PASSWORD_RESET_BODY); UserLocalServiceUtil.sendPassword(serviceContext.getCompanyId(), emailAddress, adminEmailFromName, adminEmailFromAddress, adminEmailPasswordResetSubject, adminEmailPasswordResetBody, serviceContext); User user = UserLocalServiceUtil.getUserByEmailAddress(serviceContext.getCompanyId(), emailAddress); return user;/*w ww .j av a 2 s. c o m*/ }
From source file:org.oep.cmon.portlet.taocongdan.mail.ChangePassRequestMail.java
License:Apache License
/** * Send mail/*from w w w. j a v a2 s .c o m*/ * @throws IOException */ public void send(ActionRequest request) throws IOException { // Get Mail template content URL resource = this.getClass().getClassLoader().getResource(MAIL_TEMPLATE); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); MailContext context = new MailContext(); // Bind value to value place holder context.setProperty("citizen_name", this.fullName); context.setProperty("citizen_matKhau", this.matKhau); context.setProperty("citizen_email", this.email); context.setProperty("url", this.url); context.setProperty("uri", this.uri); try { // Create mail content String mailContent = MailTemplateUtil.getContent("change_pass_confirmation_mail.template", resource.openStream(), context); // Get the file from class package structure URL configResource = this.getClass().getClassLoader().getResource(MAIL_CONFIG); Properties props = new Properties(); BufferedReader file = new BufferedReader(new InputStreamReader(configResource.openStream(), "utf-8")); props.load(file); String mailSubject = props.getProperty("MAIL_SUBJECT_ACCOUNT_CONFIRMATION"); //String fromAddress = props.getProperty("FROM_ADDRESS"); //String fromPerson = props.getProperty("FROM_PERSON"); String fromAddress = PrefsPropsUtil.getString(themeDisplay.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS); String fromPerson = PrefsPropsUtil.getString(themeDisplay.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME); SendMailUtil.send(this.email, fromAddress, fromPerson, mailSubject, mailContent); } catch (Exception e) { // Sending mail failure should not stop the process flow // so this exception is swallowed and stack trace is printed out here e.printStackTrace(); } }
From source file:org.oep.cmon.user.portlet.business.EndorsementBs.java
License:Apache License
/** * This is function send email destroy registration * Version: 1.0//from ww w. j a va2s. c o m * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param fullname * @param email * @param password * @param url * @param actionRequest * @throws IOException */ public void sendEmailHuyDK(String fullName, String email, String url, ActionRequest actionRequest) throws IOException { // Get Mail template content URL resource = this.getClass().getClassLoader().getResource(MAIL_TEMPLATE_HUY); MailContext context = new MailContext(); context.setProperty("citizen_name", fullName); context.setProperty("url", url); try { String mailContent = MailTemplateUtil.getContent("user_cancel_mail_template", resource.openStream(), context); URL configResource = this.getClass().getClassLoader().getResource(MAIL_CONFIG_HUY); Properties props = new Properties(); BufferedReader file = new BufferedReader(new InputStreamReader(configResource.openStream(), "utf-8")); props.load(file); String mailSubject = props.getProperty("MAIL_SUBJECT_USER_CREATION"); //String fromAddress = props.getProperty("FROM_ADDRESS"); //String fromPerson = props.getProperty("FROM_PERSON"); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String fromAddress = PrefsPropsUtil.getString(themeDisplay.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS); //String fromPerson = props.getProperty("FROM_PERSON"); String fromPerson = PrefsPropsUtil.getString(themeDisplay.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME); SendMailUtil.send(email, fromAddress, fromPerson, mailSubject, mailContent); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.oep.cmon.user.portlet.mail.UserCreationMail.java
License:Apache License
/** * Send mail//from w ww.j a v a 2 s . c o m * @throws IOException */ public void send(ActionRequest actionRequest) throws IOException { // Get Mail template content URL resource = this.getClass().getClassLoader().getResource(MAIL_TEMPLATE); MailContext context = new MailContext(); // Bind value to value place holder context.setProperty("citizen_name", this.fullName); context.setProperty("user_name", this.userName); context.setProperty("user_password", this.password); context.setProperty("url", this.url); try { // Create mail content String mailContent = MailTemplateUtil.getContent("user_creation_mail_template", resource.openStream(), context); // Get the file from class package structure URL configResource = this.getClass().getClassLoader().getResource(MAIL_CONFIG); Properties props = new Properties(); BufferedReader file = new BufferedReader(new InputStreamReader(configResource.openStream(), "utf-8")); props.load(file); String mailSubject = props.getProperty("MAIL_SUBJECT_USER_CREATION"); //String fromAddress = props.getProperty("FROM_ADDRESS"); //String fromPerson = props.getProperty("FROM_PERSON"); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String fromAddress = PrefsPropsUtil.getString(themeDisplay.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS); //String fromPerson = props.getProperty("FROM_PERSON"); String fromPerson = PrefsPropsUtil.getString(themeDisplay.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME); SendMailUtil.send(this.email, fromAddress, fromPerson, mailSubject, mailContent); } catch (Exception e) { // Sending mail failure should not stop the process flow // so this exception is swallowed and stack trace is printed out here e.printStackTrace(); } }
From source file:org.oep.cmon.userreg.portlet.mail.CitizenCreationRequestMail.java
License:Apache License
/** * This is function send email/*from w w w .j a v a 2s .c o m*/ * Version: 1.0 * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @throws toAddress * @throws request * @throws IOException */ public void send(String toAddress, ActionRequest request) throws IOException { // Get Mail template content ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); URL resource = this.getClass().getClassLoader().getResource(MAIL_TEMPLATE); MailContext context = new MailContext(); // Bind value to value place holder context.setProperty("citizen_name", this.fullName); context.setProperty("url", this.url); context.setProperty("uri", this.uri); try { // Create mail content String mailContent = MailTemplateUtil.getContent("citizen_confirmation_mail_template", resource.openStream(), context); // Get the file from class package structure URL configResource = this.getClass().getClassLoader().getResource(MAIL_CONFIG); Properties props = new Properties(); BufferedReader file = new BufferedReader(new InputStreamReader(configResource.openStream(), "utf-8")); props.load(file); String mailSubject = props.getProperty("MAIL_SUBJECT_CITIZEN_CREATION"); String fromAddress = PrefsPropsUtil.getString(themeDisplay.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS); //String fromPerson = props.getProperty("FROM_PERSON"); String fromPerson = PrefsPropsUtil.getString(themeDisplay.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME); //sendEmail(fromAddress, toAddress, mailSubject, mailContent, true); SendMailUtil.send(this.email, fromAddress, fromPerson, mailSubject, mailContent); } catch (Exception e) { // Sending mail failure should not stop the process flow // so this exception is swallowed and stack trace is printed out here e.printStackTrace(); } }
From source file:org.opencps.notificationmgt.utils.NotificationUtils.java
License:Open Source License
public static void sendEmailNotification(SendNotificationMessage message, String email, long dossierId, String userName) {// w w w . j a v a2s . com String fromAddress = StringPool.BLANK; String fromName = StringPool.BLANK; String to = StringPool.BLANK; String subject = StringPool.BLANK; String body = StringPool.BLANK; boolean htmlFormat = true; Locale locale = new Locale("vi", "VN"); try { Dossier dossier = new DossierImpl(); if (dossierId > 0) { dossier = DossierLocalServiceUtil.getDossier(dossierId); } fromAddress = Validator.isNotNull(dossier) ? PrefsPropsUtil.getString(dossier.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS) : StringPool.BLANK; fromName = PrefsPropsUtil.getString(dossier.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME); to = email; subject = PortletPropsValues.SUBJECT_TO_CUSTOMER; if (Validator.isNull(dossier.getReceptionNo())) { body = PortletPropsValues.CONTENT_TO_CUSTOMER_WITHOUT_RECEPTION_NO; } else { body = PortletPropsValues.CONTENT_TO_CUSTOMER; } subject = StringUtil.replace(subject, "[OpenCPS]", "[" + fromName + "]"); body = StringUtil.replace(body, "[receiverUserName]", "[" + userName + "]"); body = StringUtil.replace(body, "{OpenCPS}", fromName); body = StringUtil.replace(body, "{dossierId}", String.valueOf(message.getDossierId())); body = StringUtil.replace(body, "{receptionNo}", dossier.getReceptionNo()); body = StringUtil.replace(body, "{event}", PortletProps.get(message.getNotificationEventName())); body = StringUtil.replace(body, "{message}", message.getNotificationContent()); _log.info("fromAddress:" + fromAddress); _log.info("subject:" + subject); _log.info("to:" + to); SendMailUtils.sendEmail(fromAddress, fromName, to, StringPool.BLANK, subject, body, htmlFormat); } catch (Exception e) { _log.error(e); } }