private void init(String config, String schema) throws Exception {
    // write out elevate-data.xml to the Data dir first by copying it from conf, which we know
    // exists, this way we can test both conf and data configurations
    File parent = new File(TEST_HOME() + "/collection1", "conf");
    File elevateFile = new File(parent, "elevate.xml");
    File elevateDataFile = new File(initCoreDataDir, "elevate-data.xml");
    FileUtils.copyFile(elevateFile, elevateDataFile);

    initCore(config, schema);
    clearIndex();
    assertU(commit());
  }
Beispiel #2
0
  private void initLibs() {
    NodeList nodes = (NodeList) evaluate("lib", XPathConstants.NODESET);
    if (nodes == null || nodes.getLength() == 0) return;

    log.info("Adding specified lib dirs to ClassLoader");
    SolrResourceLoader loader = getResourceLoader();

    try {
      for (int i = 0; i < nodes.getLength(); i++) {
        Node node = nodes.item(i);

        String baseDir = DOMUtil.getAttr(node, "dir");
        String path = DOMUtil.getAttr(node, "path");
        if (null != baseDir) {
          // :TODO: add support for a simpler 'glob' mutually exclusive of regex
          String regex = DOMUtil.getAttr(node, "regex");
          FileFilter filter = (null == regex) ? null : new RegexFileFilter(regex);
          loader.addToClassLoader(baseDir, filter, false);
        } else if (null != path) {
          final File file = FileUtils.resolvePath(new File(loader.getInstanceDir()), path);
          loader.addToClassLoader(
              file.getParent(),
              new FileFilter() {
                @Override
                public boolean accept(File pathname) {
                  return pathname.equals(file);
                }
              },
              false);
        } else {
          throw new RuntimeException("lib: missing mandatory attributes: 'dir' or 'path'");
        }
      }
    } finally {
      loader.reloadLuceneSPI();
    }
  }