use of com.liferay.portal.kernel.exception.NoSuchLayoutException in project liferay-db-setup-core by ableneo.
the class SetupPages method addPages.
/**
* @param pages
* @param groupId
* @param isPrivate
* @param parentLayoutId
* @param company
* @param userId
*
* @throws SystemException
* @throws PortalException
*/
private static void addPages(final List<PageType> pages, String defaultLayout, String defaultLayoutContainedInThemeWithId, final long groupId, final boolean isPrivate, final long parentLayoutId, final long company, final long userId) throws PortalException {
for (PageType page : pages) {
Layout layout = null;
try {
layout = LayoutLocalServiceUtil.getFriendlyURLLayout(groupId, isPrivate, page.getFriendlyUrl());
LOG.info(String.format("Setup: Page %1$s already exist, not creating...", page.getName()));
if (layout != null && page.isDeleteExistingPages()) {
LayoutLocalServiceUtil.deleteLayout(layout);
if (page.getLinkToUrl() == null || page.getLinkToUrl().equals("")) {
layout = createPage(groupId, page, parentLayoutId, isPrivate);
} else {
layout = createLinkPage(page, groupId, parentLayoutId, userId);
}
} else if (layout != null && (page.getLinkToUrl() != null && !page.getLinkToUrl().equals(""))) {
updateLinkPage(page, groupId);
} else {
LOG.warn(String.format("Setup: unhandled 'else' while creatng page[%1$s]/layout[%2$s]", page.getName(), page.getLayout()));
}
} catch (NoSuchLayoutException e) {
if (page.getLinkToUrl() == null || page.getLinkToUrl().equals("")) {
layout = createPage(groupId, page, parentLayoutId, isPrivate);
} else {
layout = createLinkPage(page, groupId, parentLayoutId, userId);
}
LOG.info(String.format("Setup: Page %1$s created...", page.getName()));
} catch (Exception ex) {
LOG.error(ex);
}
// subtree
if (page.getLayout() == null) {
page.setLayout(defaultLayout);
page.setLayoutThemeId(defaultLayoutContainedInThemeWithId);
} else {
defaultLayout = page.getLayout();
defaultLayoutContainedInThemeWithId = page.getLayoutThemeId();
}
setupLiferayPage(layout, page, defaultLayout, defaultLayoutContainedInThemeWithId, groupId, isPrivate, company, userId, null);
}
}
Aggregations