Search in sources :

Example 1 with Portlet

use of com.liferay.portal.kernel.model.Portlet 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 2 with Portlet

use of com.liferay.portal.kernel.model.Portlet 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 3 with Portlet

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

Example 4 with Portlet

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

the class ChangeLogsPortletUtils method getModerationPortletUrl.

private LiferayPortletURL getModerationPortletUrl(PortletRequest request) {
    Portlet portlet = PortletLocalServiceUtil.getPortletById(PortalConstants.MODERATION_PORTLET_NAME);
    Optional<Layout> layout = LayoutLocalServiceUtil.getLayouts(portlet.getCompanyId()).stream().filter(l -> ("/moderation").equals(l.getFriendlyURL())).findFirst();
    if (layout.isPresent()) {
        long plId = layout.get().getPlid();
        LiferayPortletURL modUrl = PortletURLFactoryUtil.create(request, PortalConstants.MODERATION_PORTLET_NAME, plId, PortletRequest.RENDER_PHASE);
        modUrl.setParameter(PortalConstants.PAGENAME, PortalConstants.PAGENAME_EDIT);
        return modUrl;
    }
    return null;
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) PortletLocalServiceUtil(com.liferay.portal.kernel.service.PortletLocalServiceUtil) PaginationParameters(org.eclipse.sw360.portal.common.datatables.data.PaginationParameters) JSONFactoryUtil.createJSONObject(com.liferay.portal.kernel.json.JSONFactoryUtil.createJSONObject) ResourceResponse(javax.portlet.ResourceResponse) DATATABLE_RECORDS_TOTAL(org.eclipse.sw360.portal.common.PortalConstants.DATATABLE_RECORDS_TOTAL) DATATABLE_RECORDS_FILTERED(org.eclipse.sw360.portal.common.PortalConstants.DATATABLE_RECORDS_FILTERED) ReferenceDocDataMixin(org.eclipse.sw360.datahandler.couchdb.DatabaseMixInForChangeLog.ReferenceDocDataMixin) DATATABLE_DISPLAY_DATA(org.eclipse.sw360.portal.common.PortalConstants.DATATABLE_DISPLAY_DATA) PortalUtil(com.liferay.portal.kernel.util.PortalUtil) Portlet(com.liferay.portal.kernel.model.Portlet) ChangeLogsMixin(org.eclipse.sw360.datahandler.couchdb.DatabaseMixInForChangeLog.ChangeLogsMixin) PaginationParser(org.eclipse.sw360.portal.common.datatables.PaginationParser) List(java.util.List) Logger(org.apache.logging.log4j.Logger) CommonUtils.nullToEmptyString(org.eclipse.sw360.datahandler.common.CommonUtils.nullToEmptyString) Iface(org.eclipse.sw360.datahandler.thrift.changelogs.ChangeLogsService.Iface) Optional(java.util.Optional) PortletUtils(org.eclipse.sw360.portal.common.PortletUtils) LiferayPortletURL(com.liferay.portal.kernel.portlet.LiferayPortletURL) ChangeLogsService(org.eclipse.sw360.datahandler.thrift.changelogs.ChangeLogsService) ChangeLogs(org.eclipse.sw360.datahandler.thrift.changelogs.ChangeLogs) JSONException(com.liferay.portal.kernel.json.JSONException) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) ThriftClients(org.eclipse.sw360.datahandler.thrift.ThriftClients) ResourceRequest(javax.portlet.ResourceRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) Lists(com.google.common.collect.Lists) ChangedFields(org.eclipse.sw360.datahandler.thrift.changelogs.ChangedFields) ImmutableList(com.google.common.collect.ImmutableList) ChangedFieldsMixin(org.eclipse.sw360.datahandler.couchdb.DatabaseMixInForChangeLog.ChangedFieldsMixin) PortletRequest(javax.portlet.PortletRequest) ReferenceDocData(org.eclipse.sw360.datahandler.thrift.changelogs.ReferenceDocData) JSONFactoryUtil.createJSONArray(com.liferay.portal.kernel.json.JSONFactoryUtil.createJSONArray) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) TException(org.apache.thrift.TException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) JSONFactoryUtil(com.liferay.portal.kernel.json.JSONFactoryUtil) JSONObject(com.liferay.portal.kernel.json.JSONObject) Layout(com.liferay.portal.kernel.model.Layout) UserCacheHolder(org.eclipse.sw360.portal.users.UserCacheHolder) LayoutLocalServiceUtil(com.liferay.portal.kernel.service.LayoutLocalServiceUtil) PortalConstants(org.eclipse.sw360.portal.common.PortalConstants) JSONArray(com.liferay.portal.kernel.json.JSONArray) Comparator(java.util.Comparator) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) 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)

Example 5 with Portlet

use of com.liferay.portal.kernel.model.Portlet in project liferay-faces-bridge-ext by liferay.

the class HeaderRequestBridgeLiferayImpl method isPortletModeAllowed.

@Override
public boolean isPortletModeAllowed(PortletMode portletMode) {
    boolean portletModeAllowed = super.isPortletModeAllowed(portletMode);
    if (portletModeAllowed && PortletMode.EDIT.equals(portletMode)) {
        ThemeDisplay themeDisplay = (ThemeDisplay) super.getAttribute(WebKeys.THEME_DISPLAY);
        try {
            Portlet portlet = (Portlet) getAttribute(WebKeys.RENDER_PORTLET);
            if (portlet == null) {
                com.liferay.portal.kernel.portlet.LiferayPortletRequest liferayPortletRequest = PortalUtil.getLiferayPortletRequest(getRequest());
                if (liferayPortletRequest != null) {
                    portlet = liferayPortletRequest.getPortlet();
                }
            }
            if (portlet == null) {
                logger.warn("Unable to determine com.liferay.portal.kernel.model.Portlet from PortletRequest");
                portletModeAllowed = !isUserInRole(RoleConstants.GUEST);
            } else {
                portletModeAllowed = PortletPermissionUtil.hasAccessPermission(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), themeDisplay.getLayout(), portlet, portletMode);
            }
        } catch (PortalException portalException) {
            logger.error(portalException);
            portletModeAllowed = false;
        }
    }
    return portletModeAllowed;
}
Also used : Portlet(com.liferay.portal.kernel.model.Portlet) PortalException(com.liferay.portal.kernel.exception.PortalException) ThemeDisplay(com.liferay.portal.kernel.theme.ThemeDisplay)

Aggregations

Portlet (com.liferay.portal.kernel.model.Portlet)10 PortletRequest (javax.portlet.PortletRequest)5 Layout (com.liferay.portal.kernel.model.Layout)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 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 SystemException (com.liferay.portal.kernel.exception.SystemException)3 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 ThemeDisplay (com.liferay.portal.kernel.theme.ThemeDisplay)2