ServiceREST { @GET @Path("/policy/{policyId}/version/{versionNo}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_POLICY_FOR_VERSION_NO + "\")") public RangerPolicy getPolicyForVersionNumber(@PathParam("policyId") Long policyId, @PathParam("versionNo") int versionNo) { return svcStore.getPolicyForVersionNumber(policyId, versionNo); } ServiceREST(); @PostConstruct void initStore(); @POST @Path("/definitions") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_SERVICE_DEF + "\")") RangerServiceDef createServiceDef(RangerServiceDef serviceDef); @PUT @Path("/definitions/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.UPDATE_SERVICE_DEF + "\")") RangerServiceDef updateServiceDef(RangerServiceDef serviceDef); @DELETE @Path("/definitions/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DELETE_SERVICE_DEF + "\")") void deleteServiceDef(@PathParam("id") Long id, @Context HttpServletRequest request); @GET @Path("/definitions/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE_DEF + "\")") RangerServiceDef getServiceDef(@PathParam("id") Long id); @GET @Path("/definitions/name/{name}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE_DEF_BY_NAME + "\")") RangerServiceDef getServiceDefByName(@PathParam("name") String name); @GET @Path("/definitions") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE_DEFS + "\")") RangerServiceDefList getServiceDefs(@Context HttpServletRequest request); @GET @Path("/policies/{serviceDefName}/for-resource") @Produces({ "application/json", "application/xml" }) List<RangerPolicy> getPoliciesForResource(@PathParam("serviceDefName") String serviceDefName,
												  @DefaultValue("") @QueryParam("serviceName") String serviceName,
												  @Context HttpServletRequest request); @POST @Path("/services") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_SERVICE + "\")") RangerService createService(RangerService service); @PUT @Path("/services/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.UPDATE_SERVICE + "\")") RangerService updateService(RangerService service,
                                       @Context HttpServletRequest request); @DELETE @Path("/services/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DELETE_SERVICE + "\")") void deleteService(@PathParam("id") Long id); @GET @Path("/services/{id}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE + "\")") RangerService getService(@PathParam("id") Long id); @GET @Path("/services/name/{name}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICE_BY_NAME + "\")") RangerService getServiceByName(@PathParam("name") String name); @GET @Path("/services") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_SERVICES + "\")") RangerServiceList getServices(@Context HttpServletRequest request); List<RangerService> getServices(SearchFilter filter); @GET @Path("/services/count") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.COUNT_SERVICES + "\")") Long countServices(@Context HttpServletRequest request); @POST @Path("/services/validateConfig") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.VALIDATE_CONFIG + "\")") VXResponse validateConfig(RangerService service); @POST @Path("/services/lookupResource/{serviceName}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.LOOKUP_RESOURCE + "\")") List<String> lookupResource(@PathParam("serviceName") String serviceName, ResourceLookupContext context); @POST @Path("/services/grant/{serviceName}") @Produces({ "application/json", "application/xml" }) RESTResponse grantAccess(@PathParam("serviceName") String serviceName, GrantRevokeRequest grantRequest, @Context HttpServletRequest request); @POST @Path("/secure/services/grant/{serviceName}") @Produces({ "application/json", "application/xml" }) RESTResponse secureGrantAccess(@PathParam("serviceName") String serviceName, GrantRevokeRequest grantRequest, @Context HttpServletRequest request); @POST @Path("/services/revoke/{serviceName}") @Produces({ "application/json", "application/xml" }) RESTResponse revokeAccess(@PathParam("serviceName") String serviceName, GrantRevokeRequest revokeRequest, @Context HttpServletRequest request); @POST @Path("/secure/services/revoke/{serviceName}") @Produces({ "application/json", "application/xml" }) RESTResponse secureRevokeAccess(@PathParam("serviceName") String serviceName, GrantRevokeRequest revokeRequest, @Context HttpServletRequest request); @POST @Path("/policies") @Produces({ "application/json", "application/xml" }) RangerPolicy createPolicy(RangerPolicy policy, @Context HttpServletRequest request); @POST @Path("/policies/apply") @Produces({ "application/json", "application/xml" }) RangerPolicy applyPolicy(RangerPolicy policy, @Context HttpServletRequest request); @PUT @Path("/policies/{id}") @Produces({ "application/json", "application/xml" }) RangerPolicy updatePolicy(RangerPolicy policy); @DELETE @Path("/policies/{id}") @Produces({ "application/json", "application/xml" }) void deletePolicy(@PathParam("id") Long id); @GET @Path("/policies/{id}") @Produces({ "application/json", "application/xml" }) RangerPolicy getPolicy(@PathParam("id") Long id); @GET @Path("/policyLabels") @Produces({ "application/json", "application/xml" }) List<String> getPolicyLabels(@Context HttpServletRequest request); @GET @Path("/policies") @Produces({ "application/json", "application/xml" }) RangerPolicyList getPolicies(@Context HttpServletRequest request); @GET @Path("/policies/downloadExcel") @Produces("application/ms-excel") void getPoliciesInExcel(@Context HttpServletRequest request,
			@Context HttpServletResponse response); @GET @Path("/policies/csv") @Produces("text/csv") void getPoliciesInCsv(@Context HttpServletRequest request, @Context HttpServletResponse response); @GET @Path("/policies/exportJson") @Produces("text/json") void getPoliciesInJson(@Context HttpServletRequest request,
			@Context HttpServletResponse response,
			@QueryParam("checkPoliciesExists") Boolean checkPoliciesExists); @POST @Path("/policies/importPoliciesFromFile") @Consumes({MediaType.MULTIPART_FORM_DATA, MediaType.APPLICATION_JSON}) @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAdminOrKeyAdminRole()") void importPoliciesFromFile(
			@Context HttpServletRequest request,
			@FormDataParam("servicesMapJson") InputStream serviceMapStream,
			@FormDataParam("zoneMapJson") InputStream zoneMapStream,
			@FormDataParam("file") InputStream uploadedInputStream,
			@FormDataParam("file") FormDataContentDisposition fileDetail,
			@QueryParam("isOverride") Boolean isOverride,
			@QueryParam("importType") String importType); List<RangerPolicy> getPolicies(SearchFilter filter); @GET @Path("/policies/count") @Produces({ "application/json", "application/xml" }) Long countPolicies( @Context HttpServletRequest request); @GET @Path("/policies/service/{id}") @Produces({ "application/json", "application/xml" }) RangerPolicyList getServicePolicies(@PathParam("id") Long serviceId,
			@Context HttpServletRequest request); @GET @Path("/policies/service/name/{name}") @Produces({ "application/json", "application/xml" }) RangerPolicyList getServicePoliciesByName(@PathParam("name") String serviceName,
			@Context HttpServletRequest request); @GET @Path("/policies/download/{serviceName}") @Produces({ "application/json", "application/xml" }) ServicePolicies getServicePoliciesIfUpdated(
			@PathParam("serviceName") String serviceName,
			@QueryParam("lastKnownVersion") Long lastKnownVersion,
			@DefaultValue("0") @QueryParam("lastActivationTime") Long lastActivationTime,
			@QueryParam("pluginId") String pluginId,
			@DefaultValue("") @QueryParam("clusterName") String clusterName,
			@DefaultValue("") @QueryParam("zoneName") String zoneName,
			@DefaultValue("false") @QueryParam("supportsPolicyDeltas") Boolean supportsPolicyDeltas,
			@DefaultValue("") @QueryParam("pluginCapabilities") String pluginCapabilities,
			@Context HttpServletRequest request); @GET @Path("/secure/policies/download/{serviceName}") @Produces({ "application/json", "application/xml" }) ServicePolicies getSecureServicePoliciesIfUpdated(
			@PathParam("serviceName") String serviceName,
			@QueryParam("lastKnownVersion") Long lastKnownVersion,
			@DefaultValue("0") @QueryParam("lastActivationTime") Long lastActivationTime,
			@QueryParam("pluginId") String pluginId,
			@DefaultValue("") @QueryParam("clusterName") String clusterName,
			@DefaultValue("") @QueryParam("zoneName") String zoneName,
			@DefaultValue("false") @QueryParam("supportsPolicyDeltas") Boolean supportsPolicyDeltas,
			@DefaultValue("") @QueryParam("pluginCapabilities") String pluginCapabilities,
			@Context HttpServletRequest request); @DELETE @Path("/server/policydeltas") @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") void deletePolicyDeltas(@DefaultValue("7") @QueryParam("days") Integer olderThan, @Context HttpServletRequest request); @DELETE @Path("/server/purgepolicies/{serviceName}") @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") void purgeEmptyPolicies(@PathParam("serviceName") String serviceName, @Context HttpServletRequest request); @GET @Path("/policies/eventTime") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_POLICY_FROM_EVENT_TIME + "\")") RangerPolicy getPolicyFromEventTime(@Context HttpServletRequest request); @GET @Path("/policy/{policyId}/versionList") @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_POLICY_VERSION_LIST + "\")") VXString getPolicyVersionList(@PathParam("policyId") Long policyId); @GET @Path("/policy/{policyId}/version/{versionNo}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_POLICY_FOR_VERSION_NO + "\")") RangerPolicy getPolicyForVersionNumber(@PathParam("policyId") Long policyId,
			@PathParam("versionNo") int versionNo); @GET @Path("/plugins/info") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_PLUGINS_INFO + "\")") RangerPluginInfoList getPluginsInfo(@Context HttpServletRequest request); RangerPolicyAdmin getPolicyAdminForDelegatedAdmin(String serviceName); @GET @Path("/checksso") @Produces(MediaType.TEXT_PLAIN) String checkSSO(); @GET @Path("/csrfconf") @Produces({ "application/json"}) HashMap<String, Object> getCSRFProperties(); @GET @Path("/metrics/type/{type}") @Produces({ "application/json", "application/xml" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\""+ RangerAPIList.GET_METRICS_BY_TYPE + "\")") String getMetricByType(@PathParam("type") String type); final static public String PARAM_SERVICE_NAME; final static public String PARAM_SERVICE_TYPE; final static public String PARAM_POLICY_NAME; final static public String PARAM_ZONE_NAME; final static public String PARAM_UPDATE_IF_EXISTS; final static public String PARAM_MERGE_IF_EXISTS; final static public String PARAM_DELETE_IF_EXISTS; final static public String PARAM_IMPORT_IN_PROGRESS; static final String Allowed_User_List_For_Download; static final String Allowed_User_List_For_Grant_Revoke; static final String isCSRF_ENABLED; static final String BROWSER_USER_AGENT_PARAM; static final String CUSTOM_METHODS_TO_IGNORE_PARAM; static final String CUSTOM_HEADER_PARAM; }
@Test public void test33getPolicyForVersionNumber() throws Exception { RangerPolicy rangerPolicy = rangerPolicy(); Mockito.when(svcStore.getPolicyForVersionNumber(Id, 1)).thenReturn( rangerPolicy); RangerPolicy dbRangerPolicy = serviceREST.getPolicyForVersionNumber(Id, 1); Assert.assertNotNull(dbRangerPolicy); Mockito.verify(svcStore).getPolicyForVersionNumber(Id, 1); }