|
|
@ -31,12 +31,18 @@ public class CoapAdaptorUtils { |
|
|
List<String> queryElements = inbound.getOptions().getUriQuery(); |
|
|
List<String> queryElements = inbound.getOptions().getUriQuery(); |
|
|
TransportProtos.GetAttributeRequestMsg.Builder result = TransportProtos.GetAttributeRequestMsg.newBuilder(); |
|
|
TransportProtos.GetAttributeRequestMsg.Builder result = TransportProtos.GetAttributeRequestMsg.newBuilder(); |
|
|
if (queryElements != null && queryElements.size() > 0) { |
|
|
if (queryElements != null && queryElements.size() > 0) { |
|
|
|
|
|
boolean allClient = "true".equalsIgnoreCase(getQueryValue(queryElements, "allClientKeys")); |
|
|
|
|
|
boolean allShared = "true".equalsIgnoreCase(getQueryValue(queryElements, "allSharedKeys")); |
|
|
Set<String> clientKeys = toKeys(queryElements, "clientKeys"); |
|
|
Set<String> clientKeys = toKeys(queryElements, "clientKeys"); |
|
|
Set<String> sharedKeys = toKeys(queryElements, "sharedKeys"); |
|
|
Set<String> sharedKeys = toKeys(queryElements, "sharedKeys"); |
|
|
if (clientKeys != null) { |
|
|
if (allClient) { |
|
|
|
|
|
result.setAllClientAttributes(true); |
|
|
|
|
|
} else if (clientKeys != null) { |
|
|
result.addAllClientAttributeNames(clientKeys); |
|
|
result.addAllClientAttributeNames(clientKeys); |
|
|
} |
|
|
} |
|
|
if (sharedKeys != null) { |
|
|
if (allShared) { |
|
|
|
|
|
result.setAllSharedAttributes(true); |
|
|
|
|
|
} else if (sharedKeys != null) { |
|
|
result.addAllSharedAttributeNames(sharedKeys); |
|
|
result.addAllSharedAttributeNames(sharedKeys); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -44,6 +50,16 @@ public class CoapAdaptorUtils { |
|
|
return result.build(); |
|
|
return result.build(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static String getQueryValue(List<String> 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<String> toKeys(List<String> queryElements, String attributeName) throws AdaptorException { |
|
|
private static Set<String> toKeys(List<String> queryElements, String attributeName) throws AdaptorException { |
|
|
String keys = null; |
|
|
String keys = null; |
|
|
for (String queryElement : queryElements) { |
|
|
for (String queryElement : queryElements) { |
|
|
|