use of se.light.assembly64.model.Artifact in project archiva by apache.
the class DefaultBrowseService method getArtifactDownloadInfos.
@Override
public List<Artifact> getArtifactDownloadInfos(String groupId, String artifactId, String version, String repositoryId) throws ArchivaRestServiceException {
List<String> selectedRepos = getSelectedRepos(repositoryId);
List<Artifact> artifactDownloadInfos = new ArrayList<>();
try (RepositorySession session = repositorySessionFactory.createSession()) {
MetadataResolver metadataResolver = session.getResolver();
for (String repoId : selectedRepos) {
List<ArtifactMetadata> artifacts = new ArrayList<>(metadataResolver.resolveArtifacts(session, repoId, groupId, artifactId, version));
Collections.sort(artifacts, ArtifactMetadataVersionComparator.INSTANCE);
if (artifacts != null && !artifacts.isEmpty()) {
return buildArtifacts(artifacts, repoId);
}
}
} catch (MetadataResolutionException e) {
log.error(e.getMessage(), e);
throw new ArchivaRestServiceException(e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e);
}
return artifactDownloadInfos;
}
use of se.light.assembly64.model.Artifact in project archiva by apache.
the class BrowseServiceTest method getArtifactsByProperty.
@Test
public void getArtifactsByProperty() throws Exception {
// START SNIPPET: get-artifacts-by-property
BrowseService browseService = getBrowseService(authorizationHeader, true);
List<Artifact> artifactDownloadInfos = browseService.getArtifactsByProperty("org.name", "The Apache Software Foundation", TEST_REPO_ID);
assertThat(artifactDownloadInfos).isNotNull().isNotEmpty().hasSize(7);
// END SNIPPET: get-artifacts-by-property
}
use of se.light.assembly64.model.Artifact in project archiva by apache.
the class MergeRepositoriesServiceTest method getMergeConflictedArtifacts.
@Test
public void getMergeConflictedArtifacts() throws Exception {
MergeRepositoriesService service = getMergeRepositoriesService(authorizationHeader);
List<Artifact> artifactMetadatas = service.getMergeConflictedArtifacts(TEST_REPOSITORY + "-stage", TEST_REPOSITORY);
log.info("conflicts: {}", artifactMetadatas);
assertThat(artifactMetadatas).isNotNull().isNotEmpty().hasSize(8);
}
use of se.light.assembly64.model.Artifact in project archiva by apache.
the class RepositoriesServiceTest method deleteArtifactKarmaFailed.
@Test(expected = ForbiddenException.class)
public void deleteArtifactKarmaFailed() throws Exception {
try {
Artifact artifact = new Artifact();
artifact.setGroupId("commons-logging");
artifact.setArtifactId("commons-logging");
artifact.setVersion("1.0.1");
artifact.setPackaging("jar");
artifact.setContext(SOURCE_REPO_ID);
RepositoriesService repositoriesService = getRepositoriesService(null);
repositoriesService.deleteArtifact(artifact);
} catch (ForbiddenException e) {
assertEquals(403, e.getResponse().getStatus());
throw e;
}
}
use of se.light.assembly64.model.Artifact in project archiva by apache.
the class RepositoriesServiceTest method deleteArtifactWithClassifier.
@Test
public void deleteArtifactWithClassifier() throws Exception {
initSourceTargetRepo();
BrowseService browseService = getBrowseService(authorizationHeader, false);
List<Artifact> artifacts = browseService.getArtifactDownloadInfos("commons-logging", "commons-logging", "1.0.1", SOURCE_REPO_ID);
assertThat(artifacts).isNotNull().isNotEmpty().hasSize(3);
VersionsList versionsList = browseService.getVersionsList("commons-logging", "commons-logging", SOURCE_REPO_ID);
assertThat(versionsList.getVersions()).isNotNull().isNotEmpty().hasSize(6);
log.info("artifacts.size: {}", artifacts.size());
try {
Path artifactFile = Paths.get("target/test-origin-repo/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1-javadoc.jar");
Path artifactFilemd5 = Paths.get("target/test-origin-repo/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1-javadoc.jar.md5");
Path artifactFilesha1 = Paths.get("target/test-origin-repo/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1-javadoc.jar.sha1");
assertTrue("artifact not exists:" + artifactFile, Files.exists(artifactFile));
assertTrue("md5 not exists:" + artifactFilemd5, Files.exists(artifactFilemd5));
assertTrue("sha1 not exists:" + artifactFilesha1, Files.exists(artifactFilesha1));
Artifact artifact = new Artifact();
artifact.setGroupId("commons-logging");
artifact.setArtifactId("commons-logging");
artifact.setVersion("1.0.1");
artifact.setClassifier("javadoc");
artifact.setPackaging("jar");
artifact.setContext(SOURCE_REPO_ID);
RepositoriesService repositoriesService = getRepositoriesService(authorizationHeader);
repositoriesService.deleteArtifact(artifact);
assertFalse("artifact not deleted exists:" + artifactFile, Files.exists(artifactFile));
assertFalse("md5 still exists:" + artifactFilemd5, Files.exists(artifactFilemd5));
assertFalse("sha1 still exists:" + artifactFilesha1, Files.exists(artifactFilesha1));
artifacts = browseService.getArtifactDownloadInfos("commons-logging", "commons-logging", "1.0.1", SOURCE_REPO_ID);
log.info("artifact: {}", artifacts);
assertThat(artifacts).isNotNull().isNotEmpty().hasSize(2);
versionsList = browseService.getVersionsList("commons-logging", "commons-logging", SOURCE_REPO_ID);
log.info("versionsList: {}", versionsList);
assertThat(versionsList.getVersions()).isNotNull().isNotEmpty().hasSize(6);
} finally {
cleanRepos();
}
}
Aggregations