Search in sources :

Example 1 with ToscaMeta

use of alien4cloud.tosca.model.ToscaMeta in project alien4cloud by alien4cloud.

the class ToscaArchiveParser method parseFromToscaMeta.

private ParsingResult<ArchiveRoot> parseFromToscaMeta(FileSystem csarFS) throws ParsingException {
    YamlSimpleParser<ToscaMeta> parser = new YamlSimpleParser<ToscaMeta>(toscaMetaMapping.getParser());
    ParsingResult<ToscaMeta> parsingResult = parser.parseFile(csarFS.getPath(TOSCA_META_FILE_LOCATION));
    // FIXME shouldn't we check here if the meta parsing went well?
    ArchiveRoot archiveRoot = initFromToscaMeta(parsingResult);
    return parseFromToscaMeta(csarFS, parsingResult.getResult(), TOSCA_META_FILE_LOCATION, archiveRoot, toscaParser);
}
Also used : ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) ToscaMeta(alien4cloud.tosca.model.ToscaMeta)

Example 2 with ToscaMeta

use of alien4cloud.tosca.model.ToscaMeta in project alien4cloud by alien4cloud.

the class ToscaArchiveParser method parseFromToscaMeta.

private ParsingResult<ArchiveRoot> parseFromToscaMeta(Path csarPath) throws ParsingException {
    YamlSimpleParser<ToscaMeta> parser = new YamlSimpleParser<ToscaMeta>(toscaMetaMapping.getParser());
    ParsingResult<ToscaMeta> parsingResult = parser.parseFile(csarPath.resolve(TOSCA_META_FILE_LOCATION));
    ArchiveRoot archiveRoot = initFromToscaMeta(parsingResult);
    return parseFromToscaMeta(csarPath, parsingResult.getResult(), TOSCA_META_FILE_LOCATION, archiveRoot);
}
Also used : ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) ToscaMeta(alien4cloud.tosca.model.ToscaMeta)

Example 3 with ToscaMeta

use of alien4cloud.tosca.model.ToscaMeta 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

ToscaMeta (alien4cloud.tosca.model.ToscaMeta)3 ArchiveRoot (alien4cloud.tosca.model.ArchiveRoot)2 ToscaContextual (alien4cloud.tosca.context.ToscaContextual)1 IOException (java.io.IOException)1 FileSystem (java.nio.file.FileSystem)1 ProviderNotFoundException (java.nio.file.ProviderNotFoundException)1 CsarDependenciesBean (org.alien4cloud.tosca.model.CsarDependenciesBean)1