class CheckmarxV1XMLImporter extends AbstractProductResultImporter {

	public SerecoMetaData importResult(String xml) throws IOException {
		if (xml == null) {
			xml = "";
		}
		Document document;
		try {
			document = DocumentHelper.parseText(xml);
		} catch (DocumentException e) {
			throw new IOException("Import cannot parse xml", e);
		}

		CheckmarxCategoriesToClassificationConverter categoryConverter = new CheckmarxCategoriesToClassificationConverter();

		SerecoMetaData metaData = new SerecoMetaData();
		Element checkmarxCxXMLResults = document.getRootElement();
		List<Element> queryElements = checkmarxCxXMLResults.elements("Query");

		for (Element queryElement : queryElements) {

			String name = queryElement.attributeValue("name");
			String type = NAME_PATTERN.matcher(name).replaceAll(" ");
			String categories = queryElement.attributeValue("categories");
			String cweId = queryElement.attributeValue("cweId");

			List<Element> resultElements = queryElement.elements("Result");
			for (Element resultElement : resultElements) {

				String falsePositive = resultElement.attributeValue("FalsePositive");
				String deeplink = resultElement.attributeValue("DeepLink");
				String severity = resultElement.attributeValue("Severity");

				SerecoVulnerability vulnerability = new SerecoVulnerability();
				vulnerability.setFalsePositive(Boolean.parseBoolean(falsePositive));
				if (vulnerability.isFalsePositive()) {
				    vulnerability.setFalsePositiveReason("marked directly in security product");
				}
				vulnerability.setType(type);
				if ("Information".equalsIgnoreCase(severity)) {
					severity = "info";
				}
				vulnerability.setSeverity(SerecoSeverity.fromString(severity));

				SerecoCodeCallStackElement codeInfo = resolveCodeInfoFromElement(resultElement);

				vulnerability.setCode(codeInfo);
				vulnerability.setProductResultLink(deeplink);
				vulnerability.setDescription(""); // at least at the moment we set no description any more
				vulnerability.getClassification().setCwe(cweId);
				vulnerability.setScanType(ScanType.CODE_SCAN);

				categoryConverter.convert(categories, vulnerability.getClassification());

				metaData.getVulnerabilities().add(vulnerability);
			}
		}
		return metaData;
	}

}