public String index(Request req, Response res) throws IOException { HttpOperationResult httpOperationResult = new HttpOperationResult(); int result; try { result = Integer.parseInt(req.params(":pipeline_counter")); } catch (NumberFormatException nfe) { throw new RecordNotFoundException(); } String pipelineName = req.params("pipeline_name"); PipelineInstanceModel pipelineInstance = pipelineHistoryService.findPipelineInstance(pipelineName, result, currentUsername(), httpOperationResult); if (httpOperationResult.isSuccess()) { return writerForTopLevelObject(req, res, outputWriter -> BuildCauseRepresenter.toJSON(outputWriter, pipelineInstance.getBuildCause())); } else { return renderHTTPOperationResult(httpOperationResult, req, res); } }