List of usage examples for com.liferay.portal.kernel.util HttpUtil getProtocol
public static String getProtocol(String url)
From source file:com.beorn.paypalpaymentplugin.util.PayPalUtil.java
License:Open Source License
public static String getReturnUrl(ServletContext servletContext, String successUrl, String errorUrl) { String returnUrl = HttpUtil.getProtocol(successUrl) + "://" + HttpUtil.getDomain(successUrl); returnUrl += servletContext.getContextPath() + _returnServletPath; returnUrl = HttpUtil.addParameter(returnUrl, "successUrl", successUrl); returnUrl = HttpUtil.addParameter(returnUrl, "errorUrl", errorUrl); return returnUrl; }
From source file:com.liferay.iframe.web.internal.portlet.action.IFrameConfigurationAction.java
License:Open Source License
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String src = getParameter(actionRequest, "src"); if (!src.startsWith("/") && !StringUtil.startsWith(src, "http://") && !StringUtil.startsWith(src, "https://") && !StringUtil.startsWith(src, "mhtml://")) { src = HttpUtil.getProtocol(actionRequest) + "://" + src; setPreference(actionRequest, "src", src); }/*from ww w. j a v a 2 s . co m*/ String[] htmlAttributes = StringUtil.splitLines(getParameter(actionRequest, "htmlAttributes")); for (String htmlAttribute : htmlAttributes) { int pos = htmlAttribute.indexOf(CharPool.EQUAL); if (pos == -1) { continue; } String key = htmlAttribute.substring(0, pos); String value = htmlAttribute.substring(pos + 1); setPreference(actionRequest, key, value); } super.processAction(portletConfig, actionRequest, actionResponse); }
From source file:com.liferay.journal.util.impl.JournalUtil.java
License:Open Source License
private static void _populateTokens(Map<String, String> tokens, long articleGroupId, ThemeDisplay themeDisplay) throws PortalException { Layout layout = themeDisplay.getLayout(); Group group = layout.getGroup(); LayoutSet layoutSet = layout.getLayoutSet(); String friendlyUrlCurrent = null; if (layout.isPublicLayout()) { friendlyUrlCurrent = themeDisplay.getPathFriendlyURLPublic(); } else if (group.isUserGroup()) { friendlyUrlCurrent = themeDisplay.getPathFriendlyURLPrivateUser(); } else {/*from w ww. j av a2s.co m*/ friendlyUrlCurrent = themeDisplay.getPathFriendlyURLPrivateGroup(); } String layoutSetFriendlyUrl = themeDisplay.getI18nPath(); String virtualHostname = layoutSet.getVirtualHostname(); if (Validator.isNull(virtualHostname) || !virtualHostname.equals(themeDisplay.getServerName())) { layoutSetFriendlyUrl = friendlyUrlCurrent + group.getFriendlyURL(); } tokens.put("article_group_id", String.valueOf(articleGroupId)); tokens.put("cdn_host", themeDisplay.getCDNHost()); tokens.put("company_id", String.valueOf(themeDisplay.getCompanyId())); tokens.put("friendly_url_current", friendlyUrlCurrent); tokens.put("friendly_url_private_group", themeDisplay.getPathFriendlyURLPrivateGroup()); tokens.put("friendly_url_private_user", themeDisplay.getPathFriendlyURLPrivateUser()); tokens.put("friendly_url_public", themeDisplay.getPathFriendlyURLPublic()); tokens.put("group_friendly_url", group.getFriendlyURL()); tokens.put("image_path", themeDisplay.getPathImage()); tokens.put("layout_set_friendly_url", layoutSetFriendlyUrl); tokens.put("main_path", themeDisplay.getPathMain()); tokens.put("portal_ctx", themeDisplay.getPathContext()); tokens.put("portal_url", HttpUtil.removeProtocol(themeDisplay.getURLPortal())); tokens.put("protocol", HttpUtil.getProtocol(themeDisplay.getURLPortal())); tokens.put("root_path", themeDisplay.getPathContext()); tokens.put("scope_group_id", String.valueOf(themeDisplay.getScopeGroupId())); tokens.put("site_group_id", String.valueOf(themeDisplay.getSiteGroupId())); tokens.put("theme_image_path", themeDisplay.getPathThemeImages()); _populateCustomTokens(tokens, themeDisplay.getCompanyId()); // Deprecated tokens tokens.put("friendly_url", themeDisplay.getPathFriendlyURLPublic()); tokens.put("friendly_url_private", themeDisplay.getPathFriendlyURLPrivateGroup()); tokens.put("group_id", String.valueOf(articleGroupId)); tokens.put("page_url", themeDisplay.getPathFriendlyURLPublic()); }
From source file:com.liferay.journal.util.impl.JournalUtil.java
License:Open Source License
private static void _populateTokens(Map<String, String> tokens, long articleGroupId, ThemeDisplayModel themeDisplayModel) throws Exception { Layout layout = LayoutLocalServiceUtil.getLayout(themeDisplayModel.getPlid()); Group group = layout.getGroup(); LayoutSet layoutSet = layout.getLayoutSet(); String friendlyUrlCurrent = null; if (layout.isPublicLayout()) { friendlyUrlCurrent = themeDisplayModel.getPathFriendlyURLPublic(); } else if (group.isUserGroup()) { friendlyUrlCurrent = themeDisplayModel.getPathFriendlyURLPrivateUser(); } else {//from ww w.ja va 2s . c om friendlyUrlCurrent = themeDisplayModel.getPathFriendlyURLPrivateGroup(); } String layoutSetFriendlyUrl = themeDisplayModel.getI18nPath(); String virtualHostname = layoutSet.getVirtualHostname(); if (Validator.isNull(virtualHostname) || !virtualHostname.equals(themeDisplayModel.getServerName())) { layoutSetFriendlyUrl = friendlyUrlCurrent + group.getFriendlyURL(); } tokens.put("article_group_id", String.valueOf(articleGroupId)); tokens.put("cdn_host", themeDisplayModel.getCdnHost()); tokens.put("company_id", String.valueOf(themeDisplayModel.getCompanyId())); tokens.put("friendly_url_current", friendlyUrlCurrent); tokens.put("friendly_url_private_group", themeDisplayModel.getPathFriendlyURLPrivateGroup()); tokens.put("friendly_url_private_user", themeDisplayModel.getPathFriendlyURLPrivateUser()); tokens.put("friendly_url_public", themeDisplayModel.getPathFriendlyURLPublic()); tokens.put("group_friendly_url", group.getFriendlyURL()); tokens.put("image_path", themeDisplayModel.getPathImage()); tokens.put("layout_set_friendly_url", layoutSetFriendlyUrl); tokens.put("main_path", themeDisplayModel.getPathMain()); tokens.put("portal_ctx", themeDisplayModel.getPathContext()); tokens.put("portal_url", HttpUtil.removeProtocol(themeDisplayModel.getURLPortal())); tokens.put("protocol", HttpUtil.getProtocol(themeDisplayModel.getURLPortal())); tokens.put("root_path", themeDisplayModel.getPathContext()); tokens.put("scope_group_id", String.valueOf(themeDisplayModel.getScopeGroupId())); tokens.put("theme_image_path", themeDisplayModel.getPathThemeImages()); _populateCustomTokens(tokens, themeDisplayModel.getCompanyId()); // Deprecated tokens tokens.put("friendly_url", themeDisplayModel.getPathFriendlyURLPublic()); tokens.put("friendly_url_private", themeDisplayModel.getPathFriendlyURLPrivateGroup()); tokens.put("group_id", String.valueOf(articleGroupId)); tokens.put("page_url", themeDisplayModel.getPathFriendlyURLPublic()); }
From source file:com.liferay.portlet.iframe.action.ConfigurationActionImpl.java
License:Open Source License
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String src = getParameter(actionRequest, "src"); if (!src.startsWith("/") && !StringUtil.startsWith(src, "http://") && !StringUtil.startsWith(src, "https://") && !StringUtil.startsWith(src, "mhtml://")) { src = HttpUtil.getProtocol(actionRequest) + "://" + src; setPreference(actionRequest, "src", src); }//from ww w . j ava 2 s. c o m String[] htmlAttributes = StringUtil.splitLines(getParameter(actionRequest, "htmlAttributes")); for (String htmlAttribute : htmlAttributes) { int pos = htmlAttribute.indexOf(CharPool.EQUAL); if (pos == -1) { continue; } String key = htmlAttribute.substring(0, pos); String value = htmlAttribute.substring(pos + 1, htmlAttribute.length()); setPreference(actionRequest, key, value); } super.processAction(portletConfig, actionRequest, actionResponse); }
From source file:com.liferay.portlet.journal.util.JournalUtil.java
License:Open Source License
private static void _populateTokens(Map<String, String> tokens, long groupId, String xmlRequest) throws Exception { Document requestDocument = SAXReaderUtil.read(xmlRequest); Element rootElement = requestDocument.getRootElement(); Element themeDisplayElement = rootElement.element("theme-display"); Layout layout = LayoutLocalServiceUtil .getLayout(GetterUtil.getLong(themeDisplayElement.elementText("plid"))); Group group = layout.getGroup(); LayoutSet layoutSet = layout.getLayoutSet(); String friendlyUrlCurrent = null; if (layout.isPublicLayout()) { friendlyUrlCurrent = themeDisplayElement.elementText("path-friendly-url-public"); } else if (group.isUserGroup()) { friendlyUrlCurrent = themeDisplayElement.elementText("path-friendly-url-private-user"); } else {/* w w w. jav a 2s.c o m*/ friendlyUrlCurrent = themeDisplayElement.elementText("path-friendly-url-private-group"); } String layoutSetFriendlyUrl = StringPool.BLANK; String virtualHostname = layoutSet.getVirtualHostname(); if (Validator.isNull(virtualHostname) || !virtualHostname.equals(themeDisplayElement.elementText("server-name"))) { layoutSetFriendlyUrl = friendlyUrlCurrent + group.getFriendlyURL(); } tokens.put("cdn_host", themeDisplayElement.elementText("cdn-host")); tokens.put("company_id", themeDisplayElement.elementText("company-id")); tokens.put("friendly_url_current", friendlyUrlCurrent); tokens.put("friendly_url_private_group", themeDisplayElement.elementText("path-friendly-url-private-group")); tokens.put("friendly_url_private_user", themeDisplayElement.elementText("path-friendly-url-private-user")); tokens.put("friendly_url_public", themeDisplayElement.elementText("path-friendly-url-public")); tokens.put("group_friendly_url", group.getFriendlyURL()); tokens.put("group_id", String.valueOf(groupId)); tokens.put("image_path", themeDisplayElement.elementText("path-image")); tokens.put("layout_set_friendly_url", layoutSetFriendlyUrl); tokens.put("main_path", themeDisplayElement.elementText("path-main")); tokens.put("portal_ctx", themeDisplayElement.elementText("path-context")); tokens.put("portal_url", HttpUtil.removeProtocol(themeDisplayElement.elementText("url-portal"))); tokens.put("protocol", HttpUtil.getProtocol(themeDisplayElement.elementText("url-portal"))); tokens.put("root_path", themeDisplayElement.elementText("path-context")); tokens.put("theme_image_path", themeDisplayElement.elementText("path-theme-images")); _populateCustomTokens(tokens); // Deprecated tokens tokens.put("friendly_url", themeDisplayElement.elementText("path-friendly-url-public")); tokens.put("friendly_url_private", themeDisplayElement.elementText("path-friendly-url-private-group")); tokens.put("page_url", themeDisplayElement.elementText("path-friendly-url-public")); }
From source file:com.liferay.portlet.journal.util.JournalUtil.java
License:Open Source License
private static void _populateTokens(Map<String, String> tokens, long groupId, ThemeDisplay themeDisplay) throws PortalException, SystemException { Layout layout = themeDisplay.getLayout(); Group group = layout.getGroup(); LayoutSet layoutSet = layout.getLayoutSet(); String friendlyUrlCurrent = null; if (layout.isPublicLayout()) { friendlyUrlCurrent = themeDisplay.getPathFriendlyURLPublic(); } else if (group.isUserGroup()) { friendlyUrlCurrent = themeDisplay.getPathFriendlyURLPrivateUser(); } else {/*from www . j a va 2s . c o m*/ friendlyUrlCurrent = themeDisplay.getPathFriendlyURLPrivateGroup(); } String layoutSetFriendlyUrl = StringPool.BLANK; String virtualHostname = layoutSet.getVirtualHostname(); if (Validator.isNull(virtualHostname) || !virtualHostname.equals(themeDisplay.getServerName())) { layoutSetFriendlyUrl = friendlyUrlCurrent + group.getFriendlyURL(); } tokens.put("cdn_host", themeDisplay.getCDNHost()); tokens.put("company_id", String.valueOf(themeDisplay.getCompanyId())); tokens.put("friendly_url_current", friendlyUrlCurrent); tokens.put("friendly_url_private_group", themeDisplay.getPathFriendlyURLPrivateGroup()); tokens.put("friendly_url_private_user", themeDisplay.getPathFriendlyURLPrivateUser()); tokens.put("friendly_url_public", themeDisplay.getPathFriendlyURLPublic()); tokens.put("group_friendly_url", group.getFriendlyURL()); tokens.put("group_id", String.valueOf(groupId)); tokens.put("image_path", themeDisplay.getPathImage()); tokens.put("layout_set_friendly_url", layoutSetFriendlyUrl); tokens.put("main_path", themeDisplay.getPathMain()); tokens.put("portal_ctx", themeDisplay.getPathContext()); tokens.put("portal_url", HttpUtil.removeProtocol(themeDisplay.getURLPortal())); tokens.put("protocol", HttpUtil.getProtocol(themeDisplay.getURLPortal())); tokens.put("root_path", themeDisplay.getPathContext()); tokens.put("theme_image_path", themeDisplay.getPathThemeImages()); _populateCustomTokens(tokens); // Deprecated tokens tokens.put("friendly_url", themeDisplay.getPathFriendlyURLPublic()); tokens.put("friendly_url_private", themeDisplay.getPathFriendlyURLPrivateGroup()); tokens.put("page_url", themeDisplay.getPathFriendlyURLPublic()); }
From source file:com.liferay.portlet.webproxy.action.ConfigurationActionImpl.java
License:Open Source License
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String initUrl = getParameter(actionRequest, "initUrl"); if (!initUrl.startsWith("/") && !StringUtil.startsWith(initUrl, "http://") && !StringUtil.startsWith(initUrl, "https://") && !StringUtil.startsWith(initUrl, "mhtml://")) { initUrl = HttpUtil.getProtocol(actionRequest) + "://" + initUrl; }/*from w w w . j a va2s . c om*/ setPreference(actionRequest, "initUrl", initUrl); super.processAction(portletConfig, actionRequest, actionResponse); }
From source file:com.liferay.rss.web.internal.util.RSSFeed.java
License:Open Source License
public RSSFeed(RSSWebCacheConfiguration rssWebCacheConfiguration, String url, String title) { _rssWebCacheConfiguration = rssWebCacheConfiguration; _url = url;//from w w w.j a v a 2 s. co m SyndFeed syndFeed = getSyndFeed(); if (syndFeed == null) { _baseURL = StringPool.BLANK; _syndFeedImageLink = StringPool.BLANK; _syndFeedImageURL = StringPool.BLANK; _syndFeedLink = StringPool.BLANK; _title = title; return; } if (Validator.isNull(title)) { title = syndFeed.getTitle(); } String baseURL = StringPool.BLANK; String syndFeedImageLink = StringPool.BLANK; String syndFeedImageURL = StringPool.BLANK; String syndFeedLink = syndFeed.getLink(); if (Validator.isNull(syndFeedLink) || !HttpUtil.hasDomain(syndFeedLink)) { baseURL = HttpUtil.getProtocol(_url).concat(Http.PROTOCOL_DELIMITER).concat(HttpUtil.getDomain(_url)); if (Validator.isNotNull(syndFeedLink)) { syndFeedLink = baseURL.concat(syndFeedLink); } else { syndFeedLink = baseURL; } } else { baseURL = HttpUtil.getProtocol(syndFeedLink).concat(Http.PROTOCOL_DELIMITER) .concat(HttpUtil.getDomain(syndFeedLink)); } SyndImage syndImage = syndFeed.getImage(); if (syndImage != null) { syndFeedImageLink = syndImage.getLink(); if (!HttpUtil.hasDomain(syndFeedImageLink)) { syndFeedImageLink = baseURL + syndFeedImageLink; } syndFeedImageURL = syndImage.getUrl(); if (!HttpUtil.hasDomain(syndFeedImageURL)) { syndFeedImageURL = baseURL + syndFeedImageURL; } } _baseURL = baseURL; _syndFeedImageLink = syndFeedImageLink; _syndFeedImageURL = syndFeedImageURL; _syndFeedLink = syndFeedLink; _title = title; }
From source file:com.liferay.rtl.servlet.filters.dynamiccss.DynamicCSSFilter.java
License:Open Source License
protected String getCacheFileName(HttpServletRequest request) { CacheKeyGenerator cacheKeyGenerator = CacheKeyGeneratorUtil .getCacheKeyGenerator(DynamicCSSFilter.class.getName()); cacheKeyGenerator.append(HttpUtil.getProtocol(request.isSecure())); cacheKeyGenerator.append(StringPool.UNDERLINE); cacheKeyGenerator.append(request.getRequestURI()); String queryString = request.getQueryString(); if (queryString != null) { cacheKeyGenerator.append(sterilizeQueryString(queryString)); }// w ww. j ava2s . co m return String.valueOf(cacheKeyGenerator.finish()); }