@Test public void testGetChildren() { Collection<ConfigKeyPath> children1 = this.store.getChildren(this.rootPath, this.version); Assert.assertEquals(children1.size(), 1); Assert.assertTrue(children1.contains(this.testPath)); Collection<ConfigKeyPath> children2 = this.store.getChildren(this.testPath, this.version); Assert.assertEquals(children2.size(), 2); Assert.assertTrue(children2.contains(this.child1Path)); Assert.assertTrue(children2.contains(this.child2Path)); Collection<ConfigKeyPath> children3 = this.store.getChildren(this.child1Path, this.version); Assert.assertEquals(children3.size(), 0); }
@Override public Collection<ConfigKeyPath> getChildren(ConfigKeyPath configKey, String version) throws VersionDoesNotExistException { Preconditions.checkNotNull(configKey, "configKey cannot be null!"); Preconditions.checkArgument(version.equals(getCurrentVersion())); List<ConfigKeyPath> children = new ArrayList<>(); Path datasetDir = getDatasetDirForKey(configKey); try { if (!Files.exists(this.fs.getPath(datasetDir.toString()))) { throw new PhysicalPathNotExistException(this.logicalStoreRoot, "Cannot find physical location:" + this.fs.getPath(datasetDir.toString())); } Stream<Path> files = Files.walk(datasetDir, 1); for (Iterator<Path> it = files.iterator(); it.hasNext();) { Path path = it.next(); if (Files.isDirectory(path) && !path.equals(datasetDir)) { children.add(configKey.createChild(StringUtils.removeEnd(path.getName(path.getNameCount() - 1).toString(), SingleLinkedListConfigKeyPath.PATH_DELIMETER))); } } return children; } catch (IOException e) { throw new RuntimeException(String.format("Error while getting children for configKey: \"%s\"", configKey), e); } }
ZipFileConfigStore implements ConfigStore { @Override public Collection<ConfigKeyPath> getChildren(ConfigKeyPath configKey, String version) throws VersionDoesNotExistException { Preconditions.checkNotNull(configKey, "configKey cannot be null!"); Preconditions.checkArgument(version.equals(getCurrentVersion())); List<ConfigKeyPath> children = new ArrayList<>(); Path datasetDir = getDatasetDirForKey(configKey); try { if (!Files.exists(this.fs.getPath(datasetDir.toString()))) { throw new PhysicalPathNotExistException(this.logicalStoreRoot, "Cannot find physical location:" + this.fs.getPath(datasetDir.toString())); } Stream<Path> files = Files.walk(datasetDir, 1); for (Iterator<Path> it = files.iterator(); it.hasNext();) { Path path = it.next(); if (Files.isDirectory(path) && !path.equals(datasetDir)) { children.add(configKey.createChild(StringUtils.removeEnd(path.getName(path.getNameCount() - 1).toString(), SingleLinkedListConfigKeyPath.PATH_DELIMETER))); } } return children; } catch (IOException e) { throw new RuntimeException(String.format("Error while getting children for configKey: \"%s\"", configKey), e); } } }
ZipFileConfigStore implements ConfigStore { @Override public Collection<ConfigKeyPath> getChildren(ConfigKeyPath configKey, String version) throws VersionDoesNotExistException { Preconditions.checkNotNull(configKey, "configKey cannot be null!"); Preconditions.checkArgument(version.equals(getCurrentVersion())); List<ConfigKeyPath> children = new ArrayList<>(); Path datasetDir = getDatasetDirForKey(configKey); try { if (!Files.exists(this.fs.getPath(datasetDir.toString()))) { throw new PhysicalPathNotExistException(this.logicalStoreRoot, "Cannot find physical location:" + this.fs.getPath(datasetDir.toString())); } Stream<Path> files = Files.walk(datasetDir, 1); for (Iterator<Path> it = files.iterator(); it.hasNext();) { Path path = it.next(); if (Files.isDirectory(path) && !path.equals(datasetDir)) { children.add(configKey.createChild(StringUtils.removeEnd(path.getName(path.getNameCount() - 1).toString(), SingleLinkedListConfigKeyPath.PATH_DELIMETER))); } } return children; } catch (IOException e) { throw new RuntimeException(String.format("Error while getting children for configKey: \"%s\"", configKey), e); } } ZipFileConfigStore(ZipFileSystem fs, URI logicalStoreRoot, String version, String storePrefix); }
ZipFileConfigStore implements ConfigStore { @Override public Collection<ConfigKeyPath> getChildren(ConfigKeyPath configKey, String version) throws VersionDoesNotExistException { Preconditions.checkNotNull(configKey, "configKey cannot be null!"); Preconditions.checkArgument(version.equals(getCurrentVersion())); List<ConfigKeyPath> children = new ArrayList<>(); Path datasetDir = getDatasetDirForKey(configKey); try { if (!Files.exists(this.fs.getPath(datasetDir.toString()))) { throw new PhysicalPathNotExistException(this.logicalStoreRoot, "Cannot find physical location:" + this.fs.getPath(datasetDir.toString())); } Stream<Path> files = Files.walk(datasetDir, 1); for (Iterator<Path> it = files.iterator(); it.hasNext();) { Path path = it.next(); if (Files.isDirectory(path) && !path.equals(datasetDir)) { children.add(configKey.createChild(StringUtils.removeEnd(path.getName(path.getNameCount() - 1).toString(), SingleLinkedListConfigKeyPath.PATH_DELIMETER))); } } return children; } catch (IOException e) { throw new RuntimeException(String.format("Error while getting children for configKey: \"%s\"", configKey), e); } } ZipFileConfigStore(ZipFileSystem fs, URI logicalStoreRoot, String version, String storePrefix); @Override String getCurrentVersion(); @Override URI getStoreURI(); @Override Collection<ConfigKeyPath> getChildren(ConfigKeyPath configKey, String version); @Override List<ConfigKeyPath> getOwnImports(ConfigKeyPath configKey, String version); List<ConfigKeyPath> getOwnImports(ConfigKeyPath configKey, String version, Optional<Config> runtimeConfig); @Override Config getOwnConfig(ConfigKeyPath configKey, String version); }
ZipFileConfigStore implements ConfigStore { @Override public Collection<ConfigKeyPath> getChildren(ConfigKeyPath configKey, String version) throws VersionDoesNotExistException { Preconditions.checkNotNull(configKey, "configKey cannot be null!"); Preconditions.checkArgument(version.equals(getCurrentVersion())); List<ConfigKeyPath> children = new ArrayList<>(); Path datasetDir = getDatasetDirForKey(configKey); try { if (!Files.exists(this.fs.getPath(datasetDir.toString()))) { throw new PhysicalPathNotExistException(this.logicalStoreRoot, "Cannot find physical location:" + this.fs.getPath(datasetDir.toString())); } Stream<Path> files = Files.walk(datasetDir, 1); for (Iterator<Path> it = files.iterator(); it.hasNext();) { Path path = it.next(); if (Files.isDirectory(path) && !path.equals(datasetDir)) { children.add(configKey.createChild(StringUtils.removeEnd(path.getName(path.getNameCount() - 1).toString(), SingleLinkedListConfigKeyPath.PATH_DELIMETER))); } } return children; } catch (IOException e) { throw new RuntimeException(String.format("Error while getting children for configKey: \"%s\"", configKey), e); } } ZipFileConfigStore(ZipFileSystem fs, URI logicalStoreRoot, String version, String storePrefix); @Override String getCurrentVersion(); @Override URI getStoreURI(); @Override Collection<ConfigKeyPath> getChildren(ConfigKeyPath configKey, String version); @Override List<ConfigKeyPath> getOwnImports(ConfigKeyPath configKey, String version); List<ConfigKeyPath> getOwnImports(ConfigKeyPath configKey, String version, Optional<Config> runtimeConfig); @Override Config getOwnConfig(ConfigKeyPath configKey, String version);  }