Search in sources :

Example 11 with RangerServiceDefList

use of org.apache.ranger.view.RangerServiceDefList in project ranger by apache.

the class RangerServiceDefServiceBase method searchRangerServiceDefs.

public RangerServiceDefList searchRangerServiceDefs(SearchFilter searchFilter) {
    RangerServiceDefList retList = new RangerServiceDefList();
    int startIndex = searchFilter.getStartIndex();
    int pageSize = searchFilter.getMaxRows();
    String denyCondition = searchFilter.getParam(SearchFilter.FETCH_DENY_CONDITION);
    searchFilter.setStartIndex(0);
    searchFilter.setMaxRows(Integer.MAX_VALUE);
    boolean isAuditPage = false;
    if (searchFilter.getParam("pageSource") != null) {
        isAuditPage = true;
    }
    List<T> xSvcDefList = searchResources(searchFilter, searchFields, sortFields, retList);
    List<T> permittedServiceDefs = new ArrayList<T>();
    for (T xSvcDef : xSvcDefList) {
        if ((bizUtil.hasAccess(xSvcDef, null) || (bizUtil.isAdmin() && isAuditPage)) || ("true".equals(denyCondition))) {
            permittedServiceDefs.add(xSvcDef);
        }
    }
    if (!permittedServiceDefs.isEmpty()) {
        populatePageList(permittedServiceDefs, startIndex, pageSize, retList);
    }
    return retList;
}
Also used : ArrayList(java.util.ArrayList) RangerServiceDefList(org.apache.ranger.view.RangerServiceDefList)

Example 12 with RangerServiceDefList

use of org.apache.ranger.view.RangerServiceDefList in project ranger by apache.

the class ServiceDBStore method getPaginatedServiceDefs.

@Override
public PList<RangerServiceDef> getPaginatedServiceDefs(SearchFilter filter) throws Exception {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> ServiceDBStore.getPaginatedServiceDefs(" + filter + ")");
    }
    RangerServiceDefList svcDefList = serviceDefService.searchRangerServiceDefs(filter);
    predicateUtil.applyFilter(svcDefList.getServiceDefs(), filter);
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> ServiceDBStore.getPaginatedServiceDefs(" + filter + ")");
    }
    return new PList<RangerServiceDef>(svcDefList.getServiceDefs(), svcDefList.getStartIndex(), svcDefList.getPageSize(), svcDefList.getTotalCount(), svcDefList.getResultSize(), svcDefList.getSortType(), svcDefList.getSortBy());
}
Also used : PList(org.apache.ranger.plugin.store.PList) RangerServiceDefList(org.apache.ranger.view.RangerServiceDefList)

Aggregations

RangerServiceDefList (org.apache.ranger.view.RangerServiceDefList)12 SearchFilter (org.apache.ranger.plugin.util.SearchFilter)8 Test (org.junit.Test)8 RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)6 ArrayList (java.util.ArrayList)5 VXString (org.apache.ranger.view.VXString)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 PList (org.apache.ranger.plugin.store.PList)2 Date (java.util.Date)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 RangerPerfTracer (org.apache.ranger.plugin.util.RangerPerfTracer)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1