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

knowledgepixels / nanopub-registry / 24089041807

07 Apr 2026 03:14PM UTC coverage: 33.374% (+0.5%) from 32.913%
24089041807

push

github

web-flow
Merge pull request #96 from knowledgepixels/feat/agent-quota-enforcement

feat: enforce agent/pubkey quota restrictions

273 of 900 branches covered (30.33%)

Branch coverage included in aggregate %.

809 of 2342 relevant lines covered (34.54%)

5.77 hits per line

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

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

3
import com.mongodb.client.ClientSession;
4
import io.vertx.ext.web.RoutingContext;
5

6
import java.io.IOException;
7

8
import static com.knowledgepixels.registry.RegistryDB.*;
9

10
public class MainPage extends Page {
11

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

26
    private MainPage(ClientSession mongoSession, RoutingContext context) {
27
        super(mongoSession, context);
×
28
    }
×
29

30
    protected void show() throws IOException {
31
        RoutingContext c = getContext();
×
32
        String format;
33
        String ext = getExtension();
×
34
        if ("json".equals(ext)) {
×
35
            format = "application/json";
×
36
        } else if (ext == null || "html".equals(ext)) {
×
37
            String suppFormats = "application/json,text/html";
×
38
            format = Utils.getMimeType(c, suppFormats);
×
39
        } else {
×
40
            c.response().setStatusCode(400).setStatusMessage("Invalid request: " + getFullRequest());
×
41
            return;
×
42
        }
43

44
        if (getPresentationFormat() != null) {
×
45
            setRespContentType(getPresentationFormat());
×
46
        } else {
47
            setRespContentType(format);
×
48
        }
49

50
        if ("application/json".equals(format)) {
×
51
            println(RegistryInfo.getLocal(mongoSession).asJson());
×
52
        } else {
53
            String status = getValue(mongoSession, Collection.SERVER_INFO.toString(), "status").toString();
×
54
            printHtmlHeader("Nanopub Registry");
×
55
            println("<h1>Nanopub Registry</h1>");
×
56
            if (isSet(mongoSession, Collection.SERVER_INFO.toString(), "testInstance")) {
×
57
                println("<p style=\"color: red\">This is a test instance.</p>");
×
58
            }
59
            println("<h3>Formats</h3>");
×
60
            println("<p>");
×
61
            println("<a href=\".json\">.json</a> |");
×
62
            println("<a href=\".json.txt\">.json.txt</a>");
×
63
            println("</p>");
×
64
            println("<h3>Server</h3>");
×
65
            println("<ul>");
×
66
            println("<li><em>setupId:</em> " + getValue(mongoSession, Collection.SERVER_INFO.toString(), "setupId") + "</li>");
×
67
            println("<li><em>coverageTypes:</em> " + getValue(mongoSession, Collection.SERVER_INFO.toString(), "coverageTypes") + "</li>");
×
68
            println("<li><em>coverageAgents:</em> " + getValue(mongoSession, Collection.SERVER_INFO.toString(), "coverageAgents") + "</li>");
×
69
            println("<li><em>optionalLoadEnabled:</em> " + !"false".equals(System.getenv("REGISTRY_ENABLE_OPTIONAL_LOAD")) + "</li>");
×
70
            println("<li><em>trustCalculationEnabled:</em> " + !"false".equals(System.getenv("REGISTRY_ENABLE_TRUST_CALCULATION")) + "</li>");
×
71
            println("<li><em>status:</em> " + status + "</li>");
×
72
            println("<li><em>seqNum:</em> " + getMaxValue(mongoSession, Collection.NANOPUBS.toString(), "seqNum") + "</li>");
×
73
            println("<li><em>nanopubCount:</em> " + collection(Collection.NANOPUBS.toString()).estimatedDocumentCount() + "</li>");
×
74
            println("<li><em>trustStateCounter:</em> " + getValue(mongoSession, Collection.SERVER_INFO.toString(), "trustStateCounter") + "</li>");
×
75
            Object lastTimeUpdate = getValue(mongoSession, Collection.SERVER_INFO.toString(), "lastTrustStateUpdate");
×
76
            if (lastTimeUpdate != null) {
×
77
                println("<li><em>lastTrustStateUpdate:</em> " + lastTimeUpdate.toString().replaceFirst("\\.[^.]*$", "") + "</li>");
×
78
            } else {
79
                println("<li><em>lastTrustStateUpdate:</em> null</li>");
×
80
            }
81
            Object trustStateHash = getValue(mongoSession, Collection.SERVER_INFO.toString(), "trustStateHash");
×
82
            if (trustStateHash != null) trustStateHash = trustStateHash.toString().substring(0, 10);
×
83
            println("<li><em>trustStateHash:</em> " + trustStateHash + "</li>");
×
84
            String oSetting = getValue(mongoSession, Collection.SETTING.toString(), "original").toString();
×
85
            println("<li><em>originalSetting:</em> <a href=\"/np/" + oSetting + "\"><code>" + oSetting.substring(0, 10) + "</code></a></li>");
×
86
            String cSetting = getValue(mongoSession, Collection.SETTING.toString(), "current").toString();
×
87
            println("<li><em>currentSetting:</em> <a href=\"/np/" + cSetting + "\"><code>" + cSetting.substring(0, 10) + "</code></a></li>");
×
88
            println("</ul>");
×
89

90
            if (!"false".equals(System.getenv("REGISTRY_ENABLE_TRUST_CALCULATION"))) {
×
91
                println("<h3>Agents</h3>");
×
92
                if (status.equals("launching") || status.equals("coreLoading")) {
×
93
                    println("<p><em>(loading...)</em></p>");
×
94
                } else {
95
                    println("<p>Count: " + collection(Collection.AGENTS.toString()).countDocuments(mongoSession) + "</p>");
×
96
                    println("<p><a href=\"/agents\">&gt; agents</a></pi>");
×
97
                }
98
            }
99

100
            println("<h3>Accounts</h3>");
×
101
            if (status.equals("launching") || status.equals("coreLoading")) {
×
102
                println("<p><em>(loading...)</em></p>");
×
103
            } else {
104
                println("<p>Count: " + collection(Collection.ACCOUNTS.toString()).countDocuments(mongoSession) + "</p>");
×
105
                println("<p><a href=\"/list\">&gt; accounts</a></pi>");
×
106
            }
107

108
            println("<h3>Nanopubs</h3>");
×
109
            println("<p>Count: " + collection(Collection.NANOPUBS.toString()).estimatedDocumentCount() + "</p>");
×
110
            println("<p><a href=\"/nanopubs\">&gt; nanopubs</a></pi>");
×
111
            printHtmlFooter();
×
112
        }
113
    }
×
114

115
}
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