in repository/service/src/main/java/org/apache/karaf/cave/repository/service/maven/MavenServlet.java [376:407]
public File download(String path) throws InvalidMavenArtifactRequest {
if (path == null) {
throw new InvalidMavenArtifactRequest();
}
Matcher artifactMatcher = ARTIFACT_REQUEST_URL_REGEX.matcher(path);
Matcher metadataMatcher = ARTIFACT_METADATA_URL_REGEX.matcher(path);
if (metadataMatcher.matches()) {
LOGGER.info("Received request for maven metadata : {}", path);
try {
MavenCoord coord = convertMetadataPathToCoord(path);
return resolver.resolveMetadata(coord.groupId, coord.artifactId, coord.type, coord.version);
} catch (Exception e) {
LOGGER.warn(String.format("Could not find metadata : %s due to %s", path, e.getMessage()), e);
return null;
}
} else if (artifactMatcher.matches()) {
LOGGER.info("Received request for maven artifact : {}", path);
try {
MavenCoord artifact = convertArtifactPathToCoord(path);
Path download = resolver.resolve(artifact.groupId, artifact.artifactId, artifact.classifier, artifact.type, artifact.version).toPath();
Path tmpFile = Files.createTempFile("mvn-", ".tmp");
Files.copy(download, tmpFile, StandardCopyOption.REPLACE_EXISTING);
return tmpFile.toFile();
} catch (Exception e) {
LOGGER.warn(String.format("Could not find artifact : %s due to %s", path, e.getMessage()), e);
return null;
}
}
return null;
}