Class RESTExceptionHandler

  • Direct Known Subclasses:
    GlossaryViewClientExceptionHandler, OMAGServerExceptionHandler

    public class RESTExceptionHandler
    extends java.lang.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 Detail

      • RESTExceptionHandler

        public RESTExceptionHandler()
        Constructor
    • Method Detail

      • handleNoRequestBody

        public void handleNoRequestBody​(java.lang.String userId,
                                        java.lang.String methodName,
                                        java.lang.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
      • handleMissingValue

        public void handleMissingValue​(java.lang.String parameterName,
                                       java.lang.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​(java.lang.String expectedClassName,
                                                  java.lang.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​(java.lang.String subTypeName,
                                  java.lang.String superTypeName,
                                  java.lang.String serviceName,
                                  java.lang.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
      • 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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.Throwable error,
                                              java.lang.String methodName,
                                              java.lang.String serverName,
                                              java.lang.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,
                                               java.lang.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,
                                               java.lang.String exceptionClassName,
                                               java.util.Map<java.lang.String,​java.lang.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,
                                      java.lang.Exception error,
                                      java.lang.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,
                                      java.lang.Exception error,
                                      java.lang.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.