• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanopub-registry / 20413250445

21 Dec 2025 05:19PM UTC coverage: 0.924% (-0.03%) from 0.954%
20413250445

push

github

ashleycaselli
chore: minor code cleanup

6 of 592 branches covered (1.01%)

Branch coverage included in aggregate %.

16 of 1789 relevant lines covered (0.89%)

0.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/main/java/com/knowledgepixels/registry/DebugPage.java
1
package com.knowledgepixels.registry;
2

3
import com.mongodb.client.ClientSession;
4
import com.mongodb.client.MongoCursor;
5
import io.vertx.ext.web.RoutingContext;
6
import org.bson.Document;
7

8
import java.io.IOException;
9

10
import static com.knowledgepixels.registry.RegistryDB.collection;
11
import static com.mongodb.client.model.Indexes.ascending;
12

13
public class DebugPage extends Page {
14

15
    public static void show(RoutingContext context) {
16
        DebugPage page;
17
        try (ClientSession s = RegistryDB.getClient().startSession()) {
×
18
            s.startTransaction();
×
19
            page = new DebugPage(s, context);
×
20
            page.show();
×
21
        } catch (IOException ex) {
×
22
            ex.printStackTrace();
×
23
        } finally {
24
            context.response().end();
×
25
            // TODO Clean-up here?
26
        }
27
    }
×
28

29
    private DebugPage(ClientSession mongoSession, RoutingContext context) {
30
        super(mongoSession, context);
×
31
    }
×
32

33
    protected void show() throws IOException {
34
        RoutingContext c = getContext();
×
35

36
        if (getRequestString().matches("/debug/trustPaths")) {
×
37
            String counterString = c.request().getParam("trustStateCounter");
×
38
            if (counterString == null) {
×
39
                print(getTrustPathsTxt(mongoSession));
×
40
            } else {
41
                Long counter = Long.parseLong(counterString);
×
42
                print(RegistryDB.getOne(mongoSession, "debug_trustPaths", new Document("trustStateCounter", counter)).getString("trustStateTxt"));
×
43
            }
44
            setRespContentType("text/plain");
×
45
        } else if (getRequestString().matches("/debug/endorsements")) {
×
46
            MongoCursor<Document> tp = collection("endorsements").find(mongoSession).cursor();
×
47
            while (tp.hasNext()) {
×
48
                Document d = tp.next();
×
49
                println(d.get("agent") + ">" + d.get("pubkey") + " " + d.get("endorsedNanopub") + " " + d.get("source") + " (" + d.get("status") + ")");
×
50
            }
×
51
            setRespContentType("text/plain");
×
52
        } else if (getRequestString().matches("/debug/accounts")) {
×
53
            MongoCursor<Document> tp = collection("accounts").find(mongoSession).cursor();
×
54
            while (tp.hasNext()) {
×
55
                Document d = tp.next();
×
56
                println(d.getString("agent") + ">" + d.get("pubkey") + " " + d.get("depth") + " (" + d.get("status") + ")");
×
57
            }
×
58
        } else {
×
59
            c.response().setStatusCode(400).setStatusMessage("Invalid request: " + getFullRequest());
×
60
        }
61
    }
×
62

63
    public static String getTrustPathsTxt(ClientSession mongoSession) {
64
        String s = "";
×
65
        MongoCursor<Document> tp = collection("trustPaths").find(mongoSession).sort(ascending("_id")).cursor();
×
66
        while (tp.hasNext()) {
×
67
            Document d = tp.next();
×
68
            String path = d.getString("_id");
×
69
            path = path.replace(" ", " > ");
×
70
            if (d.getString("type").equals("extended")) {
×
71
                path = path.replaceFirst(" > ([^ ]+)$", " ~ $1");
×
72
            }
73
            s += path + "\n";
×
74
        }
×
75
        return s;
×
76
    }
77

78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc