Example usage for com.liferay.portal.kernel.portlet FriendlyURLMapperThreadLocal setPRPIdentifiers

List of usage examples for com.liferay.portal.kernel.portlet FriendlyURLMapperThreadLocal setPRPIdentifiers

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.portlet FriendlyURLMapperThreadLocal setPRPIdentifiers.

Prototype

public static void setPRPIdentifiers(Map<String, String> prpIdentifiers) 

Source Link

Usage

From source file:com.liferay.blogs.internal.util.PingbackMethodImpl.java

License:Open Source License

protected BlogsEntry getBlogsEntry(long companyId) throws Exception {
    BlogsEntry entry = null;//from  w ww  .  ja va  2s .  c o m

    URL url = new URL(_targetURI);

    String friendlyURL = url.getPath();

    int end = friendlyURL.indexOf(Portal.FRIENDLY_URL_SEPARATOR);

    if (end != -1) {
        friendlyURL = friendlyURL.substring(0, end);
    }

    long plid = PortalUtil.getPlidFromFriendlyURL(companyId, friendlyURL);
    long groupId = PortalUtil.getScopeGroupId(plid);

    Map<String, String[]> params = new HashMap<>();

    FriendlyURLMapperThreadLocal.setPRPIdentifiers(new HashMap<String, String>());

    String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(),
            PortletProvider.Action.VIEW);

    Portlet portlet = _portletLocalService.getPortletById(portletId);

    FriendlyURLMapper friendlyURLMapper = portlet.getFriendlyURLMapperInstance();

    friendlyURL = url.getPath();

    end = friendlyURL.indexOf(Portal.FRIENDLY_URL_SEPARATOR);

    if (end != -1) {
        friendlyURL = friendlyURL.substring(end + Portal.FRIENDLY_URL_SEPARATOR.length() - 1);
    }

    Map<String, Object> requestContext = new HashMap<>();

    friendlyURLMapper.populateParams(friendlyURL, params, requestContext);

    String param = getParam(params, "entryId");

    if (Validator.isNotNull(param)) {
        long entryId = GetterUtil.getLong(param);

        entry = _blogsEntryLocalService.getEntry(entryId);
    } else {
        String urlTitle = getParam(params, "urlTitle");

        entry = _blogsEntryLocalService.getEntry(groupId, urlTitle);
    }

    return entry;
}

From source file:com.liferay.portlet.blogs.util.PingbackMethodImpl.java

License:Open Source License

protected BlogsEntry getBlogsEntry(long companyId) throws Exception {
    BlogsEntry entry = null;// w ww . j av a 2 s  .c  o  m

    URL url = new URL(_targetUri);

    String friendlyURL = url.getPath();

    int end = friendlyURL.indexOf(Portal.FRIENDLY_URL_SEPARATOR);

    if (end != -1) {
        friendlyURL = friendlyURL.substring(0, end);
    }

    long plid = PortalUtil.getPlidFromFriendlyURL(companyId, friendlyURL);
    long groupId = PortalUtil.getScopeGroupId(plid);

    Map<String, String[]> params = new HashMap<String, String[]>();

    FriendlyURLMapperThreadLocal.setPRPIdentifiers(new HashMap<String, String>());

    Portlet portlet = PortletLocalServiceUtil.getPortletById(PortletKeys.BLOGS);

    FriendlyURLMapper friendlyURLMapper = portlet.getFriendlyURLMapperInstance();

    friendlyURL = url.getPath();

    end = friendlyURL.indexOf(Portal.FRIENDLY_URL_SEPARATOR);

    if (end != -1) {
        friendlyURL = friendlyURL.substring(end + Portal.FRIENDLY_URL_SEPARATOR.length() - 1);
    }

    Map<String, Object> requestContext = new HashMap<String, Object>();

    friendlyURLMapper.populateParams(friendlyURL, params, requestContext);

    String param = getParam(params, "entryId");

    if (Validator.isNotNull(param)) {
        long entryId = GetterUtil.getLong(param);

        entry = BlogsEntryLocalServiceUtil.getEntry(entryId);
    } else {
        String urlTitle = getParam(params, "urlTitle");

        entry = BlogsEntryLocalServiceUtil.getEntry(groupId, urlTitle);
    }

    return entry;
}