use of alien4cloud.tosca.context.ToscaContextual in project alien4cloud by alien4cloud.
the class TopologyDTOBuilder method buildTopologyDTO.
/**
* Build a topology dto (topology and all used types) out of a topology.
*
* @param context The edition context from which to build the dto.
*/
@ToscaContextual
public TopologyDTO buildTopologyDTO(EditionContext context) {
TopologyDTO topologyDTO = new TopologyDTO();
initTopologyDTO(context.getTopology(), topologyDTO);
topologyDTO.setArchiveContentTree(context.getArchiveContentTree());
topologyDTO.setLastOperationIndex(context.getLastOperationIndex());
topologyDTO.setOperations(context.getOperations());
topologyDTO.setDelegateType(context.getCsar().getDelegateType());
topologyDTO.setDependencyConflicts(getDependencyConflictDTOs(context));
// FIXME add validation information
return topologyDTO;
}
use of alien4cloud.tosca.context.ToscaContextual in project alien4cloud by alien4cloud.
the class EditorTopologyRecoveryHelperService method buildRecoveryOperation.
/**
* analyse a given topology and build a {@link RecoverTopologyOperation} to apply to the topology to make it synch
* with the dependencies present in the repository
*
* @param topology
* @return a {@link RecoverTopologyOperation}
*/
@ToscaContextual(requiresNew = true)
public RecoverTopologyOperation buildRecoveryOperation(Topology topology) {
RecoverTopologyOperation operation = new RecoverTopologyOperation();
buildRecoveryOperation(topology, operation);
return CollectionUtils.isNotEmpty(operation.getUpdatedDependencies()) ? operation : null;
}
use of alien4cloud.tosca.context.ToscaContextual in project alien4cloud by alien4cloud.
the class ToscaArchiveParser method parseImports.
@ToscaContextual(requiresNew = true)
public ParsingResult<CsarDependenciesBean> parseImports(Path archiveFile) throws ParsingException {
try (FileSystem csarFS = FileSystems.newFileSystem(archiveFile, null)) {
if (Files.exists(csarFS.getPath(TOSCA_META_FILE_LOCATION))) {
YamlSimpleParser<ToscaMeta> parser = new YamlSimpleParser<ToscaMeta>(toscaMetaMapping.getParser());
ParsingResult<ToscaMeta> parsingResult = parser.parseFile(csarFS.getPath(TOSCA_META_FILE_LOCATION));
CsarDependenciesBean csarDependenciesBean = initDependencyBeanFromToscaMeta(parsingResult.getResult());
return parseFromToscaMeta(csarFS, parsingResult.getResult(), TOSCA_META_FILE_LOCATION, csarDependenciesBean, toscaImportParser);
}
return parseFromRootDefinitions(csarFS, toscaImportParser);
} catch (IOException e) {
log.error("Unable to read uploaded archive [" + archiveFile + "]", e);
throw new ParsingException("Archive", new ParsingError(ErrorCode.FAILED_TO_READ_FILE, "Problem happened while accessing file", null, null, null, archiveFile.toString()));
} catch (ProviderNotFoundException e) {
log.warn("Failed to import archive", e);
throw new ParsingException("Archive", new ParsingError(ErrorCode.ERRONEOUS_ARCHIVE_FILE, "File is not in good format, only zip file is supported ", null, e.getMessage(), null, null));
}
}
Aggregations