@@ -159,11 +159,10 @@ 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
165- @ Inject
166- ApiDispatcher _dispatcher ;
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
165+ @ Inject ApiDispatcher _dispatcher ;
167166
168167 @ Inject
169168 private AccountManager _accountMgr ;
@@ -241,7 +240,7 @@ public boolean start() {
241240 s_apiNameCmdClassMap .put (apiName , cmdClass );
242241 }
243242
244- encodeApiResponse = Boolean .valueOf (_configDao .getValue (Config .EncodeApiResponse .key ()));
243+ setEncodeApiResponse ( Boolean .valueOf (_configDao .getValue (Config .EncodeApiResponse .key () )));
245244 String jsonType = _configDao .getValue (Config .JavaScriptDefaultContentType .key ());
246245 if (jsonType != null ) {
247246 jsonContentType = jsonType ;
@@ -379,7 +378,7 @@ public String handleRequest(Map params, String responseType, StringBuffer auditT
379378 buildAuditTrail (auditTrailSb , command [0 ], response );
380379 } else {
381380 if (!command [0 ].equalsIgnoreCase ("login" ) && !command [0 ].equalsIgnoreCase ("logout" )) {
382- String errorString = "Unknown API command: " + (( command == null ) ? "null" : command [0 ]) ;
381+ String errorString = "Unknown API command: " + command [0 ];
383382 s_logger .warn (errorString );
384383 auditTrailSb .append (" " + errorString );
385384 throw new ServerApiException (ApiErrorCode .UNSUPPORTED_ACTION_ERROR , errorString );
@@ -1102,7 +1101,7 @@ public List<PluggableService> getPluggableServices() {
11021101
11031102 @ Inject
11041103 public void setPluggableServices (List <PluggableService > pluggableServices ) {
1105- this . _pluggableServices = pluggableServices ;
1104+ _pluggableServices = pluggableServices ;
11061105 }
11071106
11081107 public List <APIChecker > getApiAccessCheckers () {
@@ -1111,6 +1110,18 @@ public List<APIChecker> getApiAccessCheckers() {
11111110
11121111 @ Inject
11131112 public void setApiAccessCheckers (List <APIChecker > apiAccessCheckers ) {
1114- this ._apiAccessCheckers = apiAccessCheckers ;
1113+ _apiAccessCheckers = apiAccessCheckers ;
1114+ }
1115+
1116+ public static boolean isEncodeApiResponse () {
1117+ return encodeApiResponse ;
1118+ }
1119+
1120+ private static void setEncodeApiResponse (boolean encodeApiResponse ) {
1121+ ApiServer .encodeApiResponse = encodeApiResponse ;
1122+ }
1123+
1124+ public static String getJsonContentType () {
1125+ return jsonContentType ;
11151126 }
11161127}
0 commit comments