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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addRsqlStringToUri
(@NonNull org.springframework.web.util.UriBuilder uriBuilder, @NonNull String rsql) Adds the provided RSQL string to the URI as a query parameter (cq).static String
concatRsqlStrings
(@NonNull List<String> rsqlStatements) Takes 1 or more RSQL strings and appends them together with 'and' operators and sets them on theUriBuilder
.static String
createRsqlQueryEqualTo
(@NonNull String field, @NonNull String value) Creates a RSQL string in the format, `field==value`.static String
createRsqlQueryGreaterThan
(@NonNull String field, @NonNull String value) Creates a RSQL string in the formal, `field=gt=(value)`.static String
createRsqlQueryGreaterThanOrEqualTo
(@NonNull String field, @NonNull String value) Creates a RSQL string in the format, field=ge=valuestatic String
createRsqlQueryIn
(@NonNull String field, @NonNull Collection<String> values) Creates a RSQL string in the format, `field=in=(val1,val2,val3)`.static String
createRsqlQueryLessThan
(@NonNull String field, @NonNull String value) Creates a RSQL string in the formal, `field=lt=(value)`.static String
createRsqlQueryLessThanOrEqualTo
(@NonNull String field, @NonNull String value) Creates a RSQL string in the format, field=le=valuestatic String
createRsqlQueryNotEqualTo
(@NonNull String field, @NonNull String value) Creates a RSQL string in the format, field!=valuestatic String
createRsqlQueryNotIn
(@NonNull String field, @NonNull Collection<String> values) Creates a RSQL string in the format, `field=out=(val1,val2,val3)`.static org.springframework.http.HttpHeaders
getHeaders
(@NonNull com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Convenience method to convertContextInfo
into 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 convertContextInfo
into HTTP request headers.- Parameters:
objectMapper
-contextInfo
-- Returns:
-