Class DefaultCpqClientUtil

java.lang.Object
de.hybris.platform.cpq.productconfig.services.client.DefaultCpqClientUtil
All Implemented Interfaces:
CpqClientUtil

public class DefaultCpqClientUtil extends Object implements CpqClientUtil
Default implementation of CpqClientUtil
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Exception message template in case CPQ returned unexpected HTTP status
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    checkContentType(String action, String expectedContentType, com.hybris.charon.RawResponse<?> rawResponse)
    CPQ may return in some error situations with HTTP 200/OK and issue and error page, instead of returning a JSON response.
    void
    checkHTTPStatusCode(String action, int expectedStatusCode, com.hybris.charon.RawResponse<?> rawResponse)
    CPQ may return in some error situations with HTTP 200/OK and issue and error page, instead of returning the expected HTTP 201/CREATED or 204/NO_CONTENT.
    Use this method to detect such situations and terminate gracefully, instead of running in parse errors while trying to parse unexpected content.
    In case you actually expect HTTP 200/OK, you should check the content type on top using CpqClientUtil.checkContentType(String, String, RawResponse)
    protected String
    extractErrorPage(com.hybris.charon.RawResponse<?> rawResponse)
     
    protected String
    extractLogMessage(com.hybris.charon.exp.HttpException ex)
     
    protected boolean
    hasUnexpectedContent(String expectedContentType, int contentLengh)
     
    protected boolean
    isErrorPageResponse(com.hybris.charon.RawResponse<?> rawResponse)
     
    <T> T
    toResponse(rx.Observable<T> response)
    Resolves a response observable, assuming there is only exactly one element.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ERROR_MSG_WRONG_HTTP_STATUS_CODE

      public static final String ERROR_MSG_WRONG_HTTP_STATUS_CODE
      Exception message template in case CPQ returned unexpected HTTP status
      See Also:
  • Constructor Details

    • DefaultCpqClientUtil

      public DefaultCpqClientUtil()
  • Method Details

    • checkHTTPStatusCode

      public void checkHTTPStatusCode(String action, int expectedStatusCode, com.hybris.charon.RawResponse<?> rawResponse)
      Description copied from interface: CpqClientUtil
      CPQ may return in some error situations with HTTP 200/OK and issue and error page, instead of returning the expected HTTP 201/CREATED or 204/NO_CONTENT.
      Use this method to detect such situations and terminate gracefully, instead of running in parse errors while trying to parse unexpected content.
      In case you actually expect HTTP 200/OK, you should check the content type on top using CpqClientUtil.checkContentType(String, String, RawResponse)
      Specified by:
      checkHTTPStatusCode in interface CpqClientUtil
      Parameters:
      action - log friendly string, indicating the triggering action
      expectedStatusCode - expected status HTTP code
      rawResponse - response containing the actual HTTP status code
    • extractErrorPage

      protected String extractErrorPage(com.hybris.charon.RawResponse<?> rawResponse)
    • isErrorPageResponse

      protected boolean isErrorPageResponse(com.hybris.charon.RawResponse<?> rawResponse)
    • toResponse

      public <T> T toResponse(rx.Observable<T> response)
      Resolves a response observable, assuming there is only exactly one element.
      Specified by:
      toResponse in interface CpqClientUtil
      Parameters:
      response - observable to resolve
      Returns:
      actual response
    • extractLogMessage

      protected String extractLogMessage(com.hybris.charon.exp.HttpException ex)
    • checkContentType

      public void checkContentType(String action, String expectedContentType, com.hybris.charon.RawResponse<?> rawResponse)
      Description copied from interface: CpqClientUtil
      CPQ may return in some error situations with HTTP 200/OK and issue and error page, instead of returning a JSON response.
      Specified by:
      checkContentType in interface CpqClientUtil
      Parameters:
      action - log friendly string, indicating the triggering action
      expectedContentType - expected content type
      rawResponse - response containing the actual content type
    • hasUnexpectedContent

      protected boolean hasUnexpectedContent(String expectedContentType, int contentLengh)