You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/17 06:59:03 UTC
git commit: api: Include cloudstack-version in both xml and json api
response
Updated Branches:
refs/heads/api_refactoring 59fc89abe -> f8a483fc5
api: Include cloudstack-version in both xml and json api response
Signed-off-by: Rohit Yadav <bh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/f8a483fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/f8a483fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/f8a483fc
Branch: refs/heads/api_refactoring
Commit: f8a483fc5a47cb66ac4788fcd7d53da0c9d6ea2b
Parents: 59fc89a
Author: Rohit Yadav <bh...@apache.org>
Authored: Sun Dec 16 21:37:03 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Sun Dec 16 21:37:03 2012 -0800
----------------------------------------------------------------------
api/src/org/apache/cloudstack/api/BaseCmd.java | 8 ++++----
server/src/com/cloud/api/ApiServlet.java | 14 ++++++++++----
.../cloud/api/response/ApiResponseSerializer.java | 6 ++++--
3 files changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f8a483fc/api/src/org/apache/cloudstack/api/BaseCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java
index ac87785..d89f5ea 100644
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@ -308,14 +308,14 @@ public abstract class BaseCmd {
StringBuffer sb = new StringBuffer();
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
// JSON response
- sb.append("{ \"" + getCommandName() + "\" : { " + "\"@attributes\":{\"cloud-stack-version\":\"" + _mgr.getVersion() + "\"},");
+ sb.append("{ \"" + getCommandName() + "\" : { " + "\"@attributes\":{\"cloudstack-version\":\"" + _mgr.getVersion() + "\"},");
sb.append("\"errorcode\" : \"" + apiException.getErrorCode() + "\", \"description\" : \"" + apiException.getDescription() + "\" } }");
} else {
sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
sb.append("<" + getCommandName() + ">");
sb.append("<errorcode>" + apiException.getErrorCode() + "</errorcode>");
sb.append("<description>" + escapeXml(apiException.getDescription()) + "</description>");
- sb.append("</" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">");
+ sb.append("</" + getCommandName() + " cloudstack-version=\"" + _mgr.getVersion() + "\">");
}
return sb.toString();
}
@@ -326,10 +326,10 @@ public abstract class BaseCmd {
// 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() + "\"},");
+ prefixSb.append("{ \"" + getCommandName() + "\" : { \"@attributes\":{\"cloudstack-version\":\"" + _mgr.getVersion() + "\"},");
} else {
prefixSb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
- prefixSb.append("<" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">");
+ prefixSb.append("<" + getCommandName() + " cloudstack-version=\"" + _mgr.getVersion() + "\">");
}
int i = 0;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f8a483fc/server/src/com/cloud/api/ApiServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServlet.java b/server/src/com/cloud/api/ApiServlet.java
index 7e1f2c3..8954819 100755
--- a/server/src/com/cloud/api/ApiServlet.java
+++ b/server/src/com/cloud/api/ApiServlet.java
@@ -411,10 +411,13 @@ public class ApiServlet extends HttpServlet {
}
}
}
- sb.append(" } }");
+ sb.append(" }");
+ sb.append(", \"cloudstack-version\": \"");
+ sb.append(ApiDBUtils.getVersion());
+ sb.append("\" }");
} else {
sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
- sb.append("<loginresponse cloud-stack-version=\"" + ApiDBUtils.getVersion() + "\">");
+ sb.append("<loginresponse cloudstack-version=\"" + ApiDBUtils.getVersion() + "\">");
sb.append("<timeout>" + inactiveInterval + "</timeout>");
Enumeration attrNames = session.getAttributeNames();
if (attrNames != null) {
@@ -441,10 +444,13 @@ public class ApiServlet extends HttpServlet {
private String getLogoutSuccessResponse(String responseType) {
StringBuffer sb = new StringBuffer();
if (BaseCmd.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
- sb.append("{ \"logoutresponse\" : { \"description\" : \"success\" } }");
+ sb.append("{ \"logoutresponse\" : { \"description\" : \"success\" }");
+ sb.append(", \"cloudstack-version\": \"");
+ sb.append(ApiDBUtils.getVersion());
+ sb.append("\" }");
} else {
sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
- sb.append("<logoutresponse cloud-stack-version=\"" + ApiDBUtils.getVersion() + "\">");
+ sb.append("<logoutresponse cloudstack-version=\"" + ApiDBUtils.getVersion() + "\">");
sb.append("<description>success</description>");
sb.append("</logoutresponse>");
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f8a483fc/server/src/com/cloud/api/response/ApiResponseSerializer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/response/ApiResponseSerializer.java b/server/src/com/cloud/api/response/ApiResponseSerializer.java
index 4a4d943..af37aa2 100644
--- a/server/src/com/cloud/api/response/ApiResponseSerializer.java
+++ b/server/src/com/cloud/api/response/ApiResponseSerializer.java
@@ -122,7 +122,9 @@ public class ApiResponseSerializer {
sb.append("{ }");
}
}
- sb.append(" }");
+ sb.append(", \"cloudstack-version\": \"");
+ sb.append(ApiDBUtils.getVersion());
+ sb.append("\" }");
return sb.toString();
}
return null;
@@ -131,7 +133,7 @@ public class ApiResponseSerializer {
private static String toXMLSerializedString(ResponseObject result) {
StringBuilder sb = new StringBuilder();
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- sb.append("<").append(result.getResponseName()).append(" cloud-stack-version=\"").append(ApiDBUtils.getVersion()).append("\">");
+ sb.append("<").append(result.getResponseName()).append(" cloudstack-version=\"").append(ApiDBUtils.getVersion()).append("\">");
if (result instanceof ListResponse) {
Integer count = ((ListResponse) result).getCount();