From: Martin Sunal Date: Mon, 27 Jan 2014 15:15:30 +0000 (+0100) Subject: BUG 340: Resolved instance-identifier translation in JSON X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~554^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=8ed1692034c541c1e714b99e1470ac5fbde75d0d BUG 340: Resolved instance-identifier translation in JSON Change-Id: Ia8853c00798674251b39941a675e9c359aa68a00 Signed-off-by: Martin Sunal --- 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); }