diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c index 1f0058f5..bfe6fbeb 100644 --- a/apps/backend/backend_client.c +++ b/apps/backend/backend_client.c @@ -1497,6 +1497,7 @@ from_client_get_pageable_list(clicon_handle h, } if ((xtop = xml_new("top", NULL, CX_ELMNT)) == NULL) goto done; + /* Parse xpath -> stuctured path tree */ if ((ret = clixon_instance_id_parse(yspec, &path_tree, "%s", xpath)) < 0) goto done; if (ret == 0){ @@ -1504,12 +1505,13 @@ from_client_get_pageable_list(clicon_handle h, goto done; goto ok; } - /* get last element */ + /* get last element of path, eg /a/b/c, get c */ if ((cp = PREVQ(clixon_path *, path_tree)) == NULL){ if (netconf_bad_element(cbret, "application", "list-target", "path invalid") < 0) goto done; goto ok; } + /* get yang of last element */ if ((y = cp->cp_yang) == NULL){ if (netconf_bad_element(cbret, "application", "list-target", "No yang associated with path") < 0) goto done; @@ -1520,7 +1522,10 @@ from_client_get_pageable_list(clicon_handle h, goto done; goto ok; } - /* Build a "predicate" cbuf */ + /* Build a "predicate" cbuf + * This solution uses xpath predicates to translate "count" and "skip" to + * relational operators <>. + */ if ((cb = cbuf_new()) == NULL){ clicon_err(OE_UNIX, errno, "cbuf_new"); goto done; @@ -1529,9 +1534,9 @@ from_client_get_pageable_list(clicon_handle h, if (where) cprintf(cb, "[%s]", where); if (skip){ - cprintf(cb, "[%u < position()", skip); + cprintf(cb, "[%u <= position()", skip); if (count) - cprintf(cb, " && position() < %u", count+skip); + cprintf(cb, " and position() < %u", count+skip); cprintf(cb, "]"); } else if (count) diff --git a/test/test_pagination.sh b/test/test_pagination.sh index 3f5c55cf..7ddbe6cc 100755 --- a/test/test_pagination.sh +++ b/test/test_pagination.sh @@ -56,14 +56,22 @@ cat <<'EOF' > $dir/startup_db 2 3 - - Problem Solving - 98 - Conflict Resolution 93 + + Management + 23 + + + Organization + 44 + + + Problem Solving + 98 + Joe @@ -296,13 +304,17 @@ if [ $RC -ne 0 ]; then wait_restconf fi +# draft-wwlh-netconf-list-pagination-nc-00.txt new "C.1. 'count' Parameter NETCONF" -expecteof "$clixon_netconf -qf $cfg" 0 "ds:running/exm:admins/exm:admin[exm:name='Bob']/exm:skill2]]>]]>" 'Conflict Resolution93Problem Solving98]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "ds:running/exm:admins/exm:admin[exm:name='Bob']/exm:skill2]]>]]>" 'Conflict Resolution93Management23]]>]]>$' + +new "C.2. 'skip' Parameter NETCONF" +expecteof "$clixon_netconf -qf $cfg" 0 "ds:running/exm:admins/exm:admin[exm:name='Bob']/exm:skill22]]>]]>" 'Organization44Problem Solving98]]>]]>$' + +# draft-wwlh-netconf-list-pagination-rc-00.txt +#new "A.1. 'count' Parameter RESTCONF" +#expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang.collection+xml" $RCPROTO://localhost/restconf/data/example-module:get-list-pagination/library/artist=Foo%20Fighters/album/?count=2)" 0 "HTTP/1.1 200 OK" "application/yang.collection+xml" 'Crime and Punishment1995One by One2002' -if false; then # XXX notyet -new "C.1. 'count' Parameter RESTCONF" -expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang.collection+xml" $RCPROTO://localhost/restconf/data/example-jukebox:jukebox/library/artist=Foo%20Fighters/album/?count=2)" 0 "HTTP/1.1 200 OK" "application/yang.collection+xml" 'Crime and Punishment1995One by One2002' -fi if [ $RC -ne 0 ]; then new "Kill restconf daemon" stop_restconf