From 9cf708a293d8260b8b39d89bb22eecdb6aed392d Mon Sep 17 00:00:00 2001 From: Josh Lagrimas Date: Fri, 28 Jul 2023 11:55:18 +0100 Subject: [PATCH] issue-435: handle properly searching of non-existent terms --- .../ebi/spot/ols/controller/api/v1/V1TermController.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1TermController.java b/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1TermController.java index 762f8a362..60b28273b 100644 --- a/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1TermController.java +++ b/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1TermController.java @@ -70,6 +70,9 @@ private HttpEntity> getTerms( terms = termRepository.findAllByShortForm(shortForm, lang, pageable); } else if (oboId != null) { terms = termRepository.findAllByOboId(oboId, lang, pageable); + } else { + terms = termRepository.findAll(lang, pageable); + if (terms == null) throw new ResourceNotFoundException("Ontology not found"); } } else { terms = termRepository.findAllByIri(id, lang, pageable); @@ -80,10 +83,6 @@ private HttpEntity> getTerms( } } } - if (terms == null || terms.getContent().isEmpty()) { - terms = termRepository.findAll(lang, pageable); - if (terms == null) throw new ResourceNotFoundException("Ontology not found"); - } return new ResponseEntity<>(assembler.toModel(terms, termAssembler), HttpStatus.OK); }