diff --git a/server/src/com/cloud/api/response/ApiResponseSerializer.java b/server/src/com/cloud/api/response/ApiResponseSerializer.java index 721fa0aad56..1feab79f23b 100644 --- a/server/src/com/cloud/api/response/ApiResponseSerializer.java +++ b/server/src/com/cloud/api/response/ApiResponseSerializer.java @@ -207,6 +207,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()) { @@ -233,7 +234,20 @@ public class ApiResponseSerializer { sb.append(""); } } else if (fieldValue instanceof Date) { - sb.append("<" + serializedName.value() + ">" + BaseCmd.getDateString((Date) fieldValue) + ""); + 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)) {