List of usage examples for com.liferay.portal.kernel.model Portlet getFriendlyURLMapperInstance
public com.liferay.portal.kernel.portlet.FriendlyURLMapper getFriendlyURLMapperInstance();
From source file:com.liferay.blogs.internal.util.PingbackMethodImpl.java
License:Open Source License
protected BlogsEntry getBlogsEntry(long companyId) throws Exception { BlogsEntry entry = null;/* w w w. j a v a 2 s.c om*/ 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.blogs.internal.util.PingbackMethodImplTest.java
License:Open Source License
protected void setUpPortletLocalServiceUtil() { Portlet portlet = Mockito.mock(Portlet.class); when(portlet.getFriendlyURLMapperInstance()).thenReturn(_friendlyURLMapper); when(portlet.getFriendlyURLMapping()).thenReturn(_FRIENDLY_URL_MAPPING); when(_portletLocalService.getPortletById(BlogsPortletKeys.BLOGS)).thenReturn(portlet); when(_portletLocalService.getPortletById(Matchers.anyLong(), Matchers.eq(BlogsPortletKeys.BLOGS))) .thenReturn(portlet);//from www .ja va 2 s . c o m }