From 7d0b54a75ebeeb0c93b01559f6315546890f6ef1 Mon Sep 17 00:00:00 2001 From: dshvaika Date: Wed, 24 Jun 2026 18:54:45 +0300 Subject: [PATCH] feat(attributes): CoAP allClientKeys/allSharedKeys query params Additive per-scope fetch-all; existing clientKeys/sharedKeys and onlyShared unchanged. --- .../coap/adaptors/CoapAdaptorUtils.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/adaptors/CoapAdaptorUtils.java b/common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/adaptors/CoapAdaptorUtils.java index 15838564e8..7f6b886f36 100644 --- a/common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/adaptors/CoapAdaptorUtils.java +++ b/common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/adaptors/CoapAdaptorUtils.java @@ -31,12 +31,18 @@ public class CoapAdaptorUtils { List queryElements = inbound.getOptions().getUriQuery(); TransportProtos.GetAttributeRequestMsg.Builder result = TransportProtos.GetAttributeRequestMsg.newBuilder(); if (queryElements != null && queryElements.size() > 0) { + boolean allClient = "true".equalsIgnoreCase(getQueryValue(queryElements, "allClientKeys")); + boolean allShared = "true".equalsIgnoreCase(getQueryValue(queryElements, "allSharedKeys")); Set clientKeys = toKeys(queryElements, "clientKeys"); Set sharedKeys = toKeys(queryElements, "sharedKeys"); - if (clientKeys != null) { + if (allClient) { + result.setAllClientAttributes(true); + } else if (clientKeys != null) { result.addAllClientAttributeNames(clientKeys); } - if (sharedKeys != null) { + if (allShared) { + result.setAllSharedAttributes(true); + } else if (sharedKeys != null) { result.addAllSharedAttributeNames(sharedKeys); } } @@ -44,6 +50,16 @@ public class CoapAdaptorUtils { return result.build(); } + private static String getQueryValue(List queryElements, String name) { + for (String queryElement : queryElements) { + String[] queryItem = queryElement.split("="); + if (queryItem.length == 2 && queryItem[0].equals(name)) { + return queryItem[1]; + } + } + return null; + } + private static Set toKeys(List queryElements, String attributeName) throws AdaptorException { String keys = null; for (String queryElement : queryElements) {