Class TxnValidations


  • public class TxnValidations
    extends Object
    Common validations to use within transaction functions.
    • Constructor Summary

      Constructors 
      Constructor Description
      TxnValidations()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void classification​(String classificationName, String entityTypeName, String className, String methodName)
      Validate that a classification is valid for the entity.
      static void classificationList​(clojure.lang.IPersistentMap instance, String entityTypeName, String className, String methodName)
      Validate that a classification is valid for the entity.
      static void classificationProperties​(String classificationName, org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties classificationProperties, String className, String methodName)
      Validate that a classification is valid for the entity.
      static void entityFromStore​(String guid, clojure.lang.IPersistentMap entity, String className, String methodName)
      Verify that an entity has been successfully retrieved from the repository and has valid contents.
      static void instanceCanBeUpdated​(clojure.lang.IPersistentMap instance, String guid, String metadataCollectionId, String className, String methodName)
      Verify that a metadata instance can be updated by the metadataCollection.
      static void instanceCanBeUpdated​(clojure.lang.IPersistentMap instance, String guid, String metadataCollectionId, String classificationName, String className, String methodName)
      Verify that a metadata instance can be updated by the metadataCollection.
      static void instanceIsDeleted​(clojure.lang.IPersistentMap existing, String instanceGUID, String className, String methodName)
      Validates that the provided metadata instance is in a soft-deleted state.
      static void instanceIsNotDeleted​(clojure.lang.IPersistentMap existing, String instanceGUID, String className, String methodName)
      Validates that the provided metadata instance is not in a deleted state.
      static void instanceStatus​(Integer instanceStatus, org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDef typeDef, String className, String methodName)
      Validates an instance status where null is permissible.
      static void instanceType​(clojure.lang.IPersistentMap instance, String className, String methodName)
      Verify that the instance retrieved from the repository has a valid instance type.
      static void nonProxyEntity​(clojure.lang.IPersistentMap existing, String entityGUID, String className, String methodName)
      Validates that the provided entity is not only an EntityProxy.
      static void propertiesForType​(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDef typeDef, org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties properties, String className, String methodName)
      Validate that the properties for a metadata instance match its TypeDef.
      static void relationshipEnds​(String entityOneGUID, String entityTwoGUID, clojure.lang.IPersistentMap entityOneProxy, clojure.lang.IPersistentMap entityTwoProxy, String typeDefGUID, String className, String methodName)
      Validate that the types of the two ends of a relationship match the relationship's TypeDef.
      static void relationshipFromStore​(String guid, clojure.lang.IPersistentMap relationship, String className, String methodName)
      Verify that a relationship has been successfully retrieved from the repository and has valid contents.
      static void requiredProperty​(String guid, String propertyName, Object propertyValue, String className, String methodName)
      Validates an instance status where null is not allowed.
    • Constructor Detail

      • TxnValidations

        public TxnValidations()
    • Method Detail

      • entityFromStore

        public static void entityFromStore​(String guid,
                                           clojure.lang.IPersistentMap entity,
                                           String className,
                                           String methodName)
                                    throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException,
                                           org.odpi.openmetadata.repositoryservices.ffdc.exception.EntityNotKnownException
        Verify that an entity has been successfully retrieved from the repository and has valid contents.
        Parameters:
        guid - unique identifier used to retrieve the entity
        entity - the retrieved entity (or null)
        className - doing the validation
        methodName - method receiving the call
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.EntityNotKnownException - No entity found
        org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException - logic error in the repository corrupted instance
      • relationshipFromStore

        public static void relationshipFromStore​(String guid,
                                                 clojure.lang.IPersistentMap relationship,
                                                 String className,
                                                 String methodName)
                                          throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException,
                                                 org.odpi.openmetadata.repositoryservices.ffdc.exception.RelationshipNotKnownException
        Verify that a relationship has been successfully retrieved from the repository and has valid contents.
        Parameters:
        guid - unique identifier used to retrieve the entity
        relationship - the retrieved relationship (or null)
        className - doing the validation
        methodName - method receiving the call
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.RelationshipNotKnownException - No relationship found
        org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException - logic error in the repository corrupted instance
      • classification

        public static void classification​(String classificationName,
                                          String entityTypeName,
                                          String className,
                                          String methodName)
                                   throws org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException,
                                          org.odpi.openmetadata.repositoryservices.ffdc.exception.ClassificationErrorException
        Validate that a classification is valid for the entity.
        Parameters:
        classificationName - unique name for a classification type
        entityTypeName - name of entity type
        className - doing the validation
        methodName - method receiving the call
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException - classification name is null
        org.odpi.openmetadata.repositoryservices.ffdc.exception.ClassificationErrorException - the classification is invalid for this entity
      • instanceIsNotDeleted

        public static void instanceIsNotDeleted​(clojure.lang.IPersistentMap existing,
                                                String instanceGUID,
                                                String className,
                                                String methodName)
                                         throws org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException
        Validates that the provided metadata instance is not in a deleted state.
        Parameters:
        existing - metadata instance
        instanceGUID - of the instance
        className - doing the validation
        methodName - doing the validation
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException - if the provided metadata instance is already in a deleted state
      • instanceIsDeleted

        public static void instanceIsDeleted​(clojure.lang.IPersistentMap existing,
                                             String instanceGUID,
                                             String className,
                                             String methodName)
                                      throws org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException
        Validates that the provided metadata instance is in a soft-deleted state.
        Parameters:
        existing - metadata instance
        instanceGUID - of the instance
        className - doing the validation
        methodName - doing the validation
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException - if the provided metadata instance is not in a deleted state
      • nonProxyEntity

        public static void nonProxyEntity​(clojure.lang.IPersistentMap existing,
                                          String entityGUID,
                                          String className,
                                          String methodName)
                                   throws org.odpi.openmetadata.repositoryservices.ffdc.exception.EntityNotKnownException
        Validates that the provided entity is not only an EntityProxy.
        Parameters:
        existing - entity to check
        entityGUID - of the entity
        className - doing the validation
        methodName - doing the validation
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.EntityNotKnownException - if the provided entity is only an EntityProxy
      • instanceCanBeUpdated

        public static void instanceCanBeUpdated​(clojure.lang.IPersistentMap instance,
                                                String guid,
                                                String metadataCollectionId,
                                                String className,
                                                String methodName)
                                         throws org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException
        Verify that a metadata instance can be updated by the metadataCollection. The caller can update a metadata instance provided: the instance is locally homed (matching metadataCollectionId) OR the instance has instanceProvenanceType set to external and replicatedBy is set to the local metadataCollectionId. Any other combination suggests that this is either a reference copy of an instance from the local cohort or a reference copy of an external entity (and something else is responsible for its replication): in these cases we are not permitted to update the metadata instance and will instead throw an InvalidParameterException.
        Parameters:
        instance - instance to validate
        guid - unique identifier for the metadata instance being updated
        metadataCollectionId - unique identifier for the metadata collection
        className - name of the calling class
        methodName - name of calling method
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException - the instance cannot be updated due to its status or metadataCollectionId
      • instanceCanBeUpdated

        public static void instanceCanBeUpdated​(clojure.lang.IPersistentMap instance,
                                                String guid,
                                                String metadataCollectionId,
                                                String classificationName,
                                                String className,
                                                String methodName)
                                         throws org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException
        Verify that a metadata instance can be updated by the metadataCollection. The caller can update a metadata instance provided: the instance is locally homed (matching metadataCollectionId) OR the instance has instanceProvenanceType set to external and replicatedBy is set to the local metadataCollectionId. Any other combination suggests that this is either a reference copy of an instance from the local cohort or a reference copy of an external entity (and something else is responsible for its replication): in these cases we are not permitted to update the metadata instance and will instead throw an InvalidParameterException.
        Parameters:
        instance - instance to validate
        guid - unique identifier for the metadata instance being updated
        metadataCollectionId - unique identifier for the metadata collection
        classificationName - of the classification to be updated (or null if only the base instance)
        className - name of the calling class
        methodName - name of calling method
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException - the instance cannot be updated due to its status or metadataCollectionId
      • requiredProperty

        public static void requiredProperty​(String guid,
                                            String propertyName,
                                            Object propertyValue,
                                            String className,
                                            String methodName)
                                     throws org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException
        Validates an instance status where null is not allowed.
        Parameters:
        guid - unique identifier for the metadata instance being updated
        propertyName - name of the required property
        propertyValue - value of the required property
        className - class called
        methodName - method called
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException - invalid parameter
      • instanceType

        public static void instanceType​(clojure.lang.IPersistentMap instance,
                                        String className,
                                        String methodName)
                                 throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException,
                                        IOException
        Verify that the instance retrieved from the repository has a valid instance type.
        Parameters:
        instance - the retrieved instance
        className - calling class
        methodName - calling method
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException - logic error in the repository corrupted instance
        IOException - on any error deserializing the type information
      • instanceStatus

        public static void instanceStatus​(Integer instanceStatus,
                                          org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDef typeDef,
                                          String className,
                                          String methodName)
                                   throws org.odpi.openmetadata.repositoryservices.ffdc.exception.StatusNotSupportedException
        Validates an instance status where null is permissible.
        Parameters:
        instanceStatus - initial status value
        typeDef - type of the instance
        className - calling class
        methodName - method called
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.StatusNotSupportedException - the initial status is invalid for this type
      • classificationProperties

        public static void classificationProperties​(String classificationName,
                                                    org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties classificationProperties,
                                                    String className,
                                                    String methodName)
                                             throws org.odpi.openmetadata.repositoryservices.ffdc.exception.PropertyErrorException,
                                                    org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException
        Validate that a classification is valid for the entity.
        Parameters:
        classificationName - unique name for a classification type
        classificationProperties - properties to test
        className - calling class
        methodName - method receiving the call
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.PropertyErrorException - classification name is null
        org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException - on any other error
      • classificationList

        public static void classificationList​(clojure.lang.IPersistentMap instance,
                                              String entityTypeName,
                                              String className,
                                              String methodName)
                                       throws org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException,
                                              org.odpi.openmetadata.repositoryservices.ffdc.exception.ClassificationErrorException,
                                              org.odpi.openmetadata.repositoryservices.ffdc.exception.PropertyErrorException,
                                              org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException,
                                              IOException
        Validate that a classification is valid for the entity.
        Parameters:
        instance - metadata instance with classifications
        entityTypeName - name of entity type
        className - calling class
        methodName - method receiving the call
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException - classification name is null
        org.odpi.openmetadata.repositoryservices.ffdc.exception.ClassificationErrorException - the classification is invalid for this entity
        org.odpi.openmetadata.repositoryservices.ffdc.exception.PropertyErrorException - the classification's properties are invalid for its type
        IOException - on any error deserializing values
        org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException - on any other error
      • propertiesForType

        public static void propertiesForType​(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDef typeDef,
                                             org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties properties,
                                             String className,
                                             String methodName)
                                      throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException,
                                             org.odpi.openmetadata.repositoryservices.ffdc.exception.PropertyErrorException
        Validate that the properties for a metadata instance match its TypeDef.
        Parameters:
        typeDef - type information to validate against
        properties - proposed properties for instance
        className - calling class
        methodName - method receiving the call
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.PropertyErrorException - invalid property
        org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException - on any other error
      • relationshipEnds

        public static void relationshipEnds​(String entityOneGUID,
                                            String entityTwoGUID,
                                            clojure.lang.IPersistentMap entityOneProxy,
                                            clojure.lang.IPersistentMap entityTwoProxy,
                                            String typeDefGUID,
                                            String className,
                                            String methodName)
                                     throws org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException,
                                            org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException
        Validate that the types of the two ends of a relationship match the relationship's TypeDef.
        Parameters:
        entityOneGUID - unique identifier of end one
        entityTwoGUID - unique identifier of end two
        entityOneProxy - content of end one
        entityTwoProxy - content of end two
        typeDefGUID - typeDefGUID for the relationship
        className - of the calling class
        methodName - of the calling method
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException - types do not align
        org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException - on any other error