Example usage for com.liferay.portal.kernel.model Group isStagingGroup

List of usage examples for com.liferay.portal.kernel.model Group isStagingGroup

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model Group isStagingGroup.

Prototype

public boolean isStagingGroup();

Source Link

Usage

From source file:com.liferay.asset.categories.admin.web.internal.exportimport.staged.model.repository.StagedAssetLinkStagedModelRepository.java

License:Open Source License

protected boolean isAssetEntryApplicable(AssetEntry assetEntry) throws PortalException {

    AssetRenderer<? extends StagedModel> assetRenderer = null;

    StagedModel stagedModel = null;//w w w  .ja va  2  s.  c om

    try {
        assetRenderer = (AssetRenderer<? extends StagedModel>) assetEntry.getAssetRenderer();

        stagedModel = assetRenderer.getAssetObject();
    } catch (Exception e) {
        return false;
    }

    if (stagedModel instanceof TrashedModel) {
        TrashedModel trashedModel = (TrashedModel) stagedModel;

        if (trashedModel.isInTrash()) {
            return false;
        }
    }

    if (stagedModel instanceof StagedGroupedModel) {
        StagedGroupedModel stagedGroupedModel = (StagedGroupedModel) stagedModel;

        Group group = _groupLocalService.getGroup(stagedGroupedModel.getGroupId());

        if (group.isStagingGroup()) {
            return false;
        }
    }

    return true;
}

From source file:com.liferay.asset.publisher.internal.util.AssetPublisherHelperImpl.java

License:Open Source License

@Override
public List<AssetEntry> getAssetEntries(PortletRequest portletRequest, PortletPreferences portletPreferences,
        PermissionChecker permissionChecker, long[] groupIds, boolean deleteMissingAssetEntries,
        boolean checkPermission, boolean includeNonVisibleAssets, int type) throws Exception {

    String[] assetEntryXmls = portletPreferences.getValues("assetEntryXml", new String[0]);

    List<AssetEntry> assetEntries = new ArrayList<>();

    List<String> missingAssetEntryUuids = new ArrayList<>();

    for (String assetEntryXml : assetEntryXmls) {
        Document document = SAXReaderUtil.read(assetEntryXml);

        Element rootElement = document.getRootElement();

        String assetEntryUuid = rootElement.elementText("asset-entry-uuid");

        String assetEntryType = rootElement.elementText("asset-entry-type");

        AssetRendererFactory<?> assetRendererFactory = AssetRendererFactoryRegistryUtil
                .getAssetRendererFactoryByClassName(assetEntryType);

        String portletId = assetRendererFactory.getPortletId();

        AssetEntry assetEntry = null;//from   w ww  . j a va  2 s  . co m

        for (long groupId : groupIds) {
            Group group = _groupLocalService.fetchGroup(groupId);

            if (group.isStagingGroup() && !group.isStagedPortlet(portletId)) {

                groupId = group.getLiveGroupId();
            }

            assetEntry = _assetEntryLocalService.fetchEntry(groupId, assetEntryUuid);

            if (assetEntry != null) {
                break;
            }
        }

        if (assetEntry == null) {
            if (deleteMissingAssetEntries) {
                missingAssetEntryUuids.add(assetEntryUuid);
            }

            continue;
        }

        if (!assetEntry.isVisible() && !includeNonVisibleAssets) {
            continue;
        }

        assetRendererFactory = AssetRendererFactoryRegistryUtil
                .getAssetRendererFactoryByClassName(assetEntry.getClassName());

        AssetRenderer<?> assetRenderer = assetRendererFactory.getAssetRenderer(assetEntry.getClassPK(), type);

        if (!assetRendererFactory.isActive(permissionChecker.getCompanyId())) {

            if (deleteMissingAssetEntries) {
                missingAssetEntryUuids.add(assetEntryUuid);
            }

            continue;
        }

        if (checkPermission) {
            if (!assetRenderer.isDisplayable() && !includeNonVisibleAssets) {

                continue;
            } else if (!assetRenderer.hasViewPermission(permissionChecker)) {
                assetRenderer = assetRendererFactory.getAssetRenderer(assetEntry.getClassPK(),
                        AssetRendererFactory.TYPE_LATEST_APPROVED);

                if (!assetRenderer.hasViewPermission(permissionChecker)) {
                    continue;
                }
            }
        }

        assetEntries.add(assetEntry);
    }

    if (deleteMissingAssetEntries) {
        _removeAndStoreSelection(missingAssetEntryUuids, portletPreferences);

        if (!missingAssetEntryUuids.isEmpty()) {
            SessionMessages.add(portletRequest, "deletedMissingAssetEntries", missingAssetEntryUuids);
        }
    }

    return assetEntries;
}

From source file:com.liferay.asset.publisher.web.display.context.ChildSitesItemSelectorViewDisplayContext.java

License:Open Source License

private LinkedHashMap<String, Object> _getGroupParams() throws PortalException {

    if (_groupParams != null) {
        return _groupParams;
    }//from   w w  w .j a  v  a2s  .co  m

    _groupParams = new LinkedHashMap<>();

    _groupParams.put("active", Boolean.TRUE);

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    List<Group> parentGroups = new ArrayList<>();

    parentGroups.add(themeDisplay.getSiteGroup());

    _groupParams.put("groupsTree", parentGroups);

    _groupParams.put("site", Boolean.TRUE);

    List<Long> excludedGroupIds = new ArrayList<>();

    Group group = themeDisplay.getSiteGroup();

    if (group.isStagingGroup()) {
        excludedGroupIds.add(group.getLiveGroupId());
    } else {
        excludedGroupIds.add(themeDisplay.getSiteGroupId());
    }

    _groupParams.put("excludedGroupIds", excludedGroupIds);

    return _groupParams;
}

From source file:com.liferay.asset.publisher.web.display.context.SitesThatIAdministerItemSelectorViewDisplayContext.java

License:Open Source License

private LinkedHashMap<String, Object> _getGroupParams() throws PortalException {

    if (_groupParams != null) {
        return _groupParams;
    }/*from  w  w  w.  j  a  v  a 2  s  .  c  o m*/

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
    User user = themeDisplay.getUser();

    boolean filterManageableGroups = true;

    if (permissionChecker.isCompanyAdmin()) {
        filterManageableGroups = false;
    }

    _groupParams = new LinkedHashMap<>();

    _groupParams.put("active", Boolean.TRUE);

    if (filterManageableGroups) {
        _groupParams.put("usersGroups", user.getUserId());
    }

    _groupParams.put("site", Boolean.TRUE);

    if (getGroupId() > 0) {
        List<Long> excludedGroupIds = new ArrayList<>();

        Group group = GroupLocalServiceUtil.getGroup(getGroupId());

        if (group.isStagingGroup()) {
            excludedGroupIds.add(group.getLiveGroupId());
        } else {
            excludedGroupIds.add(getGroupId());
        }

        _groupParams.put("excludedGroupIds", excludedGroupIds);
    }

    return _groupParams;
}

From source file:com.liferay.asset.publisher.web.internal.portlet.toolbar.contributor.AssetPublisherPortletToolbarContributor.java

License:Open Source License

private boolean _isVisible(AssetPublisherDisplayContext assetPublisherDisplayContext,
        PortletRequest portletRequest) {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (!assetPublisherDisplayContext.isShowAddContentButton()) {
        return false;
    }/* www .  ja va  2  s .c  o m*/

    Group scopeGroup = themeDisplay.getScopeGroup();

    if (scopeGroup.hasStagingGroup() && !scopeGroup.isStagingGroup()
            && PropsValues.STAGING_LIVE_GROUP_LOCKING_ENABLED) {

        return false;
    }

    Layout layout = themeDisplay.getLayout();

    if (layout.isLayoutPrototypeLinkActive() && assetPublisherDisplayContext.isSelectionStyleManual()) {

        return false;
    }

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    String portletName = portletDisplay.getPortletName();

    if (portletName.equals(AssetPublisherPortletKeys.HIGHEST_RATED_ASSETS)) {

        return false;
    }

    if (portletName.equals(AssetPublisherPortletKeys.MOST_VIEWED_ASSETS)) {
        return false;
    }

    if (portletName.equals(AssetPublisherPortletKeys.RELATED_ASSETS)) {
        return false;
    }

    return true;
}

From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java

License:Open Source License

public static List<AssetEntry> getAssetEntries(PortletRequest portletRequest,
        PortletPreferences portletPreferences, PermissionChecker permissionChecker, long[] groupIds,
        boolean deleteMissingAssetEntries, boolean checkPermission, boolean includeNonVisibleAssets, int type)
        throws Exception {

    String[] assetEntryXmls = portletPreferences.getValues("assetEntryXml", new String[0]);

    List<AssetEntry> assetEntries = new ArrayList<>();

    List<String> missingAssetEntryUuids = new ArrayList<>();

    for (String assetEntryXml : assetEntryXmls) {
        Document document = SAXReaderUtil.read(assetEntryXml);

        Element rootElement = document.getRootElement();

        String assetEntryUuid = rootElement.elementText("asset-entry-uuid");

        String assetEntryType = rootElement.elementText("asset-entry-type");

        AssetRendererFactory<?> assetRendererFactory = AssetRendererFactoryRegistryUtil
                .getAssetRendererFactoryByClassName(assetEntryType);

        String portletId = assetRendererFactory.getPortletId();

        AssetEntry assetEntry = null;/*from w  w  w .j a  v a 2 s. c o m*/

        for (long groupId : groupIds) {
            Group group = _groupLocalService.fetchGroup(groupId);

            if (group.isStagingGroup() && !group.isStagedPortlet(portletId)) {

                groupId = group.getLiveGroupId();
            }

            assetEntry = _assetEntryLocalService.fetchEntry(groupId, assetEntryUuid);

            if (assetEntry != null) {
                break;
            }
        }

        if (assetEntry == null) {
            if (deleteMissingAssetEntries) {
                missingAssetEntryUuids.add(assetEntryUuid);
            }

            continue;
        }

        if (!assetEntry.isVisible() && !includeNonVisibleAssets) {
            continue;
        }

        assetRendererFactory = AssetRendererFactoryRegistryUtil
                .getAssetRendererFactoryByClassName(assetEntry.getClassName());

        AssetRenderer<?> assetRenderer = assetRendererFactory.getAssetRenderer(assetEntry.getClassPK(), type);

        if (!assetRendererFactory.isActive(permissionChecker.getCompanyId())) {

            if (deleteMissingAssetEntries) {
                missingAssetEntryUuids.add(assetEntryUuid);
            }

            continue;
        }

        if (checkPermission) {
            if (!assetRenderer.isDisplayable() && !includeNonVisibleAssets) {

                continue;
            } else if (!assetRenderer.hasViewPermission(permissionChecker)) {
                assetRenderer = assetRendererFactory.getAssetRenderer(assetEntry.getClassPK(),
                        AssetRendererFactory.TYPE_LATEST_APPROVED);

                if (!assetRenderer.hasViewPermission(permissionChecker)) {
                    continue;
                }
            }
        }

        assetEntries.add(assetEntry);
    }

    if (deleteMissingAssetEntries) {
        removeAndStoreSelection(missingAssetEntryUuids, portletPreferences);

        if (!missingAssetEntryUuids.isEmpty()) {
            SessionMessages.add(portletRequest, "deletedMissingAssetEntries", missingAssetEntryUuids);
        }
    }

    return assetEntries;
}

From source file:com.liferay.asset.taglib.internal.display.context.InputAssetLinksDisplayContext.java

License:Open Source License

private long _getAssetBrowserGroupId(AssetRendererFactory<?> assetRendererFactory) {

    Group scopeGroup = _themeDisplay.getScopeGroup();

    long groupId = scopeGroup.getGroupId();

    if (_isStagedLocally() && scopeGroup.isStagingGroup()) {
        boolean stagedReferencePortlet = scopeGroup.isStagedPortlet(assetRendererFactory.getPortletId());

        if (_isStagedReferrerPortlet() && !stagedReferencePortlet) {
            groupId = scopeGroup.getLiveGroupId();
        }/*  ww w.jav  a2s . c o m*/
    }

    return groupId;
}

From source file:com.liferay.calendar.web.internal.display.context.CalendarDisplayContext.java

License:Open Source License

public List<Calendar> getOtherCalendars(long[] calendarIds) throws PortalException {

    List<Calendar> otherCalendars = new ArrayList<>();

    for (long calendarId : calendarIds) {
        Calendar calendar = _calendarService.fetchCalendar(calendarId);

        if (calendar == null) {
            continue;
        }//from  www.j av a 2 s. c o m

        CalendarResource calendarResource = calendar.getCalendarResource();

        if (!calendarResource.isActive()) {
            continue;
        }

        Group scopeGroup = _themeDisplay.getScopeGroup();

        long scopeGroupId = scopeGroup.getGroupId();
        long scopeLiveGroupId = scopeGroup.getLiveGroupId();

        Group calendarGroup = _groupLocalService.getGroup(calendar.getGroupId());

        long calendarGroupId = calendarGroup.getGroupId();

        if (scopeGroup.isStagingGroup()) {
            if (calendarGroup.isStagingGroup()) {
                if (scopeGroupId != calendarGroupId) {
                    calendar = _calendarLocalService.fetchCalendarByUuidAndGroupId(calendar.getUuid(),
                            calendarGroup.getLiveGroupId());
                }
            } else if (scopeLiveGroupId == calendarGroupId) {
                Group stagingGroup = calendarGroup.getStagingGroup();

                calendar = _calendarLocalService.fetchCalendarByUuidAndGroupId(calendar.getUuid(),
                        stagingGroup.getGroupId());
            }
        } else if (calendarGroup.isStagingGroup()) {
            calendar = _calendarLocalService.fetchCalendarByUuidAndGroupId(calendar.getUuid(),
                    calendarGroup.getLiveGroupId());
        }

        if (calendar == null) {
            continue;
        }

        otherCalendars.add(calendar);
    }

    return otherCalendars;
}

From source file:com.liferay.calendar.web.internal.portlet.CalendarPortlet.java

License:Open Source License

protected Hits search(ThemeDisplay themeDisplay, String keywords) throws Exception {

    SearchContext searchContext = new SearchContext();

    keywords = StringUtil.toLowerCase(keywords);

    searchContext.setAttribute(Field.NAME, keywords);
    searchContext.setAttribute("resourceName", keywords);

    searchContext.setCompanyId(themeDisplay.getCompanyId());
    searchContext.setEnd(SearchContainer.DEFAULT_DELTA);
    searchContext.setGroupIds(new long[0]);

    Group group = themeDisplay.getScopeGroup();

    searchContext.setIncludeStagingGroups(group.isStagingGroup());

    searchContext.setStart(0);//from  w  w w  . j a v  a 2s  .  c om
    searchContext.setUserId(themeDisplay.getUserId());

    Indexer<?> indexer = CalendarSearcher.getInstance();

    return indexer.search(searchContext);
}

From source file:com.liferay.document.library.internal.repository.capabilities.LiferaySyncCapability.java

License:Open Source License

protected boolean isStagingGroup(long groupId) {
    try {/*from w w  w  .  j  a  v a 2 s  . c om*/
        Group group = _groupServiceAdapter.getGroup(groupId);

        return group.isStagingGroup();
    } catch (Exception e) {
        return false;
    }
}