diff --git a/service/src/main/java/gov/nasa/pds/api/registry/controllers/ProductsController.java b/service/src/main/java/gov/nasa/pds/api/registry/controllers/ProductsController.java index b3e28f85..2dba1106 100644 --- a/service/src/main/java/gov/nasa/pds/api/registry/controllers/ProductsController.java +++ b/service/src/main/java/gov/nasa/pds/api/registry/controllers/ProductsController.java @@ -19,6 +19,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.context.request.NativeWebRequest; @@ -610,12 +611,33 @@ public ResponseEntity productMemberOfOf( @Override // TODO: Relocate this to ClassesController once common controller code has been extracted/refactored public ResponseEntity classList(String propertyClass, List fields, List keywords, Integer limit, String q, List sort, List searchAfter) throws Exception { - return ClassesApi.super.classList(propertyClass, fields, keywords, limit, q, sort, searchAfter); + PdsProductClasses pdsProductClass; + try { + pdsProductClass = PdsProductClasses.fromSwaggerName(propertyClass); + } catch (IllegalArgumentException err) { + throw new BadRequestException(err.getMessage()); + } + + SearchRequest searchRequest = new RegistrySearchRequestBuilder(this.connectionContext) + .matchProductClass(pdsProductClass) + .constrainByQueryString(q) + .addKeywordsParam(keywords) + .fieldsFromStrings(fields) + .paginate(limit, sort, searchAfter) + .onlyLatest() + .build(); + + SearchResponse searchResponse = + this.openSearchClient.search(searchRequest, HashMap.class); + + RawMultipleProductResponse products = new RawMultipleProductResponse(searchResponse); + + return formatMultipleProducts(products, fields); } @Override // TODO: Relocate this to ClassesController once common controller code has been extracted/refactored public ResponseEntity> classes() throws Exception { - return ClassesApi.super.classes(); + return new ResponseEntity<>(Arrays.stream(PdsProductClasses.values()).map(PdsProductClasses::getSwaggerName).toList(), HttpStatusCode.valueOf(200)); } }