Class RESTExceptionHandler

java.lang.Object
org.odpi.openmetadata.commonservices.ffdc.RESTExceptionHandler
Direct Known Subclasses:
AdminClientRESTExceptionHandler, GlossaryViewClientExceptionHandler, LineageWarehouseExceptionHandler, OMAGServerExceptionHandler, 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 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 user
      methodName - method that caught the exception
      serverName - 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 user
      methodName - method that caught the exception
      serverName - name of the server being called
      className - 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 is
      methodName - 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 class
      methodName - 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 match
      superTypeName - expected (super) type
      serviceName - calling service
      methodName - 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 called
      restResult - 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 exception
      methodName - method that caught the exception
      serverName - name of the server being called
      serverURL - 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 Response
      error - 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 Response
      error - returned response.
      exceptionClassName - class name of the exception to recreate
      exceptionProperties - 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 Response
      error - returned response
      methodName - calling method
    • captureExceptions

      public void captureExceptions(FFDCResponse response, Exception error, String methodName, AuditLog auditLog)
      Set the exception information into the response.
      Parameters:
      response - REST Response
      error - returned response
      methodName - calling method
      auditLog - 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 Response
      error - returned response.
    • capturePropertyServerException

      public void capturePropertyServerException(FFDCResponse response, PropertyServerException error)
      Set the exception information into the response.
      Parameters:
      response - REST Response
      error - returned response.
    • captureUserNotAuthorizedException

      public void captureUserNotAuthorizedException(FFDCResponse response, UserNotAuthorizedException error)
      Set the exception information into the response.
      Parameters:
      response - REST Response
      error - returned response.