Search in sources :

Example 6 with ParsingContext

use of alien4cloud.tosca.parser.ParsingContext in project alien4cloud by alien4cloud.

the class ArchiveUploadService method preParsing.

@ToscaContextual
public Map<CSARDependency, CsarDependenciesBean> preParsing(Set<Path> paths, List<ParsingResult<Csar>> parsingResults) {
    Map<CSARDependency, CsarDependenciesBean> csarDependenciesBeans = Maps.newHashMap();
    for (Path path : paths) {
        try {
            // FIXME cleanup git import archives
            ParsingResult<CsarDependenciesBean> parsingResult = parser.parseImports(path);
            parsingResult.getResult().setPath(path);
            csarDependenciesBeans.put(parsingResult.getResult().getSelf(), parsingResult.getResult());
        } catch (ParsingException e) {
            ParsingResult<Csar> failedResult = new ParsingResult<>();
            failedResult.setContext(new ParsingContext(path.getFileName().toString()));
            failedResult.getContext().setParsingErrors(e.getParsingErrors());
            parsingResults.add(failedResult);
            log.debug("Not able to parse archive, ignoring it", e);
        }
    }
    return csarDependenciesBeans;
}
Also used : Path(java.nio.file.Path) ParsingResult(alien4cloud.tosca.parser.ParsingResult) ParsingContext(alien4cloud.tosca.parser.ParsingContext) ParsingException(alien4cloud.tosca.parser.ParsingException) CsarDependenciesBean(org.alien4cloud.tosca.model.CsarDependenciesBean) CSARDependency(org.alien4cloud.tosca.model.CSARDependency) ToscaContextual(alien4cloud.tosca.context.ToscaContextual)

Aggregations

ParsingContext (alien4cloud.tosca.parser.ParsingContext)6 ParsingResult (alien4cloud.tosca.parser.ParsingResult)4 ParsingException (alien4cloud.tosca.parser.ParsingException)2 Path (java.nio.file.Path)2 CSARDependency (org.alien4cloud.tosca.model.CSARDependency)2 Csar (org.alien4cloud.tosca.model.Csar)2 CsarDependenciesBean (org.alien4cloud.tosca.model.CsarDependenciesBean)2 CSARUsedInActiveDeployment (alien4cloud.component.repository.exception.CSARUsedInActiveDeployment)1 ToscaTypeAlreadyDefinedInOtherCSAR (alien4cloud.component.repository.exception.ToscaTypeAlreadyDefinedInOtherCSAR)1 AlreadyExistException (alien4cloud.exception.AlreadyExistException)1 ToscaContextual (alien4cloud.tosca.context.ToscaContextual)1 ArchiveRoot (alien4cloud.tosca.model.ArchiveRoot)1 ParsingError (alien4cloud.tosca.parser.ParsingError)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 FilterDefinition (org.alien4cloud.tosca.model.definitions.FilterDefinition)1 NodeFilter (org.alien4cloud.tosca.model.definitions.NodeFilter)1 PropertyConstraint (org.alien4cloud.tosca.model.definitions.PropertyConstraint)1 RequirementDefinition (org.alien4cloud.tosca.model.definitions.RequirementDefinition)1