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 Summary

    Modifier and Type
    Method
    Description
    static com.entwinemedia.fn.data.json.JValue
    filtersToJSON(org.opencastproject.list.api.ResourceListQuery query, org.opencastproject.list.api.ListProvidersService listProvidersService, org.opencastproject.security.api.Organization org)
    Generate JSON presentation of the given filters
    static com.entwinemedia.fn.data.json.JValue
    filtersToJSONSeriesWriteAccess(org.opencastproject.list.api.ResourceListQuery query, org.opencastproject.list.api.ListProvidersService listProvidersService, Map<String,String> series)
    Generate JSON presentation of the given filters
    static org.codehaus.jettison.json.JSONObject
    Returns a JSON object with key-value from given map
    static com.entwinemedia.fn.data.json.JObject
    Turn a map into a JObject object
    static com.entwinemedia.fn.data.json.JValue
    Turn a set into a JObject object
    static void
     
    static Map<String,String>
    toMap(org.codehaus.jettison.json.JSONObject json)
    Converts a JSON object to a map.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • mapToJSON

      public static com.entwinemedia.fn.data.json.JObject mapToJSON(Map<String,String> map)
      Turn a map into a JObject object
      Parameters:
      map - the source map
      Returns:
      a new JObject generated with the map values
    • setToJSON

      public static com.entwinemedia.fn.data.json.JValue setToJSON(Set<String> set)
      Turn a set into a JObject object
      Parameters:
      set - the source set
      Returns:
      a new JObject generated with the map values
    • filtersToJSON

      public static com.entwinemedia.fn.data.json.JValue 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.entwinemedia.fn.data.json.JValue 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)