[CONTROLLER-1176] Restconf deserialization of xpath for instance identifiers fails to handle "/" in string literals Created: 27/Feb/15  Updated: 25/Jul/23  Resolved: 16/Mar/15

Status: Resolved
Project: controller
Component/s: restconf
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Ed Warnicke Assignee: Tony Tkacik
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 2766

 Description   

Given an instance identifier like:
"/network-topology:network-topology/network-topology:topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node/network-topology:node[network-topology:node-id='ovsdb://127.0.0.1:16640']"

Submitted via restconf, restconf fails to properly deserialize it (instead simple writing a null in the field containing that value).

Some preliminary debugging showed that in controller/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestUtil.java

what is going wrong is that on line 41 (in method asInstanceIdentifier()):

final String[] xPathParts = valueTrimmed.split("/");

This results in splitting the xpath expression mid-predicate: because the predicate:[network-topology:node-id='ovsdb://127.0.0.1:16640']

contains a number of "/" characters within the literal 'ovsdb://127.0.0.1:16640' it contains.

Looking at the XPath BNF:

http://www.w3.org/2002/11/xquery-xpath-applets/xpath-bnf.html

It appears that it is valid to have a "/" within a literal (which in this case it is.

Please fix the parsing to correctly handle string literals.



 Comments   
Comment by Tony Tkacik [ 02/Mar/15 ]

https://git.opendaylight.org/gerrit/#/c/15900/

Comment by Raghurama Bhat [ 02/Mar/15 ]

https://git.opendaylight.org/gerrit/#/c/15934/

I made a fix to the RestUtil.java in controller. Tony, I am assuming both of these code paths are utilized and both fixes are needed. If not, We can abandon my fix

Generated at Wed Feb 07 19:54:52 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.