Example usage for com.liferay.portal.kernel.search Indexer isPermissionAware

List of usage examples for com.liferay.portal.kernel.search Indexer isPermissionAware

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.search Indexer isPermissionAware.

Prototype

public boolean isPermissionAware();

Source Link

Document

Returns true if the indexer adds permission related filters to the search query prior to execution

Usage

From source file:com.rknowsys.portal.search.elastic.ElasticsearchIndexSearcher.java

License:Open Source License

private Query getPermissionQuery(SearchContext searchContext, Query query) {
    if (searchContext.getEntryClassNames() == null) {
        return query;
    }/*from  w  ww.j a v a  2 s  .c om*/
    for (String className : searchContext.getEntryClassNames()) {
        Indexer indexer = IndexerRegistryUtil.getIndexer(className);
        if (indexer != null) {
            if (indexer.isFilterSearch() && indexer.isPermissionAware()) {
                SearchPermissionChecker searchPermissionChecker = SearchEngineUtil.getSearchPermissionChecker();
                query = searchPermissionChecker.getPermissionQuery(searchContext.getCompanyId(),
                        searchContext.getGroupIds(), searchContext.getUserId(), className, query,
                        searchContext);
            }
        }
    }
    return query;
}

From source file:jorgediazest.indexchecker.model.IndexCheckerModelQuery.java

License:Open Source License

public void addPermissionsClassNameGroupIdFields(Map<Long, Data> groupMap, Data data) throws SystemException {

    String className = getPermissionsClassName(data);
    long classPK = getPermissionsClassPK(data);

    if (Validator.isNull(classPK) || Validator.isNull(className) || (classPK <= 0)) {

        return;/*from  w w  w.j a v a 2  s  .c  o  m*/
    }

    Indexer indexer = IndexerRegistryUtil.getIndexer(className);

    if (!indexer.isPermissionAware()) {
        return;
    }

    long groupId = data.get("groupId", 0L);

    Data group = groupMap.get(groupId);

    if (group != null) {
        long layoutClassNameId = PortalUtil.getClassNameId(Layout.class);

        if (group.get("classNameId", -1L) == layoutClassNameId) {
            groupId = group.get("parentGroupId", groupId);
        }

        data.set("permissionsGroupId", groupId);
    }

    data.set("permissionsClassName", className);
    data.set("permissionsClassPK", classPK);
}