public void responseSuccess(IRequest iReq) {
// cast observable to a Request
Request request = (Request) iReq;
// get the response from the request
ResponseModel response = request.getResponse();
// check the response code of the request
if (response.getStatusCode() != 200) {
controller.errorRetrievingDefect("Received " + iReq.getResponse().getStatusCode() + " error from server: " + iReq.getResponse().getStatusMessage());
return;
}
// parse the defect received from the core
Defect[] defects = Defect.fromJSONArray(response.getBody());
if (defects.length > 0 && defects[0] != null) {
controller.showDefect(defects[0]);
}
else {
controller.errorRetrievingDefect("No defects received.");