Class WebClientUtils
java.lang.Object
com.broadleafcommerce.datafeed.util.WebClientUtils
Utility to simplify RSQL string creation, HTTP header creation, etc. for making API requests to
other services.
- Author:
- Kelly Tisdell (ktisdell)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddRsqlStringToUri(@NonNull org.springframework.web.util.UriBuilder uriBuilder, @NonNull String rsql) Adds the provided RSQL string to the URI as a query parameter (cq).static StringconcatRsqlStrings(@NonNull List<String> rsqlStatements) Takes 1 or more RSQL strings and appends them together with 'and' operators and sets them on theUriBuilder.static StringcreateRsqlQueryEqualTo(@NonNull String field, @NonNull String value) Creates a RSQL string in the format, `field==value`.static StringcreateRsqlQueryGreaterThan(@NonNull String field, @NonNull String value) Creates a RSQL string in the formal, `field=gt=(value)`.static StringcreateRsqlQueryGreaterThanOrEqualTo(@NonNull String field, @NonNull String value) Creates a RSQL string in the format, field=ge=valuestatic StringcreateRsqlQueryIn(@NonNull String field, @NonNull Collection<String> values) Creates a RSQL string in the format, `field=in=(val1,val2,val3)`.static StringcreateRsqlQueryLessThan(@NonNull String field, @NonNull String value) Creates a RSQL string in the formal, `field=lt=(value)`.static StringcreateRsqlQueryLessThanOrEqualTo(@NonNull String field, @NonNull String value) Creates a RSQL string in the format, field=le=valuestatic StringcreateRsqlQueryNotEqualTo(@NonNull String field, @NonNull String value) Creates a RSQL string in the format, field!=valuestatic StringcreateRsqlQueryNotIn(@NonNull String field, @NonNull Collection<String> values) Creates a RSQL string in the format, `field=out=(val1,val2,val3)`.static org.springframework.http.HttpHeadersgetHeaders(@NonNull com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Convenience method to convertContextInfointo HTTP request headers.
-
Field Details
-
RSQL_FILTER_PARAM
- See Also:
-
SIZE_QUERY_PARAM
- See Also:
-
SORT_QUERY_PARAM
- See Also:
-
CONTEXT_ID
- See Also:
-
ID
- See Also:
-
-
Constructor Details
-
WebClientUtils
public WebClientUtils()
-
-
Method Details
-
createRsqlQueryIn
public static String createRsqlQueryIn(@NonNull @NonNull String field, @NonNull @NonNull Collection<String> values) Creates a RSQL string in the format, `field=in=(val1,val2,val3)`.- Parameters:
field-values-- Returns:
-
createRsqlQueryNotIn
public static String createRsqlQueryNotIn(@NonNull @NonNull String field, @NonNull @NonNull Collection<String> values) Creates a RSQL string in the format, `field=out=(val1,val2,val3)`.- Parameters:
field-values-- Returns:
-
createRsqlQueryGreaterThan
public static String createRsqlQueryGreaterThan(@NonNull @NonNull String field, @NonNull @NonNull String value) Creates a RSQL string in the formal, `field=gt=(value)`. than".- Parameters:
field-value-- Returns:
-
createRsqlQueryLessThan
public static String createRsqlQueryLessThan(@NonNull @NonNull String field, @NonNull @NonNull String value) Creates a RSQL string in the formal, `field=lt=(value)`.- Parameters:
field-value-- Returns:
-
createRsqlQueryEqualTo
public static String createRsqlQueryEqualTo(@NonNull @NonNull String field, @NonNull @NonNull String value) Creates a RSQL string in the format, `field==value`.- Parameters:
field-value-- Returns:
-
createRsqlQueryNotEqualTo
public static String createRsqlQueryNotEqualTo(@NonNull @NonNull String field, @NonNull @NonNull String value) Creates a RSQL string in the format, field!=value- Parameters:
field-value-- Returns:
-
createRsqlQueryGreaterThanOrEqualTo
public static String createRsqlQueryGreaterThanOrEqualTo(@NonNull @NonNull String field, @NonNull @NonNull String value) Creates a RSQL string in the format, field=ge=value- Parameters:
field-value-- Returns:
-
createRsqlQueryLessThanOrEqualTo
public static String createRsqlQueryLessThanOrEqualTo(@NonNull @NonNull String field, @NonNull @NonNull String value) Creates a RSQL string in the format, field=le=value- Parameters:
field-value-- Returns:
-
concatRsqlStrings
Takes 1 or more RSQL strings and appends them together with 'and' operators and sets them on theUriBuilder. Individual statements should not start or end with 'and' or 'or' or other operators. They should be unique statements like 'foo==bar' or `foo==bar or bar=in=baz`.- Parameters:
rsqlStatements- List of RSQL statements return concatenated string of RSQL statements with 'and' operator between them.
-
addRsqlStringToUri
public static void addRsqlStringToUri(@NonNull @NonNull org.springframework.web.util.UriBuilder uriBuilder, @NonNull @NonNull String rsql) Adds the provided RSQL string to the URI as a query parameter (cq).- Parameters:
uriBuilder-rsql-
-
getHeaders
public static org.springframework.http.HttpHeaders getHeaders(@NonNull @NonNull com.fasterxml.jackson.databind.ObjectMapper objectMapper, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Convenience method to convertContextInfointo HTTP request headers.- Parameters:
objectMapper-contextInfo-- Returns:
-