private void synchronizeSchema(DataStructureSchemaModel schemaModel) throws SynchronizationException {
try {
if (!dataStructuresCoreService.existsSchema(schemaModel.getLocation())) {
dataStructuresCoreService.createSchema(schemaModel.getLocation(), schemaModel.getName(), schemaModel.getHash());
DATA_STRUCTURE_SCHEMA_MODELS.put(schemaModel.getName(), schemaModel);
addDataStructureModelsFromSchema(schemaModel);
logger.info("Synchronized a new Schema file [{}] from location: {}", schemaModel.getName(), schemaModel.getLocation());
} else {
DataStructureSchemaModel existing = dataStructuresCoreService.getSchema(schemaModel.getLocation());
if (!schemaModel.equals(existing)) {
dataStructuresCoreService.updateSchema(schemaModel.getLocation(), schemaModel.getName(), schemaModel.getHash());
DATA_STRUCTURE_SCHEMA_MODELS.put(schemaModel.getName(), schemaModel);
addDataStructureModelsFromSchema(schemaModel);
logger.info("Synchronized a modified Schema file [{}] from location: {}", schemaModel.getName(), schemaModel.getLocation());
}
}
SCHEMA_SYNCHRONIZED.add(schemaModel.getLocation());
} catch (DataStructuresException e) {
throw new SynchronizationException(e);
}
}