Change in ovirt-engine-sdk[master]: sdk: Fix find root tag

juan.hernandez at redhat.com juan.hernandez at redhat.com
Wed Sep 3 14:48:49 UTC 2014


Juan Hernandez has submitted this change and it was merged.

Change subject: sdk: Fix find root tag
......................................................................


sdk: Fix find root tag

Currently when the SDK needs to generate the XML document for an entity
it selects the root tag doing a reverse lookup inside the _rootClassMap
dictionary. This isn't correct, because that dictionary contains
duplicates. For example, for the "User" class there are more than one
corresponding tags:

  "user": User,
  "owner": User,
  ...

The root cause of this problem is that the _rootClassMap dictionary
contains entries for all the element definitions contained in the XML
schema, not only for the top level element definitions. The non top
level element definitions shouldn't be used to determine root tags, as
they can't be used as the root tag of valid XML documents.

This _rootClassMap dictionary was introduced to overcome a limitation of
generateDS.py, but that limitation was fixed in version 2.12a. It can't
be removed now because users may be calling the "findRootClass" function
that uses this dictionary.

To address these issues this patch modifies the code generator so that
it won't use the _rootClassMap dictionary, but the dictionary generated
by generateDS.py. In addition the patch also introduces a new
_tag_for_type dictionary to be used instead of the reverse lookup in
_rootClassMap. This new dictionary only contains the types corresponding
to top level elements.

The _rootClassMap dictionary and the related functions are preserved for
backwards compatibility.

Change-Id: I67b22c07ff4b91a7bf9b2ff8883ee51bef8c8f58
Related-To: https://bugzilla.redhat.com/1122589
Signed-off-by: Juan Hernandez <juan.hernandez at redhat.com>
---
M generator/src/main/java/org/ovirt/engine/sdk/generator/rsdl/RsdlCodegen.java
M generator/src/main/java/org/ovirt/engine/sdk/generator/xsd/XsdCodegen.java
M generator/src/main/java/org/ovirt/engine/sdk/generator/xsd/XsdData.java
M generator/src/main/java/org/ovirt/engine/sdk/generator/xsd/templates/FindRootClassTemplate
D generator/src/main/java/org/ovirt/engine/sdk/generator/xsd/templates/GetRootTagTemplate
D generator/src/main/java/org/ovirt/engine/sdk/generator/xsd/templates/GetRootTagTemplate.java
D generator/src/main/java/org/ovirt/engine/sdk/generator/xsd/templates/ParseStringTemplate
D generator/src/main/java/org/ovirt/engine/sdk/generator/xsd/templates/ParseStringTemplate.java
M src/ovirtsdk/infrastructure/errors.py
M src/ovirtsdk/infrastructure/proxy.py
M src/ovirtsdk/utils/parsehelper.py
11 files changed, 99 insertions(+), 129 deletions(-)

Approvals:
  Ravi Nori: Looks good to me, but someone else must approve
  Juan Hernandez: Verified; Looks good to me, approved



-- 
To view, visit http://gerrit.ovirt.org/32044
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I67b22c07ff4b91a7bf9b2ff8883ee51bef8c8f58
Gerrit-PatchSet: 4
Gerrit-Project: ovirt-engine-sdk
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernandez at redhat.com>
Gerrit-Reviewer: Juan Hernandez <juan.hernandez at redhat.com>
Gerrit-Reviewer: Ravi Nori <rnori at redhat.com>
Gerrit-Reviewer: automation at ovirt.org



More information about the Engine-commits mailing list