Search in sources :

Example 61 with RangerServiceDef

use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.

the class MetricUtil method metricCalculation.

private void metricCalculation(String caseValue) {
    logger.info("Metric Type : " + caseValue);
    try {
        SearchCriteria searchCriteria = new SearchCriteria();
        searchCriteria.setStartIndex(0);
        searchCriteria.setMaxRows(100);
        searchCriteria.setGetCount(true);
        searchCriteria.setSortType("asc");
        switch(caseValue.toLowerCase()) {
            case "usergroup":
                try {
                    VXGroupList vxGroupList = xUserMgr.searchXGroups(searchCriteria);
                    long groupCount = vxGroupList.getTotalCount();
                    ArrayList<String> userKeyAdminRoleCount = new ArrayList<String>();
                    userKeyAdminRoleCount.add(RangerConstants.ROLE_SYS_ADMIN);
                    long userSysAdminCount = getUserCountBasedOnUserRole(userKeyAdminRoleCount);
                    ArrayList<String> userRoleListKeyRoleAdmin = new ArrayList<String>();
                    userRoleListKeyRoleAdmin.add(RangerConstants.ROLE_KEY_ADMIN);
                    long userKeyAdminCount = getUserCountBasedOnUserRole(userRoleListKeyRoleAdmin);
                    ArrayList<String> userRoleListUser = new ArrayList<String>();
                    userRoleListUser.add(RangerConstants.ROLE_USER);
                    long userRoleCount = getUserCountBasedOnUserRole(userRoleListUser);
                    long userTotalCount = userSysAdminCount + userKeyAdminCount + userRoleCount;
                    VXMetricUserGroupCount metricUserGroupCount = new VXMetricUserGroupCount();
                    metricUserGroupCount.setUserCountOfUserRole(userRoleCount);
                    metricUserGroupCount.setUserCountOfKeyAdminRole(userKeyAdminCount);
                    metricUserGroupCount.setUserCountOfSysAdminRole(userSysAdminCount);
                    metricUserGroupCount.setUserTotalCount(userTotalCount);
                    metricUserGroupCount.setGroupCount(groupCount);
                    Gson gson = new GsonBuilder().create();
                    final String jsonUserGroupCount = gson.toJson(metricUserGroupCount);
                    System.out.println(jsonUserGroupCount);
                } catch (Exception e) {
                    logger.error("Error calculating Metric for usergroup : " + e.getMessage());
                }
                break;
            case "audits":
                try {
                    int clientTimeOffsetInMinute = RestUtil.getClientTimeOffset();
                    String defaultDateFormat = "MM/dd/yyyy";
                    DateFormat formatter = new SimpleDateFormat(defaultDateFormat);
                    VXMetricAuditDetailsCount auditObj = new VXMetricAuditDetailsCount();
                    DateUtil dateUtilTwoDays = new DateUtil();
                    Date startDateUtilTwoDays = dateUtilTwoDays.getDateFromNow(-2);
                    Date dStart2 = restErrorUtil.parseDate(formatter.format(startDateUtilTwoDays), "Invalid value for startDate", MessageEnums.INVALID_INPUT_DATA, null, "startDate", defaultDateFormat);
                    Date endDateTwoDays = MiscUtil.getUTCDate();
                    Date dEnd2 = restErrorUtil.parseDate(formatter.format(endDateTwoDays), "Invalid value for endDate", MessageEnums.INVALID_INPUT_DATA, null, "endDate", defaultDateFormat);
                    dEnd2 = dateUtilTwoDays.getDateFromGivenDate(dEnd2, 0, 23, 59, 59);
                    dEnd2 = dateUtilTwoDays.addTimeOffset(dEnd2, clientTimeOffsetInMinute);
                    VXMetricServiceCount deniedCountObj = getAuditsCount(0, dStart2, dEnd2);
                    auditObj.setDenialEventsCountTwoDays(deniedCountObj);
                    VXMetricServiceCount allowedCountObj = getAuditsCount(1, dStart2, dEnd2);
                    auditObj.setAccessEventsCountTwoDays(allowedCountObj);
                    long totalAuditsCountTwoDays = deniedCountObj.getTotalCount() + allowedCountObj.getTotalCount();
                    auditObj.setSolrIndexCountTwoDays(totalAuditsCountTwoDays);
                    DateUtil dateUtilWeek = new DateUtil();
                    Date startDateUtilWeek = dateUtilWeek.getDateFromNow(-7);
                    Date dStart7 = restErrorUtil.parseDate(formatter.format(startDateUtilWeek), "Invalid value for startDate", MessageEnums.INVALID_INPUT_DATA, null, "startDate", defaultDateFormat);
                    Date endDateWeek = MiscUtil.getUTCDate();
                    DateUtil dateUtilweek = new DateUtil();
                    Date dEnd7 = restErrorUtil.parseDate(formatter.format(endDateWeek), "Invalid value for endDate", MessageEnums.INVALID_INPUT_DATA, null, "endDate", defaultDateFormat);
                    dEnd7 = dateUtilweek.getDateFromGivenDate(dEnd7, 0, 23, 59, 59);
                    dEnd7 = dateUtilweek.addTimeOffset(dEnd7, clientTimeOffsetInMinute);
                    VXMetricServiceCount deniedCountObjWeek = getAuditsCount(0, dStart7, dEnd7);
                    auditObj.setDenialEventsCountWeek(deniedCountObjWeek);
                    VXMetricServiceCount allowedCountObjWeek = getAuditsCount(1, dStart7, dEnd7);
                    auditObj.setAccessEventsCountWeek(allowedCountObjWeek);
                    long totalAuditsCountWeek = deniedCountObjWeek.getTotalCount() + allowedCountObjWeek.getTotalCount();
                    auditObj.setSolrIndexCountWeek(totalAuditsCountWeek);
                    Gson gson = new GsonBuilder().create();
                    final String jsonAudit = gson.toJson(auditObj);
                    System.out.println(jsonAudit);
                } catch (Exception e) {
                    logger.error("Error calculating Metric for audits : " + e.getMessage());
                }
                break;
            case "services":
                try {
                    SearchFilter serviceFilter = new SearchFilter();
                    serviceFilter.setMaxRows(200);
                    serviceFilter.setStartIndex(0);
                    serviceFilter.setGetCount(true);
                    serviceFilter.setSortBy("serviceId");
                    serviceFilter.setSortType("asc");
                    VXMetricServiceCount vXMetricServiceCount = new VXMetricServiceCount();
                    PList<RangerService> paginatedSvcs = svcStore.getPaginatedServices(serviceFilter);
                    long totalServiceCount = paginatedSvcs.getTotalCount();
                    List<RangerService> rangerServiceList = paginatedSvcs.getList();
                    Map<String, Long> services = new HashMap<String, Long>();
                    for (Object rangerService : rangerServiceList) {
                        RangerService RangerServiceObj = (RangerService) rangerService;
                        String serviceName = RangerServiceObj.getType();
                        if (!(services.containsKey(serviceName))) {
                            serviceFilter.setParam("serviceType", serviceName);
                            PList<RangerService> paginatedSvcscount = svcStore.getPaginatedServices(serviceFilter);
                            services.put(serviceName, paginatedSvcscount.getTotalCount());
                        }
                    }
                    vXMetricServiceCount.setServiceBasedCountList(services);
                    vXMetricServiceCount.setTotalCount(totalServiceCount);
                    Gson gson = new GsonBuilder().create();
                    final String jsonServices = gson.toJson(vXMetricServiceCount);
                    System.out.println(jsonServices);
                } catch (Exception e) {
                    logger.error("Error calculating Metric for services : " + e.getMessage());
                }
                break;
            case "policies":
                try {
                    SearchFilter policyFilter = new SearchFilter();
                    policyFilter.setMaxRows(200);
                    policyFilter.setStartIndex(0);
                    policyFilter.setGetCount(true);
                    policyFilter.setSortBy("serviceId");
                    policyFilter.setSortType("asc");
                    VXMetricPolicyCount vXMetricPolicyCount = new VXMetricPolicyCount();
                    PList<RangerPolicy> paginatedSvcsList = svcStore.getPaginatedPolicies(policyFilter);
                    vXMetricPolicyCount.setTotalCount(paginatedSvcsList.getTotalCount());
                    Map<String, VXMetricServiceCount> servicesWithPolicy = new HashMap<String, VXMetricServiceCount>();
                    for (int k = 2; k >= 0; k--) {
                        String serviceType = String.valueOf(k);
                        VXMetricServiceCount vXMetricServiceCount = getVXMetricServiceCount(serviceType);
                        if (k == 2) {
                            servicesWithPolicy.put("rowFilteringPolicies", vXMetricServiceCount);
                        } else if (k == 1) {
                            servicesWithPolicy.put("maskingPolicies", vXMetricServiceCount);
                        } else if (k == 0) {
                            servicesWithPolicy.put("resourcePolicy", vXMetricServiceCount);
                        }
                    }
                    boolean tagFlag = false;
                    if (tagFlag == false) {
                        policyFilter.setParam("serviceType", "tag");
                        PList<RangerPolicy> policiestype = svcStore.getPaginatedPolicies(policyFilter);
                        Map<String, Long> tagMap = new HashMap<String, Long>();
                        long tagCount = policiestype.getTotalCount();
                        tagMap.put("tag", tagCount);
                        VXMetricServiceCount vXMetricServiceCount = new VXMetricServiceCount();
                        vXMetricServiceCount.setServiceBasedCountList(tagMap);
                        vXMetricServiceCount.setTotalCount(tagCount);
                        servicesWithPolicy.put("tagBasedPolicies", vXMetricServiceCount);
                        tagFlag = true;
                    }
                    vXMetricPolicyCount.setPolicyCountList(servicesWithPolicy);
                    Gson gson = new GsonBuilder().create();
                    final String jsonPolicies = gson.toJson(vXMetricPolicyCount);
                    System.out.println(jsonPolicies);
                } catch (Exception e) {
                    logger.error("Error calculating Metric for policies : " + e.getMessage());
                }
                break;
            case "database":
                try {
                    int dbFlavor = RangerBizUtil.getDBFlavor();
                    String dbFlavourType = "Unknow ";
                    if (dbFlavor == AppConstants.DB_FLAVOR_MYSQL) {
                        dbFlavourType = "MYSQL ";
                    } else if (dbFlavor == AppConstants.DB_FLAVOR_ORACLE) {
                        dbFlavourType = "ORACLE ";
                    } else if (dbFlavor == AppConstants.DB_FLAVOR_POSTGRES) {
                        dbFlavourType = "POSTGRES ";
                    } else if (dbFlavor == AppConstants.DB_FLAVOR_SQLANYWHERE) {
                        dbFlavourType = "SQLANYWHERE ";
                    } else if (dbFlavor == AppConstants.DB_FLAVOR_SQLSERVER) {
                        dbFlavourType = "SQLSERVER ";
                    }
                    String dbDetail = dbFlavourType + xaBizUtil.getDBVersion();
                    Gson gson = new GsonBuilder().create();
                    final String jsonDBDetail = gson.toJson(dbDetail);
                    System.out.println(jsonDBDetail);
                } catch (Exception e) {
                    logger.error("Error calculating Metric for database : " + e.getMessage());
                }
                break;
            case "contextenrichers":
                try {
                    SearchFilter filter = new SearchFilter();
                    filter.setStartIndex(0);
                    VXMetricContextEnricher serviceWithContextEnrichers = new VXMetricContextEnricher();
                    PList<RangerServiceDef> paginatedSvcDefs = svcStore.getPaginatedServiceDefs(filter);
                    List<RangerServiceDef> repoTypeList = paginatedSvcDefs.getList();
                    if (repoTypeList != null) {
                        for (RangerServiceDef repoType : repoTypeList) {
                            RangerServiceDef rangerServiceDefObj = (RangerServiceDef) repoType;
                            String name = rangerServiceDefObj.getName();
                            List<RangerContextEnricherDef> contextEnrichers = rangerServiceDefObj.getContextEnrichers();
                            if (contextEnrichers != null && !contextEnrichers.isEmpty()) {
                                serviceWithContextEnrichers.setServiceName(name);
                                serviceWithContextEnrichers.setTotalCount(contextEnrichers.size());
                            }
                        }
                    }
                    Gson gson = new GsonBuilder().create();
                    final String jsonContextEnrichers = gson.toJson(serviceWithContextEnrichers);
                    System.out.println(jsonContextEnrichers);
                } catch (Exception e) {
                    logger.error("Error calculating Metric for contextenrichers : " + e.getMessage());
                }
                break;
            case "denyconditions":
                try {
                    SearchFilter policyFilter1 = new SearchFilter();
                    policyFilter1.setMaxRows(200);
                    policyFilter1.setStartIndex(0);
                    policyFilter1.setGetCount(true);
                    policyFilter1.setSortBy("serviceId");
                    policyFilter1.setSortType("asc");
                    int denyCount = 0;
                    Map<String, Integer> denyconditionsonMap = new HashMap<String, Integer>();
                    PList<RangerServiceDef> paginatedSvcDefs = svcStore.getPaginatedServiceDefs(policyFilter1);
                    if (paginatedSvcDefs != null) {
                        List<RangerServiceDef> rangerServiceDefs = paginatedSvcDefs.getList();
                        if (rangerServiceDefs != null && !rangerServiceDefs.isEmpty()) {
                            for (RangerServiceDef rangerServiceDef : rangerServiceDefs) {
                                if (rangerServiceDef != null) {
                                    String serviceDef = rangerServiceDef.getName();
                                    if (!StringUtils.isEmpty(serviceDef)) {
                                        policyFilter1.setParam("serviceType", serviceDef);
                                        PList<RangerPolicy> policiesList = svcStore.getPaginatedPolicies(policyFilter1);
                                        if (policiesList != null && policiesList.getListSize() > 0) {
                                            int policyListCount = policiesList.getListSize();
                                            if (policyListCount > 0 && policiesList.getList() != null) {
                                                List<RangerPolicy> policies = policiesList.getList();
                                                for (RangerPolicy policy : policies) {
                                                    if (policy != null) {
                                                        List<RangerPolicyItem> policyItem = policy.getDenyPolicyItems();
                                                        if (policyItem != null && !policyItem.isEmpty()) {
                                                            if (denyconditionsonMap.get(serviceDef) != null) {
                                                                denyCount = denyconditionsonMap.get(serviceDef) + denyCount + policyItem.size();
                                                            } else {
                                                                denyCount = denyCount + policyItem.size();
                                                            }
                                                        }
                                                        List<RangerPolicyItem> policyItemExclude = policy.getDenyExceptions();
                                                        if (policyItemExclude != null && !policyItemExclude.isEmpty()) {
                                                            if (denyconditionsonMap.get(serviceDef) != null) {
                                                                denyCount = denyconditionsonMap.get(serviceDef) + denyCount + policyItemExclude.size();
                                                            } else {
                                                                denyCount = denyCount + policyItemExclude.size();
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        policyFilter1.removeParam("serviceType");
                                    }
                                    denyconditionsonMap.put(serviceDef, denyCount);
                                    denyCount = 0;
                                }
                            }
                        }
                    }
                    Gson gson = new GsonBuilder().create();
                    String jsonContextDenyCondtionOn = gson.toJson(denyconditionsonMap);
                    System.out.println(jsonContextDenyCondtionOn);
                } catch (Exception e) {
                    logger.error("Error calculating Metric for denyconditions : " + e.getMessage());
                }
                break;
            default:
                System.out.println("type: Incorrect Arguments usage : -type policies | audits | usergroup | services | database | contextenrichers | denyconditions");
                logger.info("Please enter the valid arguments for Metric Calculation");
                break;
        }
    } catch (Exception e) {
        logger.error("Error calculating Metric : " + e.getMessage());
    }
}
Also used : VXMetricAuditDetailsCount(org.apache.ranger.view.VXMetricAuditDetailsCount) HashMap(java.util.HashMap) DateUtil(org.apache.ranger.common.DateUtil) VXGroupList(org.apache.ranger.view.VXGroupList) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) VXMetricPolicyCount(org.apache.ranger.view.VXMetricPolicyCount) RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) VXMetricUserGroupCount(org.apache.ranger.view.VXMetricUserGroupCount) RangerService(org.apache.ranger.plugin.model.RangerService) GsonBuilder(com.google.gson.GsonBuilder) VXMetricContextEnricher(org.apache.ranger.view.VXMetricContextEnricher) RangerPolicyItem(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItem) SearchCriteria(org.apache.ranger.common.SearchCriteria) Date(java.util.Date) RangerContextEnricherDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) VXMetricServiceCount(org.apache.ranger.view.VXMetricServiceCount) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) SimpleDateFormat(java.text.SimpleDateFormat)

Example 62 with RangerServiceDef

use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.

the class PublicAPIsv2 method updateServiceDefByName.

@PUT
@Path("/api/servicedef/name/{name}")
@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
@Produces({ "application/json", "application/xml" })
public RangerServiceDef updateServiceDefByName(RangerServiceDef serviceDef, @PathParam("name") String name) {
    // if serviceDef.name is specified, it should be same as the param 'name'
    if (serviceDef.getName() == null) {
        serviceDef.setName(name);
    } else if (!serviceDef.getName().equals(name)) {
        throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, "serviceDef name mismatch", true);
    }
    // ignore serviceDef.id - if specified. Retrieve using the given name and use id from the retrieved object
    RangerServiceDef existingServiceDef = getServiceDefByName(name);
    serviceDef.setId(existingServiceDef.getId());
    if (StringUtils.isEmpty(serviceDef.getGuid())) {
        serviceDef.setGuid(existingServiceDef.getGuid());
    }
    return serviceREST.updateServiceDef(serviceDef);
}
Also used : RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 63 with RangerServiceDef

use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.

the class ServiceREST method updateServiceDef.

@PUT
@Path("/definitions/{id}")
@Produces({ "application/json", "application/xml" })
@PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.UPDATE_SERVICE_DEF + "\")")
public RangerServiceDef updateServiceDef(RangerServiceDef serviceDef) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> ServiceREST.updateServiceDef(serviceDefName=" + serviceDef.getName() + ")");
    }
    RangerServiceDef ret = null;
    RangerPerfTracer perf = null;
    try {
        if (RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.updateServiceDef(" + serviceDef.getName() + ")");
        }
        RangerServiceDefValidator validator = validatorFactory.getServiceDefValidator(svcStore);
        validator.validate(serviceDef, Action.UPDATE);
        bizUtil.hasAdminPermissions("Service-Def");
        bizUtil.hasKMSPermissions("Service-Def", serviceDef.getImplClass());
        bizUtil.blockAuditorRoleUser();
        ret = svcStore.updateServiceDef(serviceDef);
    } catch (WebApplicationException excp) {
        throw excp;
    } catch (Throwable excp) {
        LOG.error("updateServiceDef(" + serviceDef + ") failed", excp);
        throw restErrorUtil.createRESTException(excp.getMessage());
    } finally {
        RangerPerfTracer.log(perf);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== ServiceREST.updateServiceDef(" + serviceDef + "): " + ret);
    }
    return ret;
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) RangerPerfTracer(org.apache.ranger.plugin.util.RangerPerfTracer) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) RangerServiceDefValidator(org.apache.ranger.plugin.model.validation.RangerServiceDefValidator) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) PUT(javax.ws.rs.PUT)

Example 64 with RangerServiceDef

use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.

the class ServiceREST method getServiceDef.

@GET
@Path("/definitions/{id}")
@Produces({ "application/json", "application/xml" })
@PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE_DEF + "\")")
public RangerServiceDef getServiceDef(@PathParam("id") Long id) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> ServiceREST.getServiceDef(" + id + ")");
    }
    RangerServiceDef ret = null;
    RangerPerfTracer perf = null;
    try {
        if (RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServiceDef(serviceDefId=" + id + ")");
        }
        XXServiceDef xServiceDef = daoManager.getXXServiceDef().getById(id);
        if (!bizUtil.hasAccess(xServiceDef, null)) {
            throw restErrorUtil.createRESTException("User is not allowed to access service-def, id: " + xServiceDef.getId(), MessageEnums.OPER_NO_PERMISSION);
        }
        ret = svcStore.getServiceDef(id);
    } catch (WebApplicationException excp) {
        throw excp;
    } catch (Throwable excp) {
        LOG.error("getServiceDef(" + id + ") failed", excp);
        throw restErrorUtil.createRESTException(excp.getMessage());
    } finally {
        RangerPerfTracer.log(perf);
    }
    if (ret == null) {
        throw restErrorUtil.createRESTException(HttpServletResponse.SC_NOT_FOUND, "Not found", true);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== ServiceREST.getServiceDef(" + id + "): " + ret);
    }
    return ret;
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) WebApplicationException(javax.ws.rs.WebApplicationException) RangerPerfTracer(org.apache.ranger.plugin.util.RangerPerfTracer) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 65 with RangerServiceDef

use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.

the class ServiceREST method getServiceDefs.

@GET
@Path("/definitions")
@Produces({ "application/json", "application/xml" })
@PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE_DEFS + "\")")
public RangerServiceDefList getServiceDefs(@Context HttpServletRequest request) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> ServiceREST.getServiceDefs()");
    }
    RangerServiceDefList ret = null;
    RangerPerfTracer perf = null;
    PList<RangerServiceDef> paginatedSvcDefs = null;
    SearchFilter filter = searchUtil.getSearchFilter(request, serviceDefService.sortFields);
    String pageSource = null;
    pageSource = request.getParameter("pageSource");
    if (pageSource != null)
        filter.setParam("pageSource", pageSource);
    try {
        if (RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServiceDefs()");
        }
        paginatedSvcDefs = svcStore.getPaginatedServiceDefs(filter);
        if (paginatedSvcDefs != null) {
            ret = new RangerServiceDefList();
            ret.setServiceDefs(paginatedSvcDefs.getList());
            ret.setPageSize(paginatedSvcDefs.getPageSize());
            ret.setResultSize(paginatedSvcDefs.getResultSize());
            ret.setStartIndex(paginatedSvcDefs.getStartIndex());
            ret.setTotalCount(paginatedSvcDefs.getTotalCount());
            ret.setSortBy(paginatedSvcDefs.getSortBy());
            ret.setSortType(paginatedSvcDefs.getSortType());
        }
    } catch (WebApplicationException excp) {
        throw excp;
    } catch (Throwable excp) {
        LOG.error("getServiceDefs() failed", excp);
        throw restErrorUtil.createRESTException(excp.getMessage());
    } finally {
        RangerPerfTracer.log(perf);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== ServiceREST.getServiceDefs(): count=" + (ret == null ? 0 : ret.getListSize()));
    }
    return ret;
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) RangerPerfTracer(org.apache.ranger.plugin.util.RangerPerfTracer) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) VXString(org.apache.ranger.view.VXString) RangerServiceDefList(org.apache.ranger.view.RangerServiceDefList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)105 Test (org.junit.Test)52 ArrayList (java.util.ArrayList)38 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)19 XXServiceDef (org.apache.ranger.entity.XXServiceDef)18 Date (java.util.Date)15 HashMap (java.util.HashMap)13 ServicePolicies (org.apache.ranger.plugin.util.ServicePolicies)13 RangerService (org.apache.ranger.plugin.model.RangerService)12 RangerResourceDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)12 RangerServiceConfigDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef)12 RangerAccessTypeDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef)11 VXString (org.apache.ranger.view.VXString)10 RangerPolicyItem (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItem)9 RangerContextEnricherDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef)9 RangerPolicyConditionDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef)9 RangerPolicyItemAccess (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemAccess)8 RangerPolicyResource (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource)8 RangerEnumDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef)8 SearchFilter (org.apache.ranger.plugin.util.SearchFilter)7