ServiceDBStore extends AbstractServiceStore { public PList<RangerPolicy> getPaginatedServicePolicies(Long serviceId, SearchFilter filter) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("==> ServiceDBStore.getPaginatedServicePolicies(" + serviceId + ")"); } XXService service = daoMgr.getXXService().getById(serviceId); if (service == null) { throw new Exception("service does not exist - id='" + serviceId); } PList<RangerPolicy> ret = getPaginatedServicePolicies(service.getName(), filter); if (LOG.isDebugEnabled()) { LOG.debug("<== ServiceDBStore.getPaginatedServicePolicies(" + serviceId + ")"); } return ret; }  @Override void init(); @PostConstruct void initStore(); @Override RangerServiceDef createServiceDef(RangerServiceDef serviceDef); @Override RangerServiceDef updateServiceDef(RangerServiceDef serviceDef); void deleteServiceDef(Long serviceDefId, Boolean forceDelete); void deleteXXAccessTypeDef(XXAccessTypeDef xAccess); void deleteXXResourceDef(XXResourceDef xRes); @Override RangerServiceDef getServiceDef(Long id); @Override RangerServiceDef getServiceDefByName(String name); @Override RangerServiceDef getServiceDefByDisplayName(String displayName); @Override List<RangerServiceDef> getServiceDefs(SearchFilter filter); @Override PList<RangerServiceDef> getPaginatedServiceDefs(SearchFilter filter); @Override RangerService createService(RangerService service); @Override RangerService updateService(RangerService service, Map<String, Object> options); @Override void deleteService(Long id); @Override List<RangerPolicy> getPoliciesByResourceSignature(String serviceName, String policySignature, Boolean isPolicyEnabled); @Override RangerService getService(Long id); @Override RangerService getServiceByName(String name); @Override RangerService getServiceByDisplayName(String displayName); RangerService getServiceByNameForDP(String name); @Override List<RangerService> getServices(SearchFilter filter); PList<RangerService> getPaginatedServices(SearchFilter filter); @Override RangerPolicy createPolicy(RangerPolicy policy); void createOrMapLabels(XXPolicy xPolicy, Set<String> uniquePolicyLabels); @Override RangerPolicy updatePolicy(RangerPolicy policy); @Override void deletePolicy(RangerPolicy policy); @Override void deletePolicy(RangerPolicy policy, RangerService service); @Override boolean policyExists(Long id); @Override RangerPolicy getPolicy(Long id); @Override List<RangerPolicy> getPolicies(SearchFilter filter); @Override Long getPolicyId(final Long serviceId, final String policyName, final Long zoneId); void getPoliciesInExcel(List<RangerPolicy> policies, HttpServletResponse response); void getPoliciesInCSV(List<RangerPolicy> policies,
			HttpServletResponse response); void getPoliciesInJson(List<RangerPolicy> policies,
			HttpServletResponse response); PList<RangerPolicy> getPaginatedPolicies(SearchFilter filter); @Override List<RangerPolicy> getServicePolicies(Long serviceId, SearchFilter filter); List<RangerPolicy> noZoneFilter(List<RangerPolicy> servicePolicies); PList<RangerPolicy> getPaginatedServicePolicies(Long serviceId, SearchFilter filter); @Override List<RangerPolicy> getServicePolicies(String serviceName, SearchFilter filter); PList<RangerPolicy> getPaginatedServicePolicies(String serviceName, SearchFilter filter); @Override ServicePolicies getServicePoliciesIfUpdated(String serviceName, Long lastKnownVersion, boolean needsBackwardCompatibility); @Override Long getServicePolicyVersion(String serviceName); @Override ServicePolicies getServicePolicyDeltasOrPolicies(String serviceName, Long lastKnownVersion); @Override ServicePolicies getServicePolicyDeltas(String serviceName, Long lastKnownVersion); @Override ServicePolicies getServicePolicies(String serviceName, Long lastKnownVersion); void createZoneDefaultPolicies(Collection<String> serviceNames, RangerSecurityZone zone); void deleteZonePolicies(Collection<String> serviceNames, Long zoneId); static void persistVersionChange(ServiceVersionUpdater serviceVersionUpdater); @Override Boolean getPopulateExistingBaseFields(); @Override void setPopulateExistingBaseFields(Boolean populateExistingBaseFields); RangerPolicy getPolicyFromEventTime(String eventTime, Long policyId); VXString getPolicyVersionList(Long policyId); RangerPolicy getPolicyForVersionNumber(Long policyId, int versionNo); @Override RangerSecurityZone getSecurityZone(Long id); @Override RangerSecurityZone getSecurityZone(String name); @Override long getPoliciesCount(final String serviceName); void putMetaDataInfo(RangerExportPolicyList rangerExportPolicyList); Map<String, String> getMapFromInputStream(InputStream mapStream); Map<String, RangerPolicy> setPolicyMapKeyValue(Map<String, RangerPolicy> policiesMap, RangerPolicy policy); Map<String, RangerPolicy> createPolicyMap(Map<String, String> zoneMappingMap, List<String> sourceZones,
			String destinationZoneName, Map<String, String> servicesMappingMap, List<String> sourceServices,
			List<String> destinationServices, RangerPolicy policy, Map<String, RangerPolicy> policiesMap); void getServiceUpgraded(); void resetPolicyUpdateLog(int retentionInDays, Integer policyChangeType); void resetTagUpdateLog(int retentionInDays, ServiceTags.TagsChangeType tagChangeType); List<String> getPolicyLabels(SearchFilter searchFilter); String getMetricByType(String type); boolean isServiceAdminUser(String serviceName, String userName); static boolean isSupportsPolicyDeltas(); static boolean isSupportsRolesDownloadByService(); @Override Map<String, String> getServiceConfigForPlugin(Long serviceId); static final String SERVICE_ADMIN_USERS; static final String CRYPT_ALGO; static final String ENCRYPT_KEY; static final String SALT; static final Integer ITERATION_COUNT; static boolean SUPPORTS_POLICY_DELTAS; static Integer RETENTION_PERIOD_IN_DAYS; static Integer TAG_RETENTION_PERIOD_IN_DAYS; static final String HIDDEN_PASSWORD_STR; static final String CONFIG_KEY_PASSWORD; static final String ACCESS_TYPE_DECRYPT_EEK; static final String ACCESS_TYPE_GENERATE_EEK; static final String ACCESS_TYPE_GET_METADATA; }
@Test public void test36getPaginatedServicePolicies() throws Exception { String serviceName = "HDFS_1"; RangerPolicyList policyList = new RangerPolicyList(); policyList.setPageSize(0); SearchFilter filter = new SearchFilter(); filter.setParam(SearchFilter.POLICY_NAME, "policyName"); filter.setParam(SearchFilter.SERVICE_NAME, "serviceName"); PList<RangerPolicy> dbRangerPolicyList = serviceDBStore .getPaginatedServicePolicies(serviceName, filter); Assert.assertNotNull(dbRangerPolicyList); }
@Test public void test37getPaginatedServicePolicies() throws Exception { SearchFilter filter = new SearchFilter(); filter.setParam(SearchFilter.POLICY_NAME, "policyName"); filter.setParam(SearchFilter.SERVICE_NAME, "serviceName"); RangerService rangerService = rangerService(); XXService xService = xService(); XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class); Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao); Mockito.when(xServiceDao.getById(Id)).thenReturn(xService); serviceDBStore.getPaginatedServicePolicies(rangerService.getId(), filter); }