use of org.apache.gobblin.config.store.api.PhysicalPathNotExistException in project incubator-gobblin by apache.
the class ZipFileConfigStore method getChildren.
/**
* Retrieves all the children of the given {@link ConfigKeyPath} using {@link Files#walk} to list files
*/
@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);
}
}
Aggregations