Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions security-admin/src/main/java/org/apache/ranger/rest/GdsREST.java
Original file line number Diff line number Diff line change
Expand Up @@ -1292,32 +1292,36 @@ public void removeSharedResource(@PathParam("id") Long resourceId) {
@DELETE
@Path("/resources")
@PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.REMOVE_SHARED_RESOURCES + "\")")
public void removeSharedResources(List<Long> resourceIds) {
LOG.debug("==> GdsREST.removeSharedResources({})", resourceIds);
public void removeSharedResources(@QueryParam("id") List<Long> id) {
LOG.debug("==> GdsREST.removeSharedResources(resourceIds={})", id);

RangerPerfTracer perf = null;

try {
if (resourceIds.size() > SHARED_RESOURCES_MAX_BATCH_SIZE) {
if (id == null) {
throw new Exception("resourceIds must not be null");
}

if (id.size() > SHARED_RESOURCES_MAX_BATCH_SIZE) {
throw new Exception("removeSharedResources batch size exceeded the configured limit: Maximum allowed is " + SHARED_RESOURCES_MAX_BATCH_SIZE);
}

if (RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "GdsREST.removeSharedResources(" + resourceIds + ")");
perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "GdsREST.removeSharedResources(" + id + ")");
}

gdsStore.removeSharedResources(resourceIds);
gdsStore.removeSharedResources(id);
} catch (WebApplicationException excp) {
throw excp;
} catch (Throwable excp) {
LOG.error("removeSharedResources({}) failed", resourceIds, excp);
LOG.error("removeSharedResources({}) failed", id, excp);

throw restErrorUtil.createRESTException(excp.getMessage());
} finally {
RangerPerfTracer.log(perf);
}

LOG.debug("<== GdsREST.removeSharedResources({})", resourceIds);
LOG.debug("<== GdsREST.removeSharedResources(resourceIds={})", id);
}

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,13 @@ public void testRemoveSharedResourcesBatchSizeExceeded() {
assertThrows(WebApplicationException.class, () -> gdsREST.removeSharedResources(resourceIds));
}

@Test
public void testRemoveSharedResourcesNullResourceIds() {
Mockito.when(restErrorUtil.createRESTException(Mockito.anyString())).thenReturn(new WebApplicationException());

assertThrows(WebApplicationException.class, () -> gdsREST.removeSharedResources(null));
}

@Test
public void testGetSharedResource() {
Long resourceId = 1L;
Expand Down
Loading