Class WebClientUtils

java.lang.Object
com.broadleafcommerce.datafeed.util.WebClientUtils

public class WebClientUtils extends Object
Utility to simplify RSQL string creation, HTTP header creation, etc. for making API requests to other services.
Author:
Kelly Tisdell (ktisdell)
  • Field Details

  • 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

      public static String concatRsqlStrings(@NonNull @NonNull List<String> rsqlStatements)
      Takes 1 or more RSQL strings and appends them together with 'and' operators and sets them on the UriBuilder. 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 convert ContextInfo into HTTP request headers.
      Parameters:
      objectMapper -
      contextInfo -
      Returns: