From 8ed1692034c541c1e714b99e1470ac5fbde75d0d Mon Sep 17 00:00:00 2001 From: Martin Sunal Date: Mon, 27 Jan 2014 16:15:30 +0100 Subject: [PATCH] BUG 340: Resolved instance-identifier translation in JSON Change-Id: Ia8853c00798674251b39941a675e9c359aa68a00 Signed-off-by: Martin Sunal --- .../controller/sal/rest/impl/JsonMapper.java | 12 ++++++++---- .../controller/sal/restconf/impl/RestCodec.java | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java index ca318e4f36..226eff44e1 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java @@ -252,14 +252,18 @@ class JsonMapper { result.append("/"); writeModuleNameAndIdentifier(result, identityValue); - if (identityValue.getPredicates() != null) { + if (identityValue.getPredicates() != null && !identityValue.getPredicates().isEmpty()) { for (Predicate predicate : identityValue.getPredicates()) { IdentityValue identityValuePredicate = predicate.getName(); result.append("["); - writeModuleNameAndIdentifier(result, identityValuePredicate); - result.append("=\""); + if (identityValuePredicate == null) { + result.append("."); + } else { + writeModuleNameAndIdentifier(result, identityValuePredicate); + } + result.append("='"); result.append(predicate.getValue()); - result.append("\""); + result.append("'"); result.append("]"); } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java index 4f643fe34d..d6b530039e 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java @@ -212,6 +212,11 @@ public class RestCodec { List predicates = keyValuesToPredicateList(((NodeIdentifierWithPredicates) pathArgument) .getKeyValues()); identityValue.setPredicates(predicates); + } else if (pathArgument instanceof NodeWithValue && identityValue != null) { + List predicates = new ArrayList<>(); + String value = String.valueOf(((NodeWithValue) pathArgument).getValue()); + predicates.add(new Predicate(null, value)); + identityValue.setPredicates(predicates); } identityValuesDTO.add(identityValue); } -- 2.36.6