Example usage for com.liferay.portal.kernel.service LayoutLocalServiceUtil updateLayout

List of usage examples for com.liferay.portal.kernel.service LayoutLocalServiceUtil updateLayout

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service LayoutLocalServiceUtil updateLayout.

Prototype

public static com.liferay.portal.kernel.model.Layout updateLayout(long groupId, boolean privateLayout,
        long layoutId, String typeSettings) throws com.liferay.portal.kernel.exception.PortalException 

Source Link

Document

Updates the layout replacing its type settings.

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  www . ja va 2 s .  c o m

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