Skip to content

Commit

Permalink
check for descriptor groups that don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
marcos-lg committed Aug 26, 2024
1 parent af4fe94 commit 86137e5
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,12 @@ public PagingResponse<Descriptor> listCollectionDescriptors(
@PathVariable("collectionKey") UUID collectionKey,
@PathVariable("key") long descriptorGroupKey,
DescriptorSearchRequest searchRequest) {
DescriptorGroup existingDescriptorGroup =
descriptorsService.getDescriptorGroup(descriptorGroupKey);
if (existingDescriptorGroup == null) {
return null;
}

searchRequest.setDescriptorGroupKey(descriptorGroupKey);
return descriptorsService.listDescriptors(searchRequest);
}
Expand All @@ -872,9 +878,15 @@ public Descriptor getCollectionDescriptor(
@PathVariable("collectionKey") UUID collectionKey,
@PathVariable("descriptorGroupKey") long descriptorGroupKey,
@PathVariable("key") long descriptorKey) {
DescriptorGroup existingDescriptorGroup =
descriptorsService.getDescriptorGroup(descriptorGroupKey);
if (existingDescriptorGroup == null) {
return null;
}

Descriptor descriptor = descriptorsService.getDescriptor(descriptorKey);
Preconditions.checkArgument(descriptor.getDescriptorGroupKey().equals(descriptorGroupKey));
getDescriptorGroupWithCheck(collectionKey, descriptorGroupKey);
Preconditions.checkArgument(existingDescriptorGroup.getCollectionKey().equals(collectionKey));
return descriptor;
}
}

0 comments on commit 86137e5

Please sign in to comment.