Class InvalidParameterHandler


  • public class InvalidParameterHandler
    extends java.lang.Object
    InvalidParameterHandler is a common error handler. It provides validation for incoming parameters.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getMaxPagingSize()
      Get the maximum paging size.
      void handleWrongTypeForGUIDException​(java.lang.String guid, java.lang.String methodName, java.lang.String actualType, java.lang.String expectedType)
      Throw an exception if the supplied guid returned an instance of the wrong type
      void setMaxPagingSize​(int maxPagingSize)
      Override the default maximum paging size.
      void throwCannotDeleteElementInUse​(java.lang.String guid, java.lang.String type, java.lang.String serviceName, java.lang.String methodName)
      Throw an exception to indicate that the call to a method is not supported.
      void throwMethodNotSupported​(java.lang.String userId, java.lang.String serviceName, java.lang.String serverName, java.lang.String methodName)
      Throw an exception to indicate that the call to a method is not supported.
      void throwUniqueNameInUse​(java.lang.String uniqueName, java.lang.String uniqueNameParameterName, java.lang.String typeName, java.lang.String serviceName, java.lang.String methodName)
      Report the fact that a unique name that was requested for a new entity is already in use or not a permitted value.
      void throwUnknownElement​(java.lang.String userId, java.lang.String guid, java.lang.String type, java.lang.String serviceName, java.lang.String serverName, java.lang.String methodName)
      Throw an exception to indicate that the requested element is not recognized.
      void validateAnchorGUID​(java.lang.String anchorGUID, java.lang.String anchorGUIDParameterName, org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail anchorEntity, java.lang.String elementGUID, java.lang.String elementTypeName, java.lang.String methodName)
      When attached elements are being retrieved for an anchor, this method checks that the anchor is set up correctly in the element's anchors classification.
      void validateAssetInSupportedZone​(java.lang.String assetGUID, java.lang.String parameterName, java.util.List<java.lang.String> assetZones, java.util.List<java.lang.String> supportedZones, java.lang.String serviceName, java.lang.String methodName)
      Compare the supported zones with the zones stored in the asset.
      void validateConnection​(Connection connection, java.lang.String parameterName, java.lang.String methodName)
      Throw an exception if the supplied connection is null
      void validateEnum​(java.lang.Object enumValue, java.lang.String parameterName, java.lang.String methodName)
      Throw an exception if the supplied enum is null
      void validateGUID​(java.lang.String guid, java.lang.String guidParameter, java.lang.String methodName)
      Throw an exception if the supplied GUID is null
      void validateInstanceProvenanceForUpdate​(java.lang.String instanceGUID, java.lang.String parameterName, ElementBase instanceHeader, ElementOriginCategory expectedOriginCategory, java.lang.String expectedMetadataCollectionGUID, java.lang.String expectedMetadataCollectionName, java.lang.String serviceName, java.lang.String methodName)
      Validate that an instance is from the expected metadata collection.
      void validateName​(java.lang.String name, java.lang.String nameParameter, java.lang.String methodName)
      Throw an exception if the supplied name is null
      void validateObject​(java.lang.Object object, java.lang.String nameParameter, java.lang.String methodName)
      Throw an exception if the supplied object is null
      void validateOMAGServerPlatformURL​(java.lang.String omagServerPlatformURL, java.lang.String methodName)
      Throw an exception if a server URL or has not been supplied.
      void validateOMAGServerPlatformURL​(java.lang.String omagServerPlatformURL, java.lang.String serverName, java.lang.String methodName)
      Throw an exception if a server URL or has not been supplied.
      int validatePaging​(int startFrom, int pageSize, java.lang.String methodName)
      Throw an exception if the supplied paging values don't make sense.
      void validateSearchString​(java.lang.String searchString, java.lang.String searchParameter, java.lang.String methodName)
      Throw an exception if the supplied search string is null
      void validateStringArray​(java.util.List<java.lang.String> stringArray, java.lang.String parameterName, java.lang.String methodName)
      Throw an exception if the supplied array is null or empty
      void validateText​(java.lang.String text, java.lang.String parameterName, java.lang.String methodName)
      Throw an exception if the supplied text field is null
      java.lang.String validateTypeName​(java.lang.String typeName, java.lang.String superTypeName, java.lang.String serviceName, java.lang.String methodName, OMRSRepositoryHelper repositoryHelper)
      Throw an exception if the supplied type name is not of the correct subclass
      void validateUserId​(java.lang.String userId, java.lang.String methodName)
      Throw an exception if the supplied userId is null
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InvalidParameterHandler

        public InvalidParameterHandler()
        Default constructor
    • Method Detail

      • setMaxPagingSize

        public void setMaxPagingSize​(int maxPagingSize)
        Override the default maximum paging size. Zero means no paging limit.
        Parameters:
        maxPagingSize - new value
      • getMaxPagingSize

        public int getMaxPagingSize()
        Get the maximum paging size.
        Returns:
        maxPagingSize new value
      • validateOMAGServerPlatformURL

        public void validateOMAGServerPlatformURL​(java.lang.String omagServerPlatformURL,
                                                  java.lang.String methodName)
                                           throws InvalidParameterException
        Throw an exception if a server URL or has not been supplied. It is typically used in OMAG Clients or OMAG Servers that call other OMAG Servers.
        Parameters:
        omagServerPlatformURL - url of the server
        methodName - name of the method making the call.
        Throws:
        InvalidParameterException - the server URL or server name are not set
      • validateOMAGServerPlatformURL

        public void validateOMAGServerPlatformURL​(java.lang.String omagServerPlatformURL,
                                                  java.lang.String serverName,
                                                  java.lang.String methodName)
                                           throws InvalidParameterException
        Throw an exception if a server URL or has not been supplied. It is typically used in OMAG Clients or OMAG Servers that call other OMAG Servers.
        Parameters:
        omagServerPlatformURL - url of the server
        serverName - requested server
        methodName - name of the method making the call.
        Throws:
        InvalidParameterException - the server URL or server name are not set
      • validateUserId

        public void validateUserId​(java.lang.String userId,
                                   java.lang.String methodName)
                            throws InvalidParameterException
        Throw an exception if the supplied userId is null
        Parameters:
        userId - user name to validate
        methodName - name of the method making the call.
        Throws:
        InvalidParameterException - the userId is null
      • validateGUID

        public void validateGUID​(java.lang.String guid,
                                 java.lang.String guidParameter,
                                 java.lang.String methodName)
                          throws InvalidParameterException
        Throw an exception if the supplied GUID is null
        Parameters:
        guid - unique identifier to validate
        guidParameter - name of the parameter that passed the guid.
        methodName - name of the method making the call.
        Throws:
        InvalidParameterException - the guid is null
      • validateName

        public void validateName​(java.lang.String name,
                                 java.lang.String nameParameter,
                                 java.lang.String methodName)
                          throws InvalidParameterException
        Throw an exception if the supplied name is null
        Parameters:
        name - unique name to validate
        nameParameter - name of the parameter that passed the name.
        methodName - name of the method making the call.
        Throws:
        InvalidParameterException - the name is null
      • validateSearchString

        public void validateSearchString​(java.lang.String searchString,
                                         java.lang.String searchParameter,
                                         java.lang.String methodName)
                                  throws InvalidParameterException
        Throw an exception if the supplied search string is null
        Parameters:
        searchString - searchString to validate
        searchParameter - name of the parameter that passed the searchString.
        methodName - name of the method making the call.
        Throws:
        InvalidParameterException - the searchString is null
      • validateObject

        public void validateObject​(java.lang.Object object,
                                   java.lang.String nameParameter,
                                   java.lang.String methodName)
                            throws InvalidParameterException
        Throw an exception if the supplied object is null
        Parameters:
        object - object to validate
        nameParameter - name of the parameter that passed the object.
        methodName - name of the method making the call.
        Throws:
        InvalidParameterException - the object is null
      • validateEnum

        public void validateEnum​(java.lang.Object enumValue,
                                 java.lang.String parameterName,
                                 java.lang.String methodName)
                          throws InvalidParameterException
        Throw an exception if the supplied enum is null
        Parameters:
        enumValue - enum value to validate
        parameterName - name of the parameter that passed the enum.
        methodName - name of the method making the call.
        Throws:
        InvalidParameterException - the enum is null
      • validateText

        public void validateText​(java.lang.String text,
                                 java.lang.String parameterName,
                                 java.lang.String methodName)
                          throws InvalidParameterException
        Throw an exception if the supplied text field is null
        Parameters:
        text - unique name to validate
        parameterName - name of the parameter that passed the name.
        methodName - name of the method making the call.
        Throws:
        InvalidParameterException - the text is null
      • validatePaging

        public int validatePaging​(int startFrom,
                                  int pageSize,
                                  java.lang.String methodName)
                           throws InvalidParameterException
        Throw an exception if the supplied paging values don't make sense. If page size is zero it means return as much as there is. in which case this method sets the page size to the maximum value for this server. If the server has its max page size set to zero then zero is used.
        Parameters:
        startFrom - index of the list ot start from (0 for start)
        pageSize - maximum number of elements to return.
        methodName - name of the method making the call.
        Returns:
        validated page size.
        Throws:
        InvalidParameterException - the paging options are incorrect
      • validateStringArray

        public void validateStringArray​(java.util.List<java.lang.String> stringArray,
                                        java.lang.String parameterName,
                                        java.lang.String methodName)
                                 throws InvalidParameterException
        Throw an exception if the supplied array is null or empty
        Parameters:
        stringArray - object to validate
        parameterName - name of the parameter that passed the array.
        methodName - name of the method making the call.
        Throws:
        InvalidParameterException - the array is null or empty
      • validateAnchorGUID

        public void validateAnchorGUID​(java.lang.String anchorGUID,
                                       java.lang.String anchorGUIDParameterName,
                                       org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail anchorEntity,
                                       java.lang.String elementGUID,
                                       java.lang.String elementTypeName,
                                       java.lang.String methodName)
                                throws InvalidParameterException
        When attached elements are being retrieved for an anchor, this method checks that the anchor is set up correctly in the element's anchors classification.
        Parameters:
        anchorGUID - unique identifier of the expected anchor
        anchorGUIDParameterName - parameter name used to supply anchorGUID
        anchorEntity - current setting for the anchor
        elementGUID - unique identifier of the element being retrieved
        elementTypeName - type of element being retrieved
        methodName - calling method
        Throws:
        InvalidParameterException - exception raise when the anchors do not match
      • validateConnection

        public void validateConnection​(Connection connection,
                                       java.lang.String parameterName,
                                       java.lang.String methodName)
                                throws InvalidParameterException
        Throw an exception if the supplied connection is null
        Parameters:
        connection - object to validate
        parameterName - name of the parameter that passed the connection.
        methodName - name of the method making the call.
        Throws:
        InvalidParameterException - the connection is null
      • validateTypeName

        public java.lang.String validateTypeName​(java.lang.String typeName,
                                                 java.lang.String superTypeName,
                                                 java.lang.String serviceName,
                                                 java.lang.String methodName,
                                                 OMRSRepositoryHelper repositoryHelper)
                                          throws InvalidParameterException
        Throw an exception if the supplied type name is not of the correct subclass
        Parameters:
        typeName - name of type
        superTypeName - name of expected supertype (or null if no super type)
        serviceName - calling service
        methodName - calling method
        repositoryHelper - helper class that can return information about type
        Returns:
        unique identifier (guid) of typeName
        Throws:
        InvalidParameterException - the type name is not correct
      • handleWrongTypeForGUIDException

        public void handleWrongTypeForGUIDException​(java.lang.String guid,
                                                    java.lang.String methodName,
                                                    java.lang.String actualType,
                                                    java.lang.String expectedType)
                                             throws InvalidParameterException
        Throw an exception if the supplied guid returned an instance of the wrong type
        Parameters:
        guid - unique identifier of instance
        methodName - name of the method making the call.
        actualType - type of retrieved instance
        expectedType - type the instance should be
        Throws:
        InvalidParameterException - the guid is for the wrong type of object
      • validateInstanceProvenanceForUpdate

        public void validateInstanceProvenanceForUpdate​(java.lang.String instanceGUID,
                                                        java.lang.String parameterName,
                                                        ElementBase instanceHeader,
                                                        ElementOriginCategory expectedOriginCategory,
                                                        java.lang.String expectedMetadataCollectionGUID,
                                                        java.lang.String expectedMetadataCollectionName,
                                                        java.lang.String serviceName,
                                                        java.lang.String methodName)
                                                 throws InvalidParameterException
        Validate that an instance is from the expected metadata collection.
        Parameters:
        instanceGUID - unique identifier of the instance
        parameterName - name of the parameter tha supplied the instance
        instanceHeader - header of the instance
        expectedOriginCategory - expected origin (defined by the type of API) - null means any
        expectedMetadataCollectionGUID - unique identifier of expected metadata collection id - null means any
        expectedMetadataCollectionName - unique name of expected metadata collection id - used for error logging
        serviceName - name of calling service
        methodName - name of calling method
        Throws:
        InvalidParameterException - the metadata collection id or origin is not correct
      • validateAssetInSupportedZone

        public void validateAssetInSupportedZone​(java.lang.String assetGUID,
                                                 java.lang.String parameterName,
                                                 java.util.List<java.lang.String> assetZones,
                                                 java.util.List<java.lang.String> supportedZones,
                                                 java.lang.String serviceName,
                                                 java.lang.String methodName)
                                          throws InvalidParameterException
        Compare the supported zones with the zones stored in the asset. If the asset is not in one of the supported zones then throw an exception. Otherwise, return ok. Null values in either returns ok. Note the error message implies that the asset does not exist. This is because the consequence of not being in the supported zone is that the asset is invisible - just like it does not exist.
        Parameters:
        assetGUID - unique identifier of the asset
        parameterName - name of the parameter that passed the asset guid
        assetZones - list of zone names from the asset
        supportedZones - list of zone names supported by the service
        serviceName - calling service
        methodName - calling method
        Throws:
        InvalidParameterException - the asset is not in the supported zone.
      • throwMethodNotSupported

        public void throwMethodNotSupported​(java.lang.String userId,
                                            java.lang.String serviceName,
                                            java.lang.String serverName,
                                            java.lang.String methodName)
                                     throws InvalidParameterException
        Throw an exception to indicate that the call to a method is not supported. This is a temporary situation.
        Parameters:
        userId - user name to validate
        serviceName - name of called service
        serverName - name of this server
        methodName - name of the called method.
        Throws:
        InvalidParameterException - the method is not supported
      • throwUnknownElement

        public void throwUnknownElement​(java.lang.String userId,
                                        java.lang.String guid,
                                        java.lang.String type,
                                        java.lang.String serviceName,
                                        java.lang.String serverName,
                                        java.lang.String methodName)
                                 throws InvalidParameterException
        Throw an exception to indicate that the requested element is not recognized. This is probably due to the types of metadata repositories that this server is connected to.
        Parameters:
        userId - user name to validate
        guid - unique identifier of element
        type - type of element
        serviceName - name of called service
        serverName - name of this server
        methodName - name of the called method.
        Throws:
        InvalidParameterException - the element is not known
      • throwUniqueNameInUse

        public void throwUniqueNameInUse​(java.lang.String uniqueName,
                                         java.lang.String uniqueNameParameterName,
                                         java.lang.String typeName,
                                         java.lang.String serviceName,
                                         java.lang.String methodName)
                                  throws InvalidParameterException
        Report the fact that a unique name that was requested for a new entity is already in use or not a permitted value.
        Parameters:
        uniqueName - value of unique parameter that is in error
        uniqueNameParameterName - parameter that passed the qualified name
        typeName - requested type name
        serviceName - calling service
        methodName - calling method
        Throws:
        InvalidParameterException - the unique name is in use
      • throwCannotDeleteElementInUse

        public void throwCannotDeleteElementInUse​(java.lang.String guid,
                                                  java.lang.String type,
                                                  java.lang.String serviceName,
                                                  java.lang.String methodName)
                                           throws InvalidParameterException
        Throw an exception to indicate that the call to a method is not supported. This is a temporary situation.
        Parameters:
        guid - unique identifier of element
        type - type of element
        serviceName - name of called service
        methodName - name of the called method.
        Throws:
        InvalidParameterException - the guid is in use