use of org.apache.archiva.maven2.model.Artifact in project archiva by apache.
the class BrowseServiceTest method getArtifactsByProjectVersionMetadata.
@Test
public void getArtifactsByProjectVersionMetadata() throws Exception {
// START SNIPPET: get-artifacts-by-project-version-metadata
BrowseService browseService = getBrowseService(authorizationHeader, true);
browseService.addMetadata("commons-cli", "commons-cli", "1.0", "wine", "bordeaux", TEST_REPO_ID);
List<Artifact> artifactDownloadInfos = browseService.getArtifactsByProjectVersionMetadata("wine", "bordeaux", TEST_REPO_ID);
assertThat(artifactDownloadInfos).isNotNull().isNotEmpty().hasSize(3);
// END SNIPPET: get-artifacts-by-project-version-metadata
}
use of org.apache.archiva.maven2.model.Artifact in project archiva by apache.
the class BrowseServiceTest method getArtifactsByMetadata.
@Test
public void getArtifactsByMetadata() throws Exception {
// START SNIPPET: get-artifacts-by-metadata
BrowseService browseService = getBrowseService(authorizationHeader, true);
List<Artifact> artifactDownloadInfos = browseService.getArtifactsByMetadata("type", "pom", TEST_REPO_ID);
assertThat(artifactDownloadInfos).isNotNull().isNotEmpty().hasSize(11);
// END SNIPPET: get-artifacts-by-metadata
}
use of org.apache.archiva.maven2.model.Artifact in project archiva by apache.
the class BrowseServiceTest method getArtifactsByProjectVersionMetadataWithNoRepository.
@Test
public void getArtifactsByProjectVersionMetadataWithNoRepository() throws Exception {
BrowseService browseService = getBrowseService(authorizationHeader, true);
browseService.addMetadata("commons-cli", "commons-cli", "1.0", "wine", "bordeaux", TEST_REPO_ID);
List<Artifact> artifactDownloadInfos = browseService.getArtifactsByProjectVersionMetadata("wine", "bordeaux", null);
assertThat(artifactDownloadInfos).isNotNull().isNotEmpty().hasSize(3);
}
use of org.apache.archiva.maven2.model.Artifact in project archiva by apache.
the class BrowseServiceTest method getArtifactDownloadInfos.
@Test
public void getArtifactDownloadInfos() throws Exception {
BrowseService browseService = getBrowseService(authorizationHeader, true);
List<Artifact> artifactDownloadInfos = browseService.getArtifactDownloadInfos("commons-logging", "commons-logging", "1.1", TEST_REPO_ID);
log.info("artifactDownloadInfos {}", artifactDownloadInfos);
assertThat(artifactDownloadInfos).isNotNull().isNotEmpty().hasSize(3);
}
use of org.apache.archiva.maven2.model.Artifact in project archiva by apache.
the class DefaultBrowseService method getDependees.
@Override
public List<Artifact> getDependees(String groupId, String artifactId, String version, String repositoryId) throws ArchivaRestServiceException {
List<ProjectVersionReference> references = new ArrayList<>();
// TODO: what if we get duplicates across repositories?
RepositorySession repositorySession = repositorySessionFactory.createSession();
try {
MetadataResolver metadataResolver = repositorySession.getResolver();
for (String repoId : getObservableRepos()) {
// TODO: what about if we want to see this irrespective of version?
references.addAll(metadataResolver.resolveProjectReferences(repositorySession, repoId, groupId, artifactId, version));
}
} catch (MetadataResolutionException e) {
throw new ArchivaRestServiceException(e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e);
} finally {
repositorySession.close();
}
List<Artifact> artifacts = new ArrayList<>(references.size());
for (ProjectVersionReference projectVersionReference : references) {
artifacts.add(new Artifact(projectVersionReference.getNamespace(), projectVersionReference.getProjectId(), projectVersionReference.getProjectVersion()));
}
return artifacts;
}
Aggregations