use of org.hisp.dhis.dxf2.metadata.MetadataWrapper in project dhis2-core by dhis2.
the class DefaultMetadataVersionService method createMetadataVersionInDataStore.
@Override
@Transactional
public void createMetadataVersionInDataStore(String versionName, String versionSnapshot) {
if (StringUtils.isEmpty(versionSnapshot)) {
throw new MetadataVersionServiceException("The Metadata Snapshot is null while trying to create a Metadata Version entry in DataStore.");
}
DatastoreEntry entry = new DatastoreEntry();
entry.setKey(versionName);
entry.setNamespace(MetadataDatastoreService.METADATA_STORE_NS);
// MetadataWrapper is used to avoid Metadata keys reordering by jsonb
// (jsonb does not preserve keys order)
entry.setValue(renderService.toJsonAsString(new MetadataWrapper(versionSnapshot)));
try {
metaDataDatastoreService.addMetaEntry(entry);
} catch (Exception ex) {
String message = "Exception occurred while saving the Metadata snapshot in Data Store" + ex.getMessage();
log.error(message, ex);
throw new MetadataVersionServiceException(message, ex);
}
}
Aggregations