()
| 49 | public BoxBrowser(Box root) { |
| 50 | this.root = root; |
| 51 | } |
| 52 | |
| 53 | public void loaded() { |
| 54 | |
| 55 | this.s = root.find(ServerSupport.server, this.both()) |
| 56 | .findFirst() |
| 57 | .orElseThrow(() -> new IllegalArgumentException("need server for boxbrowser")); |
| 58 | |
| 59 | s.addDocumentRoot(fieldagent.Main.app + "/fieldbox/resources/"); |
| 60 | s.addURIHandler((uri, method, headers, params, files) -> { |
| 61 | if (uri.startsWith(NAMED)) { |
| 62 | uri = uri.substring(NAMED.length()); |
| 63 | String[] pieces = uri.split("/"); |
| 64 | return handleBy(x -> x.properties.has(Box.name) && x.properties.get(Box.name) |
| 65 | .equals(pieces[0]), pieces.length > 1 ? pieces[1] : null); |
| 66 | } else if (uri.startsWith(ID)) { |
| 67 | uri = uri.substring(ID.length()); |
| 68 | String[] pieces = uri.split("/"); |
| 69 | return handleBy(x -> x.properties.has(IO.id) && x.properties.get(IO.id) |
| 70 | .equals(pieces[0]), pieces.length > 1 ? pieces[1] : null); |
| 71 | } else if (uri.startsWith(DOCUMENTATION)) { |
| 72 | uri = uri.substring(DOCUMENTATION.length()); |
| 73 | String[] pieces = uri.split("/"); |
| 74 | Object object = knownObjects.get(pieces[0]); |
| 75 | if (object != null) { |
| 76 | return handleObject(object, pieces.length > 1 ? pieces[1] : null); |
| 77 | } |
| 78 | } |
| 79 | return null; |
| 80 | }); |
| 81 | } |
| 82 |
nothing calls this directly
no test coverage detected