use of com.liferay.portal.kernel.model.Layout in project liferay-db-setup-core by ableneo.
the class SetupPages method createLinkPage.
private static Layout createLinkPage(final PageType p, final long groupId, final long parentLayoutId, final long userId) {
// all values are usually retrieved via special methods from our code
// for better readability I have added the real values here
String title = "my title";
ServiceContext serviceContext = new ServiceContext();
String layoutType = LayoutConstants.TYPE_URL;
boolean hidden = p.isHidden();
String friendlyURL = p.getFriendlyUrl();
// add the layout
Layout layout = null;
try {
layout = LayoutLocalServiceUtil.addLayout(userId, groupId, false, parentLayoutId, title, title, StringPool.BLANK, layoutType, hidden, friendlyURL, serviceContext);
String linkToPageUrl = p.getLinkToUrl();
// set the value of the "link to page"
UnicodeProperties props = layout.getTypeSettingsProperties();
props.put("url", linkToPageUrl);
layout.setTypeSettingsProperties(props);
LayoutLocalServiceUtil.updateLayout(layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), layout.getTypeSettings());
} catch (PortalException | SystemException e) {
LOG.error(String.format("Could not create link page %1$s with link to url %2$s", p.getFriendlyUrl(), p.getLinkToUrl()), e);
}
return layout;
}
Aggregations