class CheckmarxScanReportSupport {

	void fetchReportResult(CheckmarxAdapterContext context) throws AdapterException {
		ReportDetails details = context.getReportDetails();
		try {
			RestOperations restTemplate = context.getRestOperations();
			ResponseEntity<String> queueData = restTemplate
					.getForEntity(context.getAPIURL("reports/sastScan/" + context.getReportId()), String.class);
			String body = queueData.getBody();
			if (body == null) { // NOSONAR
				body = "";
			}
			int index = body.indexOf("<?xml");
			if (index > 0) {
				body = body.substring(index);
			}
			context.setResult(body);

		} catch (HttpStatusCodeException e) {
			if (HttpStatus.NOT_FOUND.equals(e.getStatusCode())) {
				/* ok just no longer in queue / or never existed */
				details.notFound = true;
				return;
			}
			throw e; // rethrow
		}
	}

}