Search in sources :

Example 1 with Repository

use of alien4cloud.model.repository.Repository in project alien4cloud by alien4cloud.

the class RepositoryController method update.

@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Update the repository.", authorizations = { @Authorization("COMPONENTS_MANAGER") })
@PreAuthorize("hasAnyAuthority('ADMIN', 'COMPONENTS_MANAGER')")
@Audit
public RestResponse<Void> update(@ApiParam(value = "Id of the repository to update", required = true) @PathVariable String id, @ApiParam(value = "Request for repository update", required = true) @Valid @RequestBody UpdateRepositoryRequest updateRequest) {
    Repository repository = repositoryService.getOrFail(id);
    String oldName = repository.getName();
    ReflectionUtil.mergeObject(updateRequest, repository);
    repositoryService.updateRepository(repository, oldName, updateRequest.getConfiguration() != null);
    return RestResponseBuilder.<Void>builder().build();
}
Also used : Repository(alien4cloud.model.repository.Repository) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Repository

use of alien4cloud.model.repository.Repository in project alien4cloud by alien4cloud.

the class RegistryUtil method getUsages.

public static List<PluginUsage> getUsages(IGenericSearchDAO alienDAO, String pluginId) {
    // query the list of repositories that uses the given plugin
    GetMultipleDataResult<Repository> dataResult = alienDAO.search(Repository.class, null, MapUtil.newHashMap(new String[] { "pluginId" }, new String[][] { new String[] { pluginId } }), Integer.MAX_VALUE);
    List<PluginUsage> usages = Lists.newArrayList();
    for (Repository repository : dataResult.getData()) {
        usages.add(new PluginUsage(repository.getId(), repository.getName(), Repository.class.getSimpleName()));
    }
    return usages;
}
Also used : Repository(alien4cloud.model.repository.Repository) PluginUsage(alien4cloud.plugin.model.PluginUsage)

Example 3 with Repository

use of alien4cloud.model.repository.Repository in project alien4cloud by alien4cloud.

the class RepositoryService method createRepositoryConfiguration.

public String createRepositoryConfiguration(String name, String pluginId, Object configuration) {
    String id = UUID.randomUUID().toString();
    Repository repository = new Repository(id, name, pluginId, getResolverFactoryOrFail(pluginId).getResolverType(), configuration);
    createConfiguredResolver(id, configuration, pluginId);
    ensureNameUnicityAndSave(repository, null);
    return id;
}
Also used : Repository(alien4cloud.model.repository.Repository)

Example 4 with Repository

use of alien4cloud.model.repository.Repository 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();
    }
}
Also used : RepositoryPluginComponent(alien4cloud.repository.model.RepositoryPluginComponent) AvailableTopologyRepositories(alien4cloud.repository.model.AvailableTopologyRepositories) Topology(org.alien4cloud.tosca.model.templates.Topology) FilteredSearchRequest(alien4cloud.rest.model.FilteredSearchRequest) Repository(alien4cloud.model.repository.Repository) AvailableTopologyRepository(alien4cloud.repository.model.AvailableTopologyRepository) NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) DeploymentArtifact(org.alien4cloud.tosca.model.definitions.DeploymentArtifact) AvailableTopologyRepository(alien4cloud.repository.model.AvailableTopologyRepository) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Repository (alien4cloud.model.repository.Repository)4 ApiOperation (io.swagger.annotations.ApiOperation)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Audit (alien4cloud.audit.annotation.Audit)1 PluginUsage (alien4cloud.plugin.model.PluginUsage)1 AvailableTopologyRepositories (alien4cloud.repository.model.AvailableTopologyRepositories)1 AvailableTopologyRepository (alien4cloud.repository.model.AvailableTopologyRepository)1 RepositoryPluginComponent (alien4cloud.repository.model.RepositoryPluginComponent)1 FilteredSearchRequest (alien4cloud.rest.model.FilteredSearchRequest)1 DeploymentArtifact (org.alien4cloud.tosca.model.definitions.DeploymentArtifact)1 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)1 Topology (org.alien4cloud.tosca.model.templates.Topology)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1