* @param path The request path, following the format: {@code <groupId>/<artifactId>/<version>/<artifactId>-<version>-[<classifier>].extension}
* @return
* @throws InvalidMavenArtifactRequest
*/
protected Metadata convertPathToMetadata(String path) throws InvalidMavenArtifactRequest {
DefaultMetadata metadata = null;
if (path == null) {
throw new InvalidMavenArtifactRequest("Cannot match request path to maven url, request path is empty.");
}
Matcher pathMatcher = ARTIFACT_METADATA_URL_REGEX.matcher(path);
if (pathMatcher.matches()) {
String groupId = pathMatcher.group(1).replaceAll("/", ".");
String artifactId = pathMatcher.group(2);
String version = pathMatcher.group(3);
String type = pathMatcher.group(9);
if (type == null) {
type = "maven-metadata.xml";
} else {
type = "maven-metadata.xml." + type;
}
metadata = new DefaultMetadata(groupId, artifactId, version, type, Metadata.Nature.RELEASE_OR_SNAPSHOT);
}
return metadata;
}