private MavenVersion verifyVersionInRepo(String repo, Artifact artifact) throws IOException, DownloadException, SAXException, ParseException {
        Metadata artifactMetaData = getArtifactMetaData(repo, artifact);

        if (!artifact.getGroupId().equals(artifactMetaData.getGroupId())) {
            throw new DownloadException("Got groupId " + artifactMetaData.getGroupId() + " which does not match " + artifact.getGroupId());
        }
        if (!artifact.getArtifactId().equals(artifactMetaData.getArtifactId())) {
            throw new DownloadException("Got artifactId " + artifactMetaData.getArtifactId() + " which does not match " + artifact.getArtifactId());
        }

        boolean foundVersion = false;
        // Check that version exists
        List<Version> versions = artifactMetaData.getVersioning().getVersions();
        for (Version version : versions) {
            if (version.getVersion().equals(artifact.getVersion())) {
                foundVersion = true;
            }
        }
        if (!foundVersion) {
            throw new DownloadException("Version " + artifact.getVersion() + " not found on server");
        }


        // Check that the requested version exists, then get the version meta data
        MavenVersion version = MavenVersion.parse(artifact.getVersion());
        return version;
    }