Class RESTExceptionHandler
java.lang.Object
org.odpi.openmetadata.commonservices.ffdc.RESTExceptionHandler
- Direct Known Subclasses:
AdminClientRESTExceptionHandler
,OMAGServerExceptionHandler
,RESTExceptionHandler
RESTExceptionHandler converts standard exceptions to REST responses. These responses ensure exception objects
(with their stack traces) are not serialized over REST APIs.
This class does use developer logging (SLF4J) for components that are not mature enough to have implemented
FFDC. For mature components, this logging is superfluous.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
captureCheckedException
(FFDCResponse response, OCFCheckedExceptionBase error, String exceptionClassName) Set the exception information into the response.protected void
captureCheckedException
(FFDCResponse response, OCFCheckedExceptionBase error, String exceptionClassName, Map<String, Object> exceptionProperties) Set the exception information into the response.void
captureExceptions
(FFDCResponse response, Exception error, String methodName) Set the exception information into the response.void
captureExceptions
(FFDCResponse response, Exception error, String methodName, AuditLog auditLog) Set the exception information into the response.void
captureInvalidParameterException
(FFDCResponse response, InvalidParameterException error) Set the exception information into the response.void
capturePropertyServerException
(FFDCResponse response, PropertyServerException error) Set the exception information into the response.void
captureUserNotAuthorizedException
(FFDCResponse response, UserNotAuthorizedException error) Set the exception information into the response.void
detectAndThrowInvalidParameterException
(String methodName, FFDCResponseBase restResult) Deprecated.void
detectAndThrowInvalidParameterException
(FFDCResponse restResult) Throw an InvalidParameterException if it is encoded in the REST response.void
detectAndThrowPropertyServerException
(String methodName, FFDCResponseBase restResult) Deprecated.void
detectAndThrowPropertyServerException
(FFDCResponse restResult) Throw a PropertyServerException if it is encoded in the REST response.void
detectAndThrowStandardExceptions
(String methodName, FFDCResponse restResult) Throw an exception if it is encoded in the REST response.void
detectAndThrowUserNotAuthorizedException
(String methodName, FFDCResponseBase restResult) Deprecated.void
detectAndThrowUserNotAuthorizedException
(FFDCResponse restResult) Throw an UserNotAuthorizedException if it is encoded in the REST response.void
handleBadType
(String subTypeName, String superTypeName, String serviceName, String methodName) Manage a bad type namevoid
handleInvalidCallToServer
(String expectedClassName, String methodName, String serverGUID, String actualClassName) Manage an unexpected exceptionvoid
handleInvalidPropertiesObject
(String expectedClassName, String methodName) Manage an unexpected exceptionvoid
handleMissingValue
(String parameterName, String methodName) Manage an unexpected exceptionvoid
handleNoRequestBody
(String userId, String methodName, String serverName) Manage an unexpected exceptionvoid
handleNoRequestBody
(String userId, String methodName, String serverName, String className) Manage an unexpected exceptionvoid
handleUnexpectedException
(Throwable error, String methodName, String serverName, String serverURL) Manage an unexpected exception
-
Constructor Details
-
RESTExceptionHandler
public RESTExceptionHandler()Constructor
-
-
Method Details
-
handleNoRequestBody
public void handleNoRequestBody(String userId, String methodName, String serverName) throws InvalidParameterException Manage an unexpected exception- Parameters:
userId
- calling usermethodName
- method that caught the exceptionserverName
- name of the server being called- Throws:
InvalidParameterException
- exception to report error
-
handleNoRequestBody
public void handleNoRequestBody(String userId, String methodName, String serverName, String className) throws InvalidParameterException Manage an unexpected exception- Parameters:
userId
- calling usermethodName
- method that caught the exceptionserverName
- name of the server being calledclassName
- name of the class to supply- Throws:
InvalidParameterException
- exception to report error
-
handleMissingValue
public void handleMissingValue(String parameterName, String methodName) throws InvalidParameterException Manage an unexpected exception- Parameters:
parameterName
- name of null parameter - use to help locate where the problem ismethodName
- method that caught the exception- Throws:
InvalidParameterException
- exception to report error
-
handleInvalidPropertiesObject
public void handleInvalidPropertiesObject(String expectedClassName, String methodName) throws InvalidParameterException Manage an unexpected exception- Parameters:
expectedClassName
- name of expected properties classmethodName
- method that caught the exception- Throws:
InvalidParameterException
- exception to report error
-
handleInvalidCallToServer
public void handleInvalidCallToServer(String expectedClassName, String methodName, String serverGUID, String actualClassName) throws InvalidParameterException Manage an unexpected exception- Parameters:
expectedClassName
- name of expected properties classmethodName
- method that caught the exception- Throws:
InvalidParameterException
- exception to report error
-
handleBadType
public void handleBadType(String subTypeName, String superTypeName, String serviceName, String methodName) throws InvalidParameterException Manage a bad type name- Parameters:
subTypeName
- subtype that does not matchsuperTypeName
- expected (super) typeserviceName
- calling servicemethodName
- method that caught the exception- Throws:
InvalidParameterException
- exception to report error
-
detectAndThrowStandardExceptions
public void detectAndThrowStandardExceptions(String methodName, FFDCResponse restResult) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException Throw an exception if it is encoded in the REST response.- Parameters:
methodName
- name of the method calledrestResult
- response from the rest call. This generated in the remote server.- Throws:
InvalidParameterException
- one of the parameters is invalid.UserNotAuthorizedException
- the user is not authorized to make this request.PropertyServerException
- something went wrong with the REST call stack.
-
detectAndThrowInvalidParameterException
public void detectAndThrowInvalidParameterException(FFDCResponse restResult) throws InvalidParameterException Throw an InvalidParameterException if it is encoded in the REST response.- Parameters:
restResult
- response from the rest call. This generated in the remote server.- Throws:
InvalidParameterException
- encoded exception from the server
-
detectAndThrowInvalidParameterException
@Deprecated public void detectAndThrowInvalidParameterException(String methodName, FFDCResponseBase restResult) throws InvalidParameterException Deprecated.Throw an InvalidParameterException if it is encoded in the REST response.- Parameters:
methodName
- calling method.restResult
- response from the rest call. This generated in the remote server.- Throws:
InvalidParameterException
- encoded exception from the server
-
detectAndThrowUserNotAuthorizedException
@Deprecated public void detectAndThrowUserNotAuthorizedException(String methodName, FFDCResponseBase restResult) throws UserNotAuthorizedException Deprecated.Throw an UserNotAuthorizedException if it is encoded in the REST response.- Parameters:
methodName
- calling method.restResult
- response from the rest call. This generated in the remote server.- Throws:
UserNotAuthorizedException
- encoded exception from the server
-
detectAndThrowPropertyServerException
@Deprecated public void detectAndThrowPropertyServerException(String methodName, FFDCResponseBase restResult) throws PropertyServerException Deprecated.Throw an PropertyServerException if it is encoded in the REST response.- Parameters:
methodName
- calling method.restResult
- response from the rest call. This generated in the remote server.- Throws:
PropertyServerException
- encoded exception from the server
-
detectAndThrowPropertyServerException
public void detectAndThrowPropertyServerException(FFDCResponse restResult) throws PropertyServerException Throw a PropertyServerException if it is encoded in the REST response.- Parameters:
restResult
- response from the rest call. This generated in the remote server.- Throws:
PropertyServerException
- encoded exception from the server
-
detectAndThrowUserNotAuthorizedException
public void detectAndThrowUserNotAuthorizedException(FFDCResponse restResult) throws UserNotAuthorizedException Throw an UserNotAuthorizedException if it is encoded in the REST response.- Parameters:
restResult
- response from UserNotAuthorizedException encoded exception from the server.- Throws:
UserNotAuthorizedException
- encoded exception from the server
-
handleUnexpectedException
public void handleUnexpectedException(Throwable error, String methodName, String serverName, String serverURL) throws PropertyServerException Manage an unexpected exception- Parameters:
error
- unexpected exceptionmethodName
- method that caught the exceptionserverName
- name of the server being calledserverURL
- platform URL- Throws:
PropertyServerException
- wrapping exception for the caught exception
-
captureCheckedException
protected void captureCheckedException(FFDCResponse response, OCFCheckedExceptionBase error, String exceptionClassName) Set the exception information into the response.- Parameters:
response
- REST Responseerror
- returned response.exceptionClassName
- class name of the exception to recreate
-
captureCheckedException
protected void captureCheckedException(FFDCResponse response, OCFCheckedExceptionBase error, String exceptionClassName, Map<String, Object> exceptionProperties) Set the exception information into the response.- Parameters:
response
- REST Responseerror
- returned response.exceptionClassName
- class name of the exception to recreateexceptionProperties
- map of properties stored in the exception to help with diagnostics
-
captureExceptions
Set the exception information into the response.- Parameters:
response
- REST Responseerror
- returned responsemethodName
- calling method
-
captureExceptions
public void captureExceptions(FFDCResponse response, Exception error, String methodName, AuditLog auditLog) Set the exception information into the response.- Parameters:
response
- REST Responseerror
- returned responsemethodName
- calling methodauditLog
- log location for recording an unexpected exception
-
captureInvalidParameterException
public void captureInvalidParameterException(FFDCResponse response, InvalidParameterException error) Set the exception information into the response.- Parameters:
response
- REST Responseerror
- returned response.
-
capturePropertyServerException
Set the exception information into the response.- Parameters:
response
- REST Responseerror
- returned response.
-
captureUserNotAuthorizedException
public void captureUserNotAuthorizedException(FFDCResponse response, UserNotAuthorizedException error) Set the exception information into the response.- Parameters:
response
- REST Responseerror
- returned response.
-