RESTCONF JSON identity had wrong namespace in sub-objetcs
This commit is contained in:
parent
a57dbfc6f0
commit
f319c18374
4 changed files with 39 additions and 3 deletions
|
|
@ -49,6 +49,8 @@
|
||||||
* pseudo-plugin added, to enable callbacks also for main programs. Useful for extensions
|
* pseudo-plugin added, to enable callbacks also for main programs. Useful for extensions
|
||||||
|
|
||||||
### Corrected Bugs
|
### Corrected Bugs
|
||||||
|
* RESTCONF JSON identity had wrong namespace in sub-objetcs
|
||||||
|
* Showed if you GET an object with JSON encoding that have identities
|
||||||
* Fixed Segv in nacm write when MERGE and creating object
|
* Fixed Segv in nacm write when MERGE and creating object
|
||||||
* Should only be applicable on netconf MERGE and restconf PATCH
|
* Should only be applicable on netconf MERGE and restconf PATCH
|
||||||
* Corrected problem with namespace context cache, was not always cleared when adding new subtrees.
|
* Corrected problem with namespace context cache, was not always cleared when adding new subtrees.
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ int xml_name_set(cxobj *xn, char *name);
|
||||||
char *xml_prefix(cxobj *xn);
|
char *xml_prefix(cxobj *xn);
|
||||||
int xml_prefix_set(cxobj *xn, char *name);
|
int xml_prefix_set(cxobj *xn, char *name);
|
||||||
int nscache_clear(cxobj *x);
|
int nscache_clear(cxobj *x);
|
||||||
|
int nscache_replace(cxobj *x, cvec *ns);
|
||||||
int xml2ns(cxobj *x, char *localname, char **namespace);
|
int xml2ns(cxobj *x, char *localname, char **namespace);
|
||||||
int xmlns_set(cxobj *x, char *prefix, char *namespace);
|
int xmlns_set(cxobj *x, char *prefix, char *namespace);
|
||||||
cxobj *xml_parent(cxobj *xn);
|
cxobj *xml_parent(cxobj *xn);
|
||||||
|
|
|
||||||
|
|
@ -917,13 +917,20 @@ xml2json_cbuf_vec(cbuf *cb,
|
||||||
cxobj *xp = NULL;
|
cxobj *xp = NULL;
|
||||||
int i;
|
int i;
|
||||||
cxobj *xc;
|
cxobj *xc;
|
||||||
|
cvec *nsc = NULL;
|
||||||
|
|
||||||
if ((xp = xml_new("xml2json", NULL, NULL)) == NULL)
|
if ((xp = xml_new("xml2json", NULL, NULL)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
/* Some complexities in grafting namespace in existing trees to new */
|
/* Make a copy of old and graft it into new top-object
|
||||||
|
* Also copy namespace context */
|
||||||
for (i=0; i<veclen; i++){
|
for (i=0; i<veclen; i++){
|
||||||
xc = xml_dup(vec[i]);
|
if (xml_nsctx_node(vec[i], &nsc) < 0)
|
||||||
|
goto done;
|
||||||
|
if ((xc = xml_dup(vec[i])) == NULL)
|
||||||
|
goto done;
|
||||||
xml_addsub(xp, xc);
|
xml_addsub(xp, xc);
|
||||||
|
nscache_replace(xc, nsc);
|
||||||
|
nsc = NULL; /* nsc consumed */
|
||||||
}
|
}
|
||||||
if (0){
|
if (0){
|
||||||
cprintf(cb, "[%s", pretty?"\n":" ");
|
cprintf(cb, "[%s", pretty?"\n":" ");
|
||||||
|
|
@ -944,6 +951,8 @@ xml2json_cbuf_vec(cbuf *cb,
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (nsc)
|
||||||
|
xml_nsctx_free(nsc);
|
||||||
if (xp)
|
if (xp)
|
||||||
xml_free(xp);
|
xml_free(xp);
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
||||||
|
|
@ -246,12 +246,13 @@ nscache_get(cxobj *x,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Set cached namespace. Replace if necessary
|
/*! Set cached namespace for specific namespace. Replace if necessary
|
||||||
* @param[in] x XML node
|
* @param[in] x XML node
|
||||||
* @param[in] prefix Namespace prefix, or NULL for default
|
* @param[in] prefix Namespace prefix, or NULL for default
|
||||||
* @param[in] namespace Cached namespace to set (assume non-null?)
|
* @param[in] namespace Cached namespace to set (assume non-null?)
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
|
* @see nscache_replace to replace the whole context
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
nscache_set(cxobj *x,
|
nscache_set(cxobj *x,
|
||||||
|
|
@ -271,6 +272,29 @@ nscache_set(cxobj *x,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Set complete cached namespace context
|
||||||
|
* @param[in] x XML node
|
||||||
|
* @param[in] nsc Namespace context (note consumed, dont free)
|
||||||
|
* @retval 0 OK
|
||||||
|
* @retval -1 Error
|
||||||
|
* @see nscache_set set a single cache line
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
nscache_replace(cxobj *x,
|
||||||
|
cvec *nsc)
|
||||||
|
{
|
||||||
|
int retval = -1;
|
||||||
|
|
||||||
|
if (x->x_ns_cache != NULL){
|
||||||
|
xml_nsctx_free(x->x_ns_cache);
|
||||||
|
x->x_ns_cache = NULL;
|
||||||
|
}
|
||||||
|
x->x_ns_cache = nsc;
|
||||||
|
retval = 0;
|
||||||
|
// done:
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
/*! Clear cached namespace context
|
/*! Clear cached namespace context
|
||||||
* Clear the whole namespace context, not just single cache lines
|
* Clear the whole namespace context, not just single cache lines
|
||||||
* @param[in] x XML node
|
* @param[in] x XML node
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue