Class JSONUtils

java.lang.Object
org.opencastproject.index.service.util.JSONUtils

public final class JSONUtils extends Object
Utility class providing helpers for all operation related to JSON.
  • Method Details

    • safeString

      public static String safeString(Object input)
    • collectionToJsonArray

      public static com.google.gson.JsonArray collectionToJsonArray(Collection<?> collection)
      Turn a collection into a JsonArray
      Parameters:
      collection - the collection
      Returns:
      a new JsonArray generated with the colleciton values
    • arrayToJsonArray

      public static <T> com.google.gson.JsonArray arrayToJsonArray(T[] array)
    • mapToJsonObject

      public static com.google.gson.JsonObject mapToJsonObject(Map<?,?> map)
      Turn a map into a JsonObject object
      Parameters:
      map - the source map
      Returns:
      a new JsonObject generated with the map values
    • filtersToJSON

      public static com.google.gson.JsonObject filtersToJSON(org.opencastproject.list.api.ResourceListQuery query, org.opencastproject.list.api.ListProvidersService listProvidersService, org.opencastproject.security.api.Organization org) throws org.opencastproject.list.api.ListProviderException
      Generate JSON presentation of the given filters
      Parameters:
      query - The ResourceListQuery
      listProvidersService - The ListProvidersService to get the possible values
      org - The Organization
      Returns:
      Throws:
      org.opencastproject.list.api.ListProviderException - if the possible values can not be retrieved correctly from the list provider.
    • filtersToJSONSeriesWriteAccess

      public static com.google.gson.JsonObject filtersToJSONSeriesWriteAccess(org.opencastproject.list.api.ResourceListQuery query, org.opencastproject.list.api.ListProvidersService listProvidersService, Map<String,String> series) throws org.opencastproject.list.api.ListProviderException
      Generate JSON presentation of the given filters
      Parameters:
      query - The ResourceListQuery
      listProvidersService - The ListProvidersService to get the possible values
      series - The Series with write access
      Returns:
      Throws:
      org.opencastproject.list.api.ListProviderException - if the possible values can not be retrieved correctly from the list provider.
    • fromMap

      public static org.codehaus.jettison.json.JSONObject fromMap(Map<String,String> map) throws org.codehaus.jettison.json.JSONException
      Returns a JSON object with key-value from given map
      Parameters:
      map - The source list for the JSON object
      Returns:
      a JSON object containing the all the key-value as parameter
      Throws:
      org.codehaus.jettison.json.JSONException
    • toMap

      public static Map<String,String> toMap(org.codehaus.jettison.json.JSONObject json)
      Converts a JSON object to a map. All values are of type String
      Parameters:
      json - the JSON object to convert
      Returns:
      the map
    • setUserRegex

      public static void setUserRegex(String regex)