use of alien4cloud.rest.model.FilteredSearchRequest in project alien4cloud by alien4cloud.
the class GroupsStepDefinitions method I_search_in_groups_for_from_with_result_size_of.
@When("^I search in groups for \"([^\"]*)\" from (\\d+) with result size of (\\d+)$")
public void I_search_in_groups_for_from_with_result_size_of(String query, int from, int size) throws Throwable {
FilteredSearchRequest request = new FilteredSearchRequest(query, from, size, null);
Context.getInstance().registerRestResponse(Context.getRestClientInstance().postJSon("/rest/v1/groups/search", JsonUtil.toString(request)));
}
use of alien4cloud.rest.model.FilteredSearchRequest in project alien4cloud by alien4cloud.
the class EditorRepositoryController method getAvailableRepositories.
/**
* Get the available repositories regarding archive repositories and A4C repositories.
*/
@ApiOperation(value = "Get the available repositories regarding archive repositories and A4C repositories", notes = "Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ]")
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public RestResponse<AvailableTopologyRepositories> getAvailableRepositories(@ApiParam(value = "The topology id.", required = true) @NotBlank @PathVariable final String topologyId) {
try {
editionContextManager.init(topologyId);
Topology topology = EditionContextManager.getTopology();
List<AvailableTopologyRepository> archiveRepositories = Lists.newArrayList();
List<AvailableTopologyRepository> alienRepositories = Lists.newArrayList();
List<String> repositoryTypes = Lists.newArrayList();
AvailableTopologyRepositories result = new AvailableTopologyRepositories(archiveRepositories, alienRepositories, repositoryTypes);
Set<String> repositoriesName = Sets.newHashSet();
Set<String> repositoriesUrl = Sets.newHashSet();
for (NodeTemplate node : topology.getNodeTemplates().values()) {
if (node.getArtifacts() != null && CollectionUtils.isNotEmpty(node.getArtifacts().values())) {
for (DeploymentArtifact artifact : node.getArtifacts().values()) {
if (artifact.getRepositoryURL() != null && !repositoriesName.contains(artifact.getRepositoryName())) {
AvailableTopologyRepository atr = new AvailableTopologyRepository(artifact.getRepositoryName(), artifact.getArtifactRepository(), artifact.getRepositoryURL());
archiveRepositories.add(atr);
repositoriesName.add(artifact.getRepositoryName());
repositoriesUrl.add(artifact.getRepositoryURL());
}
}
}
}
FilteredSearchRequest searchRequest = new FilteredSearchRequest();
searchRequest.setFrom(0);
searchRequest.setSize(Integer.MAX_VALUE);
FacetedSearchResult<Repository> searchResult = repositoryService.search(searchRequest);
for (Repository repository : searchResult.getData()) {
String url = repositoryService.getRepositoryUrl(repository);
if (!repositoriesUrl.contains(url)) {
// only return this repository if it's url doesn't not match existing archive repository url
AvailableTopologyRepository atr = new AvailableTopologyRepository(repository.getName(), repository.getRepositoryType(), url);
alienRepositories.add(atr);
}
}
List<RepositoryPluginComponent> plugins = repositoryService.listPluginComponents();
for (RepositoryPluginComponent repositoryPluginComponent : plugins) {
repositoryTypes.add(repositoryPluginComponent.getRepositoryType());
}
return RestResponseBuilder.<AvailableTopologyRepositories>builder().data(result).build();
} finally {
ToscaContext.destroy();
}
}
Aggregations