use of io.atlasmap.v2.ADMDigest in project atlasmap by atlasmap.
the class ADMArchiveHandler method getDataSourceMetadataMap.
/**
* Gets a map of DataSource metadata.
* @return a map of DataSource metadata.
* @throws AtlasException unexpected error
*/
public Map<DataSourceKey, DataSourceMetadata> getDataSourceMetadataMap() throws AtlasException {
if (this.dataSourceMetadata == null) {
if (this.gzippedAdmDigestBytes == null) {
return null;
}
try (GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(this.gzippedAdmDigestBytes))) {
ADMDigest digest = jsonMapperForDigest.readValue(in, ADMDigest.class);
this.dataSourceMetadata = new HashMap<>();
for (int i = 0; i < digest.getExportMeta().length; i++) {
DataSourceMetadata meta = digest.getExportMeta()[i];
String spec = digest.getExportBlockData()[i].getValue();
if (meta.getId() == null) {
meta.setId(meta.getName());
}
meta.setSpecification(spec != null ? spec.getBytes() : null);
this.dataSourceMetadata.put(new DataSourceKey(meta.getIsSource(), meta.getId()), meta);
}
} catch (Exception e) {
throw new AtlasException(e);
}
}
return Collections.unmodifiableMap(this.dataSourceMetadata);
}
Aggregations