Class InvalidParameterHandler
java.lang.Object
org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler
InvalidParameterHandler is a common error handler. It provides validation for incoming parameters.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Get the maximum paging size.void
handleWrongTypeForGUIDException
(String guid, String methodName, String actualType, String expectedType) Throw an exception if the supplied guid returned an instance of the wrong typevoid
setMaxPagingSize
(int maxPagingSize) Override the default maximum paging size.void
throwCannotDeleteElementInUse
(String guid, String type, String serviceName, String methodName) Throw an exception to indicate that the call to a method is not supported.void
throwMethodNotSupported
(String userId, String serviceName, String serverName, String methodName) Throw an exception to indicate that the call to a method is not supported.void
throwUniqueNameInUse
(String uniqueName, String uniqueNameParameterName, String typeName, String serviceName, 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
(String userId, String guid, String type, String serviceName, String serverName, String methodName) Throw an exception to indicate that the requested element is not recognized.void
throwUnknownElementQualifiedName
(String userId, String qualifiedName, String type, String serviceName, String serverName, String methodName) Throw an exception to indicate that the requested element is not recognized.void
validateAnchorGUID
(String anchorGUID, String anchorGUIDParameterName, EntityDetail anchorEntity, String elementGUID, String elementTypeName, 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
(String assetGUID, String parameterName, List<String> assetZones, List<String> supportedZones, String serviceName, String methodName) Compare the supported zones with the zones stored in the asset.void
validateConnection
(Connection connection, String parameterName, String methodName) Throw an exception if the supplied connection is nullvoid
validateEnum
(Object enumValue, String parameterName, String methodName) Throw an exception if the supplied enum is nullvoid
validateGUID
(String guid, String guidParameter, String methodName) Throw an exception if the supplied GUID is nullvoid
validateInstanceProvenanceForUpdate
(String instanceGUID, String parameterName, ElementBase instanceHeader, ElementOriginCategory expectedOriginCategory, String expectedMetadataCollectionGUID, String expectedMetadataCollectionName, String serviceName, String methodName) Validate that an instance is from the expected metadata collection.void
validateName
(String name, String nameParameter, String methodName) Throw an exception if the supplied name is nullvoid
validateObject
(Object object, String nameParameter, String methodName) Throw an exception if the supplied object is nullvoid
validateOMAGServerPlatformURL
(String omagServerPlatformURL, String methodName) Throw an exception if a server URL or has not been supplied.void
validateOMAGServerPlatformURL
(String omagServerPlatformURL, String serverName, String methodName) Throw an exception if a server URL or has not been supplied.int
validatePaging
(int startFrom, int pageSize, String methodName) Throw an exception if the supplied paging values don't make sense.void
validateSearchString
(String searchString, String searchParameter, String methodName) Throw an exception if the supplied search string is nullvoid
validateStringArray
(List<String> stringArray, String parameterName, String methodName) Throw an exception if the supplied array is null or emptyvoid
validateText
(String text, String parameterName, String methodName) Throw an exception if the supplied text field is nullvalidateTypeDefName
(String typeName, String superTypeName, String serviceName, String methodName, OMRSRepositoryHelper repositoryHelper) Throw an exception if the supplied type name is not of the correct subclassvalidateTypeName
(String typeName, String superTypeName, String serviceName, String methodName, OMRSRepositoryHelper repositoryHelper) Throw an exception if the supplied type name is not of the correct subclassvoid
validateUserId
(String userId, String methodName) Throw an exception if the supplied userId is null
-
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 servermethodName
- 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 serverserverName
- requested servermethodName
- name of the method making the call.- Throws:
InvalidParameterException
- the server URL or server name are not set
-
validateUserId
Throw an exception if the supplied userId is null- Parameters:
userId
- user name to validatemethodName
- 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 validateguidParameter
- 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 validatenameParameter
- 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 validatesearchParameter
- 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 validatenameParameter
- 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 validateparameterName
- 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 validateparameterName
- 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 validateparameterName
- 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 anchoranchorGUIDParameterName
- parameter name used to supply anchorGUIDanchorEntity
- current setting for the anchorelementGUID
- unique identifier of the element being retrievedelementTypeName
- type of element being retrievedmethodName
- 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 validateparameterName
- 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 typesuperTypeName
- name of expected supertype (or null if no super type)serviceName
- calling servicemethodName
- calling methodrepositoryHelper
- 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 typesuperTypeName
- name of expected supertype (or null if no super type)serviceName
- calling servicemethodName
- calling methodrepositoryHelper
- 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 instancemethodName
- name of the method making the call.actualType
- type of retrieved instanceexpectedType
- 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 instanceparameterName
- name of the parameter tha supplied the instanceinstanceHeader
- header of the instanceexpectedOriginCategory
- expected origin (defined by the type of API) - null means anyexpectedMetadataCollectionGUID
- unique identifier of expected metadata collection id - null means anyexpectedMetadataCollectionName
- unique name of expected metadata collection id - used for error loggingserviceName
- name of calling servicemethodName
- 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 assetparameterName
- name of the parameter that passed the asset guidassetZones
- list of zone names from the assetsupportedZones
- list of zone names supported by the serviceserviceName
- calling servicemethodName
- 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 validateserviceName
- name of called serviceserverName
- name of this servermethodName
- 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 validateguid
- unique identifier of elementtype
- type of elementserviceName
- name of called serviceserverName
- name of this servermethodName
- 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 validatequalifiedName
- unique name of elementtype
- type of elementserviceName
- name of called serviceserverName
- name of this servermethodName
- 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 erroruniqueNameParameterName
- parameter that passed the qualified nametypeName
- requested type nameserviceName
- calling servicemethodName
- 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 elementtype
- type of elementserviceName
- name of called servicemethodName
- name of the called method.- Throws:
InvalidParameterException
- the guid is in use
-