List of usage examples for com.liferay.portal.kernel.portlet FriendlyURLMapper populateParams
public void populateParams(String friendlyURLPath, Map<String, String[]> parameterMap, Map<String, Object> requestContext);
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 ww w . java 2 s. com 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;//from w w w . j a v a2 s. com 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; }