use of com.liferay.portal.kernel.model.LayoutTemplate in project liferay-db-setup-core by ableneo.
the class SetupPages method setLayoutTemplate.
public static void setLayoutTemplate(final Layout layout, final PageType page, final long userid) {
if (layout.getLayoutType() instanceof LayoutTypePortlet) {
LayoutTypePortlet portletLayout = (LayoutTypePortlet) layout.getLayoutType();
if (page.isClearPage()) {
if (page.getPagePortlet() != null && !page.getPagePortlet().isEmpty() && page.getLinkToUrl() != null && !page.getLinkToUrl().equals("")) {
LOG.error("This is a link page! It cannot be cleared. If you intend to use this page for portlets, please delete this page, or remove the link from the page!");
} else {
removeAllPortlets(userid, portletLayout, layout);
}
}
String themeId = null;
try {
if (!Validator.isBlank(page.getLayoutThemeId())) {
themeId = page.getLayoutThemeId();
}
LayoutTemplate layoutTemplate = LayoutTemplateLocalServiceUtil.getLayoutTemplate(page.getLayout(), false, themeId);
if (layoutTemplate != null) {
LOG.info(String.format("Setting layout to %1$s for page %2$s", page.getLayout(), page.getName()));
if (themeId != null) {
LOG.info(String.format(LAYOUT_WAS_LOOKED_UP_IN_THEME, themeId));
}
portletLayout.setLayoutTemplateId(UserLocalServiceUtil.getDefaultUserId(layout.getCompanyId()), layoutTemplate.getLayoutTemplateId());
LayoutLocalServiceUtil.updateLayout(layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), layout.getTypeSettings());
} else {
LOG.error(String.format("Layout template %1$s not found !", page.getLayout()));
if (themeId != null) {
LOG.error(String.format(LAYOUT_WAS_LOOKED_UP_IN_THEME, themeId));
}
}
} catch (Exception e) {
LOG.error(String.format("Error by setting layout template : %1$s", page.getLayout()), e);
if (themeId != null) {
LOG.error(String.format(LAYOUT_WAS_LOOKED_UP_IN_THEME, themeId));
}
}
}
}
Aggregations