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);
}
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);
}
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));
}
}
Aggregations