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/11 02:43:55 UTC
[5/6] git commit: api: minor fixes in ApiServlet
api: minor fixes in ApiServlet
- Reusing local variable for string splitting/processing
- Fix comments
- Fix indentations
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/8fbbc764
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/8fbbc764
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/8fbbc764
Branch: refs/heads/api_refactoring
Commit: 8fbbc7646648c86da56239d9cfee8633edaf2484
Parents: c8923c9
Author: Rohit Yadav <bh...@apache.org>
Authored: Mon Dec 10 16:19:40 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Mon Dec 10 16:19:40 2012 -0800
----------------------------------------------------------------------
server/src/com/cloud/api/ApiServlet.java | 30 ++++++++++--------------
1 files changed, 13 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8fbbc764/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 4c2739c..7e1f2c3 100755
--- a/server/src/com/cloud/api/ApiServlet.java
+++ b/server/src/com/cloud/api/ApiServlet.java
@@ -86,8 +86,8 @@ public class ApiServlet extends HttpServlet {
for (String param : paramsInQueryString) {
String[] paramTokens = param.split("=");
if (paramTokens != null && paramTokens.length == 2) {
- String name = param.split("=")[0];
- String value = param.split("=")[1];
+ String name = paramTokens[0];
+ String value = paramTokens[1];
try {
name = URLDecoder.decode(name, "UTF-8");
@@ -99,7 +99,7 @@ public class ApiServlet extends HttpServlet {
}
params.put(name, new String[] { value });
} else {
- s_logger.debug("Invalid paramemter in URL found. param: " + param);
+ s_logger.debug("Invalid parameter in URL found. param: " + param);
}
}
}
@@ -115,13 +115,10 @@ public class ApiServlet extends HttpServlet {
Map<String, Object[]> params = new HashMap<String, Object[]>();
params.putAll(req.getParameterMap());
- //
// For HTTP GET requests, it seems that HttpServletRequest.getParameterMap() actually tries
// to unwrap URL encoded content from ISO-9959-1.
- //
- // After failed in using setCharacterEncoding() to control it, end up with following hacking : for all GET requests,
- // we will override it with our-own way of UTF-8 based URL decoding.
- //
+ // After failed in using setCharacterEncoding() to control it, end up with following hacking:
+ // for all GET requests, we will override it with our-own way of UTF-8 based URL decoding.
utf8Fixup(req, params);
// logging the request start and end in management log for easy debugging
@@ -265,7 +262,8 @@ public class ApiServlet extends HttpServlet {
}
// Do a sanity check here to make sure the user hasn't already been deleted
- if ((userId != null) && (account != null) && (accountObj != null) && _apiServer.verifyUser(userId)) {
+ if ((userId != null) && (account != null)
+ && (accountObj != null) && _apiServer.verifyUser(userId)) {
String[] command = (String[]) params.get("command");
if (command == null) {
s_logger.info("missing command, ignoring request...");
@@ -276,9 +274,8 @@ public class ApiServlet extends HttpServlet {
}
UserContext.updateContext(userId, (Account) accountObj, session.getId());
} else {
- // Invalidate the session to ensure we won't allow a request across management server restarts if the userId
- // was serialized to the
- // stored session
+ // Invalidate the session to ensure we won't allow a request across management server
+ // restarts if the userId was serialized to the stored session
try {
session.invalidate();
} catch (IllegalStateException ise) {
@@ -389,12 +386,11 @@ public class ApiServlet extends HttpServlet {
StringBuffer sb = new StringBuffer();
int inactiveInterval = session.getMaxInactiveInterval();
- String user_UUID = (String)session.getAttribute("user_UUID");
- session.removeAttribute("user_UUID");
+ String user_UUID = (String)session.getAttribute("user_UUID");
+ session.removeAttribute("user_UUID");
- String domain_UUID = (String)session.getAttribute("domain_UUID");
- session.removeAttribute("domain_UUID");
-
+ String domain_UUID = (String)session.getAttribute("domain_UUID");
+ session.removeAttribute("domain_UUID");
if (BaseCmd.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
sb.append("{ \"loginresponse\" : { ");