protected NexusArtifact ai2Na(Request request, ArtifactInfo ai) {
if (ai == null) {
return null;
}
NexusArtifact a = new NexusArtifact();
a.setGroupId(ai.groupId);
a.setArtifactId(ai.artifactId);
a.setVersion(ai.version);
a.setClassifier(ai.classifier);
a.setPackaging(ai.packaging);
a.setExtension(ai.fextension);
a.setRepoId(ai.repository);
a.setContextId(ai.context);
a.setHighlightedFragment(getMatchHighlightHtmlSnippet(ai));
if (ai.repository != null) {
a.setPomLink(createPomLink(request, ai));
a.setArtifactLink(createArtifactLink(request, ai));
try {
Repository repository = getUnprotectedRepositoryRegistry().getRepository(ai.repository);
if (MavenRepository.class.isAssignableFrom(repository.getClass())) {
MavenRepository mavenRepository = (MavenRepository) repository;
Gav gav =
new Gav(ai.groupId, ai.artifactId, ai.version, ai.classifier,
mavenRepository.getArtifactPackagingMapper().getExtensionForPackaging(ai.packaging),
null, null, null, false, null, false, null);
ResourceStoreRequest req =
new ResourceStoreRequest(mavenRepository.getGavCalculator().gavToPath(gav));
a.setResourceURI(createRepositoryReference(request, ai.repository, req.getRequestPath()).toString());
}
}
catch (NoSuchRepositoryException e) {
getLogger().warn("No such repository: '" + ai.repository + "'.", e);