use of io.syndesis.qe.util.servicenow.model.IncidentRecordList in project syndesis-qe by syndesisio.
the class ServiceNow method parseResponse.
/**
* Service-Now API returns single object when there is 1 record, but list of records when there are more records.
*
* @param response json response
* @return list of records
*/
private static List<Incident> parseResponse(String response) {
List<Incident> incidents = new ArrayList<>();
try {
IncidentRecordList irl = om.readValue(response, IncidentRecordList.class);
incidents.addAll(irl.getRecords());
return incidents;
} catch (IOException e) {
// Try to parse it as single record response
try {
incidents.add(om.readValue(response, IncidentSingleResponse.class).getRecord());
return incidents;
} catch (IOException e1) {
fail("Unable to unmarshall incident response", e);
}
}
return null;
}
Aggregations