Class DefaultCpqClientUtil
java.lang.Object
de.hybris.platform.cpq.productconfig.services.client.DefaultCpqClientUtil
- All Implemented Interfaces:
CpqClientUtil
Default implementation of
CpqClientUtil-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringException message template in case CPQ returned unexpected HTTP status -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckContentType(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.voidcheckHTTPStatusCode(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 usingCpqClientUtil.checkContentType(String, String, RawResponse)protected StringextractErrorPage(com.hybris.charon.RawResponse<?> rawResponse) protected StringextractLogMessage(com.hybris.charon.exp.HttpException ex) protected booleanhasUnexpectedContent(String expectedContentType, int contentLengh) protected booleanisErrorPageResponse(com.hybris.charon.RawResponse<?> rawResponse) <T> TtoResponse(rx.Observable<T> response) Resolves a response observable, assuming there is only exactly one element.
-
Field Details
-
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:CpqClientUtilCPQ 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 usingCpqClientUtil.checkContentType(String, String, RawResponse)- Specified by:
checkHTTPStatusCodein interfaceCpqClientUtil- Parameters:
action- log friendly string, indicating the triggering actionexpectedStatusCode- expected status HTTP coderawResponse- response containing the actual HTTP status code
-
extractErrorPage
-
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:
toResponsein interfaceCpqClientUtil- Parameters:
response- observable to resolve- Returns:
- actual response
-
extractLogMessage
-
checkContentType
public void checkContentType(String action, String expectedContentType, com.hybris.charon.RawResponse<?> rawResponse) Description copied from interface:CpqClientUtilCPQ may return in some error situations with HTTP 200/OK and issue and error page, instead of returning a JSON response.- Specified by:
checkContentTypein interfaceCpqClientUtil- Parameters:
action- log friendly string, indicating the triggering actionexpectedContentType- expected content typerawResponse- response containing the actual content type
-
hasUnexpectedContent
-