use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.
the class CloudServiceArchiveController method addDependency.
@ApiOperation(value = "Add dependency to the csar with given id.")
@RequestMapping(value = "/{csarId:.+?}/dependencies", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit
@Deprecated
public RestResponse<Boolean> addDependency(@PathVariable String csarId, @Valid @RequestBody CSARDependency dependency) {
Csar csar = csarService.getOrFail(csarId);
csarAuthorizationFilter.checkWriteAccess(csar);
Set<CSARDependency> existingDependencies = csar.getDependencies();
if (existingDependencies == null) {
existingDependencies = Sets.newHashSet();
csar.setDependencies(existingDependencies);
}
boolean couldBeSaved = existingDependencies.add(dependency);
csarDAO.save(csar);
return RestResponseBuilder.<Boolean>builder().data(couldBeSaved).build();
}
use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.
the class ToscaParserSimpleProfileAlien130Test method testImportDependency.
@Test
public void testImportDependency() throws FileNotFoundException, ParsingException {
Csar csar = new Csar("tosca-normative-types", "1.0.0-SNAPSHOT-wd03");
Mockito.when(csarRepositorySearchService.getArchive(csar.getName(), csar.getVersion())).thenReturn(csar);
ParsingResult<ArchiveRoot> parsingResult = parser.parseFile(Paths.get(getRootDirectory(), "tosca-import-dependency.yml"));
Mockito.verify(csarRepositorySearchService).getArchive(csar.getName(), csar.getVersion());
assertNoBlocker(parsingResult);
ArchiveRoot archiveRoot = parsingResult.getResult();
assertNotNull(archiveRoot.getArchive());
assertNotNull(archiveRoot.getArchive().getDependencies());
Assert.assertEquals(1, archiveRoot.getArchive().getDependencies().size());
Assert.assertEquals(new CSARDependency(csar.getName(), csar.getVersion()), archiveRoot.getArchive().getDependencies().iterator().next());
}
use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.
the class LocalRepositoryImpl method getArchive.
@Override
public Csar getArchive(String archiveName, String archiveVersion) {
CSARDependency dependency = new CSARDependency(archiveName, archiveVersion);
ArchiveRoot root = parse(dependency).getResult();
return root == null ? null : root.getArchive();
}
use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.
the class ToscaTypeSearchService method getDependencyQuery.
/**
* Build an elasticsearch query to get data tosca elements based on a set of dependencies.
*
* @param dependencies The set of dependencies.
* @param keyValueFilters List of key1, value1, key2, value2 to add term filters to the query for each dependency.
* @return
*/
private BoolQueryBuilder getDependencyQuery(Set<CSARDependency> dependencies, String... keyValueFilters) {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
for (CSARDependency dependency : dependencies) {
BoolQueryBuilder dependencyQuery = QueryBuilders.boolQuery();
dependencyQuery.must(QueryBuilders.termQuery("archiveName", dependency.getName())).must(QueryBuilders.termQuery("archiveVersion", dependency.getVersion()));
if (keyValueFilters != null) {
for (int i = 0; i < keyValueFilters.length; i += 2) {
dependencyQuery.must(QueryBuilders.termQuery(keyValueFilters[i], keyValueFilters[i + 1]));
}
}
boolQueryBuilder.should(dependencyQuery);
}
return boolQueryBuilder;
}
use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.
the class RecoverTopologyProcessor method process.
@Override
public void process(Csar csar, Topology topology, RecoverTopologyOperation operation) {
checkOperation(operation, topology);
// process every recovery operation
// we need a new context here, as we want to have fresh types from elasticsearch
recoveryHelperService.processRecoveryOperations(topology, operation.getRecoveringOperations());
// make sure we also synch the dependencies and the caches types
for (CSARDependency updatedDependency : AlienUtils.safe(operation.getUpdatedDependencies())) {
ToscaContext.get().updateDependency(updatedDependency);
}
// TODO passing to this function the processRecoveryOperations ToscaContext should help reducing ES requests
topologyService.rebuildDependencies(topology);
}
Aggregations