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

knowledgepixels / nanopub-registry / 28155387420

25 Jun 2026 07:53AM UTC coverage: 31.926% (-0.2%) from 32.089%
28155387420

push

github

web-flow
chore: enhance and standardize logging across multiple components (#116)

* chore(EntryStatus): enhance logging for null and unsupported status value handling

* chore(logging): standardize logger variable names across multiple classes

* chore(CoverageFilter): enhance logging for coverage filter initialization and type checks

* chore(RegistryPeerConnector): enhance logging for peer connection and nanopub fetching

* chore(logging): enhance logging for request handling and error reporting in multiple pages

* chore(MainVerticle): enhance logging for HTTP server startup, request routing, and POST processing

* chore(Task): improve logging messages

* chore(Task): enhance logging for server status checks and account loading processes

* chore(RegistryInfo): add logging messages for RegistryInfo snapshot assembly and JSON serialization

* chore(logging): enhance logging throughout various components for better traceability and debugging

* chore(Utils): enhance logging for user IRI extraction in IntroNanopub

* chore(TrustStatePage): enhance logging for trust-state snapshot resolution and querying

* chore(NanopubLoader): enhance logging for nanopub retrieval and processing

* chore(Task): enhance logging for task execution and status transitions

313 of 1106 branches covered (28.3%)

Branch coverage included in aggregate %.

1048 of 3157 relevant lines covered (33.2%)

5.51 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
import org.slf4j.Logger;
6
import org.slf4j.LoggerFactory;
7

8
import java.io.IOException;
9

10
import static com.knowledgepixels.registry.RegistryDB.*;
11

12
public class MainPage extends Page {
13

14
    private static final Logger logger = LoggerFactory.getLogger(MainPage.class);
×
15

16
    public static void show(RoutingContext context) {
17
        MainPage page;
18
        logger.info("Received main request: {}", context.request().path());
×
19
        try (ClientSession s = RegistryDB.getClient().startSession()) {
×
20
            s.startTransaction();
×
21
            page = new MainPage(s, context);
×
22
            page.show();
×
23
        } catch (IOException ex) {
×
24
            logger.warn("Failed to show main page for request {}: {} ({})", context.request().path(), ex.getMessage(), ex.getClass().getSimpleName(), ex);
×
25
        } finally {
26
            logger.debug("Ending response for main request: {}", context.request().path());
×
27
            context.response().end();
×
28
            // TODO Clean-up here?
29
        }
30
    }
×
31

32
    private MainPage(ClientSession mongoSession, RoutingContext context) {
33
        super(mongoSession, context);
×
34
    }
×
35

36
    protected void show() throws IOException {
37
        RoutingContext c = getContext();
×
38
        String format;
39
        String ext = getExtension();
×
40

41
        logger.debug("Preparing main page response for request: {} (ext={})", getFullRequest(), ext);
×
42

43
        if ("json".equals(ext)) {
×
44
            format = "application/json";
×
45
        } else if (ext == null || "html".equals(ext)) {
×
46
            String suppFormats = "application/json,text/html";
×
47
            format = Utils.getMimeType(c, suppFormats);
×
48
        } else {
×
49
            logger.warn("Invalid main request (unsupported extension) for {}: {}", getFullRequest(), ext);
×
50
            c.response().setStatusCode(400).setStatusMessage("Invalid request: " + getFullRequest());
×
51
            return;
×
52
        }
53

54
        if (getPresentationFormat() != null) {
×
55
            setRespContentType(getPresentationFormat());
×
56
            logger.debug("Overriding response content type with presentation format: {}", getPresentationFormat());
×
57
        } else {
58
            setRespContentType(format);
×
59
            logger.debug("Set response content type: {}", format);
×
60
        }
61

62
        if ("application/json".equals(format)) {
×
63
            logger.info("Serving main registry info as JSON for {}", getFullRequest());
×
64
            println(RegistryInfo.getLocal(mongoSession).asJson());
×
65
        } else {
66
            String status = serverInfo.get("status") != null ? serverInfo.get("status").toString() : "launching";
×
67
            printHtmlHeader("Nanopub Registry");
×
68
            println("<h1>Nanopub Registry</h1>");
×
69
            if (serverInfo.get("testInstance") != null && (Boolean) serverInfo.get("testInstance")) {
×
70
                println("<p style=\"color: red\">This is a test instance.</p>");
×
71
            }
72
            println("<h3>Formats</h3>");
×
73
            println("<p>");
×
74
            println("<a href=\".json\">.json</a> |");
×
75
            println("<a href=\".json.txt\">.json.txt</a>");
×
76
            println("</p>");
×
77
            println("<h3>Server</h3>");
×
78
            println("<ul>");
×
79
            println("<li><em>setupId:</em> " + serverInfo.get("setupId") + "</li>");
×
80
            println("<li><em>coverageTypes:</em> " + (serverInfo.get("coverageTypes") != null ? serverInfo.get("coverageTypes") : "all") + "</li>");
×
81
            println("<li><em>coverageAgents:</em> " + (serverInfo.get("coverageAgents") != null ? serverInfo.get("coverageAgents") : "viaSetting") + "</li>");
×
82
            println("<li><em>optionalLoadEnabled:</em> " + !"false".equals(System.getenv("REGISTRY_ENABLE_OPTIONAL_LOAD")) + "</li>");
×
83
            println("<li><em>trustCalculationEnabled:</em> " + !"false".equals(System.getenv("REGISTRY_ENABLE_TRUST_CALCULATION")) + "</li>");
×
84
            println("<li><em>status:</em> " + status + "</li>");
×
85
            println("<li><em>loadCounter:</em> " + getMaxValue(mongoSession, Collection.NANOPUBS.toString(), "counter") + "</li>");
×
86
            println("<li><em>nanopubCount:</em> " + collection(Collection.NANOPUBS.toString()).estimatedDocumentCount() + "</li>");
×
87
            println("<li><em>trustStateCounter:</em> " + serverInfo.get("trustStateCounter") + "</li>");
×
88
            Object lastTimeUpdate = serverInfo.get("lastTrustStateUpdate");
×
89
            if (lastTimeUpdate != null) {
×
90
                println("<li><em>lastTrustStateUpdate:</em> " + lastTimeUpdate.toString().replaceFirst("\\.[^.]*$", "") + "</li>");
×
91
            } else {
92
                println("<li><em>lastTrustStateUpdate:</em> null</li>");
×
93
            }
94
            Object trustStateHash = serverInfo.get("trustStateHash");
×
95
            if (trustStateHash != null) {
×
96
                trustStateHash = trustStateHash.toString().substring(0, 10);
×
97
            }
98
            println("<li><em>trustStateHash:</em> " + trustStateHash + "</li>");
×
99
            String oSetting = getValue(mongoSession, Collection.SETTING.toString(), "original").toString();
×
100
            println("<li><em>originalSetting:</em> <a href=\"/np/" + oSetting + "\"><code>" + oSetting.substring(0, 10) + "</code></a></li>");
×
101
            String cSetting = getValue(mongoSession, Collection.SETTING.toString(), "current").toString();
×
102
            println("<li><em>currentSetting:</em> <a href=\"/np/" + cSetting + "\"><code>" + cSetting.substring(0, 10) + "</code></a></li>");
×
103
            println("</ul>");
×
104

105
            if (!"false".equals(System.getenv("REGISTRY_ENABLE_TRUST_CALCULATION"))) {
×
106
                println("<h3>Agents</h3>");
×
107
                if (status.equals("launching") || status.equals("coreLoading")) {
×
108
                    println("<p><em>(loading...)</em></p>");
×
109
                } else {
110
                    println("<p>Count: " + collection(Collection.AGENTS.toString()).countDocuments(mongoSession) + "</p>");
×
111
                    println("<p><a href=\"/agents\">&gt; agents</a></pi>");
×
112
                }
113
            }
114

115
            println("<h3>Current Trust State</h3>");
×
116
            if (status.equals("launching") || status.equals("coreLoading")) {
×
117
                println("<p><em>(loading...)</em></p>");
×
118
            } else {
119
                println("<p>Accounts: " + collection(Collection.ACCOUNTS.toString()).countDocuments(mongoSession) + "</p>");
×
120
                println("<p><a href=\"/list\">&gt; current trust state</a></pi>");
×
121
            }
122

123
            println("<h3>Trust State History</h3>");
×
124
            println("<p>Retained snapshots: " + collection(Collection.TRUST_STATE_SNAPSHOTS.toString()).countDocuments(mongoSession) + "</p>");
×
125
            println("<p><a href=\"/trust-state\">&gt; trust state history</a></p>");
×
126

127
            println("<h3>Nanopubs</h3>");
×
128
            println("<p>Count: " + collection(Collection.NANOPUBS.toString()).estimatedDocumentCount() + "</p>");
×
129
            println("<p><a href=\"/nanopubs\">&gt; nanopubs</a></pi>");
×
130
            printHtmlFooter();
×
131
        }
132
    }
×
133

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