forked from Qortal/qortal
Added "name" filter to GET /arbitrary/resources
and LIST_QDN_RESOURCES
.
This commit is contained in:
parent
952d18390b
commit
929d0ac897
@ -299,7 +299,8 @@ let res = await qortalRequest({
|
|||||||
let res = await qortalRequest({
|
let res = await qortalRequest({
|
||||||
action: "LIST_QDN_RESOURCES",
|
action: "LIST_QDN_RESOURCES",
|
||||||
service: "THUMBNAIL",
|
service: "THUMBNAIL",
|
||||||
identifier: "qortal_avatar", // Optional
|
name: "QortalDemo", // Optional (exact match)
|
||||||
|
identifier: "qortal_avatar", // Optional (exact match)
|
||||||
default: true, // Optional
|
default: true, // Optional
|
||||||
includeStatus: false, // Optional - will take time to respond, so only request if necessary
|
includeStatus: false, // Optional - will take time to respond, so only request if necessary
|
||||||
includeMetadata: false, // Optional - will take time to respond, so only request if necessary
|
includeMetadata: false, // Optional - will take time to respond, so only request if necessary
|
||||||
|
@ -96,6 +96,7 @@ public class ArbitraryResource {
|
|||||||
@ApiErrors({ApiError.REPOSITORY_ISSUE})
|
@ApiErrors({ApiError.REPOSITORY_ISSUE})
|
||||||
public List<ArbitraryResourceInfo> getResources(
|
public List<ArbitraryResourceInfo> getResources(
|
||||||
@QueryParam("service") Service service,
|
@QueryParam("service") Service service,
|
||||||
|
@QueryParam("name") String name,
|
||||||
@QueryParam("identifier") String identifier,
|
@QueryParam("identifier") String identifier,
|
||||||
@Parameter(description = "Default resources (without identifiers) only") @QueryParam("default") Boolean defaultResource,
|
@Parameter(description = "Default resources (without identifiers) only") @QueryParam("default") Boolean defaultResource,
|
||||||
@Parameter(ref = "limit") @QueryParam("limit") Integer limit,
|
@Parameter(ref = "limit") @QueryParam("limit") Integer limit,
|
||||||
@ -118,9 +119,14 @@ public class ArbitraryResource {
|
|||||||
throw ApiExceptionFactory.INSTANCE.createCustomException(request, ApiError.INVALID_CRITERIA, "identifier cannot be specified when requesting a default resource");
|
throw ApiExceptionFactory.INSTANCE.createCustomException(request, ApiError.INVALID_CRITERIA, "identifier cannot be specified when requesting a default resource");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load filter from list if needed
|
// Set up name filters if supplied
|
||||||
List<String> names = null;
|
List<String> names = null;
|
||||||
if (nameFilter != null) {
|
if (name != null) {
|
||||||
|
// Filter using single name
|
||||||
|
names = Arrays.asList(name);
|
||||||
|
}
|
||||||
|
else if (nameFilter != null) {
|
||||||
|
// Filter using supplied list of names
|
||||||
names = ResourceListManager.getInstance().getStringsInList(nameFilter);
|
names = ResourceListManager.getInstance().getStringsInList(nameFilter);
|
||||||
if (names.isEmpty()) {
|
if (names.isEmpty()) {
|
||||||
// List doesn't exist or is empty - so there will be no matches
|
// List doesn't exist or is empty - so there will be no matches
|
||||||
|
@ -166,6 +166,7 @@ window.addEventListener("message", (event) => {
|
|||||||
case "LIST_QDN_RESOURCES":
|
case "LIST_QDN_RESOURCES":
|
||||||
url = "/arbitrary/resources?";
|
url = "/arbitrary/resources?";
|
||||||
if (data.service != null) url = url.concat("&service=" + data.service);
|
if (data.service != null) url = url.concat("&service=" + data.service);
|
||||||
|
if (data.name != null) url = url.concat("&name=" + data.name);
|
||||||
if (data.identifier != null) url = url.concat("&identifier=" + data.identifier);
|
if (data.identifier != null) url = url.concat("&identifier=" + data.identifier);
|
||||||
if (data.default != null) url = url.concat("&default=" + new Boolean(data.default).toString());
|
if (data.default != null) url = url.concat("&default=" + new Boolean(data.default).toString());
|
||||||
if (data.includeStatus != null) url = url.concat("&includestatus=" + new Boolean(data.includeStatus).toString());
|
if (data.includeStatus != null) url = url.concat("&includestatus=" + new Boolean(data.includeStatus).toString());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user