From ea7a2224d3e1f217ee8ee76c23d8d94f171241f3 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Fri, 14 Apr 2023 17:44:06 +0100 Subject: [PATCH] Allow the name of a list to be specified as a "namefilter" param in GET /arbitrary/resources/search. Any names in the list will be included in the search (same as if they were specified manually via &name=). --- .../java/org/qortal/api/resource/ArbitraryResource.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/qortal/api/resource/ArbitraryResource.java b/src/main/java/org/qortal/api/resource/ArbitraryResource.java index 7adf1cec..5725c155 100644 --- a/src/main/java/org/qortal/api/resource/ArbitraryResource.java +++ b/src/main/java/org/qortal/api/resource/ArbitraryResource.java @@ -172,6 +172,7 @@ public class ArbitraryResource { @Parameter(description = "Query (searches both name and identifier fields)") @QueryParam("query") String query, @Parameter(description = "Identifier (searches identifier field only)") @QueryParam("identifier") String identifier, @Parameter(description = "Name (searches name field only)") @QueryParam("name") List names, + @Parameter(description = "Filter names by list (partial matches allowed)") @QueryParam("namefilter") String nameListFilter, @Parameter(description = "Prefix only (if true, only the beginning of fields are matched)") @QueryParam("prefix") Boolean prefixOnly, @Parameter(description = "Default resources (without identifiers) only") @QueryParam("default") Boolean defaultResource, @Parameter(ref = "limit") @QueryParam("limit") Integer limit, @@ -185,6 +186,11 @@ public class ArbitraryResource { boolean defaultRes = Boolean.TRUE.equals(defaultResource); boolean usePrefixOnly = Boolean.TRUE.equals(prefixOnly); + if (nameListFilter != null) { + // Load names from supplied list of names + names.addAll(ResourceListManager.getInstance().getStringsInList(nameListFilter)); + } + List resources = repository.getArbitraryRepository() .searchArbitraryResources(service, query, identifier, names, usePrefixOnly, defaultRes, limit, offset, reverse);