Xml.resetResolver();
}
SchematronRepository schemaRepo = applicationContext.getBean(SchematronRepository.class);
SchematronCriteriaGroupRepository criteriaGroupRepository = applicationContext.getBean(SchematronCriteriaGroupRepository.class);
MetadataSchema mds = new SchemaLoader().load(xmlSchemaFile, xmlSubstitutionsFile, schemaRepo, criteriaGroupRepository);
mds.setName(name);
mds.setSchemaDir(path);
mds.loadSchematronRules(basePath);
// -- add cached xml files (schema codelists and label files)
// -- as Jeeves XmlFile objects (they need not exist)
String base = fromAppPath + name + FS + "loc";
Map<String, XmlFile> xfMap = new HashMap<String, XmlFile>();
for (String fname : fnames) {
String filePath = path + FS + "loc" + FS + defaultLang + FS + fname;
if (Log.isDebugEnabled(Geonet.SCHEMA_MANAGER))
Log.debug(Geonet.SCHEMA_MANAGER, "Searching for " + filePath);
if (new File(filePath).exists()) {
Element config = new Element("xml");
config.setAttribute("name", name);
config.setAttribute("base", base);
config.setAttribute("file", fname);
if (Log.isDebugEnabled(Geonet.SCHEMA_MANAGER))
Log.debug(Geonet.SCHEMA_MANAGER, "Adding XmlFile " + Xml.getString(config));
XmlFile xf = new XmlFile(config, defaultLang, true);
xfMap.put(fname, xf);
} else {
Log.warning(Geonet.SCHEMA_MANAGER, "Unable to load loc file: " + filePath);
}
}
Pair<String, String> idInfo = extractIdInfo(xmlIdFile, name);
mds.setReadwriteUUID(extractReadWriteUuid(xmlIdFile));
mds.setOperationFilters(extractOperationFilters(xmlIdFile));
Log.debug(Geonet.SCHEMA_MANAGER, " UUID is read/write mode: " + mds.isReadwriteUUID());
putSchemaInfo(
name,
idInfo.one(), // uuid of schema
idInfo.two(), // version of schema