Class RESTUtils

java.lang.Object
org.apache.gravitino.rest.RESTUtils

public class RESTUtils extends Object
Referred from Apache Iceberg's RESTUtil implementation core/src/main/java/org/apache/iceberg/rest/RESTUtil.java

Utility class for working with REST related operations.

  • Method Details

    • stripTrailingSlash

      public static String stripTrailingSlash(String path)
      Remove trailing slashes from a path.
      Parameters:
      path - The path to strip trailing slashes from.
      Returns:
      The path with trailing slashes removed.
    • encodeFormData

      public static String encodeFormData(Map<?,?> formData)
      Encode a map of form data into a URL encoded string.
      Parameters:
      formData - The form data to encode.
      Returns:
      The URL encoded form data string.
    • decodeFormData

      public static Map<String,String> decodeFormData(String formString)
      Decode a URL encoded form data string into a map.
      Parameters:
      formString - The URL encoded form data string.
      Returns:
      The decoded form data map.
    • encodeString

      public static String encodeString(String toEncode)
      URL encode a string.
      Parameters:
      toEncode - The string to encode.
      Returns:
      The URL encoded string.
      Throws:
      IllegalArgumentException - If the input string is null.
      UncheckedIOException - If URL encoding fails.
    • decodeString

      public static String decodeString(String encoded)
      Decode a URL encoded string.
      Parameters:
      encoded - The URL encoded string to decode.
      Returns:
      The decoded string.
      Throws:
      IllegalArgumentException - if the input string is null.
      UncheckedIOException - if URL decoding fails.
    • findAvailablePort

      public static int findAvailablePort(int portRangeStart, int portRangeEnd) throws IOException
      Find an available port in the port range.
      Parameters:
      portRangeStart - the start of the port range
      portRangeEnd - the end of the port range
      Returns:
      the available port
      Throws:
      IOException - if no available port in the port range