Example usage for com.liferay.portal.kernel.model LayoutTypePortlet setTypeSettingsProperty

List of usage examples for com.liferay.portal.kernel.model LayoutTypePortlet setTypeSettingsProperty

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model LayoutTypePortlet setTypeSettingsProperty.

Prototype

public void setTypeSettingsProperty(String key, String value);

Source Link

Usage

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  w  w  w .  ja  va  2s . com*/

    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) {
    }
}