@Test public void directoryMapping() throws Exception{ LuceneIndexDefinition defn = LuceneIndexDefinition.newBuilder(root, idx.getNodeState(), "/fooIndex").build(); FSDirectoryFactory factory = new FSDirectoryFactory(temporaryFolder.getRoot()); Directory dir1 = factory.newInstance(defn, idx, ":data", false); dir1.close(); Directory dir2 = factory.newInstance(defn, idx, ":some-other-data", false); dir2.close(); IndexRootDirectory idxDir = new IndexRootDirectory(temporaryFolder.getRoot()); LocalIndexDir indexDir = idxDir.getLocalIndexes("/fooIndex").get(0); for (File dir : indexDir.dir.listFiles((FileFilter)DirectoryFileFilter.DIRECTORY)){ assertNotNull(indexDir.indexMeta.getJcrNameFromFSName(dir.getName())); } }
@Override public Directory newInstance(LuceneIndexDefinition definition, NodeBuilder builder, String dirName, boolean reindex) throws IOException { File indexDir = DirectoryUtils.createIndexDir(baseDir, definition.getIndexPath()); File readMe = new File(indexDir, INDEX_METADATA_FILE_NAME); File subDir = DirectoryUtils.createSubDir(indexDir, dirName); FileUtils.forceMkdir(subDir); IndexMeta meta; if (!readMe.exists()) { meta = new IndexMeta(definition.getIndexPath()); } else { meta = new IndexMeta(readMe); } meta.addDirectoryMapping(dirName, subDir.getName()); DirectoryUtils.writeMeta(indexDir, meta); return FSDirectory.open(subDir, NoLockFactory.getNoLockFactory()); }
FSDirectoryFactory implements DirectoryFactory { @Override public Directory newInstance(LuceneIndexDefinition definition, NodeBuilder builder, String dirName, boolean reindex) throws IOException { File indexDir = DirectoryUtils.createIndexDir(baseDir, definition.getIndexPath()); File readMe = new File(indexDir, INDEX_METADATA_FILE_NAME); File subDir = DirectoryUtils.createSubDir(indexDir, dirName); FileUtils.forceMkdir(subDir); IndexMeta meta; if (!readMe.exists()) { meta = new IndexMeta(definition.getIndexPath()); } else { meta = new IndexMeta(readMe); } meta.addDirectoryMapping(dirName, subDir.getName()); DirectoryUtils.writeMeta(indexDir, meta); return FSDirectory.open(subDir, NoLockFactory.getNoLockFactory()); } }
FSDirectoryFactory implements DirectoryFactory { @Override public Directory newInstance(LuceneIndexDefinition definition, NodeBuilder builder, String dirName, boolean reindex) throws IOException { File indexDir = DirectoryUtils.createIndexDir(baseDir, definition.getIndexPath()); File readMe = new File(indexDir, INDEX_METADATA_FILE_NAME); File subDir = DirectoryUtils.createSubDir(indexDir, dirName); FileUtils.forceMkdir(subDir); IndexMeta meta; if (!readMe.exists()) { meta = new IndexMeta(definition.getIndexPath()); } else { meta = new IndexMeta(readMe); } meta.addDirectoryMapping(dirName, subDir.getName()); DirectoryUtils.writeMeta(indexDir, meta); return FSDirectory.open(subDir, NoLockFactory.getNoLockFactory()); } FSDirectoryFactory(File baseDir); }
FSDirectoryFactory implements DirectoryFactory { @Override public Directory newInstance(LuceneIndexDefinition definition, NodeBuilder builder, String dirName, boolean reindex) throws IOException { File indexDir = DirectoryUtils.createIndexDir(baseDir, definition.getIndexPath()); File readMe = new File(indexDir, INDEX_METADATA_FILE_NAME); File subDir = DirectoryUtils.createSubDir(indexDir, dirName); FileUtils.forceMkdir(subDir); IndexMeta meta; if (!readMe.exists()) { meta = new IndexMeta(definition.getIndexPath()); } else { meta = new IndexMeta(readMe); } meta.addDirectoryMapping(dirName, subDir.getName()); DirectoryUtils.writeMeta(indexDir, meta); return FSDirectory.open(subDir, NoLockFactory.getNoLockFactory()); } FSDirectoryFactory(File baseDir); @Override Directory newInstance(LuceneIndexDefinition definition, NodeBuilder builder,
                                 String dirName, boolean reindex); @Override boolean remoteDirectory(); }
FSDirectoryFactory implements DirectoryFactory { @Override public Directory newInstance(LuceneIndexDefinition definition, NodeBuilder builder, String dirName, boolean reindex) throws IOException { File indexDir = DirectoryUtils.createIndexDir(baseDir, definition.getIndexPath()); File readMe = new File(indexDir, INDEX_METADATA_FILE_NAME); File subDir = DirectoryUtils.createSubDir(indexDir, dirName); FileUtils.forceMkdir(subDir); IndexMeta meta; if (!readMe.exists()) { meta = new IndexMeta(definition.getIndexPath()); } else { meta = new IndexMeta(readMe); } meta.addDirectoryMapping(dirName, subDir.getName()); DirectoryUtils.writeMeta(indexDir, meta); return FSDirectory.open(subDir, NoLockFactory.getNoLockFactory()); } FSDirectoryFactory(File baseDir); @Override Directory newInstance(LuceneIndexDefinition definition, NodeBuilder builder,
                                 String dirName, boolean reindex); @Override boolean remoteDirectory();  }