Search in sources :

Example 1 with NoSuchLayoutException

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);
    }
}
Also used : Layout(com.liferay.portal.kernel.model.Layout) NoSuchLayoutException(com.liferay.portal.kernel.exception.NoSuchLayoutException) PageType(com.ableneo.liferay.portal.setup.domain.PageType) ReadOnlyException(javax.portlet.ReadOnlyException) NoSuchLayoutException(com.liferay.portal.kernel.exception.NoSuchLayoutException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException)

Aggregations

PageType (com.ableneo.liferay.portal.setup.domain.PageType)1 NoSuchLayoutException (com.liferay.portal.kernel.exception.NoSuchLayoutException)1 PortalException (com.liferay.portal.kernel.exception.PortalException)1 SystemException (com.liferay.portal.kernel.exception.SystemException)1 Layout (com.liferay.portal.kernel.model.Layout)1 ReadOnlyException (javax.portlet.ReadOnlyException)1