Class CustomODataExceptionAwareErrorCallback

  • All Implemented Interfaces:
    ErrorContextPopulator, org.apache.olingo.odata2.api.ODataCallback, org.apache.olingo.odata2.api.processor.ODataErrorCallback

    public class CustomODataExceptionAwareErrorCallback
    extends java.lang.Object
    implements org.apache.olingo.odata2.api.processor.ODataErrorCallback, ErrorContextPopulator
    ODataErrorCallback implementation that populates the Context with Status, ErrorCode and Message for custom OData runtime exceptions.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addErrorContextPopulator​(ErrorContextPopulator populator)
      Adds a populator to the populators already existing in this callback.
      java.lang.Class<? extends java.lang.Exception> getExceptionClass()
      Specifies what exception class this ErrorContextPopulator can provide values for.
      org.apache.olingo.odata2.api.processor.ODataResponse handleError​(org.apache.olingo.odata2.api.processor.ODataErrorContext context)  
      void populate​(org.apache.olingo.odata2.api.processor.ODataErrorContext context)
      Populates context with values specific for the exception in the context, i.e.
      void setErrorContextPopulators​(java.util.Collection<ErrorContextPopulator> populators)
      Sets populators to be used for error conversion.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CustomODataExceptionAwareErrorCallback

        public CustomODataExceptionAwareErrorCallback()
    • Method Detail

      • handleError

        public org.apache.olingo.odata2.api.processor.ODataResponse handleError​(org.apache.olingo.odata2.api.processor.ODataErrorContext context)
        Specified by:
        handleError in interface org.apache.olingo.odata2.api.processor.ODataErrorCallback
      • populate

        public void populate​(org.apache.olingo.odata2.api.processor.ODataErrorContext context)
        Populates context with values specific for the exception in the context, i.e. ODataErrorContext.getException(). At a minimum, the implementations should set HTTP status code, error code and message, etc in the ODataErrorContext depending on the exception.

        It works as a composite ErrorContextPopulator, which delegates to other registered populators

        Specified by:
        populate in interface ErrorContextPopulator
        Parameters:
        context - a context to update with the exception specific values.
        See Also:
        setErrorContextPopulators(Collection)
      • getExceptionClass

        public java.lang.Class<? extends java.lang.Exception> getExceptionClass()
        Description copied from interface: ErrorContextPopulator
        Specifies what exception class this ErrorContextPopulator can provide values for.
        Specified by:
        getExceptionClass in interface ErrorContextPopulator
        Returns:
        the exception class
      • setErrorContextPopulators

        public void setErrorContextPopulators​(java.util.Collection<ErrorContextPopulator> populators)
        Sets populators to be used for error conversion. An exception handling can be customized by registering a specific for that exception populator, which presents that exception in the error response.
        Parameters:
        populators - populators handling different kind of exceptions. If there several populators for the same ErrorContextPopulator.getExceptionClass(), then the last one (from the iteration stand point) will be used. All previous populators will be ignored.
      • addErrorContextPopulator

        public void addErrorContextPopulator​(ErrorContextPopulator populator)
        Adds a populator to the populators already existing in this callback.
        Parameters:
        populator - a populator to add to existing populators.