Search in sources :

Example 1 with ADMDigest

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);
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) DataSourceKey(io.atlasmap.v2.DataSourceKey) DataSourceMetadata(io.atlasmap.v2.DataSourceMetadata) ByteArrayInputStream(java.io.ByteArrayInputStream) AtlasException(io.atlasmap.api.AtlasException) AtlasException(io.atlasmap.api.AtlasException) ADMDigest(io.atlasmap.v2.ADMDigest)

Aggregations

AtlasException (io.atlasmap.api.AtlasException)1 ADMDigest (io.atlasmap.v2.ADMDigest)1 DataSourceKey (io.atlasmap.v2.DataSourceKey)1 DataSourceMetadata (io.atlasmap.v2.DataSourceMetadata)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 GZIPInputStream (java.util.zip.GZIPInputStream)1