use of org.apache.archiva.rest.api.model.BrowseResultEntry in project archiva by apache.
the class BrowseServiceTest method browserootGroups.
@Test
public void browserootGroups() throws Exception {
BrowseService browseService = getBrowseService(authorizationHeader, false);
BrowseResult browseResult = browseService.getRootGroups(TEST_REPO_ID);
assertThat(browseResult).isNotNull();
//
assertThat(browseResult.getBrowseResultEntries()).isNotNull().isNotEmpty().hasSize(//
3).contains(//
new BrowseResultEntry("commons-cli", false), //
new BrowseResultEntry("commons-logging", false), new BrowseResultEntry("org.apache", false));
}
use of org.apache.archiva.rest.api.model.BrowseResultEntry in project archiva by apache.
the class DefaultBrowseService method browseGroupId.
@Override
public BrowseResult browseGroupId(String groupId, String repositoryId) throws ArchivaRestServiceException {
List<String> selectedRepos = getSelectedRepos(repositoryId);
Set<String> projects = new LinkedHashSet<>();
RepositorySession repositorySession = repositorySessionFactory.createSession();
Set<String> namespaces;
try {
MetadataResolver metadataResolver = repositorySession.getResolver();
Set<String> namespacesToCollapse = new LinkedHashSet<>();
for (String repoId : selectedRepos) {
namespacesToCollapse.addAll(metadataResolver.resolveNamespaces(repositorySession, repoId, groupId));
projects.addAll(metadataResolver.resolveProjects(repositorySession, repoId, groupId));
}
// TODO: this logic should be optional, particularly remembering we want to keep this code simple
// it is located here to avoid the content repository implementation needing to do too much for what
// is essentially presentation code
namespaces = new LinkedHashSet<>();
for (String n : namespacesToCollapse) {
// TODO: check performance of this
namespaces.add(collapseNamespaces(repositorySession, metadataResolver, selectedRepos, groupId + "." + n));
}
} catch (MetadataResolutionException e) {
throw new ArchivaRestServiceException(e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e);
} finally {
repositorySession.close();
}
List<BrowseResultEntry> browseGroupResultEntries = new ArrayList<>(namespaces.size() + projects.size());
for (String namespace : namespaces) {
browseGroupResultEntries.add(new BrowseResultEntry(namespace, false).groupId(namespace));
}
for (String project : projects) {
browseGroupResultEntries.add(new BrowseResultEntry(groupId + '.' + project, true).groupId(groupId).artifactId(project));
}
Collections.sort(browseGroupResultEntries);
return new BrowseResult(browseGroupResultEntries);
}
use of org.apache.archiva.rest.api.model.BrowseResultEntry in project archiva by apache.
the class DefaultBrowseService method getRootGroups.
@Override
public BrowseResult getRootGroups(String repositoryId) throws ArchivaRestServiceException {
List<String> selectedRepos = getSelectedRepos(repositoryId);
Set<String> namespaces = new LinkedHashSet<String>();
// TODO: this logic should be optional, particularly remembering we want to keep this code simple
// it is located here to avoid the content repository implementation needing to do too much for what
// is essentially presentation code
Set<String> namespacesToCollapse = new LinkedHashSet<String>();
RepositorySession repositorySession = repositorySessionFactory.createSession();
try {
MetadataResolver metadataResolver = repositorySession.getResolver();
for (String repoId : selectedRepos) {
namespacesToCollapse.addAll(metadataResolver.resolveRootNamespaces(repositorySession, repoId));
}
for (String n : namespacesToCollapse) {
// TODO: check performance of this
namespaces.add(collapseNamespaces(repositorySession, metadataResolver, selectedRepos, n));
}
} catch (MetadataResolutionException e) {
throw new ArchivaRestServiceException(e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e);
} finally {
repositorySession.close();
}
List<BrowseResultEntry> browseGroupResultEntries = new ArrayList<>(namespaces.size());
for (String namespace : namespaces) {
browseGroupResultEntries.add(new BrowseResultEntry(namespace, false));
}
Collections.sort(browseGroupResultEntries);
return new BrowseResult(browseGroupResultEntries);
}
use of org.apache.archiva.rest.api.model.BrowseResultEntry in project archiva by apache.
the class BrowseServiceTest method browsegroupId.
@Test
public void browsegroupId() throws Exception {
BrowseService browseService = getBrowseService(authorizationHeader, false);
BrowseResult browseResult = browseService.browseGroupId("org.apache", TEST_REPO_ID);
assertThat(browseResult).isNotNull();
//
assertThat(browseResult.getBrowseResultEntries()).isNotNull().isNotEmpty().hasSize(//
2).contains(//
new BrowseResultEntry("org.apache.felix", false), new BrowseResultEntry("org.apache.karaf.features", false));
}
use of org.apache.archiva.rest.api.model.BrowseResultEntry in project archiva by apache.
the class RepositoriesServiceTest method deleteGroupId.
@Test
public void deleteGroupId() throws Exception {
initSourceTargetRepo();
try {
BrowseService browseService = getBrowseService(authorizationHeader, false);
BrowseResult browseResult = browseService.browseGroupId("org.apache.karaf.features", SOURCE_REPO_ID);
assertNotNull(browseResult);
log.info("browseResult: {}", browseResult);
assertThat(browseResult.getBrowseResultEntries()).isNotNull().isNotEmpty().contains(new BrowseResultEntry("org.apache.karaf.features.org.apache.karaf.features.command", true), new BrowseResultEntry("org.apache.karaf.features.org.apache.karaf.features.core", true));
Path directory = Paths.get("target/test-origin-repo/org/apache/karaf/features/org.apache.karaf.features.command");
assertTrue("directory not exists", Files.exists(directory));
RepositoriesService repositoriesService = getRepositoriesService(authorizationHeader);
repositoriesService.deleteGroupId("org.apache.karaf", SOURCE_REPO_ID);
assertFalse("directory not exists", Files.exists(directory));
browseResult = browseService.browseGroupId("org.apache.karaf.features", SOURCE_REPO_ID);
assertNotNull(browseResult);
assertThat(browseResult.getBrowseResultEntries()).isNotNull().isEmpty();
browseResult = browseService.browseGroupId("org.apache.karaf", SOURCE_REPO_ID);
assertNotNull(browseResult);
assertThat(browseResult.getBrowseResultEntries()).isNotNull().isEmpty();
log.info("browseResult empty: {}", browseResult);
} finally {
cleanRepos();
}
}
Aggregations