Search in sources :

Example 1 with PluginArchiveException

use of alien4cloud.plugin.exception.PluginArchiveException in project alien4cloud by alien4cloud.

the class AbstractPluginArchiveService method parse.

/**
 * Parse an archive given a path relative to the plugin
 *
 * @param archiveRelativePath Relative path where the archive is in the plugin
 * @return The parsed archive as a @{@link PluginArchive}
 * @throws PluginArchiveException
 */
public PluginArchive parse(String archiveRelativePath) throws PluginArchiveException {
    String archiveErrorMsge = "Archive in path: [ " + archiveRelativePath + " ]";
    // Parse the archives
    ParsingResult<ArchiveRoot> result;
    Path archivePath = selfContext.getPluginPath().resolve(archiveRelativePath);
    try {
        result = this.archiveParser.parseDir(archivePath, AlienConstants.GLOBAL_WORKSPACE_ID);
    } catch (ParsingException e) {
        throw new PluginArchiveException("Failed to parse " + archiveErrorMsge, e);
    }
    if (result.getContext().getParsingErrors() != null && !result.getContext().getParsingErrors().isEmpty()) {
        log.error("Parsing errors for" + archiveErrorMsge);
        for (ParsingError parsingError : result.getContext().getParsingErrors()) {
            log.error(parsingError.toString());
        }
        throw new PluginArchiveException(archiveErrorMsge + " is invalid");
    }
    return new PluginArchive(result.getResult(), archivePath);
}
Also used : Path(java.nio.file.Path) ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) ParsingError(alien4cloud.tosca.parser.ParsingError) PluginArchive(alien4cloud.orchestrators.plugin.model.PluginArchive) ParsingException(alien4cloud.tosca.parser.ParsingException) PluginArchiveException(alien4cloud.plugin.exception.PluginArchiveException)

Aggregations

PluginArchive (alien4cloud.orchestrators.plugin.model.PluginArchive)1 PluginArchiveException (alien4cloud.plugin.exception.PluginArchiveException)1 ArchiveRoot (alien4cloud.tosca.model.ArchiveRoot)1 ParsingError (alien4cloud.tosca.parser.ParsingError)1 ParsingException (alien4cloud.tosca.parser.ParsingException)1 Path (java.nio.file.Path)1