Class JsonTools

java.lang.Object
io.goobi.viewer.controller.JsonTools

public final class JsonTools extends Object

JsonTools class.

  • Field Details

  • Method Details

    • getRecordJsonArray

      public static org.json.JSONArray getRecordJsonArray(org.apache.solr.common.SolrDocumentList result, Map<String,org.apache.solr.common.SolrDocumentList> expanded, javax.servlet.http.HttpServletRequest request, String languageToTranslate) throws IndexUnreachableException, PresentationException, DAOException, ViewerConfigurationException
      Returns a JSONArray containing JSON objects for every SolrDocument in the given result. Order remains the same as in the result list.
      Parameters:
      result - a SolrDocumentList object.
      expanded -
      request - a HttpServletRequest object.
      languageToTranslate -
      Returns:
      a JSONArray object.
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
      DAOException - if any.
      ViewerConfigurationException - if any.
    • getAsJson

      public static org.json.JSONObject getAsJson(org.apache.solr.common.SolrDocument doc, Locale locale) throws com.fasterxml.jackson.core.JsonProcessingException
      Parameters:
      doc -
      locale -
      Returns:
      Given Solr doc as JSONObject
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getAsJson

      public static String getAsJson(Object object) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getAsObject

      public static <T> T getAsObject(String json, Class<T> clazz) throws IOException
      Type Parameters:
      T -
      Parameters:
      json -
      clazz -
      Returns:
      T
      Throws:
      IOException
    • getAsObjectForJson

      public static Object getAsObjectForJson(Object value)
    • translateJSONObject

      public static org.json.JSONObject translateJSONObject(Locale locale, org.json.JSONObject object)
      Parameters:
      locale -
      object -
      Returns:
      object translated to locale
    • getDateCentricRecordJsonArray

      public static org.json.JSONArray getDateCentricRecordJsonArray(org.apache.solr.common.SolrDocumentList result, javax.servlet.http.HttpServletRequest request) throws IndexUnreachableException, PresentationException, DAOException, ViewerConfigurationException
      JSON array of records grouped by their import date.
      Parameters:
      result - a SolrDocumentList object.
      request - a HttpServletRequest object.
      Returns:
      a JSONArray object.
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
      DAOException - if any.
      ViewerConfigurationException - if any.
    • getRecordJsonObject

      public static org.json.JSONObject getRecordJsonObject(org.apache.solr.common.SolrDocument doc, String rootUrl, ThumbnailHandler thumbs) throws ViewerConfigurationException
      Creates a single JSONObject with metadata for the given record SolrDocument.
      Parameters:
      doc - a SolrDocument object.
      rootUrl - a String object.
      thumbs -
      Returns:
      a JSONObject object.
      Throws:
      ViewerConfigurationException - if any.
    • getRecordJsonObject

      public static org.json.JSONObject getRecordJsonObject(org.apache.solr.common.SolrDocument doc, String rootUrl, String language, ThumbnailHandler thumbs)
      Creates a single JSONObject with metadata for the given record SolrDocument.
      Parameters:
      doc - a SolrDocument object.
      rootUrl - a String object.
      language - a String object.
      thumbs -
      Returns:
      a JSONObject object.
    • formatVersionString

      public static String formatVersionString(String json)
      Parameters:
      json - JSON string
      Returns:
      Version information as a single line string
    • shortFormatVersionString

      public static String shortFormatVersionString(String json)
      Parameters:
      json - JSON string
      Returns:
      Only version number and git hash as a single line string
    • getVersion

      public static String getVersion(String json)
      Parameters:
      json -
      Returns:
      String containing value of "version" from json
    • getGitRevision

      public static String getGitRevision(String json)
      Parameters:
      json -
      Returns:
      String containing value of "git-revision" from json