cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [11/50] [abbrv] git commit: updated refs/heads/ui-restyle to 849d601
Date Thu, 30 Jan 2014 22:41:02 GMT
findbugs: fixes for ApiServer, ApiSerializerHelper and
ApiXmlDocWriter(cherry picked from commit
9aced41d708acd22b43ef0e512fa2cc657a6c0a2)


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

Branch: refs/heads/ui-restyle
Commit: a71871d11ce97216d0e50c01bcd84cc59d3d18dc
Parents: 1c73617
Author: Daan Hoogland <daan@onecht.net>
Authored: Tue Jan 28 14:47:06 2014 +0100
Committer: Daan Hoogland <dhoogland@schubergphilis.com>
Committed: Tue Jan 28 14:47:06 2014 +0100

----------------------------------------------------------------------
 .../src/com/cloud/api/ApiSerializerHelper.java  |  2 +-
 server/src/com/cloud/api/ApiServer.java         | 29 ++++++++++++++------
 server/src/com/cloud/api/ApiServlet.java        |  2 +-
 .../com/cloud/api/EncodedStringTypeAdapter.java |  2 +-
 server/src/com/cloud/api/doc/Alert.java         | 12 ++++++--
 server/src/com/cloud/api/doc/Command.java       | 11 ++++++--
 .../api/response/ApiResponseSerializer.java     |  2 +-
 7 files changed, 41 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a71871d1/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 cd5c7e6..7426d9f 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/a71871d1/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 71a1b8d..d715db6 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -159,11 +159,10 @@ 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
-    @Inject
-    ApiDispatcher _dispatcher;
+    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;
@@ -241,7 +240,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler,
ApiSer
             s_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;
@@ -379,7 +378,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);
@@ -1102,7 +1101,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler,
ApiSer
 
     @Inject
     public void setPluggableServices(List<PluggableService> pluggableServices) {
-        this._pluggableServices = pluggableServices;
+        _pluggableServices = pluggableServices;
     }
 
     public List<APIChecker> getApiAccessCheckers() {
@@ -1111,6 +1110,18 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler,
ApiSer
 
     @Inject
     public void setApiAccessCheckers(List<APIChecker> apiAccessCheckers) {
-        this._apiAccessCheckers = apiAccessCheckers;
+        _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/a71871d1/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 6a33c14..46f7eba 100755
--- a/server/src/com/cloud/api/ApiServlet.java
+++ b/server/src/com/cloud/api/ApiServlet.java
@@ -375,7 +375,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/a71871d1/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 cde1448..50dbd0d 100644
--- a/server/src/com/cloud/api/EncodedStringTypeAdapter.java
+++ b/server/src/com/cloud/api/EncodedStringTypeAdapter.java
@@ -37,7 +37,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/a71871d1/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 e73cb0e..3e61d0b 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/a71871d1/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 998b39f..549ca29 100644
--- a/server/src/com/cloud/api/doc/Command.java
+++ b/server/src/com/cloud/api/doc/Command.java
@@ -16,10 +16,15 @@
 // 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 static final long serialVersionUID = -4318310162503004975L;
     private String name;
     private String description;
     private String usage;
@@ -85,7 +90,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;
             }
@@ -94,7 +99,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/a71871d1/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 d8b728a..f276e89 100644
--- a/server/src/com/cloud/api/response/ApiResponseSerializer.java
+++ b/server/src/com/cloud/api/response/ApiResponseSerializer.java
@@ -291,7 +291,7 @@ public class ApiResponseSerializer {
     }
 
     private static String encodeParam(String value) {
-        if (!ApiServer.encodeApiResponse) {
+        if (!ApiServer.isEncodeApiResponse()) {
             return value;
         }
         try {


Mime
View raw message