Skip to content

Commit

Permalink
Add keyspaceName verification to flush and gc
Browse files Browse the repository at this point in the history
  • Loading branch information
burmanm authored and emerkle826 committed Oct 13, 2023
1 parent 6593935 commit 763c35f
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,12 @@ public Response garbageCollect(
String keyspaceName = keyspaceRequest.keyspaceName;
if (StringUtils.isBlank(keyspaceName)) {
keyspaceName = "ALL";
} else if (!keyspaceExists(keyspaceName)) {
return Response.status(HttpStatus.SC_BAD_REQUEST)
.entity("keyspace " + keyspaceName + " does not exists")
.build();
}

String tombstoneOption = tombstoneOptionStr;
if (StringUtils.isBlank(tombstoneOption)) {
tombstoneOption = "ROW";
Expand Down Expand Up @@ -388,6 +393,14 @@ public Response garbageCollect(
mediaType = MediaType.TEXT_PLAIN,
schema = @Schema(implementation = String.class),
examples = @ExampleObject(value = "d69d1d95-9348-4460-95d2-ae342870fade")))
@ApiResponse(
responseCode = "400",
description = "Invalid flush request",
content =
@Content(
mediaType = MediaType.TEXT_PLAIN,
schema = @Schema(implementation = String.class),
examples = @ExampleObject(value = "keyspace sys-tem does not exists")))
@Operation(summary = "Flush one or more tables", operationId = "flush")
public Response flush(KeyspaceRequest keyspaceRequest) {
return handle(
Expand All @@ -400,6 +413,10 @@ public Response flush(KeyspaceRequest keyspaceRequest) {
String keyspaceName = keyspaceRequest.keyspaceName;
if (StringUtils.isBlank(keyspaceName)) {
keyspaceName = "ALL";
} else if (!keyspaceExists(keyspaceName)) {
return Response.status(HttpStatus.SC_BAD_REQUEST)
.entity("keyspace " + keyspaceName + " does not exists")
.build();
}

return Response.accepted(
Expand Down

0 comments on commit 763c35f

Please sign in to comment.