diff --git a/registry-ws/src/main/java/org/gbif/registry/ws/resources/collections/CollectionResource.java b/registry-ws/src/main/java/org/gbif/registry/ws/resources/collections/CollectionResource.java index a7ef4bd68..a1773a55c 100644 --- a/registry-ws/src/main/java/org/gbif/registry/ws/resources/collections/CollectionResource.java +++ b/registry-ws/src/main/java/org/gbif/registry/ws/resources/collections/CollectionResource.java @@ -850,6 +850,12 @@ public PagingResponse 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); } @@ -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; } }