Ok. I can say that this path (using child.getName
) does work; if anyone else would find the code helpful, my version automatically recurses into (only) folders:
fun GatewayTagManager.streamTags(
visit: (TagProvider) -> ((TagPath, TagConfigurationModel) -> Boolean)?
) {
fun browseNode(visit: (TagPath, TagConfigurationModel)->Boolean, fullPath: TagPath, tagConfig: TagConfigurationModel) {
if (visit(fullPath, tagConfig)) when (tagConfig.type) {
TagObjectType.Folder -> {
for (child in tagConfig.children) {
browseNode(visit, fullPath.getChildPath(child.name), child)
}
}
else -> return
}
}
}
runBlocking {
for (provider in tagProviders) {
val root = TagPathParser.parse("[${provider.name}]") // Though one might use some subdir in some cases...
val visitor = visit(provider)
?: continue
val firstGenerations = provider.getTagConfigsAsync(listOf(root), true, false).get(30, TimeUnit.SECONDS)
for (firstGeneration in firstGenerations) {
when (firstGeneration.type) {
TagObjectType.Provider -> for (secondGeneration in firstGeneration.children) {
browseNode(visitor, root.getChildPath(secondGeneration.name), secondGeneration)
}
else -> browseNode(visitor, root.getChildPath(firstGeneration.name), firstGeneration)
}
}
}
}
}