From 24e57e283ec9bdd69a0325a3b605b2be83e4a410 Mon Sep 17 00:00:00 2001 From: Vijayendra Bhamidipati Date: Tue, 20 Mar 2012 15:35:09 -0700 Subject: [PATCH] Bug 14071: queryAsyncJobResult in xml format gives incorrect UUIDs back Description: Incorrectly removed part of the XML serializer that serialized the IdentityProxy object in normal responses, when putting in support for serialization of lists of IdentityProxy objects in exception responses as part of the code changes put in for bug 13217, resulting in this bug. Putting it back in place. --- .../cloud/api/response/ApiResponseSerializer.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/src/com/cloud/api/response/ApiResponseSerializer.java b/server/src/com/cloud/api/response/ApiResponseSerializer.java index 55d54483a89..4b8dbaaf96b 100644 --- a/server/src/com/cloud/api/response/ApiResponseSerializer.java +++ b/server/src/com/cloud/api/response/ApiResponseSerializer.java @@ -213,6 +213,7 @@ public class ApiResponseSerializer { } serializeResponseObjXML(sb, subObj); } else if (value instanceof IdentityProxy) { + // Only exception reponses carry a list of IdentityProxy objects. IdentityProxy idProxy = (IdentityProxy)value; String id = (idProxy.getValue() != null ? String.valueOf(idProxy.getValue()) : ""); if(!id.isEmpty()) { @@ -240,6 +241,19 @@ public class ApiResponseSerializer { } } else if (fieldValue instanceof Date) { sb.append("<" + serializedName.value() + ">" + BaseCmd.getDateString((Date) fieldValue) + ""); + } else if (fieldValue instanceof IdentityProxy) { + IdentityProxy idProxy = (IdentityProxy)fieldValue; + String id = (idProxy.getValue() != null ? String.valueOf(idProxy.getValue()) : ""); + if(!id.isEmpty()) { + IdentityDao identityDao = new IdentityDaoImpl(); + if(idProxy.getTableName() != null) { + id = identityDao.getIdentityUuid(idProxy.getTableName(), id); + } else { + s_logger.warn("IdentityProxy sanity check issue, invalid IdentityProxy table name found in class: " + obj.getClass().getName()); + } + } + if(id != null && !id.isEmpty()) + sb.append("<" + serializedName.value() + ">" + id + ""); } else { String resultString = escapeSpecialXmlChars(fieldValue.toString()); if (!(obj instanceof ExceptionResponse)) {