Class SolrPaths

  • public final class SolrPaths
    extends Object
    Utility methods about paths in Solr.
    • Method Detail

      • locateSolrHome

        public static Path locateSolrHome()
        Finds the solrhome based on looking up the value in one of three places:
        1. JNDI: via java:comp/env/solr/home
        2. The system property solr.solr.home
        3. Look in the current working directory for a solr/ directory

        The return value is normalized. Normalization essentially means it ends in a trailing slash.

        A normalized solrhome
        See Also:
      • normalizeDir

        public static String normalizeDir​(String path)
        Ensures a directory name always ends with a '/'.
      • assertPathAllowed

        public static void assertPathAllowed​(Path pathToAssert,
                                             Set<Path> allowPaths)
                                      throws SolrException
        Checks that the given path is relative to one of the allowPaths supplied. Typically this will be called from CoreContainer.assertPathAllowed(Path) and allowPaths pre-filled with the node's SOLR_HOME, SOLR_DATA_HOME and coreRootDirectory folders, as well as any paths specified in solr.xml's allowPaths element. The following paths will always fail validation:
        • Relative paths starting with ..
        • Windows UNC paths (such as \\host\share\path)
        • Paths which are not relative to any of allowPaths
        pathToAssert - path to check
        allowPaths - list of paths that should be allowed prefixes for pathToAssert
        SolrException - if path is outside allowed paths