Class CmsSearchUtil

java.lang.Object
org.opencms.search.CmsSearchUtil

public final class CmsSearchUtil extends Object
Provides common functions regarding searching.

Since:
9.0.0
  • Field Details

  • Method Details

    • computeScopeFolders

      Computes the search root folders for the given search parameters based on the search scope.

      Parameters:
      cms - the current CMS context
      params - the current search parameters
      Returns:
      the search root folders based on the search scope
    • getDateAsIso8601

      public static String getDateAsIso8601(Date date)
      Returns a given date object in the ISO 8601 format.
      Parameters:
      date - that should be converted.
      Returns:
      string that represents the given date in the ISO 8601 format.
    • getDateAsIso8601

      public static String getDateAsIso8601(long date)
      Returns a given date object in the ISO 8601 format.
      Parameters:
      date - that should be converted.
      Returns:
      string that represents the given date in the ISO 8601 format.
    • getDateCreatedTimeRangeFilterQuery

      public static String getDateCreatedTimeRangeFilterQuery(String searchField, long startTime, long endTime)
      Returns a time interval as Solr compatible query string.
      Parameters:
      searchField - the field to search for.
      startTime - the lower limit of the interval.
      endTime - the upper limit of the interval.
      Returns:
      Solr compatible query string.
    • getSearchRootsForScope

      public static List<String> getSearchRootsForScope(CmsGallerySearchScope scope, String siteParam, String subSiteParam)
      Gets the search roots to use for the given site/subsite parameters.

      Parameters:
      scope - the search scope
      siteParam - the current site
      subSiteParam - the current subsite
      Returns:
      the list of search roots for that option
    • getSolrRangeString

      public static String getSolrRangeString(String from, String to)
      Returns a string that represents a valid Solr query range.
      Parameters:
      from - Lower bound of the query range.
      to - Upper bound of the query range.
      Returns:
      String that represents a Solr query range.
    • parseDate

      public static Date parseDate(String d) throws ParseException
      Returns a formatter that can be use by the current thread if needed to convert Date objects to the Internal representation.
      Parameters:
      d - The input date to parse
      Returns:
      The parsed Date
      Throws:
      ParseException - If the input can't be parsed
    • parseDate

      public static Date parseDate(String d, Collection<String> fmts) throws ParseException
      Throws:
      ParseException
    • parseDate

      public static Date parseDate(String dateValue, Collection<String> dateFormats, Date startDate) throws ParseException
      Slightly modified from org.apache.commons.httpclient.util.DateUtil.parseDate

      Parses the date value using the given date formats.

      Parameters:
      dateValue - the date value to parse
      dateFormats - the date formats to use
      startDate - During parsing, two digit years will be placed in the range startDate to startDate + 100 years. This value may be null. When null is given as a parameter, year 2000 will be used.
      Returns:
      the parsed date
      Throws:
      ParseException - if none of the dataFormats could parse the dateValue
    • stripHtmlFromPropertyIfNecessary

      public static String stripHtmlFromPropertyIfNecessary(String propertyName, String value)
      Strips of HTML of the value to map, if necessary (depending on the property name).
      Parameters:
      propertyName - name of the property.
      value - the properties value (possibly with HTML)
      Returns:
      the value with HTML stripped of, or the original value, if stripping of the HTML fails.
    • toContentStreams

      public static Collection<org.apache.solr.common.util.ContentStream> toContentStreams(String str, String contentType)
      Take a string and make it an iterable ContentStream
    • toSolrDocument

      @Deprecated public static org.apache.solr.common.SolrDocument toSolrDocument(org.apache.solr.common.SolrInputDocument d)
      Deprecated.
      This method will be removed in Solr 6.0
      Parameters:
      d - SolrInputDocument to convert
      Returns:
      a SolrDocument with the same fields and values as the SolrInputDocument
    • toSolrInputDocument

      @Deprecated public static org.apache.solr.common.SolrInputDocument toSolrInputDocument(org.apache.solr.common.SolrDocument d)
      Deprecated.
      This method will be removed in Solr 6.0
      Parameters:
      d - SolrDocument to convert
      Returns:
      a SolrInputDocument with the same fields and values as the SolrDocument.