use of org.apache.archiva.rest.api.model.BrowseResult 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.BrowseResult 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.BrowseResult 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.BrowseResult in project archiva by apache.
the class BrowseServiceTest method browsegroupIdWithReleaseStartNumber.
@Test
public void browsegroupIdWithReleaseStartNumber() throws Exception {
BrowseService browseService = getBrowseService(authorizationHeader, false);
BrowseResult browseResult = browseService.browseGroupId("commons-logging.commons-logging", TEST_REPO_ID);
log.info("browseResult: {}", browseResult);
}
use of org.apache.archiva.rest.api.model.BrowseResult 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));
}
Aggregations