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 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.
-
-
Constructor Summary
Constructors Constructor Description CustomODataExceptionAwareErrorCallback()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddErrorContextPopulator(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 thisErrorContextPopulatorcan provide values for.org.apache.olingo.odata2.api.processor.ODataResponsehandleError(org.apache.olingo.odata2.api.processor.ODataErrorContext context)voidpopulate(org.apache.olingo.odata2.api.processor.ODataErrorContext context)Populates context with values specific for the exception in the context, i.e.voidsetErrorContextPopulators(java.util.Collection<ErrorContextPopulator> populators)Sets populators to be used for error conversion.
-
-
-
Method Detail
-
handleError
public org.apache.olingo.odata2.api.processor.ODataResponse handleError(org.apache.olingo.odata2.api.processor.ODataErrorContext context)
- Specified by:
handleErrorin interfaceorg.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 theODataErrorContextdepending on the exception.It works as a composite
ErrorContextPopulator, which delegates to other registered populators- Specified by:
populatein interfaceErrorContextPopulator- 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:ErrorContextPopulatorSpecifies what exception class thisErrorContextPopulatorcan provide values for.- Specified by:
getExceptionClassin interfaceErrorContextPopulator- 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 sameErrorContextPopulator.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.
-
-