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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddErrorContextPopulator(ErrorContextPopulator populator) Adds a populator to the populators already existing in this callback.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(Collection<ErrorContextPopulator> populators) Sets populators to be used for error conversion.
-
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:
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:
-
getExceptionClass
Description copied from interface:ErrorContextPopulatorSpecifies what exception class thisErrorContextPopulatorcan provide values for.- Specified by:
getExceptionClassin interfaceErrorContextPopulator- Returns:
- the exception class
-
setErrorContextPopulators
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
Adds a populator to the populators already existing in this callback.- Parameters:
populator- a populator to add to existing populators.
-