Skip to content

Commit b90d99a

Browse files
author
Ramesh Mani
committed
RANGER-5577:API to support bulk delete of resources in DataShare
1 parent 21520b7 commit b90d99a

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

security-admin/src/main/java/org/apache/ranger/rest/GdsREST.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,12 +1292,16 @@ public void removeSharedResource(@PathParam("id") Long resourceId) {
12921292
@DELETE
12931293
@Path("/resources")
12941294
@PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.REMOVE_SHARED_RESOURCES + "\")")
1295-
public void removeSharedResources(List<Long> resourceIds) {
1296-
LOG.debug("==> GdsREST.removeSharedResources({})", resourceIds);
1295+
public void removeSharedResources(@QueryParam("resourceIds") List<Long> resourceIds) {
1296+
LOG.debug("==> GdsREST.removeSharedResources(resourceIds={})", resourceIds);
12971297

12981298
RangerPerfTracer perf = null;
12991299

13001300
try {
1301+
if (resourceIds == null) {
1302+
throw new Exception("resourceIds must not be null");
1303+
}
1304+
13011305
if (resourceIds.size() > SHARED_RESOURCES_MAX_BATCH_SIZE) {
13021306
throw new Exception("removeSharedResources batch size exceeded the configured limit: Maximum allowed is " + SHARED_RESOURCES_MAX_BATCH_SIZE);
13031307
}
@@ -1317,7 +1321,7 @@ public void removeSharedResources(List<Long> resourceIds) {
13171321
RangerPerfTracer.log(perf);
13181322
}
13191323

1320-
LOG.debug("<== GdsREST.removeSharedResources({})", resourceIds);
1324+
LOG.debug("<== GdsREST.removeSharedResources(resourceIds={})", resourceIds);
13211325
}
13221326

13231327
@GET

security-admin/src/test/java/org/apache/ranger/rest/TestGdsREST.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,13 @@ public void testRemoveSharedResourcesBatchSizeExceeded() {
962962
assertThrows(WebApplicationException.class, () -> gdsREST.removeSharedResources(resourceIds));
963963
}
964964

965+
@Test
966+
public void testRemoveSharedResourcesNullResourceIds() {
967+
Mockito.when(restErrorUtil.createRESTException(Mockito.anyString())).thenReturn(new WebApplicationException());
968+
969+
assertThrows(WebApplicationException.class, () -> gdsREST.removeSharedResources(null));
970+
}
971+
965972
@Test
966973
public void testGetSharedResource() {
967974
Long resourceId = 1L;

0 commit comments

Comments
 (0)