Class ADMArchiveHandler


  • public class ADMArchiveHandler
    extends Object
    The API for handling ADM archive. It encapsulates ADM archive structure and format and isolate file/stream I/O from other part. ADM archive is a zipped archive file or its exploded directory which contains
    • Mapping Definition file (atlasmapping-UI.n.json)
    • Gzipped digest file which contains all non-Java document metadata and mapping definition in a single JSON file (adm-catalog-files-n.gz)
    • Java libraries (jar files in lib/ directory)
    load(Path) export(OutputStream)
    This handler follows lazy loading strategy as much as possible, i.e. defer to serialize/deserialize until it is really required. Also note that at this moment Java library directory is not managed by this class. Only when it imports/exports ADM archive file, library jars are extracted/bundled if isIgnoreLibrary() is set to false.
    TODO https://github.com/atlasmap/atlasmap/issues/1476 A gzipped digest file have to be splitted into individual schemas and a catalog file.
    • Constructor Detail

      • ADMArchiveHandler

        public ADMArchiveHandler()
      • ADMArchiveHandler

        public ADMArchiveHandler​(ClassLoader loader)
    • Method Detail

      • load

        public void load​(Path path)
                  throws io.atlasmap.api.AtlasException
        Load an ADM archive file, an exploded directory or mapping definition JSON file.
        Parameters:
        path - java.nio.file.Path of the ADM archive file or an exploded directory
        Throws:
        io.atlasmap.api.AtlasException - If it fails to load
      • load

        public void load​(InputStream in)
                  throws io.atlasmap.api.AtlasException
        Load an ADM archive from stream.
        Parameters:
        in - InputStream to read an ADM Archive
        Throws:
        io.atlasmap.api.AtlasException - If it fails to load
      • load

        public void load​(io.atlasmap.api.AtlasContextFactory.Format format,
                         InputStream in)
                  throws io.atlasmap.api.AtlasException
        Load an ADM archive or mapping definition from stream.
        Parameters:
        format - AtlasContextFactory.Format to indicate stream format
        in - InputStream to read an ADM Archive
        Throws:
        io.atlasmap.api.AtlasException - If it fails to load
      • export

        public void export​(OutputStream out)
                    throws io.atlasmap.api.AtlasException
        Export into an ADM archive.
        Parameters:
        out - OutputStream to write an ADM archive
        Throws:
        io.atlasmap.api.AtlasException - If it fails to export
      • persist

        public void persist()
                     throws io.atlasmap.api.AtlasException
        Persist ADM archive into a directory.
        Throws:
        io.atlasmap.api.AtlasException - If it fails to persist
      • getMappingDefinition

        public io.atlasmap.v2.AtlasMapping getMappingDefinition()
      • setMappingDefinition

        public void setMappingDefinition​(io.atlasmap.v2.AtlasMapping mapping)
      • setMappingDefinitionBytes

        public void setMappingDefinitionBytes​(InputStream is)
                                       throws io.atlasmap.api.AtlasException
        Throws:
        io.atlasmap.api.AtlasException
      • getMappingDefinitionBytes

        public byte[] getMappingDefinitionBytes()
                                         throws io.atlasmap.api.AtlasException
        Throws:
        io.atlasmap.api.AtlasException
      • setGzippedADMDigest

        public void setGzippedADMDigest​(InputStream is)
                                 throws io.atlasmap.api.AtlasException
        Throws:
        io.atlasmap.api.AtlasException
      • getGzippedADMDigestBytes

        public byte[] getGzippedADMDigestBytes()
      • getDataSourceMetadata

        public io.atlasmap.v2.DataSourceMetadata getDataSourceMetadata​(boolean isSource,
                                                                       String documentId)
                                                                throws io.atlasmap.api.AtlasException
        Throws:
        io.atlasmap.api.AtlasException
      • getDataSourceMetadata

        public io.atlasmap.v2.DataSourceMetadata getDataSourceMetadata​(io.atlasmap.v2.DataSourceKey key)
                                                                throws io.atlasmap.api.AtlasException
        Throws:
        io.atlasmap.api.AtlasException
      • getDataSourceMetadataMap

        public Map<io.atlasmap.v2.DataSourceKey,​io.atlasmap.v2.DataSourceMetadata> getDataSourceMetadataMap()
                                                                                                           throws io.atlasmap.api.AtlasException
        Throws:
        io.atlasmap.api.AtlasException
      • cloneMappingDefinition

        public io.atlasmap.v2.AtlasMapping cloneMappingDefinition()
                                                           throws io.atlasmap.api.AtlasException
        Throws:
        io.atlasmap.api.AtlasException
      • clear

        public void clear()
      • setIgnoreLibrary

        public void setIgnoreLibrary​(boolean ignoreLib)
      • isIgnoreLibrary

        public boolean isIgnoreLibrary()
      • setPersistDirectory

        public void setPersistDirectory​(Path dir)
                                 throws io.atlasmap.api.AtlasException
        Throws:
        io.atlasmap.api.AtlasException
      • setLibraryDirectory

        public void setLibraryDirectory​(Path dir)
                                 throws io.atlasmap.api.AtlasException
        Throws:
        io.atlasmap.api.AtlasException
      • setMappingDefinitionId

        public void setMappingDefinitionId​(String id)
      • getGzippedADMDigestFileName

        public String getGzippedADMDigestFileName()
      • getMappingDefinitionFileName

        public String getMappingDefinitionFileName()