diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java index 781b692fa64..4f4d0db5f35 100644 --- a/api/src/org/apache/cloudstack/api/BaseCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseCmd.java @@ -302,65 +302,6 @@ public abstract class BaseCmd { return lowercaseParams; } - public String buildResponse(ServerApiException apiException, String responseType) { - StringBuffer sb = new StringBuffer(); - if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { - // JSON response - sb.append("{ \"" + getCommandName() + "\" : { " + "\"@attributes\":{\"cloud-stack-version\":\"" + _mgr.getVersion() + "\"},"); - sb.append("\"errorcode\" : \"" + apiException.getErrorCode() + "\", \"description\" : \"" + apiException.getDescription() + "\" } }"); - } else { - sb.append(""); - sb.append("<" + getCommandName() + ">"); - sb.append("" + apiException.getErrorCode() + ""); - sb.append("" + escapeXml(apiException.getDescription()) + ""); - sb.append(""); - } - return sb.toString(); - } - - public String buildResponse(List> tagList, String responseType) { - StringBuffer prefixSb = new StringBuffer(); - StringBuffer suffixSb = new StringBuffer(); - - // set up the return value with the name of the response - if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { - prefixSb.append("{ \"" + getCommandName() + "\" : { \"@attributes\":{\"cloud-stack-version\":\"" + _mgr.getVersion() + "\"},"); - } else { - prefixSb.append(""); - prefixSb.append("<" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">"); - } - - int i = 0; - for (Pair tagData : tagList) { - String tagName = tagData.first(); - Object tagValue = tagData.second(); - if (tagValue instanceof Object[]) { - Object[] subObjects = (Object[]) tagValue; - if (subObjects.length < 1) { - continue; - } - writeObjectArray(responseType, suffixSb, i++, tagName, subObjects); - } else { - writeNameValuePair(suffixSb, tagName, tagValue, responseType, i++); - } - } - - if (suffixSb.length() > 0) { - if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { // append comma only if we have some suffix else - // not as per strict Json syntax. - prefixSb.append(","); - } - prefixSb.append(suffixSb); - } - // close the response - if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { - prefixSb.append("} }"); - } else { - prefixSb.append(""); - } - return prefixSb.toString(); - } - private void writeNameValuePair(StringBuffer sb, String tagName, Object tagValue, String responseType, int propertyCount) { if (tagValue == null) { return;