diff --git a/src/main/java/com/marklogic/client/schemasloader/impl/DefaultSchemasLoader.java b/src/main/java/com/marklogic/client/schemasloader/impl/DefaultSchemasLoader.java index 9209cef..d47f798 100644 --- a/src/main/java/com/marklogic/client/schemasloader/impl/DefaultSchemasLoader.java +++ b/src/main/java/com/marklogic/client/schemasloader/impl/DefaultSchemasLoader.java @@ -6,9 +6,12 @@ import java.util.Set; import com.marklogic.client.DatabaseClient; +import com.marklogic.client.document.JSONDocumentManager; import com.marklogic.client.document.TextDocumentManager; import com.marklogic.client.document.XMLDocumentManager; import com.marklogic.client.helper.LoggingObject; +import com.marklogic.client.impl.JSONDocumentImpl; +import com.marklogic.client.io.DocumentMetadataHandle; import com.marklogic.client.io.FileHandle; import com.marklogic.client.io.Format; import com.marklogic.client.schemasloader.SchemasFinder; @@ -20,15 +23,22 @@ public class DefaultSchemasLoader extends LoggingObject implements SchemasLoader public Set loadSchemas(File baseDir, SchemasFinder schemasDataFinder, DatabaseClient client) { XMLDocumentManager xmlDocMgr = client.newXMLDocumentManager(); TextDocumentManager textDocMgr = client.newTextDocumentManager(); + JSONDocumentManager jsonDocMgr = client.newJSONDocumentManager(); List schemasData = schemasDataFinder.findSchemas(baseDir); Set loadedSchemas = new HashSet<>(); - + DocumentMetadataHandle tdeCollection = new DocumentMetadataHandle().withCollections("http://marklogic.com/xdmp/tde"); for (File f : schemasData) { String extension = getExtensionNameFromFile(f); FileHandle handle = new FileHandle(f); - if (extension.equals("tde") || extension.equals("xsd")) { + if (extension.equals("tdej")) { + jsonDocMgr.write(f.getName(), tdeCollection, handle.withFormat(Format.JSON)); + } + else if (extension.equals("tdex")) { + xmlDocMgr.write(f.getName(), tdeCollection, handle.withFormat(Format.XML)); + } + else if (extension.equals("xsd")) { xmlDocMgr.write(f.getName(), handle.withFormat(Format.XML)); } else { textDocMgr.write(f.getName(), handle.withFormat(Format.TEXT));