Search in sources :

Example 1 with Layout

use of com.liferay.portal.kernel.model.Layout in project liferay-db-setup-core by ableneo.

the class SetupPages method setCustomFields.

private static void setCustomFields(final long groupId, final long company, final PageType page, final Layout layout) {
    Class clazz = Layout.class;
    String resolverHint = "Resolving customized value for page " + page.getFriendlyUrl() + " " + "failed for key " + "%%key%% and value %%value%%";
    for (CustomFieldSetting cfs : page.getCustomFieldSetting()) {
        String key = cfs.getKey();
        String value = cfs.getValue();
        CustomFieldSettingUtil.setExpandoValue(resolverHint.replace("%%key%%", key).replace("%%value%%", value), groupId, company, clazz, layout.getPlid(), key, value);
    }
}
Also used : Layout(com.liferay.portal.kernel.model.Layout) CustomFieldSetting(com.ableneo.liferay.portal.setup.domain.CustomFieldSetting)

Example 2 with Layout

use of com.liferay.portal.kernel.model.Layout 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)

Example 3 with Layout

use of com.liferay.portal.kernel.model.Layout in project sw360 by eclipse.

the class ProjectPortletUtils method createVulnerabilityFriendlyUrl.

public static String createVulnerabilityFriendlyUrl(ResourceRequest request) {
    Portlet portlet = PortletLocalServiceUtil.getPortletById(PortalConstants.VULNERABILITIES_PORTLET_NAME);
    Optional<Layout> layout = LayoutLocalServiceUtil.getLayouts(portlet.getCompanyId()).stream().filter(l -> ("/vulnerabilities").equals(l.getFriendlyURL())).findFirst();
    if (layout.isPresent()) {
        long plId = layout.get().getPlid();
        LiferayPortletURL vulUrl = PortletURLFactoryUtil.create(request, PortalConstants.VULNERABILITIES_PORTLET_NAME, plId, PortletRequest.RENDER_PHASE);
        vulUrl.setParameter(PortalConstants.PAGENAME, PortalConstants.PAGENAME_DETAIL);
        vulUrl.setParameter(PortalConstants.VULNERABILITY_ID, "replacewithexternalid");
        return vulUrl.toString();
    }
    return "";
}
Also used : LiferayPortletURL(com.liferay.portal.kernel.portlet.LiferayPortletURL) java.util(java.util) PortletLocalServiceUtil(com.liferay.portal.kernel.service.PortletLocalServiceUtil) User(org.eclipse.sw360.datahandler.thrift.users.User) RenderRequest(javax.portlet.RenderRequest) BiFunction(java.util.function.BiFunction) ProjectVulnerabilityRating(org.eclipse.sw360.datahandler.thrift.vulnerabilities.ProjectVulnerabilityRating) Function(java.util.function.Function) ProjectLink(org.eclipse.sw360.datahandler.thrift.projects.ProjectLink) ResourceRequest(javax.portlet.ResourceRequest) org.eclipse.sw360.datahandler.thrift(org.eclipse.sw360.datahandler.thrift) ReleaseLink(org.eclipse.sw360.datahandler.thrift.components.ReleaseLink) VulnerabilityCheckStatus(org.eclipse.sw360.datahandler.thrift.vulnerabilities.VulnerabilityCheckStatus) CustomFieldHelper(org.eclipse.sw360.portal.common.CustomFieldHelper) PortletRequest(javax.portlet.PortletRequest) org.eclipse.sw360.datahandler.thrift.attachments(org.eclipse.sw360.datahandler.thrift.attachments) Project(org.eclipse.sw360.datahandler.thrift.projects.Project) com.google.common.collect(com.google.common.collect) LicenseNameWithText(org.eclipse.sw360.datahandler.thrift.licenseinfo.LicenseNameWithText) ProjectRelationship(org.eclipse.sw360.datahandler.thrift.projects.ProjectRelationship) SW360Utils(org.eclipse.sw360.datahandler.common.SW360Utils) Predicate(java.util.function.Predicate) Portlet(com.liferay.portal.kernel.model.Portlet) Layout(com.liferay.portal.kernel.model.Layout) Collectors(java.util.stream.Collectors) VulnerabilityRatingForProject(org.eclipse.sw360.datahandler.thrift.vulnerabilities.VulnerabilityRatingForProject) CommonUtils(org.eclipse.sw360.datahandler.common.CommonUtils) CommonUtils.arrayToList(org.eclipse.sw360.datahandler.common.CommonUtils.arrayToList) Logger(org.apache.logging.log4j.Logger) LayoutLocalServiceUtil(com.liferay.portal.kernel.service.LayoutLocalServiceUtil) UserCacheHolder(org.eclipse.sw360.portal.users.UserCacheHolder) PortalConstants(org.eclipse.sw360.portal.common.PortalConstants) NotNull(org.jetbrains.annotations.NotNull) LogManager(org.apache.logging.log4j.LogManager) StringEscapeUtils(org.apache.commons.lang.StringEscapeUtils) PortletURLFactoryUtil(com.liferay.portal.kernel.portlet.PortletURLFactoryUtil) ProjectProjectRelationship(org.eclipse.sw360.datahandler.thrift.projects.ProjectProjectRelationship) PortletUtils(org.eclipse.sw360.portal.common.PortletUtils) Portlet(com.liferay.portal.kernel.model.Portlet) Layout(com.liferay.portal.kernel.model.Layout) LiferayPortletURL(com.liferay.portal.kernel.portlet.LiferayPortletURL)

Example 4 with Layout

use of com.liferay.portal.kernel.model.Layout in project sw360 by eclipse.

the class ProjectPortletUtils method createProjectPortletUrlWithViewSizeFriendlyUrl.

public static String createProjectPortletUrlWithViewSizeFriendlyUrl(RenderRequest request, String projectId) {
    Portlet portlet = PortletLocalServiceUtil.getPortletById(PortalConstants.PROJECT_PORTLET_NAME);
    Optional<Layout> layout = LayoutLocalServiceUtil.getLayouts(portlet.getCompanyId()).stream().filter(l -> ("/projects").equals(l.getFriendlyURL())).findFirst();
    if (layout.isPresent()) {
        long plId = layout.get().getPlid();
        LiferayPortletURL projUrl = PortletURLFactoryUtil.create(request, PortalConstants.PROJECT_PORTLET_NAME, plId, PortletRequest.RENDER_PHASE);
        projUrl.setParameter(PortalConstants.PAGENAME, PortalConstants.PAGENAME_DETAIL);
        projUrl.setParameter(PortalConstants.PROJECT_ID, projectId);
        projUrl.setParameter(PortalConstants.VIEW_SIZE, "replacewithviewsize");
        return projUrl.toString();
    }
    return "";
}
Also used : LiferayPortletURL(com.liferay.portal.kernel.portlet.LiferayPortletURL) java.util(java.util) PortletLocalServiceUtil(com.liferay.portal.kernel.service.PortletLocalServiceUtil) User(org.eclipse.sw360.datahandler.thrift.users.User) RenderRequest(javax.portlet.RenderRequest) BiFunction(java.util.function.BiFunction) ProjectVulnerabilityRating(org.eclipse.sw360.datahandler.thrift.vulnerabilities.ProjectVulnerabilityRating) Function(java.util.function.Function) ProjectLink(org.eclipse.sw360.datahandler.thrift.projects.ProjectLink) ResourceRequest(javax.portlet.ResourceRequest) org.eclipse.sw360.datahandler.thrift(org.eclipse.sw360.datahandler.thrift) ReleaseLink(org.eclipse.sw360.datahandler.thrift.components.ReleaseLink) VulnerabilityCheckStatus(org.eclipse.sw360.datahandler.thrift.vulnerabilities.VulnerabilityCheckStatus) CustomFieldHelper(org.eclipse.sw360.portal.common.CustomFieldHelper) PortletRequest(javax.portlet.PortletRequest) org.eclipse.sw360.datahandler.thrift.attachments(org.eclipse.sw360.datahandler.thrift.attachments) Project(org.eclipse.sw360.datahandler.thrift.projects.Project) com.google.common.collect(com.google.common.collect) LicenseNameWithText(org.eclipse.sw360.datahandler.thrift.licenseinfo.LicenseNameWithText) ProjectRelationship(org.eclipse.sw360.datahandler.thrift.projects.ProjectRelationship) SW360Utils(org.eclipse.sw360.datahandler.common.SW360Utils) Predicate(java.util.function.Predicate) Portlet(com.liferay.portal.kernel.model.Portlet) Layout(com.liferay.portal.kernel.model.Layout) Collectors(java.util.stream.Collectors) VulnerabilityRatingForProject(org.eclipse.sw360.datahandler.thrift.vulnerabilities.VulnerabilityRatingForProject) CommonUtils(org.eclipse.sw360.datahandler.common.CommonUtils) CommonUtils.arrayToList(org.eclipse.sw360.datahandler.common.CommonUtils.arrayToList) Logger(org.apache.logging.log4j.Logger) LayoutLocalServiceUtil(com.liferay.portal.kernel.service.LayoutLocalServiceUtil) UserCacheHolder(org.eclipse.sw360.portal.users.UserCacheHolder) PortalConstants(org.eclipse.sw360.portal.common.PortalConstants) NotNull(org.jetbrains.annotations.NotNull) LogManager(org.apache.logging.log4j.LogManager) StringEscapeUtils(org.apache.commons.lang.StringEscapeUtils) PortletURLFactoryUtil(com.liferay.portal.kernel.portlet.PortletURLFactoryUtil) ProjectProjectRelationship(org.eclipse.sw360.datahandler.thrift.projects.ProjectProjectRelationship) PortletUtils(org.eclipse.sw360.portal.common.PortletUtils) Portlet(com.liferay.portal.kernel.model.Portlet) Layout(com.liferay.portal.kernel.model.Layout) LiferayPortletURL(com.liferay.portal.kernel.portlet.LiferayPortletURL)

Example 5 with Layout

use of com.liferay.portal.kernel.model.Layout in project sw360 by eclipse.

the class ModerationPortletUtils method getProjectPortletUrl.

private static LiferayPortletURL getProjectPortletUrl(PortletRequest request, String projectId) {
    Portlet portlet = PortletLocalServiceUtil.getPortletById(PortalConstants.PROJECT_PORTLET_NAME);
    Optional<Layout> layout = LayoutLocalServiceUtil.getLayouts(portlet.getCompanyId()).stream().filter(l -> ("/" + PortalConstants.PROJECTS.toLowerCase()).equals(l.getFriendlyURL())).findFirst();
    if (layout.isPresent()) {
        long plId = layout.get().getPlid();
        LiferayPortletURL projectUrl = PortletURLFactoryUtil.create(request, PortalConstants.PROJECT_PORTLET_NAME, plId, PortletRequest.RENDER_PHASE);
        projectUrl.setParameter(PortalConstants.PROJECT_ID, projectId);
        projectUrl.setParameter(PortalConstants.PAGENAME, PortalConstants.PAGENAME_DETAIL);
        return projectUrl;
    }
    return null;
}
Also used : LiferayPortletURL(com.liferay.portal.kernel.portlet.LiferayPortletURL) User(org.eclipse.sw360.datahandler.thrift.users.User) PortletLocalServiceUtil(com.liferay.portal.kernel.service.PortletLocalServiceUtil) AddDocumentRequestStatus(org.eclipse.sw360.datahandler.thrift.AddDocumentRequestStatus) CUSTOM_FIELD_PREFERRED_CLEARING_DATE_LIMIT(org.eclipse.sw360.portal.common.PortalConstants.CUSTOM_FIELD_PREFERRED_CLEARING_DATE_LIMIT) ThriftClients(org.eclipse.sw360.datahandler.thrift.ThriftClients) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) ClearingRequestState(org.eclipse.sw360.datahandler.thrift.ClearingRequestState) Comment(org.eclipse.sw360.datahandler.thrift.Comment) ClearingRequestPriority(org.eclipse.sw360.datahandler.thrift.ClearingRequestPriority) CustomFieldHelper(org.eclipse.sw360.portal.common.CustomFieldHelper) PortletRequest(javax.portlet.PortletRequest) SW360Utils(org.eclipse.sw360.datahandler.common.SW360Utils) ModerationState(org.eclipse.sw360.datahandler.thrift.ModerationState) TException(org.apache.thrift.TException) ClearingRequest(org.eclipse.sw360.datahandler.thrift.projects.ClearingRequest) Portlet(com.liferay.portal.kernel.model.Portlet) Layout(com.liferay.portal.kernel.model.Layout) Integer.parseInt(java.lang.Integer.parseInt) ModerationService(org.eclipse.sw360.datahandler.thrift.moderation.ModerationService) CommonUtils(org.eclipse.sw360.datahandler.common.CommonUtils) Logger(org.apache.logging.log4j.Logger) ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest) UserCacheHolder(org.eclipse.sw360.portal.users.UserCacheHolder) LayoutLocalServiceUtil(com.liferay.portal.kernel.service.LayoutLocalServiceUtil) DateTimeFormatter(java.time.format.DateTimeFormatter) PortalConstants(org.eclipse.sw360.portal.common.PortalConstants) Optional(java.util.Optional) LogManager(org.apache.logging.log4j.LogManager) AddDocumentRequestSummary(org.eclipse.sw360.datahandler.thrift.AddDocumentRequestSummary) PortletURLFactoryUtil(com.liferay.portal.kernel.portlet.PortletURLFactoryUtil) Portlet(com.liferay.portal.kernel.model.Portlet) Layout(com.liferay.portal.kernel.model.Layout) LiferayPortletURL(com.liferay.portal.kernel.portlet.LiferayPortletURL)

Aggregations

Layout (com.liferay.portal.kernel.model.Layout)11 PortalException (com.liferay.portal.kernel.exception.PortalException)4 SystemException (com.liferay.portal.kernel.exception.SystemException)4 Portlet (com.liferay.portal.kernel.model.Portlet)4 LiferayPortletURL (com.liferay.portal.kernel.portlet.LiferayPortletURL)4 PortletURLFactoryUtil (com.liferay.portal.kernel.portlet.PortletURLFactoryUtil)4 LayoutLocalServiceUtil (com.liferay.portal.kernel.service.LayoutLocalServiceUtil)4 PortletLocalServiceUtil (com.liferay.portal.kernel.service.PortletLocalServiceUtil)4 PortletRequest (javax.portlet.PortletRequest)4 LogManager (org.apache.logging.log4j.LogManager)4 Logger (org.apache.logging.log4j.Logger)4 User (org.eclipse.sw360.datahandler.thrift.users.User)4 PortalConstants (org.eclipse.sw360.portal.common.PortalConstants)4 UserCacheHolder (org.eclipse.sw360.portal.users.UserCacheHolder)4 ResourceRequest (javax.portlet.ResourceRequest)3 CommonUtils (org.eclipse.sw360.datahandler.common.CommonUtils)3 SW360Utils (org.eclipse.sw360.datahandler.common.SW360Utils)3 CustomFieldHelper (org.eclipse.sw360.portal.common.CustomFieldHelper)3 PortletUtils (org.eclipse.sw360.portal.common.PortletUtils)3 com.google.common.collect (com.google.common.collect)2