Example usage for com.liferay.portal.kernel.util HttpUtil removeProtocol

List of usage examples for com.liferay.portal.kernel.util HttpUtil removeProtocol

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util HttpUtil removeProtocol.

Prototype

public static String removeProtocol(String url) 

Source Link

Usage

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  www.  ja  v  a 2 s .  c o  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 w  ww  . java2 s .  co m
        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.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 {//  ww w.ja  va2 s . 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 v a  2 s.c om*/
        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.util.portlet.PortletRequestUtil.java

License:Open Source License

private static void _themeDisplayToXML(ThemeDisplay themeDisplay, Element themeDisplayElement) {

    themeDisplayElement.addElement("cdn-host", themeDisplay.getCDNHost());
    themeDisplayElement.addElement("company-id", themeDisplay.getCompanyId());
    themeDisplayElement.addElement("do-as-user-id", themeDisplay.getDoAsUserId());
    themeDisplayElement.addElement("i18n-language-id", themeDisplay.getI18nLanguageId());
    themeDisplayElement.addElement("i18n-path", themeDisplay.getI18nPath());
    themeDisplayElement.addElement("language-id", themeDisplay.getLanguageId());
    themeDisplayElement.addElement("locale", themeDisplay.getLocale());
    themeDisplayElement.addElement("path-context", themeDisplay.getPathContext());
    themeDisplayElement.addElement("path-friendly-url-private-group",
            themeDisplay.getPathFriendlyURLPrivateGroup());
    themeDisplayElement.addElement("path-friendly-url-private-user",
            themeDisplay.getPathFriendlyURLPrivateUser());
    themeDisplayElement.addElement("path-friendly-url-public", themeDisplay.getPathFriendlyURLPublic());
    themeDisplayElement.addElement("path-image", themeDisplay.getPathImage());
    themeDisplayElement.addElement("path-main", themeDisplay.getPathMain());
    themeDisplayElement.addElement("path-theme-images", themeDisplay.getPathThemeImages());
    themeDisplayElement.addElement("plid", themeDisplay.getPlid());
    themeDisplayElement.addElement("portal-url", HttpUtil.removeProtocol(themeDisplay.getPortalURL()));
    themeDisplayElement.addElement("real-user-id", themeDisplay.getRealUserId());
    themeDisplayElement.addElement("scope-group-id", themeDisplay.getScopeGroupId());
    themeDisplayElement.addElement("secure", themeDisplay.isSecure());
    themeDisplayElement.addElement("server-name", themeDisplay.getServerName());
    themeDisplayElement.addElement("server-port", themeDisplay.getServerPort());
    themeDisplayElement.addElement("time-zone", themeDisplay.getTimeZone().getID());
    themeDisplayElement.addElement("url-portal", HttpUtil.removeProtocol(themeDisplay.getURLPortal()));
    themeDisplayElement.addElement("user-id", themeDisplay.getUserId());

    if (themeDisplay.getPortletDisplay() != null) {
        Element portletDisplayElement = themeDisplayElement.addElement("portlet-display");

        _portletDisplayToXML(themeDisplay.getPortletDisplay(), portletDisplayElement);
    }//from ww w.  j a v a  2 s  . co m
}