mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fix incorrect response handling logic
This commit is contained in:
parent
5ed5754991
commit
7cf8ff8516
@ -42,6 +42,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.xml.serialize.OutputFormat;
|
import org.apache.xml.serialize.OutputFormat;
|
||||||
import org.apache.xml.serialize.XMLSerializer;
|
import org.apache.xml.serialize.XMLSerializer;
|
||||||
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
@ -231,10 +232,18 @@ public class HandlerUtil {
|
|||||||
|
|
||||||
if (!StringUtils.isEmpty(responseData)) {
|
if (!StringUtils.isEmpty(responseData)) {
|
||||||
try {
|
try {
|
||||||
JSONObject responseDataJsonObj = new JSONObject(responseData);
|
if (responseData.startsWith("{")) {
|
||||||
response.put("data", responseDataJsonObj);
|
JSONObject responseDataJsonObj = new JSONObject(responseData);
|
||||||
|
response.put("data", responseDataJsonObj);
|
||||||
|
} else if (responseData.startsWith("[")) {
|
||||||
|
JSONArray responseDataJsonArr = new JSONArray(responseData);
|
||||||
|
response.put("data", responseDataJsonArr);
|
||||||
|
} else {
|
||||||
|
log.warn("Response data is not valid json string >> " + responseData);
|
||||||
|
response.put("data", responseData);
|
||||||
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.debug("Response data is not valid json string");
|
log.error("Response data is not passable");
|
||||||
response.put("data", responseData);
|
response.put("data", responseData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user