-1

I would appreciate any hints on how to make recursive requests with the WSClient. I am accessing a REST api which returns nodes of a tree in json format, for example this would be the root node:

{
  id: "root"
  children:[
    {
      id: "node1"
      children:[...]
    },
    {
      id: "node2"
      children:[...]
    },
    {
      id: "node3"
      children:[...]
    }
  ]
}

To access each node the url pattern is

root/node1/node1-1

What i would like to do is to traverse the whole tree and get some information according to some criteria.

Thanks in advance

jorgeb
  • 23
  • 5
  • `flatMap` is the way to go. On a more serious note, you should show what you have tried and where you got stuck rather than expect somebody to come up with the solution for you. – rethab Feb 26 '17 at 19:28
  • Hello, i am not asking for someone to give me the solution This is the reason i'm not giving any extra details. So far i can access a single node using the CompletionStage from java8. – jorgeb Feb 26 '17 at 19:34

1 Answers1

0

This task is like a twin of classic directory tree traverse.

I am pretty sure you can do this with clean recursion, but using Akka is a more clean way to do it.

Here are the examples:

Use akka actors to traverse directory tree

https://gist.github.com/TheDIM47/8bfa2bbf80e791c00e73

You can use Java as well, but it's a more verbose.

Community
  • 1
  • 1
Andriy Kuba
  • 8,093
  • 2
  • 29
  • 46