List of usage examples for com.liferay.portal.kernel.util PortalUtil getActualURL
public static String getActualURL(long groupId, boolean privateLayout, String mainPath, String friendlyURL, Map<String, String[]> params, Map<String, Object> requestContext) throws PortalException
From source file:com.liferay.asset.publisher.portlet.test.DisplayPageFriendlyURLResolverTest.java
License:Open Source License
@Test public void testJournalArticleFriendlyURL() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(); LayoutLocalServiceUtil.addLayout(TestPropsValues.getUserId(), _group.getGroupId(), false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "Home", StringPool.BLANK, StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, StringPool.BLANK, serviceContext); Layout layout = LayoutLocalServiceUtil.addLayout(TestPropsValues.getUserId(), _group.getGroupId(), false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "Test " + RandomTestUtil.nextInt(), StringPool.BLANK, StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, StringPool.BLANK, serviceContext); LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); String portletId = layoutTypePortlet.addPortletId(TestPropsValues.getUserId(), AssetPublisherPortletKeys.ASSET_PUBLISHER, "column-1", 0); layoutTypePortlet.setTypeSettingsProperty(LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID, portletId);/*from ww w .j av a2 s. c om*/ layout = LayoutLocalServiceUtil.updateLayout(layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), layout.getTypeSettings()); Map<Locale, String> titleMap = new HashMap<>(); titleMap.put(LocaleUtil.US, "Test Journal Article"); Map<Locale, String> contentMap = new HashMap<>(); contentMap.put(LocaleUtil.US, "This test content is in English."); JournalTestUtil.addArticle(_group.getGroupId(), JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID, JournalArticleConstants.CLASSNAME_ID_DEFAULT, titleMap, titleMap, contentMap, layout.getUuid(), LocaleUtil.US, null, false, false, serviceContext); String actualURL = PortalUtil.getActualURL(_group.getGroupId(), false, Portal.PATH_MAIN, "/-/test-journal-article", new HashMap<String, String[]>(), getRequestContext()); Assert.assertNotNull(actualURL); try { PortalUtil.getActualURL(_group.getGroupId(), false, Portal.PATH_MAIN, "/-/nonexistent-test-journal-article", new HashMap<String, String[]>(), getRequestContext()); Assert.fail(); } catch (NoSuchLayoutException nsle) { } }