mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
findbugs: fixes for ApiServer, ApiSerializerHelper and
ApiXmlDocWriter(cherry picked from commit 9aced41d708acd22b43ef0e512fa2cc657a6c0a2)
This commit is contained in:
parent
1c7361756c
commit
a71871d11c
@ -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) {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ public class ApiResponseSerializer {
|
||||
}
|
||||
|
||||
private static String encodeParam(String value) {
|
||||
if (!ApiServer.encodeApiResponse) {
|
||||
if (!ApiServer.isEncodeApiResponse()) {
|
||||
return value;
|
||||
}
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user