@Test public void longFileName() throws Exception{ String longName = Strings.repeat("x", IndexRootDirectory.MAX_NAME_LENGTH); assertEquals(longName, IndexRootDirectory.getIndexFolderBaseName(longName)); String longName2 = Strings.repeat("x", IndexRootDirectory.MAX_NAME_LENGTH + 10); assertEquals(longName, IndexRootDirectory.getIndexFolderBaseName(longName2)); }
static String getIndexFolderBaseName(String indexPath) { List<String> elements = Lists.newArrayList(PathUtils.elements(indexPath)); Collections.reverse(elements); List<String> result = Lists.newArrayListWithCapacity(2); for (String e : Iterables.limit(elements, 3)) { if ("oak:index".equals(e)) { continue; } result.add(getFSSafeName(e)); } Collections.reverse(result); String name = Joiner.on('_').join(result); if (name.length() > MAX_NAME_LENGTH){ name = name.substring(0, MAX_NAME_LENGTH); } return name; }
IndexRootDirectory { static String getIndexFolderBaseName(String indexPath) { List<String> elements = Lists.newArrayList(PathUtils.elements(indexPath)); Collections.reverse(elements); List<String> result = Lists.newArrayListWithCapacity(2); for (String e : Iterables.limit(elements, 3)) { if ("oak:index".equals(e)) { continue; } result.add(getFSSafeName(e)); } Collections.reverse(result); String name = Joiner.on('_').join(result); if (name.length() > MAX_NAME_LENGTH){ name = name.substring(0, MAX_NAME_LENGTH); } return name; } }
IndexRootDirectory { static String getIndexFolderBaseName(String indexPath) { List<String> elements = Lists.newArrayList(PathUtils.elements(indexPath)); Collections.reverse(elements); List<String> result = Lists.newArrayListWithCapacity(2); for (String e : Iterables.limit(elements, 3)) { if ("oak:index".equals(e)) { continue; } result.add(getFSSafeName(e)); } Collections.reverse(result); String name = Joiner.on('_').join(result); if (name.length() > MAX_NAME_LENGTH){ name = name.substring(0, MAX_NAME_LENGTH); } return name; } IndexRootDirectory(File indexRootDir);  IndexRootDirectory(File indexRootDir, boolean gcOnStart); }
IndexRootDirectory { static String getIndexFolderBaseName(String indexPath) { List<String> elements = Lists.newArrayList(PathUtils.elements(indexPath)); Collections.reverse(elements); List<String> result = Lists.newArrayListWithCapacity(2); for (String e : Iterables.limit(elements, 3)) { if ("oak:index".equals(e)) { continue; } result.add(getFSSafeName(e)); } Collections.reverse(result); String name = Joiner.on('_').join(result); if (name.length() > MAX_NAME_LENGTH){ name = name.substring(0, MAX_NAME_LENGTH); } return name; } IndexRootDirectory(File indexRootDir);  IndexRootDirectory(File indexRootDir, boolean gcOnStart); long getSize(); File getIndexDir(IndexDefinition definition, String indexPath, String dirName); List<LocalIndexDir> getAllLocalIndexes(); List<LocalIndexDir> getLocalIndexes(String jcrPath); long gcEmptyDirs(File subDir); }
IndexRootDirectory { static String getIndexFolderBaseName(String indexPath) { List<String> elements = Lists.newArrayList(PathUtils.elements(indexPath)); Collections.reverse(elements); List<String> result = Lists.newArrayListWithCapacity(2); for (String e : Iterables.limit(elements, 3)) { if ("oak:index".equals(e)) { continue; } result.add(getFSSafeName(e)); } Collections.reverse(result); String name = Joiner.on('_').join(result); if (name.length() > MAX_NAME_LENGTH){ name = name.substring(0, MAX_NAME_LENGTH); } return name; } IndexRootDirectory(File indexRootDir);  IndexRootDirectory(File indexRootDir, boolean gcOnStart); long getSize(); File getIndexDir(IndexDefinition definition, String indexPath, String dirName); List<LocalIndexDir> getAllLocalIndexes(); List<LocalIndexDir> getLocalIndexes(String jcrPath); long gcEmptyDirs(File subDir); static final String INDEX_METADATA_FILE_NAME; }