@@ -159,9 +159,9 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
159159 private static final Logger s_logger = Logger .getLogger (ApiServer .class .getName ());
160160 private static final Logger s_accessLogger = Logger .getLogger ("apiserver." + ApiServer .class .getName ());
161161
162- public static boolean encodeApiResponse = false ;
163- public static String jsonContentType = "text/javascript" ;
164- public static String controlCharacters = "[\000 -\011 \013 -\014 \016 -\037 \177 ]" ; // Non-printable ASCII characters - numbers 0 to 31 and 127 decimal
162+ private static boolean encodeApiResponse = false ;
163+ private static String jsonContentType = "text/javascript" ;
164+ private static String controlCharacters = "[\000 -\011 \013 -\014 \016 -\037 \177 ]" ; // Non-printable ASCII characters - numbers 0 to 31 and 127 decimal
165165 @ Inject ApiDispatcher _dispatcher ;
166166
167167 @ Inject private AccountManager _accountMgr ;
@@ -237,7 +237,7 @@ public boolean start() {
237237 _apiNameCmdClassMap .put (apiName , cmdClass );
238238 }
239239
240- encodeApiResponse = Boolean .valueOf (_configDao .getValue (Config .EncodeApiResponse .key ()));
240+ setEncodeApiResponse ( Boolean .valueOf (_configDao .getValue (Config .EncodeApiResponse .key () )));
241241 String jsonType = _configDao .getValue (Config .JavaScriptDefaultContentType .key ());
242242 if (jsonType != null ) {
243243 jsonContentType = jsonType ;
@@ -375,7 +375,7 @@ public String handleRequest(Map params, String responseType, StringBuffer auditT
375375 buildAuditTrail (auditTrailSb , command [0 ], response );
376376 } else {
377377 if (!command [0 ].equalsIgnoreCase ("login" ) && !command [0 ].equalsIgnoreCase ("logout" )) {
378- String errorString = "Unknown API command: " + (( command == null ) ? "null" : command [0 ]) ;
378+ String errorString = "Unknown API command: " + command [0 ];
379379 s_logger .warn (errorString );
380380 auditTrailSb .append (" " + errorString );
381381 throw new ServerApiException (ApiErrorCode .UNSUPPORTED_ACTION_ERROR , errorString );
@@ -1115,4 +1115,16 @@ public List<APIChecker> getApiAccessCheckers() {
11151115 public void setApiAccessCheckers (List <APIChecker > _apiAccessCheckers ) {
11161116 this ._apiAccessCheckers = _apiAccessCheckers ;
11171117 }
1118+
1119+ public static boolean isEncodeApiResponse () {
1120+ return encodeApiResponse ;
1121+ }
1122+
1123+ private static void setEncodeApiResponse (boolean encodeApiResponse ) {
1124+ ApiServer .encodeApiResponse = encodeApiResponse ;
1125+ }
1126+
1127+ public static String getJsonContentType () {
1128+ return jsonContentType ;
1129+ }
11181130}
0 commit comments