Class CustomODataExceptionAwareErrorCallback

java.lang.Object
de.hybris.platform.odata2services.odata.errors.CustomODataExceptionAwareErrorCallback
All Implemented Interfaces:
ErrorContextPopulator, org.apache.olingo.odata2.api.ODataCallback, org.apache.olingo.odata2.api.processor.ODataErrorCallback

public class CustomODataExceptionAwareErrorCallback extends 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.
  • Constructor Details

    • CustomODataExceptionAwareErrorCallback

      public CustomODataExceptionAwareErrorCallback()
  • Method Details

    • 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:
    • getExceptionClass

      public Class<? extends 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(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.