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