use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testNewItemStreamWithNamespace2.
@Test
public void testNewItemStreamWithNamespace2() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").recurse().build();
Stream<? extends ContentItem> stream = repoContent.newItemStream(selector, false);
List<? extends ContentItem> result = stream.collect(Collectors.toList());
assertEquals(170, result.size());
assertEquals(92, result.stream().filter(a -> a instanceof DataItem).count());
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testArtifactListWithNamespaceSelectorRecursive.
@Test
public void testArtifactListWithNamespaceSelectorRecursive() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.multilevel").recurse().build();
List<? extends Artifact> results = repoContent.getArtifacts(selector);
checkArtifactListWithNamespaceSelectorRecursive(results);
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testGetArtifactListWithVersionSelector2.
@Test
public void testGetArtifactListWithVersionSelector2() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.axis2").withProjectId("axis2").withVersion("1.3-SNAPSHOT").build();
List<? extends Artifact> results = repoContent.getArtifacts(selector);
checkArtifactListWithVersionSelector2(results);
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class MavenContentHelperTest method assertExtension.
private void assertExtension(String expectedExtension, String type, String extension) {
ItemSelector selector = ArchivaItemSelector.builder().withType(type).withExtension(extension).build();
assertEquals(expectedExtension, MavenContentHelper.getArtifactExtension(selector));
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class DefaultFileUploadService method savePomFile.
protected void savePomFile(String repositoryId, FileMetadata fileMetadata, String groupId, String artifactId, String version, String packaging) throws ArchivaRestServiceException {
log.debug("Saving POM");
try {
boolean fixChecksums = !(archivaAdministration.getKnownContentConsumers().contains("create-missing-checksums"));
org.apache.archiva.repository.ManagedRepository repository = repositoryRegistry.getManagedRepository(repositoryId);
ItemSelector selector = ArchivaItemSelector.builder().withNamespace(groupId).withProjectId(artifactId).withArtifactId(artifactId).withArtifactVersion(version).withExtension(packaging).build();
StorageAsset pomPath = repository.getContent().getItem(selector).getAsset();
StorageAsset targetPath = pomPath.getParent();
String pomFilename = pomPath.getName();
if (StringUtils.isNotEmpty(fileMetadata.getClassifier())) {
pomFilename = StringUtils.remove(pomFilename, "-" + fileMetadata.getClassifier());
}
pomFilename = FilenameUtils.removeExtension(pomFilename) + ".pom";
copyFile(Paths.get(fileMetadata.getServerFileName()), targetPath, pomFilename, fixChecksums);
triggerAuditEvent(repository.getId(), targetPath.resolve(pomFilename).toString(), AuditEvent.UPLOAD_FILE);
queueRepositoryTask(repository.getId(), targetPath.resolve(pomFilename));
log.debug("Finished Saving POM");
} catch (IOException ie) {
log.error("IOException for POM {}", ie.getMessage());
throw new ArchivaRestServiceException("Error encountered while uploading pom file: " + ie.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), ie);
} catch (RepositoryAdminException e) {
log.error("RepositoryAdminException for POM {}", e.getMessage());
throw new ArchivaRestServiceException("RepositoryAdmin exception: " + e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e);
}
}
Aggregations