@Test(expected = IndexVersion.IndexVersionException.class) public void testIndexVersionOldIndex() throws Exception { oldIndexDataDir = Files.createTempDirectory("data"); Path indexPath = oldIndexDataDir.resolve("index"); Files.createDirectory(indexPath); File indexDir = new File(indexPath.toString()); assertTrue("index directory check", indexDir.isDirectory()); URL oldindex = getClass().getResource("/index/oldindex.zip"); assertNotNull("resource needs to be non null", oldindex); File archive = new File(oldindex.getPath()); assertTrue("archive exists", archive.isFile()); FileUtilities.extractArchive(archive, indexDir); env.setDataRoot(oldIndexDataDir.toString()); env.setProjectsEnabled(false); IndexVersion.check(new ArrayList<>()); }
public static void check(List<String> subFilesList) throws Exception { RuntimeEnvironment env = RuntimeEnvironment.getInstance(); File indexRoot = new File(env.getDataRootPath(), IndexDatabase.INDEX_DIR); LOGGER.log(Level.FINE, "Checking for Lucene index version mismatch in {0}", indexRoot); if (!subFilesList.isEmpty()) { for (String projectName : subFilesList) { LOGGER.log(Level.FINER, "Checking Lucene index version in project {0}", projectName); checkDir(new File(indexRoot, projectName)); } } else { if (env.isProjectsEnabled()) { for (String projectName : env.getProjects().keySet()) { LOGGER.log(Level.FINER, "Checking Lucene index version in project {0}", projectName); checkDir(new File(indexRoot, projectName)); } } else { LOGGER.log(Level.FINER, "Checking Lucene index version in {0}", indexRoot); checkDir(indexRoot); } } }
IndexVersion { public static void check(List<String> subFilesList) throws Exception { RuntimeEnvironment env = RuntimeEnvironment.getInstance(); File indexRoot = new File(env.getDataRootPath(), IndexDatabase.INDEX_DIR); LOGGER.log(Level.FINE, "Checking for Lucene index version mismatch in {0}", indexRoot); if (!subFilesList.isEmpty()) { for (String projectName : subFilesList) { LOGGER.log(Level.FINER, "Checking Lucene index version in project {0}", projectName); checkDir(new File(indexRoot, projectName)); } } else { if (env.isProjectsEnabled()) { for (String projectName : env.getProjects().keySet()) { LOGGER.log(Level.FINER, "Checking Lucene index version in project {0}", projectName); checkDir(new File(indexRoot, projectName)); } } else { LOGGER.log(Level.FINER, "Checking Lucene index version in {0}", indexRoot); checkDir(indexRoot); } } } }
IndexVersion { public static void check(List<String> subFilesList) throws Exception { RuntimeEnvironment env = RuntimeEnvironment.getInstance(); File indexRoot = new File(env.getDataRootPath(), IndexDatabase.INDEX_DIR); LOGGER.log(Level.FINE, "Checking for Lucene index version mismatch in {0}", indexRoot); if (!subFilesList.isEmpty()) { for (String projectName : subFilesList) { LOGGER.log(Level.FINER, "Checking Lucene index version in project {0}", projectName); checkDir(new File(indexRoot, projectName)); } } else { if (env.isProjectsEnabled()) { for (String projectName : env.getProjects().keySet()) { LOGGER.log(Level.FINER, "Checking Lucene index version in project {0}", projectName); checkDir(new File(indexRoot, projectName)); } } else { LOGGER.log(Level.FINER, "Checking Lucene index version in {0}", indexRoot); checkDir(indexRoot); } } } private  IndexVersion(); }
IndexVersion { public static void check(List<String> subFilesList) throws Exception { RuntimeEnvironment env = RuntimeEnvironment.getInstance(); File indexRoot = new File(env.getDataRootPath(), IndexDatabase.INDEX_DIR); LOGGER.log(Level.FINE, "Checking for Lucene index version mismatch in {0}", indexRoot); if (!subFilesList.isEmpty()) { for (String projectName : subFilesList) { LOGGER.log(Level.FINER, "Checking Lucene index version in project {0}", projectName); checkDir(new File(indexRoot, projectName)); } } else { if (env.isProjectsEnabled()) { for (String projectName : env.getProjects().keySet()) { LOGGER.log(Level.FINER, "Checking Lucene index version in project {0}", projectName); checkDir(new File(indexRoot, projectName)); } } else { LOGGER.log(Level.FINER, "Checking Lucene index version in {0}", indexRoot); checkDir(indexRoot); } } } private  IndexVersion(); static void check(List<String> subFilesList); }
IndexVersion { public static void check(List<String> subFilesList) throws Exception { RuntimeEnvironment env = RuntimeEnvironment.getInstance(); File indexRoot = new File(env.getDataRootPath(), IndexDatabase.INDEX_DIR); LOGGER.log(Level.FINE, "Checking for Lucene index version mismatch in {0}", indexRoot); if (!subFilesList.isEmpty()) { for (String projectName : subFilesList) { LOGGER.log(Level.FINER, "Checking Lucene index version in project {0}", projectName); checkDir(new File(indexRoot, projectName)); } } else { if (env.isProjectsEnabled()) { for (String projectName : env.getProjects().keySet()) { LOGGER.log(Level.FINER, "Checking Lucene index version in project {0}", projectName); checkDir(new File(indexRoot, projectName)); } } else { LOGGER.log(Level.FINER, "Checking Lucene index version in {0}", indexRoot); checkDir(indexRoot); } } } private  IndexVersion(); static void check(List<String> subFilesList);  }