Change in ovirt-engine[master]: restapi: Don't assume names in completeness assertor

juan.hernandez at redhat.com juan.hernandez at redhat.com
Mon Sep 28 13:14:18 UTC 2015


Juan Hernandez has submitted this change and it was merged.

Change subject: restapi: Don't assume names in completeness assertor
......................................................................


restapi: Don't assume names in completeness assertor

Currently the completeness assertor assumes that access to a element of
a list in the code generated by the XJC compiler is always done calling
two methods with identical names. For example, it assumes that getting
the slaves of a bonding works like this:

  Bonding bonding = ...;
  Slave slave = bonding.getSlaves().getSlaves().get(0);

This kind of call isn't performed directly, but using reflection, but
anyhow the completeness assertor assumes that there will be two
consecutive calls to methods named "getSlaves" and "getSlaves".
Internally this is used when checking validations like the following:

  validateParameters(bonding, "bonding.slaves.id|name");

This works fine in the current environment, but if the types are changed
it breaks. For example, assume that the code is changed so that
"Bonding.getSlaves()" returns an object of type "HostNics" instead of
"Slaves". The way to get slaves will then be like this:

  Bonding bonding = ...;
  Slave slave = bonding.getSlaves().getHostNics().get(0);

But the completeness assertor won't be able to do this via reflection,
because the names of the method are now different, "getSlaves" and then
"getHostNics".

To avoid this limitation this patch changes the completeness assertor so
instead of assuming the two method names it will only assume the first
and will find the second method assuming that objects that represent
lists have only one getter that returns a list object.

Change-Id: I35badb0f5365a41a1d57ce7a99f81bbe32e5a451
Signed-off-by: Juan Hernandez <juan.hernandez at redhat.com>
---
M backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/util/CompletenessAssertor.java
1 file changed, 44 insertions(+), 8 deletions(-)

Approvals:
  Juan Hernandez: Verified; Looks good to me, approved
  Jenkins CI: Passed CI tests



-- 
To view, visit https://gerrit.ovirt.org/46727
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I35badb0f5365a41a1d57ce7a99f81bbe32e5a451
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernandez at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Juan Hernandez <juan.hernandez at redhat.com>
Gerrit-Reviewer: Ori Liel <oliel at redhat.com>
Gerrit-Reviewer: automation at ovirt.org



More information about the Engine-commits mailing list