diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-02-01 15:05:40 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-02-01 15:05:40 +0100 |
commit | 58a80a9ea9dafd36a8d9f204725bfced2e0dbcad (patch) | |
tree | 09e5395270a7ee89793dd071079a1bb27ad8f74d /config-model/src/main/java/com/yahoo/searchdefinition/ApplicationBuilder.java | |
parent | c2dc7f1e3f9371cc8b04246ca346b1c5f7f2fd3f (diff) |
Avoid schema dir
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition/ApplicationBuilder.java')
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/ApplicationBuilder.java | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/ApplicationBuilder.java b/config-model/src/main/java/com/yahoo/searchdefinition/ApplicationBuilder.java index 98c6897dbb7..134fc4dc5a2 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/ApplicationBuilder.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/ApplicationBuilder.java @@ -139,7 +139,7 @@ public class ApplicationBuilder { */ public Schema addSchemaFile(String fileName) throws IOException, ParseException { File file = new File(fileName); - return addSchema(IOUtils.readFile(file), file.getAbsoluteFile().getParent()); + return addSchema(IOUtils.readFile(file)); } /** @@ -148,9 +148,9 @@ public class ApplicationBuilder { * * @param reader the reader whose content to import */ - private void addSchema(NamedReader reader) { + public void addSchema(NamedReader reader) { try { - String schemaName = addSchema(IOUtils.readAll(reader), reader.getName()).getName(); + String schemaName = addSchema(IOUtils.readAll(reader)).getName(); String schemaFileName = stripSuffix(reader.getName(), ApplicationPackage.SD_NAME_SUFFIX); if ( ! schemaFileName.equals(schemaName)) { throw new IllegalArgumentException("The file containing schema '" + schemaName + "' must be named '" + @@ -172,18 +172,12 @@ public class ApplicationBuilder { } /** - * Adds a schema to this application. + * Adds a schema to this * - * @param string the string to parse - * @return the schema - * @throws ParseException thrown if the file does not contain a valid search definition + * @param schemaString the content of the schema */ - public Schema addSchema(String string) throws ParseException { - return addSchema(string, null); - } - - private Schema addSchema(String schemaString, String schemaPath) throws ParseException { - return add(createSchema(schemaString, schemaPath)); + public Schema addSchema(String schemaString) throws ParseException { + return add(createSchema(schemaString)); } /** @@ -201,18 +195,18 @@ public class ApplicationBuilder { return schema; } - private Schema createSchema(String schemaString, String schemaPath) throws ParseException { - Schema schema = parseSchema(schemaString, schemaPath); - addRankProfileFiles(schema, schemaPath); + private Schema createSchema(String schemaString) throws ParseException { + Schema schema = parseSchema(schemaString); + addRankProfileFiles(schema); return schema; } - private Schema parseSchema(String schemaString, String schemaPath) throws ParseException { + private Schema parseSchema(String schemaString) throws ParseException { SimpleCharStream stream = new SimpleCharStream(schemaString); try { return new SDParser(stream, applicationPackage, fileRegistry, deployLogger, properties, rankProfileRegistry, documentsOnly) - .schema(documentTypeManager, schemaPath); + .schema(documentTypeManager); } catch (TokenMgrException e) { throw new ParseException("Unknown symbol: " + e.getMessage()); } catch (ParseException pe) { @@ -220,9 +214,9 @@ public class ApplicationBuilder { } } - private void addRankProfileFiles(Schema schema, String schemaPath) { - if (applicationPackage == null || schemaPath == null) return; - Path rankProfilePath = Path.fromString(schemaPath).append(schema.getName()); + private void addRankProfileFiles(Schema schema) { + if (applicationPackage == null) return; + Path rankProfilePath = ApplicationPackage.SCHEMAS_DIR.append(schema.getName()); for (NamedReader reader : applicationPackage.getFiles(rankProfilePath, ".profile")) { parseRankProfile(reader, schema); } |