Martin Sivák has uploaded a new change for review. Change subject: engine: Enhance the xml-rpc Long support to deal with Maps and Lists ......................................................................
engine: Enhance the xml-rpc Long support to deal with Maps and Lists It is common to have a Long value in a sub-map of an xml-rpc argument. The current implementation does not deal with this case. The ideal solution to this would be to instruct the marshaller to do this. Unfortunately that is not possible and we have to work around that limitation. Change-Id: I5a5933a68f937c4734b547c173188e88bd7b9464 Signed-off-by: Martin Sivák <msi...@redhat.com> --- M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/xmlrpc/XmlRpcUtils.java 1 file changed, 32 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/55/35355/1 diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/xmlrpc/XmlRpcUtils.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/xmlrpc/XmlRpcUtils.java index fa4ea00..4a5e10d 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/xmlrpc/XmlRpcUtils.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/xmlrpc/XmlRpcUtils.java @@ -9,8 +9,11 @@ import java.net.URL; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.FutureTask; @@ -295,14 +298,38 @@ List<Object> result = new ArrayList<>(); for (int i = 0; i < request.getParameterCount(); i++) { Object object = request.getParameter(i); - if (Long.class.isInstance(object)) { - result.add(object.toString()); - continue; - } - result.add(object); + result.add(longToString(object)); } return result.toArray(); } + + /** + * Workaround the lack of Long support in VDSM by converting all + * Long typed variables to String. + * + * @param object object that potentially contains Long items + * @return new object where all the Longs are converted to Strings + */ + @SuppressWarnings("unchecked") + private Object longToString(Object object) { + if (Long.class.isInstance(object)) { + return object.toString(); + } else if (Map.class.isInstance(object)) { + Map<Object, Object> map = new HashMap<>(); + for (Map.Entry<Object, Object> entry: ((Map<Object, Object>)object).entrySet()) { + map.put(entry.getKey(), longToString(entry.getValue())); + } + return map; + } else if (Collection.class.isInstance(object)) { + List<Object> list = new ArrayList<>(); + for (Object entry: (List<Object>)object) { + list.add(longToString(entry)); + } + return list; + } else { + return object; + } + } }; /** -- To view, visit http://gerrit.ovirt.org/35355 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5a5933a68f937c4734b547c173188e88bd7b9464 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Sivák <msi...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches