Locate the data directory for a given config and core descriptor. @param directoryFactory The directory factory to use if necessary to calculate an absolute path. Should be the same as what will be used to open the data directory later. @param dataDir An optional hint to the data directory loca
(
DirectoryFactory directoryFactory,
String dataDir,
SolrConfig config,
CoreDescriptor coreDescriptor)
| 1470 | * @param directoryFactory The directory factory to use if necessary to calculate an absolute |
| 1471 | * path. Should be the same as what will be used to open the data directory later. |
| 1472 | * @param dataDir An optional hint to the data directory location. Will be normalized and used if |
| 1473 | * not null. |
| 1474 | * @param config A solr config to retrieve the default data directory location, if used. |
| 1475 | * @param coreDescriptor descriptor to load the actual data dir from, if not using the default. |
| 1476 | * @return a normalized data directory name |
| 1477 | * @throws SolrException if the data directory cannot be loaded from the core descriptor |
| 1478 | */ |
| 1479 | static String findDataDir( |
| 1480 | DirectoryFactory directoryFactory, |
| 1481 | String dataDir, |
| 1482 | SolrConfig config, |
| 1483 | CoreDescriptor coreDescriptor) { |
| 1484 | if (dataDir == null) { |
| 1485 | if (coreDescriptor.usingDefaultDataDir()) { |
| 1486 | dataDir = config.getDataDir(); |
| 1487 | } |
| 1488 | if (dataDir == null) { |
| 1489 | try { |
| 1490 | dataDir = coreDescriptor.getDataDir(); |
| 1491 | if (!directoryFactory.isAbsolute(dataDir)) { |
| 1492 | dataDir = directoryFactory.getDataHome(coreDescriptor); |
| 1493 | } |
| 1494 | } catch (IOException e) { |
| 1495 | throw new SolrException(ErrorCode.SERVER_ERROR, e); |
| 1496 | } |
no test coverage detected