Search in sources :

Example 11 with ToscaContextual

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;
}
Also used : AbstractTopologyDTO(alien4cloud.topology.AbstractTopologyDTO) TopologyDTO(alien4cloud.topology.TopologyDTO) ToscaContextual(alien4cloud.tosca.context.ToscaContextual)

Example 12 with ToscaContextual

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;
}
Also used : RecoverTopologyOperation(org.alien4cloud.tosca.editor.operations.RecoverTopologyOperation) ToscaContextual(alien4cloud.tosca.context.ToscaContextual)

Example 13 with ToscaContextual

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));
    }
}
Also used : ProviderNotFoundException(java.nio.file.ProviderNotFoundException) ToscaMeta(alien4cloud.tosca.model.ToscaMeta) FileSystem(java.nio.file.FileSystem) IOException(java.io.IOException) CsarDependenciesBean(org.alien4cloud.tosca.model.CsarDependenciesBean) ToscaContextual(alien4cloud.tosca.context.ToscaContextual)

Aggregations

ToscaContextual (alien4cloud.tosca.context.ToscaContextual)13 TopologyDTO (alien4cloud.topology.TopologyDTO)2 ParsingException (alien4cloud.tosca.parser.ParsingException)2 Path (java.nio.file.Path)2 CSARDependency (org.alien4cloud.tosca.model.CSARDependency)2 CsarDependenciesBean (org.alien4cloud.tosca.model.CsarDependenciesBean)2 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)2 NodeType (org.alien4cloud.tosca.model.types.NodeType)2 PaaSNodeTemplate (alien4cloud.paas.model.PaaSNodeTemplate)1 PaaSTopology (alien4cloud.paas.model.PaaSTopology)1 AbstractTopologyDTO (alien4cloud.topology.AbstractTopologyDTO)1 PropertiesTask (alien4cloud.topology.task.PropertiesTask)1 ArchiveRoot (alien4cloud.tosca.model.ArchiveRoot)1 ToscaMeta (alien4cloud.tosca.model.ToscaMeta)1 ParsingContext (alien4cloud.tosca.parser.ParsingContext)1 ParsingResult (alien4cloud.tosca.parser.ParsingResult)1 IOException (java.io.IOException)1 FileSystem (java.nio.file.FileSystem)1 ProviderNotFoundException (java.nio.file.ProviderNotFoundException)1 HashMap (java.util.HashMap)1