List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getCompany
public Company getCompany()
From source file:com.liferay.asset.publisher.web.internal.util.AssetPublisherWebUtil.java
License:Open Source License
public Map<String, String> getEmailDefinitionTerms(PortletRequest portletRequest, String emailFromAddress, String emailFromName) {//from w w w. j a v a 2 s. c o m ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Map<String, String> definitionTerms = new LinkedHashMap<>(); definitionTerms.put("[$ASSET_ENTRIES$]", LanguageUtil.get(themeDisplay.getLocale(), "the-list-of-assets")); definitionTerms.put("[$COMPANY_ID$]", LanguageUtil.get(themeDisplay.getLocale(), "the-company-id-associated-with-the-assets")); definitionTerms.put("[$COMPANY_MX$]", LanguageUtil.get(themeDisplay.getLocale(), "the-company-mx-associated-with-the-assets")); definitionTerms.put("[$COMPANY_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-company-name-associated-with-the-assets")); definitionTerms.put("[$FROM_ADDRESS$]", HtmlUtil.escape(emailFromAddress)); definitionTerms.put("[$FROM_NAME$]", HtmlUtil.escape(emailFromName)); Company company = themeDisplay.getCompany(); definitionTerms.put("[$PORTAL_URL$]", company.getVirtualHostname()); definitionTerms.put("[$PORTLET_NAME$]", HtmlUtil.escape( _portal.getPortletTitle(AssetPublisherPortletKeys.ASSET_PUBLISHER, themeDisplay.getLocale()))); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); definitionTerms.put("[$PORTLET_TITLE$]", HtmlUtil.escape(portletDisplay.getTitle())); definitionTerms.put("[$SITE_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-site-name-associated-with-the-assets")); definitionTerms.put("[$TO_ADDRESS$]", LanguageUtil.get(themeDisplay.getLocale(), "the-address-of-the-email-recipient")); definitionTerms.put("[$TO_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-name-of-the-email-recipient")); return definitionTerms; }
From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java
License:Open Source License
public static Map<String, String> getEmailDefinitionTerms(PortletRequest portletRequest, String emailFromAddress, String emailFromName) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Map<String, String> definitionTerms = new LinkedHashMap<>(); definitionTerms.put("[$ASSET_ENTRIES$]", LanguageUtil.get(themeDisplay.getLocale(), "the-list-of-assets")); definitionTerms.put("[$COMPANY_ID$]", LanguageUtil.get(themeDisplay.getLocale(), "the-company-id-associated-with-the-assets")); definitionTerms.put("[$COMPANY_MX$]", LanguageUtil.get(themeDisplay.getLocale(), "the-company-mx-associated-with-the-assets")); definitionTerms.put("[$COMPANY_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-company-name-associated-with-the-assets")); definitionTerms.put("[$FROM_ADDRESS$]", HtmlUtil.escape(emailFromAddress)); definitionTerms.put("[$FROM_NAME$]", HtmlUtil.escape(emailFromName)); Company company = themeDisplay.getCompany(); definitionTerms.put("[$PORTAL_URL$]", company.getVirtualHostname()); definitionTerms.put("[$PORTLET_NAME$]", HtmlUtil.escape( PortalUtil.getPortletTitle(AssetPublisherPortletKeys.ASSET_PUBLISHER, themeDisplay.getLocale()))); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); definitionTerms.put("[$PORTLET_TITLE$]", HtmlUtil.escape(portletDisplay.getTitle())); definitionTerms.put("[$SITE_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-site-name-associated-with-the-assets")); definitionTerms.put("[$TO_ADDRESS$]", LanguageUtil.get(themeDisplay.getLocale(), "the-address-of-the-email-recipient")); definitionTerms.put("[$TO_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-name-of-the-email-recipient")); return definitionTerms; }
From source file:com.liferay.blogs.util.BlogsUtil.java
License:Open Source License
public static Map<String, String> getEmailDefinitionTerms(PortletRequest portletRequest, String emailFromAddress, String emailFromName) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Map<String, String> definitionTerms = new LinkedHashMap<>(); definitionTerms.put("[$BLOGS_ENTRY_CONTENT$]", LanguageUtil.get(themeDisplay.getLocale(), "the-blog-entry-content")); definitionTerms.put("[$BLOGS_ENTRY_CREATE_DATE$]", LanguageUtil.get(themeDisplay.getLocale(), "the-date-the-blog-entry-was-created")); definitionTerms.put("[$BLOGS_ENTRY_DESCRIPTION$]", LanguageUtil.get(themeDisplay.getLocale(), "the-blog-entry-description")); definitionTerms.put("[$BLOGS_ENTRY_SITE_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-name-of-the-site-where-the-blog-entry-was-created")); definitionTerms.put("[$BLOGS_ENTRY_STATUS_BY_USER_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-user-who-updated-the-blog-entry")); definitionTerms.put("[$BLOGS_ENTRY_TITLE$]", LanguageUtil.get(themeDisplay.getLocale(), "the-blog-entry-title")); definitionTerms.put("[$BLOGS_ENTRY_UPDATE_COMMENT$]", LanguageUtil.get(themeDisplay.getLocale(), "the-comment-of-the-user-who-updated-the-blog-entry")); definitionTerms.put("[$BLOGS_ENTRY_USER_ADDRESS$]", LanguageUtil.get(themeDisplay.getLocale(), "the-email-address-of-the-user-who-added-the-blog-entry")); definitionTerms.put("[$BLOGS_ENTRY_USER_PORTRAIT_URL$]", LanguageUtil.get(themeDisplay.getLocale(), "the-portrait-url-of-the-user-who-added-the-blog-entry")); definitionTerms.put("[$BLOGS_ENTRY_USER_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-user-who-added-the-blog-entry")); definitionTerms.put("[$BLOGS_ENTRY_USER_URL$]", LanguageUtil.get(themeDisplay.getLocale(), "the-public-site-url-of-the-user-who-added-the-blog-entry")); definitionTerms.put("[$BLOGS_ENTRY_URL$]", LanguageUtil.get(themeDisplay.getLocale(), "the-blog-entry-url")); definitionTerms.put("[$COMPANY_ID$]", LanguageUtil.get(themeDisplay.getLocale(), "the-company-id-associated-with-the-blog")); definitionTerms.put("[$COMPANY_MX$]", LanguageUtil.get(themeDisplay.getLocale(), "the-company-mx-associated-with-the-blog")); definitionTerms.put("[$COMPANY_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-company-name-associated-with-the-blog")); definitionTerms.put("[$FROM_ADDRESS$]", HtmlUtil.escape(emailFromAddress)); definitionTerms.put("[$FROM_NAME$]", HtmlUtil.escape(emailFromName)); Company company = themeDisplay.getCompany(); definitionTerms.put("[$PORTAL_URL$]", company.getVirtualHostname()); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); definitionTerms.put("[$PORTLET_NAME$]", HtmlUtil.escape(portletDisplay.getTitle())); definitionTerms.put("[$SITE_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-site-name-associated-with-the-blog")); definitionTerms.put("[$TO_ADDRESS$]", LanguageUtil.get(themeDisplay.getLocale(), "the-address-of-the-email-recipient")); definitionTerms.put("[$TO_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-name-of-the-email-recipient")); definitionTerms.put("[$UNSUBSCRIBE_URL$]", LanguageUtil.get(themeDisplay.getLocale(), "the-url-to-unsubscribe-the-user")); return definitionTerms; }
From source file:com.liferay.bookmarks.web.internal.portlet.util.BookmarksUtil.java
License:Open Source License
public static Map<String, String> getEmailDefinitionTerms(PortletRequest portletRequest, String emailFromAddress, String emailFromName) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Map<String, String> definitionTerms = new LinkedHashMap<>(); definitionTerms.put("[$BOOKMARKS_ENTRY_USER_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-user-who-added-the-bookmark-entry")); definitionTerms.put("[$BOOKMARKS_ENTRY_STATUS_BY_USER_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-user-who-updated-the-bookmark-entry")); definitionTerms.put("[$BOOKMARKS_ENTRY_URL$]", LanguageUtil.get(themeDisplay.getLocale(), "the-bookmark-entry-url")); definitionTerms.put("[$FROM_ADDRESS$]", HtmlUtil.escape(emailFromAddress)); definitionTerms.put("[$FROM_NAME$]", HtmlUtil.escape(emailFromName)); Company company = themeDisplay.getCompany(); definitionTerms.put("[$PORTAL_URL$]", company.getVirtualHostname()); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); definitionTerms.put("[$PORTLET_NAME$]", HtmlUtil.escape(portletDisplay.getTitle())); definitionTerms.put("[$TO_ADDRESS$]", LanguageUtil.get(themeDisplay.getLocale(), "the-address-of-the-email-recipient")); definitionTerms.put("[$TO_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-name-of-the-email-recipient")); return definitionTerms; }
From source file:com.liferay.flags.taglib.servlet.taglib.soy.FlagsTag.java
License:Open Source License
@Override public int doStartTag() { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String randomNamespace = StringUtil.randomId() + StringPool.UNDERLINE; try {//from ww w . j av a2s . co m Map<String, Object> context = getContext(); boolean enabled = GetterUtil.getBoolean(context.get("enabled"), true); Company company = themeDisplay.getCompany(); putValue("companyName", company.getName()); putValue("flagsEnabled", _isFlagsEnabled(themeDisplay)); putValue("formData", _getDataJSONObject(context)); putValue("id", randomNamespace + "id"); putValue("enabled", enabled); boolean label = GetterUtil.getBoolean(context.get("label"), true); putValue("label", label); String message = GetterUtil.getString(context.get("message"), LanguageUtil.get(request, "flag")); putValue("message", message); putValue("pathTermsOfUse", themeDisplay.getPathMain() + "/portal/terms_of_use"); putValue("pathThemeImages", themeDisplay.getPathThemeImages()); putValue("portletNamespace", PortalUtil.getPortletNamespace(PortletKeys.FLAGS)); boolean signedIn = themeDisplay.isSignedIn(); putValue("signedIn", signedIn); if (signedIn) { User user = themeDisplay.getUser(); putValue("reporterEmailAddress", user.getEmailAddress()); } String title = message; if (!enabled) { title = LanguageUtil.get(request, "flags-are-disabled-because-this-entry-is-in-the-recycle-" + "bin"); } putValue("title", title); putValue("uri", _getURI()); putValue("reasons", _getReasons(themeDisplay.getCompanyId())); } catch (Exception e) { _log.error(e, e); } setTemplateNamespace("Flags.render"); return super.doStartTag(); }
From source file:com.liferay.journal.transformer.JournalTransformer.java
License:Open Source License
protected Company getCompany(ThemeDisplay themeDisplay, long companyId) throws Exception { if (themeDisplay != null) { return themeDisplay.getCompany(); }/*w w w . java 2 s . c o m*/ return CompanyLocalServiceUtil.getCompany(companyId); }
From source file:com.liferay.journal.util.impl.JournalUtil.java
License:Open Source License
public static Map<String, String> getEmailDefinitionTerms(PortletRequest portletRequest, String emailFromAddress, String emailFromName, String emailType) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); String fromAddress = HtmlUtil.escape(emailFromAddress); String fromName = HtmlUtil.escape(emailFromName); String toAddress = LanguageUtil.get(themeDisplay.getLocale(), "the-address-of-the-email-recipient"); String toName = LanguageUtil.get(themeDisplay.getLocale(), "the-name-of-the-email-recipient"); if (emailType.equals("requested")) { toName = fromName;//from w ww .j ava 2s .co m toAddress = fromAddress; fromName = LanguageUtil.get(themeDisplay.getLocale(), "the-name-of-the-email-sender"); fromAddress = LanguageUtil.get(themeDisplay.getLocale(), "the-address-of-the-email-sender"); } Map<String, String> definitionTerms = new LinkedHashMap<>(); definitionTerms.put("[$ARTICLE_CONTENT]", LanguageUtil.get(themeDisplay.getLocale(), "the-web-content")); definitionTerms.put("[$ARTICLE_DIFFS$]", LanguageUtil.get(themeDisplay.getLocale(), "the-web-content-compared-with-the-previous-version-web-" + "content")); definitionTerms.put("[$ARTICLE_ID$]", LanguageUtil.get(themeDisplay.getLocale(), "the-web-content-id")); definitionTerms.put("[$ARTICLE_TITLE$]", LanguageUtil.get(themeDisplay.getLocale(), "the-web-content-title")); definitionTerms.put("[$ARTICLE_URL$]", LanguageUtil.get(themeDisplay.getLocale(), "the-web-content-url")); definitionTerms.put("[$ARTICLE_VERSION$]", LanguageUtil.get(themeDisplay.getLocale(), "the-web-content-version")); definitionTerms.put("[$FROM_ADDRESS$]", fromAddress); definitionTerms.put("[$FROM_NAME$]", fromName); Company company = themeDisplay.getCompany(); definitionTerms.put("[$PORTAL_URL$]", company.getVirtualHostname()); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); definitionTerms.put("[$PORTLET_NAME$]", HtmlUtil.escape(portletDisplay.getTitle())); definitionTerms.put("[$TO_ADDRESS$]", toAddress); definitionTerms.put("[$TO_NAME$]", toName); return definitionTerms; }
From source file:com.liferay.login.extension.ForgotPasswordExtensionMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { System.out.println("ForgotPassword Render Command Override...."); ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); if (!company.isSendPassword() && !company.isSendPasswordResetLink()) { return "/login.jsp"; }//from www .j ava2 s .c o m renderResponse.setTitle(themeDisplay.translate("forgot-password")); return "/forgot_password.jsp"; }
From source file:com.liferay.login.web.internal.portlet.action.CreateAccountMVCActionCommand.java
License:Open Source License
protected void addUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { HttpServletRequest request = _portal.getHttpServletRequest(actionRequest); HttpSession session = request.getSession(); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); boolean autoPassword = true; String password1 = null;//from w w w . j a v a 2 s .c om String password2 = null; boolean autoScreenName = isAutoScreenName(); String screenName = ParamUtil.getString(actionRequest, "screenName"); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); long facebookId = ParamUtil.getLong(actionRequest, "facebookId"); String openId = ParamUtil.getString(actionRequest, "openId"); String languageId = ParamUtil.getString(actionRequest, "languageId"); String firstName = ParamUtil.getString(actionRequest, "firstName"); String middleName = ParamUtil.getString(actionRequest, "middleName"); String lastName = ParamUtil.getString(actionRequest, "lastName"); long prefixId = ParamUtil.getInteger(actionRequest, "prefixId"); long suffixId = ParamUtil.getInteger(actionRequest, "suffixId"); boolean male = ParamUtil.getBoolean(actionRequest, "male", true); int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth"); int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay"); int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear"); String jobTitle = ParamUtil.getString(actionRequest, "jobTitle"); long[] groupIds = null; long[] organizationIds = null; long[] roleIds = null; long[] userGroupIds = null; boolean sendEmail = true; ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest); if (PropsValues.LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD) { autoPassword = false; password1 = ParamUtil.getString(actionRequest, "password1"); password2 = ParamUtil.getString(actionRequest, "password2"); } boolean openIdPending = false; Boolean openIdLoginPending = (Boolean) session.getAttribute(WebKeys.OPEN_ID_LOGIN_PENDING); if ((openIdLoginPending != null) && openIdLoginPending.booleanValue() && Validator.isNotNull(openId)) { sendEmail = false; openIdPending = true; } User user = _userService.addUserWithWorkflow(company.getCompanyId(), autoPassword, password1, password2, autoScreenName, screenName, emailAddress, facebookId, openId, LocaleUtil.fromLanguageId(languageId), firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext); if (openIdPending) { session.setAttribute(WebKeys.OPEN_ID_LOGIN, Long.valueOf(user.getUserId())); session.removeAttribute(WebKeys.OPEN_ID_LOGIN_PENDING); } else { // Session messages if (user.getStatus() == WorkflowConstants.STATUS_APPROVED) { SessionMessages.add(request, "userAdded", user.getEmailAddress()); SessionMessages.add(request, "userAddedPassword", user.getPasswordUnencrypted()); } else { SessionMessages.add(request, "userPending", user.getEmailAddress()); } } // Send redirect sendRedirect(actionRequest, actionResponse, themeDisplay, user, user.getPasswordUnencrypted()); }
From source file:com.liferay.login.web.internal.portlet.action.CreateAccountMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); if (!company.isStrangers()) { throw new PrincipalException.MustBeEnabled(company.getCompanyId(), PropsKeys.COMPANY_SECURITY_STRANGERS); }// w w w .j a v a 2s. c o m actionRequest = _wrapActionRequest(actionRequest); String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try { if (cmd.equals(Constants.ADD)) { CaptchaConfiguration captchaConfiguration = getCaptchaConfiguration(); if (captchaConfiguration.createAccountCaptchaEnabled()) { CaptchaUtil.check(actionRequest); } addUser(actionRequest, actionResponse); } else if (cmd.equals(Constants.RESET)) { resetUser(actionRequest, actionResponse); } else if (cmd.equals(Constants.UPDATE)) { updateIncompleteUser(actionRequest, actionResponse); } } catch (Exception e) { if (e instanceof UserEmailAddressException.MustNotBeDuplicate || e instanceof UserScreenNameException.MustNotBeDuplicate) { String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); User user = _userLocalService.fetchUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); if ((user == null) || (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) { SessionErrors.add(actionRequest, e.getClass(), e); } else { actionResponse.setRenderParameter("mvcPath", "/update_account.jsp"); } } else if (e instanceof AddressCityException || e instanceof AddressStreetException || e instanceof AddressZipException || e instanceof CaptchaConfigurationException || e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException || e instanceof ContactBirthdayException || e instanceof ContactNameException || e instanceof DuplicateOpenIdException || e instanceof EmailAddressException || e instanceof GroupFriendlyURLException || e instanceof NoSuchCountryException || e instanceof NoSuchListTypeException || e instanceof NoSuchOrganizationException || e instanceof NoSuchRegionException || e instanceof OrganizationParentException || e instanceof PhoneNumberException || e instanceof RequiredFieldException || e instanceof RequiredUserException || e instanceof TermsOfUseException || e instanceof UserEmailAddressException || e instanceof UserIdException || e instanceof UserPasswordException || e instanceof UserScreenNameException || e instanceof UserSmsException || e instanceof WebsiteURLException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { throw e; } } if (Validator.isNull(PropsValues.COMPANY_SECURITY_STRANGERS_URL)) { return; } try { Layout layout = _layoutLocalService.getFriendlyURLLayout(themeDisplay.getScopeGroupId(), false, PropsValues.COMPANY_SECURITY_STRANGERS_URL); String redirect = _portal.getLayoutURL(layout, themeDisplay); sendRedirect(actionRequest, actionResponse, redirect); } catch (NoSuchLayoutException nsle) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(nsle, nsle); } } }