cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [07/11] git commit: updated refs/heads/4.3 to d6bbfbb
Date Wed, 29 Jan 2014 20:59:38 GMT
findbugs fixes for ApiServer, ApiSerializerHelper and ApiXmlDocWriter


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/594fd42d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/594fd42d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/594fd42d

Branch: refs/heads/4.3
Commit: 594fd42d5dd199059c44e735bd0e913aad43d4c5
Parents: c3a63b6
Author: Daan Hoogland <daan@onecht.net>
Authored: Sun Jan 26 13:27:37 2014 +0100
Committer: Daan Hoogland <dhoogland@schubergphilis.com>
Committed: Wed Jan 29 21:36:46 2014 +0100

----------------------------------------------------------------------
 .../src/com/cloud/api/ApiSerializerHelper.java  |  2 +-
 server/src/com/cloud/api/ApiServer.java         | 22 +++++++++++++++-----
 server/src/com/cloud/api/ApiServlet.java        |  3 ++-
 .../com/cloud/api/EncodedStringTypeAdapter.java |  2 +-
 server/src/com/cloud/api/doc/Alert.java         | 12 ++++++++---
 server/src/com/cloud/api/doc/Command.java       | 13 ++++++++----
 .../api/response/ApiResponseSerializer.java     |  2 +-
 7 files changed, 40 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594fd42d/server/src/com/cloud/api/ApiSerializerHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiSerializerHelper.java b/server/src/com/cloud/api/ApiSerializerHelper.java
index e65d5e7..67b9a38 100644
--- a/server/src/com/cloud/api/ApiSerializerHelper.java
+++ b/server/src/com/cloud/api/ApiSerializerHelper.java
@@ -24,7 +24,7 @@ import org.apache.cloudstack.api.ResponseObject;
 
 public class ApiSerializerHelper {
     public static final Logger s_logger = Logger.getLogger(ApiSerializerHelper.class.getName());
-    public static String token = "/";
+    private static String token = "/";
 
     public static String toSerializedString(Object result) {
         if (result != null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594fd42d/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index bf987be..c6a581c 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -159,9 +159,9 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler,
ApiSer
     private static final Logger s_logger = Logger.getLogger(ApiServer.class.getName());
     private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName());
 
-    public static boolean encodeApiResponse = false;
-    public static String jsonContentType = "text/javascript";
-    public static String controlCharacters = "[\000-\011\013-\014\016-\037\177]"; // Non-printable
ASCII characters - numbers 0 to 31 and 127 decimal
+    private static boolean encodeApiResponse = false;
+    private static String jsonContentType = "text/javascript";
+    private static String controlCharacters = "[\000-\011\013-\014\016-\037\177]"; // Non-printable
ASCII characters - numbers 0 to 31 and 127 decimal
     @Inject ApiDispatcher _dispatcher;
 
     @Inject private AccountManager _accountMgr;
@@ -237,7 +237,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler,
ApiSer
             _apiNameCmdClassMap.put(apiName, cmdClass);
         }
 
-        encodeApiResponse = Boolean.valueOf(_configDao.getValue(Config.EncodeApiResponse.key()));
+        setEncodeApiResponse(Boolean.valueOf(_configDao.getValue(Config.EncodeApiResponse.key())));
         String jsonType = _configDao.getValue(Config.JavaScriptDefaultContentType.key());
         if (jsonType != null) {
             jsonContentType = jsonType;
@@ -375,7 +375,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler,
ApiSer
                     buildAuditTrail(auditTrailSb, command[0], response);
                 } else {
                     if (!command[0].equalsIgnoreCase("login") && !command[0].equalsIgnoreCase("logout"))
{
-                        String errorString = "Unknown API command: " + ((command == null)
? "null" : command[0]);
+                        String errorString = "Unknown API command: " + command[0];
                         s_logger.warn(errorString);
                         auditTrailSb.append(" " + errorString);
                         throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR,
errorString);
@@ -1115,4 +1115,16 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler,
ApiSer
     public void setApiAccessCheckers(List<APIChecker> _apiAccessCheckers) {
         this._apiAccessCheckers = _apiAccessCheckers;
     }
+
+    public static boolean isEncodeApiResponse() {
+        return encodeApiResponse;
+    }
+
+    private static void setEncodeApiResponse(boolean encodeApiResponse) {
+        ApiServer.encodeApiResponse = encodeApiResponse;
+    }
+
+    public static String getJsonContentType() {
+        return jsonContentType;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594fd42d/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 def18d0..6dd826a 100755
--- a/server/src/com/cloud/api/ApiServlet.java
+++ b/server/src/com/cloud/api/ApiServlet.java
@@ -34,6 +34,7 @@ import javax.servlet.http.HttpSession;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 import org.springframework.web.context.support.SpringBeanAutowiringSupport;
+
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.ServerApiException;
@@ -366,7 +367,7 @@ public class ApiServlet extends HttpServlet {
     private void writeResponse(HttpServletResponse resp, String response, int responseCode,
String responseType) {
         try {
             if (BaseCmd.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
-                resp.setContentType(ApiServer.jsonContentType + "; charset=UTF-8");
+                resp.setContentType(ApiServer.getJsonContentType() + "; charset=UTF-8");
             } else {
                 resp.setContentType("text/xml; charset=UTF-8");
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594fd42d/server/src/com/cloud/api/EncodedStringTypeAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/EncodedStringTypeAdapter.java b/server/src/com/cloud/api/EncodedStringTypeAdapter.java
index daec4fd..dca5828 100644
--- a/server/src/com/cloud/api/EncodedStringTypeAdapter.java
+++ b/server/src/com/cloud/api/EncodedStringTypeAdapter.java
@@ -36,7 +36,7 @@ public class EncodedStringTypeAdapter implements JsonSerializer<String>{
     }
 
     private static String encodeString(String value) {
-        if (!ApiServer.encodeApiResponse) {
+        if (!ApiServer.isEncodeApiResponse()) {
             return value;
         }
         try {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594fd42d/server/src/com/cloud/api/doc/Alert.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/doc/Alert.java b/server/src/com/cloud/api/doc/Alert.java
index 211f2e9..bfd3b2a 100644
--- a/server/src/com/cloud/api/doc/Alert.java
+++ b/server/src/com/cloud/api/doc/Alert.java
@@ -16,9 +16,15 @@
 // under the License.
 package com.cloud.api.doc;
 
-public class Alert {
-    private String type;
-    private int value;
+import java.io.Serializable;
+
+public class Alert implements Serializable{
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 960408026527837920L;
+    private final String type;
+    private final int value;
     
     public Alert(String type, int value) {
         this.type = type;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594fd42d/server/src/com/cloud/api/doc/Command.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/doc/Command.java b/server/src/com/cloud/api/doc/Command.java
index a267605..1946b30 100644
--- a/server/src/com/cloud/api/doc/Command.java
+++ b/server/src/com/cloud/api/doc/Command.java
@@ -16,11 +16,16 @@
 // under the License.
 package com.cloud.api.doc;
 
+import java.io.Serializable;
 import java.util.ArrayList;
 
-public class Command {
+public class Command implements Serializable{
 	
-	private String name;
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -4318310162503004975L;
+    private String name;
 	private String description;
     private String usage;
 	private boolean isAsync;
@@ -84,7 +89,7 @@ public class Command {
 	}
 	
     public Argument getReqArgByName(String name){
-		for (Argument a : this.getRequest()) {
+		for (Argument a : getRequest()) {
 			if (a.getName().equals(name)) {
                 return a;
             }
@@ -93,7 +98,7 @@ public class Command {
 	}
 	
 	public Argument getResArgByName(String name){
-		for (Argument a : this.getResponse()) {
+		for (Argument a : getResponse()) {
 			if (a.getName().equals(name)) {
                 return a;
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594fd42d/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 fb32e7d..a3e6f0f 100644
--- a/server/src/com/cloud/api/response/ApiResponseSerializer.java
+++ b/server/src/com/cloud/api/response/ApiResponseSerializer.java
@@ -277,7 +277,7 @@ public class ApiResponseSerializer {
     }
 
     private static String encodeParam(String value) {
-        if (!ApiServer.encodeApiResponse) {
+        if (!ApiServer.isEncodeApiResponse()) {
             return value;
         }
         try {


Mime
View raw message