use of com.mashape.unirest.http.JsonNode in project InciDashboard_i3a by Arquisoft.
the class IncidentService method getAllOpenIncidents.
public static Incident[] getAllOpenIncidents() {
try {
HttpResponse<JsonNode> response = Unirest.post(API_GATEWAY + "/incidents?status=OPEN").asJson();
ObjectMapper mapper = new ObjectMapper();
Incident[] items = mapper.readValue(response.getBody().toString(), Incident[].class);
log.info("Incidents retrieved: " + items.length);
return items;
} catch (IOException | UnirestException e) {
log.error("Error getting all open incidents: " + e.getMessage());
return null;
}
}
use of com.mashape.unirest.http.JsonNode in project InciDashboard_i3a by Arquisoft.
the class IncidentService method getIncident.
public static Incident getIncident(String id) {
try {
HttpResponse<JsonNode> response = Unirest.post(API_GATEWAY + "/incidents/" + id).asJson();
ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(response.getBody().toString(), Incident.class);
} catch (IOException | UnirestException e) {
e.printStackTrace();
return null;
}
}
use of com.mashape.unirest.http.JsonNode in project InciDashboard_i3a by Arquisoft.
the class IncidentService method getAllIncidents.
public static List<Incident> getAllIncidents() {
try {
HttpResponse<JsonNode> response = Unirest.post(API_GATEWAY + "/incidents").asJson();
ObjectMapper mapper = new ObjectMapper();
List<Incident> items = mapper.readValue(response.getBody().toString(), mapper.getTypeFactory().constructParametricType(List.class, Incident.class));
return items;
} catch (IOException | UnirestException e) {
e.printStackTrace();
return null;
}
}
use of com.mashape.unirest.http.JsonNode in project InciDashboard_i3a by Arquisoft.
the class AgentService method getAgent.
public static Agent getAgent(String id) {
try {
HttpResponse<JsonNode> response = Unirest.post(API_GATEWAY + "/agents/" + id).asJson();
ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(response.getBody().toString(), Agent.class);
} catch (IOException | UnirestException e) {
e.printStackTrace();
return null;
}
}
use of com.mashape.unirest.http.JsonNode in project InciDashboard_i3a by Arquisoft.
the class AgentService method getAllSensors.
public static Agent[] getAllSensors() {
try {
HttpResponse<JsonNode> response = Unirest.post(API_GATEWAY + "/agents?kindCode=3").asJson();
ObjectMapper mapper = new ObjectMapper();
Agent[] items = mapper.readValue(response.getBody().toString(), Agent[].class);
return items;
} catch (IOException | UnirestException e) {
e.printStackTrace();
return null;
}
}
Aggregations