Class InvalidParameterHandler

java.lang.Object
org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler

public class InvalidParameterHandler extends Object
InvalidParameterHandler is a common error handler. It provides validation for incoming parameters.
  • Constructor Details

    • InvalidParameterHandler

      public InvalidParameterHandler()
      Default constructor
  • Method Details

    • 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(String omagServerPlatformURL, 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(String omagServerPlatformURL, String serverName, 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(String userId, 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(String guid, String guidParameter, 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(String name, String nameParameter, 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(String searchString, String searchParameter, 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(Object object, String nameParameter, 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(Object enumValue, String parameterName, 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(String text, String parameterName, 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, 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(List<String> stringArray, String parameterName, 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(String anchorGUID, String anchorGUIDParameterName, EntityDetail anchorEntity, String elementGUID, String elementTypeName, 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, String parameterName, 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
    • validateTypeDefName

      public TypeDef validateTypeDefName(String typeName, String superTypeName, String serviceName, 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
    • validateTypeName

      public String validateTypeName(String typeName, String superTypeName, String serviceName, 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(String guid, String methodName, String actualType, 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(String instanceGUID, String parameterName, ElementBase instanceHeader, ElementOriginCategory expectedOriginCategory, String expectedMetadataCollectionGUID, String expectedMetadataCollectionName, String serviceName, 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(String assetGUID, String parameterName, List<String> assetZones, List<String> supportedZones, String serviceName, 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(String userId, String serviceName, String serverName, 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(String userId, String guid, String type, String serviceName, String serverName, 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
    • throwUnknownElementQualifiedName

      public void throwUnknownElementQualifiedName(String userId, String qualifiedName, String type, String serviceName, String serverName, 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
      qualifiedName - unique name 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(String uniqueName, String uniqueNameParameterName, String typeName, String serviceName, 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(String guid, String type, String serviceName, 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