Skip to content

Commit

Permalink
Fix number check based on review - was checking wrong value.
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwallen authored and github-actions[bot] committed Jun 24, 2024
1 parent 57b4ac3 commit a8161a5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions services/src/main/java/org/fao/geonet/api/ApiUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,16 @@ public static String getInternalId(String uuidOrInternalId, Boolean approved)
id = String.valueOf(metadata.getId());
}

if (!StringUtils.hasLength(id) && Lib.type.isInteger(id)) {
//It wasn't a UUID
id = String.valueOf(metadataUtils.findOne(uuidOrInternalId).getId());
AbstractMetadata foundMetadata = null;
if (!StringUtils.hasLength(id) && Lib.type.isInteger(uuidOrInternalId)) {
//It wasn't a UUID so assume it is an internalId which should be a number
foundMetadata = metadataUtils.findOne(uuidOrInternalId);
} else if (Boolean.TRUE.equals(approved)) {
//It was a UUID, check if draft or approved version
AbstractMetadata approvedMetadata = ApplicationContextHolder.get().getBean(MetadataRepository.class).findOneByUuid(uuidOrInternalId);
if (approvedMetadata != null) {
id = String.valueOf(approvedMetadata.getId());
}
foundMetadata = ApplicationContextHolder.get().getBean(MetadataRepository.class).findOneByUuid(uuidOrInternalId);
}
if (foundMetadata != null) {
id = String.valueOf(foundMetadata.getId());
}

if (!StringUtils.hasLength(id)) {
Expand Down

0 comments on commit a8161a5

Please sign in to comment.