in text-translators-agent/src/jetbrains/buildServer/agent/messages/regex/impl/ParserLoaderImpl.java [53:87]
private RegexParser doLoadPath(@NotNull final ParserCommand.ParserId parserId) throws FileNotFoundException, ParserLoadingException {
RegexParser parser;
if (!StringUtil.isEmptyOrSpaces(parserId.getResourcePath())) {
final String path = parserId.getResourcePath();
LOG.info("Loading parser config from resource " + path);
parser = RegexParsersHelper.loadParserFromResource(path);
} else if (!StringUtil.isEmptyOrSpaces(parserId.getFile())) {
final String path = parserId.getFile();
final File file;
if (FileUtil.isAbsolute(path)) {
file = new File(path);
} else {
// Path relative to checkout directory
if (!myBuildTracker.isRunningBuild()) {
String message = "Cannot register parser from file: no running build found and not absolute path specified: " + path;
LOG.error(message);
throw new IllegalStateException(message);
}
final File wd = myBuildTracker.getCurrentBuild().getCheckoutDirectory();
file = new File(wd, path);
}
if (file.exists()) {
final File cf = FileUtil.getCanonicalFile(file);
LOG.info("Loading parser config from file " + cf.getAbsolutePath());
parser = RegexParsersHelper.loadParserFromFile(cf);
} else {
String message = "Cannot register parser from file: file not found: " + file.getAbsolutePath();
LOG.warn(message);
throw new FileNotFoundException(message);
}
} else {
throw new IllegalArgumentException("Expected non-empty resource path or file path");
}
return parser;
}