Class RESTExceptionHandler
- java.lang.Object
-
- org.odpi.openmetadata.commonservices.ffdc.RESTExceptionHandler
-
public class RESTExceptionHandler extends Object
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
Constructors Constructor Description RESTExceptionHandler()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidcaptureCheckedException(FFDCResponse response, OCFCheckedExceptionBase error, String exceptionClassName)Set the exception information into the response.protected voidcaptureCheckedException(FFDCResponse response, OCFCheckedExceptionBase error, String exceptionClassName, Map<String,Object> exceptionProperties)Set the exception information into the response.voidcaptureExceptions(FFDCResponse response, Exception error, String methodName)Set the exception information into the response.voidcaptureExceptions(FFDCResponse response, Exception error, String methodName, AuditLog auditLog)Set the exception information into the response.voidcaptureInvalidParameterException(FFDCResponse response, InvalidParameterException error)Set the exception information into the response.voidcapturePropertyServerException(FFDCResponse response, PropertyServerException error)Set the exception information into the response.voidcaptureUserNotAuthorizedException(FFDCResponse response, UserNotAuthorizedException error)Set the exception information into the response.voiddetectAndThrowInvalidParameterException(String methodName, FFDCResponseBase restResult)Deprecated.voiddetectAndThrowInvalidParameterException(FFDCResponse restResult)Throw an InvalidParameterException if it is encoded in the REST response.voiddetectAndThrowPropertyServerException(String methodName, FFDCResponseBase restResult)Deprecated.voiddetectAndThrowPropertyServerException(FFDCResponse restResult)Throw a PropertyServerException if it is encoded in the REST response.voiddetectAndThrowStandardExceptions(String methodName, FFDCResponse restResult)Throw an exception if it is encoded in the REST response.voiddetectAndThrowUserNotAuthorizedException(String methodName, FFDCResponseBase restResult)Deprecated.voiddetectAndThrowUserNotAuthorizedException(FFDCResponse restResult)Throw an UserNotAuthorizedException if it is encoded in the REST response.voidhandleMissingValue(String parameterName, String methodName)Manage an unexpected exceptionvoidhandleNoRequestBody(String userId, String methodName, String serverName)Manage an unexpected exceptionvoidhandleUnexpectedException(Throwable error, String methodName, String serverName, String serverURL)Manage an unexpected exception
-
-
-
Method Detail
-
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
-
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
-
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
public void captureExceptions(FFDCResponse response, Exception error, String methodName)
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
public void capturePropertyServerException(FFDCResponse response, PropertyServerException error)
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.
-
-