Package org.apache.solr.core
Class SolrPaths
- java.lang.Object
-
- org.apache.solr.core.SolrPaths
-
public final class SolrPaths extends Object
Utility methods about paths in Solr.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
assertPathAllowed(Path pathToAssert, Set<Path> allowPaths)
Checks that the given path is relative to one of the allowPaths supplied.static Path
locateSolrHome()
Finds the solrhome based on looking up the value in one of three places: JNDI: via java:comp/env/solr/home The system property solr.solr.home Look in the current working directory for a solr/ directorystatic String
normalizeDir(String path)
Ensures a directory name always ends with a '/'.
-
-
-
Method Detail
-
locateSolrHome
public static Path locateSolrHome()
Finds the solrhome based on looking up the value in one of three places:- JNDI: via java:comp/env/solr/home
- The system property solr.solr.home
- Look in the current working directory for a solr/ directory
The return value is normalized. Normalization essentially means it ends in a trailing slash.
- Returns:
- A normalized solrhome
- See Also:
normalizeDir(String)
-
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 fromCoreContainer.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
- Parameters:
pathToAssert
- path to checkallowPaths
- list of paths that should be allowed prefixes for pathToAssert- Throws:
SolrException
- if path is outside allowed paths
- Relative paths starting with
-
-