Class ApacheAtlasRESTConnector

java.lang.Object
org.odpi.openmetadata.frameworks.connectors.Connector
org.odpi.openmetadata.frameworks.connectors.ConnectorBase
org.odpi.openmetadata.adapters.connectors.apacheatlas.resource.ApacheAtlasRESTConnector
All Implemented Interfaces:
AuditLoggingComponent, SecureConnectorExtension, VirtualConnectorExtension

public class ApacheAtlasRESTConnector extends ConnectorBase implements AuditLoggingComponent
ApacheAtlasRESTConnector is responsible for issuing calls to the Apache Atlas REST APIs. It covers basic calls such as retrieving and adding types, entities, relationships, labels, classifications and business metadata.
  • Field Details

  • Constructor Details

    • ApacheAtlasRESTConnector

      public ApacheAtlasRESTConnector()
      Default Constructor used by the connector provider.
  • Method Details

    • setAuditLog

      public void setAuditLog(AuditLog auditLog)
      Receive an audit log object that can be used to record audit log messages. The caller has initialized it with the correct component description and log destinations.
      Specified by:
      setAuditLog in interface AuditLoggingComponent
      Parameters:
      auditLog - audit log object
    • getConnectorComponentDescription

      public ComponentDescription getConnectorComponentDescription()
      Return the component description that is used by this connector in the audit log.
      Specified by:
      getConnectorComponentDescription in interface AuditLoggingComponent
      Returns:
      id, name, description, wiki page URL.
    • start

      public void start() throws ConnectorCheckedException
      Indicates that the connector is completely configured and can begin processing. This call can be used to register with non-blocking services.
      Overrides:
      start in class ConnectorBase
      Throws:
      ConnectorCheckedException - there is a problem within the connector.
    • getAtlasVersion

      public AtlasVersion getAtlasVersion() throws PropertyServerException
      Return the version of this Apache Atlas.
      Returns:
      atlas version information
      Throws:
      PropertyServerException - problem communicating with Apache Atlas
    • getAtlasMetrics

      public AtlasMetrics getAtlasMetrics() throws PropertyServerException
      Return the metrics of this Apache Atlas.
      Returns:
      atlas metrics information
      Throws:
      PropertyServerException - problem communicating with Apache Atlas
    • isTypeDefinedInAtlas

      public org.odpi.openmetadata.adapters.connectors.apacheatlas.resource.ApacheAtlasRESTConnector.TypeStatus isTypeDefinedInAtlas(String atlasTypeName, long version)
      Is the named type already defined in Apache Atlas? Is the version correct?
      Parameters:
      atlasTypeName - name of type to check for
      version - type version to test for
      Returns:
      result
    • addTypeDefinitions

      public void addTypeDefinitions(AtlasTypesDef atlasTypesDef)
      Make updates to the atlas types map based on the type changes described in the supplied Apache Atlas type definitions
      Parameters:
      atlasTypesDef - type definitions returned from Apache Atlas
    • getAllTypes

      public AtlasTypesDef getAllTypes() throws PropertyServerException
      Return the types registered to Apache Atlas.
      Returns:
      type definition list from Apache Atlas
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • getTypeNamesAsString

      public String getTypeNamesAsString(Set<String> typeNames)
      Return the list of entity types as a list encoded as a single string with escaped type names. This format is used with business metadata type definitions.
      Returns:
      list of entity type names with escape characters or null
    • getTopLevelEntityTypes

      public Set<String> getTopLevelEntityTypes() throws PropertyServerException
      Return the list of entity types that are top level - eg Referenceable.
      Returns:
      set of entity type names
      Throws:
      PropertyServerException - error calling Atlas
    • getEntityType

      public AtlasEntityDef getEntityType(String typeName) throws PropertyServerException
      Return the requested type from Apache Atlas.
      Parameters:
      typeName - name of type to retrieve
      Returns:
      type definition from Apache Atlas
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • getRelationshipType

      public AtlasRelationshipDef getRelationshipType(String typeName) throws PropertyServerException
      Return the requested type from Apache Atlas.
      Parameters:
      typeName - name of type to retrieve
      Returns:
      type definition from Apache Atlas
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • getClassificationType

      public AtlasClassificationDef getClassificationType(String typeName) throws PropertyServerException
      Return the requested type from Apache Atlas.
      Parameters:
      typeName - name of type to retrieve
      Returns:
      type definition from Apache Atlas
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • getBusinessMetadataType

      public AtlasBusinessMetadataDef getBusinessMetadataType(String typeName) throws PropertyServerException
      Return the requested type from Apache Atlas.
      Parameters:
      typeName - name of type to retrieve
      Returns:
      type definition from Apache Atlas
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • addNewTypes

      public void addNewTypes(AtlasTypesDef newTypeDefinitions) throws PropertyServerException
      Create new types. The registered types are returned from Apache Atlas.
      Parameters:
      newTypeDefinitions - gallery of new types
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • updateTypes

      public void updateTypes(AtlasTypesDef newTypeDefinitions) throws PropertyServerException
      Update existing types. The registered types are returned from Apache Atlas.
      Parameters:
      newTypeDefinitions - gallery of new types
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • addOpenMetadataElement

      public String addOpenMetadataElement(OpenMetadataElement openMetadataElement) throws PropertyServerException
      Copy the contents of an open metadata element into Apache Atlas and return the unique identifier of the new Apache Atlas element. Note: this method assumes the type has been defined.
      Parameters:
      openMetadataElement - element to copy into Apache Atlas
      Returns:
      unique identifier of the resulting Atlas entity
      Throws:
      PropertyServerException - problem with communicating with Apache Atlas
    • updateOpenMetadataElement

      public void updateOpenMetadataElement(String atlasGUID, OpenMetadataElement openMetadataElement) throws PropertyServerException
      Update the contents of an Apache Atlas entity using the contents of an open metadata element.
      Parameters:
      atlasGUID - unique identifier of the atlas entity to update
      openMetadataElement - entity from the open metadata ecosystem to copy into Apache Atlas
      Throws:
      PropertyServerException - problem with communicating with Apache Atlas
    • setupRelatedMetadataEntities

      public void setupRelatedMetadataEntities(String relationshipTypeName, ElementProperties relationshipProperties, String end1AtlasGUID, String end2AtlasGUID) throws PropertyServerException
      Create an open metadata ecosystem relationship between Apache Atlas entities. The associated relationship may or may not exist in Apache Atlas. If the relationship exists, it is updated. If it does not exist, it is created. Note: this method assumes the type has been defined. Also note that this logic is assuming uni-link relationships. todo - add support for multi-link relationships
      Parameters:
      relationshipTypeName - relationship from the open metadata ecosystem
      relationshipProperties - properties from open metadata ecosystem
      end1AtlasGUID - unique identifier of Atlas entity at end 1 of the relationship
      end2AtlasGUID - unique identifier of Atlas entity at end 2 of the relationship
      Throws:
      PropertyServerException - problem with communicating with Apache Atlas
    • addOpenMetadataType

      public void addOpenMetadataType(OpenMetadataTypeDef openMetadataTypeDef) throws PropertyServerException
      Take an open metadata type definition and add it to Apache Atlas's type system.
      Parameters:
      openMetadataTypeDef - type definition from open metadata
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • addOpenMetadataEntityType

      public void addOpenMetadataEntityType(OpenMetadataEntityDef openMetadataEntityDef) throws PropertyServerException
      Convert an open metadata entity type to an Atlas type and add it to Apache Atlas.
      Parameters:
      openMetadataEntityDef - entity from open metadata
      Throws:
      PropertyServerException - unable to add type to Apache Atlas
    • addOpenMetadataRelationshipType

      public void addOpenMetadataRelationshipType(OpenMetadataRelationshipDef openMetadataRelationshipDef) throws PropertyServerException
      Convert an open metadata relationship type to an Atlas type and add it to Apache Atlas.
      Parameters:
      openMetadataRelationshipDef - relationship from open metadata
      Throws:
      PropertyServerException - unable to add type to Apache Atlas
    • addOpenMetadataClassificationType

      public void addOpenMetadataClassificationType(OpenMetadataClassificationDef openMetadataClassificationDef) throws PropertyServerException
      Add a classification definition from open metadata as a type of business metadata in Apache Atlas.
      Parameters:
      openMetadataClassificationDef - classification type definition
      Throws:
      PropertyServerException
    • addClassificationType

      public void addClassificationType(String classificationName, String classificationDescription, Map<String,String> classificationProperties) throws PropertyServerException
      Add a classification definition to Apache Atlas. This classification can be added to any top-level atlas entity type.
      Parameters:
      classificationName - name of the classification
      classificationDescription - description of the classification
      classificationProperties - name/descriptions of string properties that will be added to the definition
      Throws:
      PropertyServerException - unable to connect to Apache Atlas
    • addOpenMetadataEnumType

      public void addOpenMetadataEnumType(OpenMetadataEnumDef openMetadataEnumDef) throws PropertyServerException
      Add an enum definition from open metadata as an enum definition in Apache Atlas.
      Parameters:
      openMetadataEnumDef - enum type definition
      Throws:
      PropertyServerException
    • getAtlasAttributeDef

      public AtlasAttributeDef getAtlasAttributeDef(OpenMetadataTypeDefAttribute openMetadataTypeDefAttribute, int maxStringLength, String applicableEntityTypes) throws PropertyServerException
      Return a single attribute definition for a business metadata type.
      Parameters:
      openMetadataTypeDefAttribute - details of the attribute
      maxStringLength - maximum length of string
      applicableEntityTypes - list of type names that this attribute can be attached to
      Returns:
      atlas attribute definition
      Throws:
      PropertyServerException - problem calling Apache Atlas
    • getStandardAttributeDef

      public AtlasAttributeDef getStandardAttributeDef(String propertyName, String propertyDescription, OpenMetadataAttributeTypeDef openMetadataAttributeTypeDef)
      Create an attribute of the requested type. Note enums are represented as strings in Apache Atlas.
      Parameters:
      propertyName - name of the attribute
      propertyDescription - description of the attribute
      openMetadataAttributeTypeDef - type of the attribute
      Returns:
      attribute definition
    • getStandardAttributeDef

      public AtlasAttributeDef getStandardAttributeDef(String propertyName, String propertyDescription, String typeName)
      Create an Apache Atlas attribute of the requested type.
      Parameters:
      propertyName - name of the attribute
      propertyDescription - description of the attribute
      typeName - name of the Apache Atlas type to use
      Returns:
      attribute definition
    • getStringAttributeDef

      public AtlasAttributeDef getStringAttributeDef(String propertyName, String propertyDescription)
      Create an attribute of type string
      Parameters:
      propertyName - name of the attribute
      propertyDescription - description of the attribute
      Returns:
      attribute definition
    • getStringAttributeDef

      public AtlasAttributeDef getStringAttributeDef(String propertyName, String propertyDescription, int maxStringLength, String applicableEntityTypes)
      Create an attribute of type string for a business metadata element.
      Parameters:
      propertyName - name of the attribute
      maxStringLength - maximum string length
      applicableEntityTypes - list of entity types that this attribute can be attached to
      propertyDescription - description of the attribute
      Returns:
      attribute definition
    • getBooleanAttributeDef

      public AtlasAttributeDef getBooleanAttributeDef(String propertyName, String propertyDescription)
      Create an attribute of type boolean
      Parameters:
      propertyName - name of the attribute
      propertyDescription - description of the attribute
      Returns:
      attribute definition
    • getBooleanAttributeDef

      public AtlasAttributeDef getBooleanAttributeDef(String propertyName, String propertyDescription, String applicableEntityTypes)
      Create an attribute of type boolean for a business metadata element.
      Parameters:
      propertyName - name of the attribute
      propertyDescription - description of the attribute
      applicableEntityTypes - list of entity types that this attribute can be attached to
      Returns:
      attribute definition
    • addEntity

      public String addEntity(AtlasEntity entity) throws PropertyServerException
      Add an entity.
      Parameters:
      entity - description of entity
      Returns:
      description of the operation
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • updateEntity

      public AtlasEntityWithExtInfo updateEntity(AtlasEntityWithExtInfo entityWithExtInfo) throws PropertyServerException
      Update an entity's properties.
      Parameters:
      entityWithExtInfo - description of entity and any associated entities
      Returns:
      updated entity
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • addLabelsToEntity

      public void addLabelsToEntity(String entityGUID, List<String> labels) throws PropertyServerException
      Add labels to an entity. This call overrides existing labels.
      Parameters:
      entityGUID - unique identifier of entity and any associated entities
      labels - list of labels to assign to the entity
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • addBusinessMetadataToEntity

      public void addBusinessMetadataToEntity(String entityGUID, String businessMetadataType, Map<String,Object> attributes) throws PropertyServerException
      Add business metadata to an entity. This call overrides specified attributes, leaving the rest intact.
      Parameters:
      entityGUID - unique identifier of entity and any associated entities
      businessMetadataType - name of business metadata type that the attributes are added to
      attributes - map of attribute names to attribute values to assign to the entity
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • deleteEntity

      public AtlasEntityMutationResponse deleteEntity(String entityGUID) throws PropertyServerException
      Delete an entity.
      Parameters:
      entityGUID - unique identifier of entity and any associated entities
      Returns:
      description of the operation
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • getRelationshipByGUID

      public AtlasRelationship getRelationshipByGUID(String guid) throws PropertyServerException
      Retrieve a single relationship by GUID.
      Parameters:
      guid - unique identifier
      Returns:
      description of requested entity
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • addRelationship

      public AtlasRelationship addRelationship(AtlasRelationship atlasRelationship) throws PropertyServerException
      Add a relationship.
      Parameters:
      atlasRelationship - description of relationship
      Returns:
      description of the operation
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • updateRelationship

      public AtlasRelationship updateRelationship(AtlasRelationship atlasRelationship) throws PropertyServerException
      Add a relationship.
      Parameters:
      atlasRelationship - description of relationship
      Returns:
      description of the operation
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • clearRelationship

      public void clearRelationship(String atlasRelationshipGUID) throws PropertyServerException
      Remove a relationship.
      Parameters:
      atlasRelationshipGUID - relationship to delete
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • getEntityByGUID

      public AtlasEntityWithExtInfo getEntityByGUID(String guid) throws PropertyServerException
      Retrieve a single entity by GUID.
      Parameters:
      guid - unique identifier
      Returns:
      description of requested entity
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • getRelatedEntity

      public AtlasEntityWithExtInfo getRelatedEntity(AtlasEntityWithExtInfo startingEntity, String relationshipLabel) throws PropertyServerException
      Retrieve the entity at the other end of the named relationship.
      Parameters:
      startingEntity - entity information detailing the entity proxy for the entity at the far end of a named relationship.
      relationshipLabel - name of relationship to traverse
      Returns:
      description of requested entity
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • getRelationshipGUID

      public String getRelationshipGUID(AtlasEntityWithExtInfo startingEntity, String relationshipLabel) throws PropertyServerException
      Retrieve the named relationship.
      Parameters:
      startingEntity - entity information detailing the entity proxy for the entity at the far end of a named relationship.
      relationshipLabel - name of relationship to traverse
      Returns:
      description of requested entity
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • getRelatedEntity

      public AtlasEntityWithExtInfo getRelatedEntity(AtlasEntity startingEntity, String relationshipLabel) throws PropertyServerException
      Retrieve the entity at the other end of the named relationship.
      Parameters:
      startingEntity - entity information detailing the entity proxy for the entity at the far end of a named relationship.
      relationshipLabel - name of relationship to traverse
      Returns:
      description of requested entity
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • getRelatedEntity

      public AtlasEntityWithExtInfo getRelatedEntity(AtlasEntityHeader startingEntity, String relationshipLabel) throws PropertyServerException
      Retrieve the entity at the other end of the named relationship.
      Parameters:
      startingEntity - entity information detailing the entity proxy for the entity at the far end of a named relationship.
      relationshipLabel - name of relationship to traverse
      Returns:
      description of requested entity
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • getRelationships

      public Map<String,String> getRelationships(AtlasEntityWithExtInfo startingEntity, String relationshipLabel) throws PropertyServerException
      Retrieve the entities at the other end of the named relationship and build a map of the relationships.
      Parameters:
      startingEntity - entity information detailing the entity proxy for the entity at the far end of a named relationship.
      relationshipLabel - name of relationship to traverse
      Returns:
      Map of related entity GUIDs mapped to their relationship GUID
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • getRelatedEntities

      public List<AtlasEntityWithExtInfo> getRelatedEntities(AtlasEntityWithExtInfo startingEntity, String relationshipLabel) throws PropertyServerException
      Retrieve the entities at the other end of the named relationship.
      Parameters:
      startingEntity - entity information detailing the entity proxy for the entity at the far end of a named relationship.
      relationshipLabel - name of relationship to traverse
      Returns:
      list of related entities
      Throws:
      PropertyServerException - problem connecting to Apache Atlas
    • getEntitiesForType

      public List<AtlasEntityHeader> getEntitiesForType(String typeName, int startFrom, int pageSize) throws PropertyServerException
      Return a list of entities that are of the requested type.
      Parameters:
      typeName - name of the type to query
      startFrom - offset to start results
      pageSize - max number of results
      Returns:
      list of matching entities. List may be empty if no matches
      Throws:
      PropertyServerException - problem communicating with Apache Atlas
    • getAtlasGlossary

      public AtlasGlossaryElement getAtlasGlossary(int glossaryCount) throws PropertyServerException
      Return a glossary based on the paging count.
      Parameters:
      glossaryCount - position of the glossary in the paging list.
      Returns:
      glossary or null
      Throws:
      PropertyServerException - problem with the request
    • getAtlasGlossary

      public AtlasGlossaryElement getAtlasGlossary(String glossaryGUID) throws PropertyServerException
      Return a glossary based on its guid.
      Parameters:
      glossaryGUID - unique identifier of the glossary.
      Returns:
      glossary or null
      Throws:
      PropertyServerException - problem with the request
    • createAtlasGlossary

      public String createAtlasGlossary(AtlasGlossaryElement glossary) throws PropertyServerException
      Create a new empty glossary.
      Parameters:
      glossary - glossary to create
      Returns:
      glossaryGUID
      Throws:
      PropertyServerException - problem with the request
    • saveAtlasGlossary

      public AtlasGlossaryElement saveAtlasGlossary(AtlasGlossaryElement glossary) throws PropertyServerException
      Save a glossary with all of its links to terms and categories.
      Parameters:
      glossary - glossary to create/update
      Returns:
      glossary or null
      Throws:
      PropertyServerException - problem with the request
    • deleteAtlasGlossary

      public void deleteAtlasGlossary(AtlasGlossaryElement glossary) throws PropertyServerException
      Delete a glossary with all of its links to terms and categories.
      Parameters:
      glossary - glossary to delete
      Throws:
      PropertyServerException - problem with the request
    • getAtlasGlossaryTerm

      public AtlasGlossaryTermElement getAtlasGlossaryTerm(String glossaryTermGUID) throws PropertyServerException
      Return a glossary term based on its guid.
      Parameters:
      glossaryTermGUID - unique identifier of the glossary term.
      Returns:
      glossary or null
      Throws:
      PropertyServerException - problem with the request
    • createAtlasGlossaryTerm

      public String createAtlasGlossaryTerm(AtlasGlossaryTermElement term) throws PropertyServerException, NameConflictException
      Create a new term linked to its glossary, other terms and categories.
      Parameters:
      term - term to create
      Returns:
      glossaryTermGUID
      Throws:
      PropertyServerException - problem with the request
      NameConflictException - the name supplied clashes with another term
    • saveAtlasGlossaryTerm

      Save a term with all of its links to other terms and categories.
      Parameters:
      term - term to create/update
      Returns:
      term or null
      Throws:
      PropertyServerException - problem with the request
    • deleteAtlasGlossaryTerm

      public void deleteAtlasGlossaryTerm(AtlasGlossaryTermElement term) throws PropertyServerException
      Delete a term with all of its links to other terms and categories.
      Parameters:
      term - term to delete
      Throws:
      PropertyServerException - problem with the request
    • getAtlasGlossaryCategory

      public AtlasGlossaryCategoryElement getAtlasGlossaryCategory(String glossaryCategoryGUID) throws PropertyServerException
      Return a category based on its guid.
      Parameters:
      glossaryCategoryGUID - unique identifier of the category.
      Returns:
      glossary or null
      Throws:
      PropertyServerException - problem with the request
    • createAtlasGlossaryCategory

      public String createAtlasGlossaryCategory(AtlasGlossaryCategoryElement category) throws PropertyServerException, NameConflictException
      Create a new category linked to its glossary and potentially other categories and terms.
      Parameters:
      category - category to create
      Returns:
      glossaryCategoryGUID
      Throws:
      PropertyServerException - problem with the request
      NameConflictException - the name supplied clashes with another term
    • saveAtlasGlossaryCategory

      public AtlasGlossaryCategoryElement saveAtlasGlossaryCategory(AtlasGlossaryCategoryElement category) throws PropertyServerException
      Save a category with all of its links to terms and categories.
      Parameters:
      category - category to create/update
      Returns:
      glossary category or null
      Throws:
      PropertyServerException - problem with the request
    • deleteAtlasGlossaryCategory

      public void deleteAtlasGlossaryCategory(AtlasGlossaryCategoryElement category) throws PropertyServerException
      Delete a category with all of its links to terms and categories.
      Parameters:
      category - category to create/update
      Throws:
      PropertyServerException - problem with the request