Example usage for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId.

Prototype

public long getScopeGroupId() 

Source Link

Document

Returns the ID of the scoped or sub-scoped active group (e.g.

Usage

From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java

License:Open Source License

public SearchContainer getVocabulariesSearchContainer() throws PortalException {

    if (_vocabulariesSearchContainer != null) {
        return _vocabulariesSearchContainer;
    }/*from  w  w w.ja v a  2s  .com*/

    SearchContainer vocabulariesSearchContainer = new SearchContainer(_renderRequest,
            _renderResponse.createRenderURL(), null, "there-are-no-vocabularies");

    String keywords = getKeywords();

    if (Validator.isNull(keywords)) {
        if (isShowVocabulariesAddButton()) {
            vocabulariesSearchContainer
                    .setEmptyResultsMessage("there-are-no-vocabularies.-you-can-add-a-vocabulary-by-"
                            + "clicking-the-plus-button-on-the-bottom-right-corner");
            vocabulariesSearchContainer
                    .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
        }
    } else {
        vocabulariesSearchContainer.setSearch(true);
    }

    vocabulariesSearchContainer.setOrderByCol(getOrderByCol());

    String orderByType = getOrderByType();

    boolean orderByAsc = false;

    if (orderByType.equals("asc")) {
        orderByAsc = true;
    }

    OrderByComparator<AssetVocabulary> orderByComparator = new AssetVocabularyCreateDateComparator(orderByAsc);

    vocabulariesSearchContainer.setOrderByComparator(orderByComparator);

    vocabulariesSearchContainer.setOrderByType(orderByType);

    EmptyOnClickRowChecker emptyOnClickRowChecker = new EmptyOnClickRowChecker(_renderResponse);

    StringBundler sb = new StringBundler(5);

    sb.append("^(?!.*");
    sb.append(_renderResponse.getNamespace());
    sb.append("redirect).*(/vocabulary/");
    sb.append(getVocabularyId());
    sb.append(")");

    emptyOnClickRowChecker.setRememberCheckBoxStateURLRegex(sb.toString());

    vocabulariesSearchContainer.setRowChecker(emptyOnClickRowChecker);

    List<AssetVocabulary> vocabularies = null;
    int vocabulariesCount = 0;

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

    long scopeGroupId = themeDisplay.getScopeGroupId();

    if (Validator.isNotNull(keywords)) {
        Sort sort = new Sort("createDate", Sort.LONG_TYPE, orderByAsc);

        AssetVocabularyDisplay assetVocabularyDisplay = AssetVocabularyServiceUtil.searchVocabulariesDisplay(
                scopeGroupId, keywords, true, vocabulariesSearchContainer.getStart(),
                vocabulariesSearchContainer.getEnd(), sort);

        vocabulariesCount = assetVocabularyDisplay.getTotal();

        vocabulariesSearchContainer.setTotal(vocabulariesCount);

        vocabularies = assetVocabularyDisplay.getVocabularies();
    } else {
        vocabulariesCount = AssetVocabularyServiceUtil.getGroupVocabulariesCount(scopeGroupId);

        vocabulariesSearchContainer.setTotal(vocabulariesCount);

        vocabularies = AssetVocabularyServiceUtil.getGroupVocabularies(scopeGroupId, true,
                vocabulariesSearchContainer.getStart(), vocabulariesSearchContainer.getEnd(),
                vocabulariesSearchContainer.getOrderByComparator());

        if (vocabulariesCount == 0) {
            vocabulariesCount = AssetVocabularyServiceUtil.getGroupVocabulariesCount(scopeGroupId);

            vocabulariesSearchContainer.setTotal(vocabulariesCount);
        }
    }

    vocabulariesSearchContainer.setResults(vocabularies);

    _vocabulariesSearchContainer = vocabulariesSearchContainer;

    return _vocabulariesSearchContainer;
}

From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java

License:Open Source License

public boolean hasPermission(AssetCategory category, String actionId) throws PortalException {

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

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    Boolean hasPermission = StagingPermissionUtil.hasPermission(permissionChecker,
            themeDisplay.getScopeGroupId(), AssetCategory.class.getName(), category.getCategoryId(),
            AssetCategoriesAdminPortletKeys.ASSET_CATEGORIES_ADMIN, actionId);

    if (hasPermission != null) {
        return hasPermission.booleanValue();
    }//from w  ww  . ja v  a2 s  . c o m

    return AssetCategoryPermission.contains(permissionChecker, category, actionId);
}

From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java

License:Open Source License

public boolean hasPermission(AssetVocabulary vocabulary, String actionId) throws PortalException {

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

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    Boolean hasPermission = StagingPermissionUtil.hasPermission(permissionChecker,
            themeDisplay.getScopeGroupId(), AssetVocabulary.class.getName(), vocabulary.getVocabularyId(),
            AssetCategoriesAdminPortletKeys.ASSET_CATEGORIES_ADMIN, actionId);

    if (hasPermission != null) {
        return hasPermission.booleanValue();
    }/*from ww w .jav  a 2 s  .  c o m*/

    return AssetVocabularyPermission.contains(permissionChecker, vocabulary, actionId);
}

From source file:com.liferay.asset.categories.navigation.web.internal.display.context.AssetCategoriesNavigationDisplayContext.java

License:Open Source License

public List<AssetVocabulary> getAssetVocabularies() {
    if (_assetVocabularies != null) {
        return _assetVocabularies;
    }/*from  w w  w. j av a 2s. c  o  m*/

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

    long[] groupIds = new long[0];

    try {
        groupIds = PortalUtil.getCurrentAndAncestorSiteGroupIds(themeDisplay.getScopeGroupId());
    } catch (PortalException pe) {
        groupIds = new long[] { themeDisplay.getScopeGroupId() };

        _log.error(pe, pe);
    }

    _assetVocabularies = AssetVocabularyServiceUtil.getGroupVocabularies(groupIds);

    return _assetVocabularies;
}

From source file:com.liferay.asset.categories.navigation.web.internal.display.context.AssetCategoriesNavigationDisplayContext.java

License:Open Source License

public long getDisplayStyleGroupId() {
    if (_displayStyleGroupId != 0) {
        return _displayStyleGroupId;
    }/*w  w  w . j av a  2  s  .  c  o m*/

    _displayStyleGroupId = _assetCategoriesNavigationPortletInstanceConfiguration.displayStyleGroupId();

    if (_displayStyleGroupId <= 0) {
        ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

        _displayStyleGroupId = themeDisplay.getScopeGroupId();
    }

    return _displayStyleGroupId;
}

From source file:com.liferay.asset.display.template.web.internal.display.context.AssetDisplayTemplateDisplayContext.java

License:Open Source License

public SearchContainer getSearchContainer() throws PortalException {
    if (_searchContainer != null) {
        return _searchContainer;
    }/* ww  w . j  av  a2s  .c o  m*/

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

    SearchContainer searchContainer = new SearchContainer(_renderRequest, _renderResponse.createRenderURL(),
            null, "there-are-no-asset-display-templates");

    if (!isSearch()) {
        if (isShowAddButton()) {
            searchContainer.setEmptyResultsMessage("there-are-no-asset-display-templates-you-can-add-an-"
                    + "asset-display-template-by-clicking-plus-button-on-" + "the-bottom-right-corner");
            searchContainer.setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
        }
    } else {
        searchContainer.setSearch(true);
    }

    searchContainer.setRowChecker(new EmptyOnClickRowChecker(_renderResponse));
    searchContainer.setOrderByCol(getOrderByCol());

    OrderByComparator<AssetDisplayTemplate> orderByComparator = _getOrderByComparator(getOrderByCol(),
            getOrderByType());

    searchContainer.setOrderByComparator(orderByComparator);

    searchContainer.setOrderByType(getOrderByType());

    int assetDisplayTemplatesCount = 0;
    List<AssetDisplayTemplate> assetDisplayTemplates = null;

    if (isSearch()) {
        assetDisplayTemplatesCount = AssetDisplayTemplateLocalServiceUtil
                .getAssetDisplayTemplatesCount(themeDisplay.getScopeGroupId(), getKeywords());

        assetDisplayTemplates = AssetDisplayTemplateLocalServiceUtil.getAssetDisplayTemplates(
                themeDisplay.getScopeGroupId(), getKeywords(), searchContainer.getStart(),
                searchContainer.getEnd(), orderByComparator);
    } else {
        assetDisplayTemplatesCount = AssetDisplayTemplateLocalServiceUtil
                .getAssetDisplayTemplatesCount(themeDisplay.getScopeGroupId());

        assetDisplayTemplates = AssetDisplayTemplateLocalServiceUtil.getAssetDisplayTemplates(
                themeDisplay.getScopeGroupId(), searchContainer.getStart(), searchContainer.getEnd(),
                orderByComparator);
    }

    searchContainer.setTotal(assetDisplayTemplatesCount);
    searchContainer.setResults(assetDisplayTemplates);

    _searchContainer = searchContainer;

    return _searchContainer;
}

From source file:com.liferay.asset.display.template.web.internal.portlet.action.EditAssetDisplayTemplateMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    long assetDisplayTemplateId = ParamUtil.getLong(actionRequest, "assetDisplayTemplateId");

    String name = ParamUtil.getString(actionRequest, "name");
    long classNameId = ParamUtil.getLong(actionRequest, "classNameId");
    String language = ParamUtil.getString(actionRequest, "language");
    String scriptContent = ParamUtil.getString(actionRequest, "scriptContent");
    boolean main = ParamUtil.getBoolean(actionRequest, "main");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

    if (assetDisplayTemplateId <= 0) {
        _assetDisplayTemplateService.addAssetDisplayTemplate(themeDisplay.getScopeGroupId(),
                themeDisplay.getUserId(), name, classNameId, language, scriptContent, main, serviceContext);
    } else {/*from  w  w  w .ja v  a 2  s .  c om*/
        _assetDisplayTemplateService.updateAssetDisplayTemplate(assetDisplayTemplateId, name, classNameId,
                language, scriptContent, main, serviceContext);
    }
}

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

License:Open Source License

@Override
public String getAssetViewURL(LiferayPortletRequest liferayPortletRequest,
        LiferayPortletResponse liferayPortletResponse, AssetRenderer<?> assetRenderer, AssetEntry assetEntry,
        boolean viewInContext) {

    PortletURL viewFullContentURL = liferayPortletResponse.createRenderURL();

    viewFullContentURL.setParameter("mvcPath", "/view_content.jsp");
    viewFullContentURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId()));

    PortletURL redirectURL = liferayPortletResponse.createRenderURL();

    int cur = ParamUtil.getInteger(liferayPortletRequest, "cur");
    int delta = ParamUtil.getInteger(liferayPortletRequest, "delta");
    boolean resetCur = ParamUtil.getBoolean(liferayPortletRequest, "resetCur");

    redirectURL.setParameter("cur", String.valueOf(cur));

    if (delta > 0) {
        redirectURL.setParameter("delta", String.valueOf(delta));
    }//  ww  w  . jav  a2 s. c  o m

    redirectURL.setParameter("resetCur", String.valueOf(resetCur));
    redirectURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId()));

    viewFullContentURL.setParameter("redirect", redirectURL.toString());

    AssetRendererFactory<?> assetRendererFactory = assetRenderer.getAssetRendererFactory();

    viewFullContentURL.setParameter("type", assetRendererFactory.getType());

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

    if (Validator.isNotNull(assetRenderer.getUrlTitle())) {
        if (assetRenderer.getGroupId() != themeDisplay.getScopeGroupId()) {
            viewFullContentURL.setParameter("groupId", String.valueOf(assetRenderer.getGroupId()));
        }

        viewFullContentURL.setParameter("urlTitle", assetRenderer.getUrlTitle());
    }

    String viewURL = null;

    if (viewInContext) {
        try {
            String noSuchEntryRedirect = viewFullContentURL.toString();

            viewURL = assetRenderer.getURLViewInContext(liferayPortletRequest, liferayPortletResponse,
                    noSuchEntryRedirect);

            if (Validator.isNotNull(viewURL) && !Objects.equals(viewURL, noSuchEntryRedirect)) {

                viewURL = _http.setParameter(viewURL, "redirect", _portal.getCurrentURL(liferayPortletRequest));
            }
        } catch (Exception e) {
        }
    }

    if (Validator.isNull(viewURL)) {
        viewURL = viewFullContentURL.toString();
    }

    return viewURL;
}

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

License:Open Source License

public AssetEntryQuery getAssetEntryQuery() throws Exception {
    if (_assetEntryQuery != null) {
        return _assetEntryQuery;
    }//from w  ww  .  j av a 2s .c om

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

    _assetEntryQuery = AssetPublisherUtil.getAssetEntryQuery(_portletPreferences,
            themeDisplay.getScopeGroupId(), themeDisplay.getLayout(), getAllAssetCategoryIds(),
            getAllAssetTagNames());

    _assetEntryQuery.setEnablePermissions(isEnablePermissions());

    configureSubtypeFieldFilter(_assetEntryQuery, themeDisplay.getLocale());

    _assetEntryQuery.setPaginationType(getPaginationType());

    _assetPublisherWebUtil.processAssetEntryQuery(themeDisplay.getUser(), _portletPreferences,
            _assetEntryQuery);

    _assetPublisherCustomizer.setAssetEntryQueryOptions(_assetEntryQuery, _request);

    return _assetEntryQuery;
}

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

License:Open Source License

public JSONArray getAutoFieldRulesJSONArray() {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    String queryLogicIndexesParam = ParamUtil.getString(_request, "queryLogicIndexes");

    int[] queryLogicIndexes = null;

    if (Validator.isNotNull(queryLogicIndexesParam)) {
        queryLogicIndexes = StringUtil.split(queryLogicIndexesParam, 0);
    } else {//from   w  w  w.  j a  v a 2s . c  o m
        queryLogicIndexes = new int[0];

        for (int i = 0; true; i++) {
            String queryValues = PrefsParamUtil.getString(_portletPreferences, _request, "queryValues" + i);

            if (Validator.isNull(queryValues)) {
                break;
            }

            queryLogicIndexes = ArrayUtil.append(queryLogicIndexes, i);
        }

        if (queryLogicIndexes.length == 0) {
            queryLogicIndexes = ArrayUtil.append(queryLogicIndexes, -1);
        }
    }

    JSONArray rulesJSONArray = JSONFactoryUtil.createJSONArray();

    for (int queryLogicIndex : queryLogicIndexes) {
        JSONObject ruleJSONObject = JSONFactoryUtil.createJSONObject();

        boolean queryAndOperator = PrefsParamUtil.getBoolean(_portletPreferences, _request,
                "queryAndOperator" + queryLogicIndex);

        ruleJSONObject.put("queryAndOperator", queryAndOperator);

        boolean queryContains = PrefsParamUtil.getBoolean(_portletPreferences, _request,
                "queryContains" + queryLogicIndex, true);

        ruleJSONObject.put("queryContains", queryContains);

        String queryValues = StringUtil
                .merge(_portletPreferences.getValues("queryValues" + queryLogicIndex, new String[0]));

        String queryName = PrefsParamUtil.getString(_portletPreferences, _request,
                "queryName" + queryLogicIndex, "assetTags");

        if (Objects.equals(queryName, "assetTags")) {
            queryValues = ParamUtil.getString(_request, "queryTagNames" + queryLogicIndex, queryValues);

            queryValues = _assetPublisherWebUtil.filterAssetTagNames(themeDisplay.getScopeGroupId(),
                    queryValues);
        } else {
            queryValues = ParamUtil.getString(_request, "queryCategoryIds" + queryLogicIndex, queryValues);

            JSONArray categoryIdsTitles = JSONFactoryUtil.createJSONArray();

            long[] categoryIds = GetterUtil.getLongValues(queryValues.split(","));

            for (long categoryId : categoryIds) {
                AssetCategory category = AssetCategoryLocalServiceUtil.fetchAssetCategory(categoryId);

                categoryIdsTitles.put(category.getTitle(themeDisplay.getLocale()));
            }

            ruleJSONObject.put("categoryIdsTitles", categoryIdsTitles);
        }

        ruleJSONObject.put("queryValues", queryValues);
        ruleJSONObject.put("type", queryName);

        rulesJSONArray.put(ruleJSONObject);
    }

    return rulesJSONArray;
}