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

knowledgepixels / nanopub-registry / 28113618611

24 Jun 2026 04:28PM UTC coverage: 31.926% (-0.2%) from 32.089%
28113618611

Pull #116

github

web-flow
Merge d931f8afc into eebd16ba4
Pull Request #116: Enhance and standardize logging across multiple components

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/ResourcePage.java
1
package com.knowledgepixels.registry;
2

3
import com.mongodb.client.ClientSession;
4
import io.vertx.ext.web.RoutingContext;
5
import org.apache.commons.io.IOUtils;
6
import org.slf4j.Logger;
7
import org.slf4j.LoggerFactory;
8

9
import java.io.IOException;
10
import java.io.InputStream;
11

12
public class ResourcePage extends Page {
13

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

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

31
    private String resourceName, resourceType;
32

33
    public ResourcePage(ClientSession mongoSession, RoutingContext context, String resourceName, String resourceType) {
34
        super(mongoSession, context);
×
35
        this.resourceName = resourceName;
×
36
        this.resourceType = resourceType;
×
37
    }
×
38

39
    public void show() throws IOException {
40
        setRespContentType(resourceType);
×
41
        logger.debug("Preparing to serve resource {} (type={})", resourceName, resourceType);
×
42
        InputStream in = null;
×
43
        BufferOutputStream out = null;
×
44
        try {
45
            in = MainVerticle.class.getResourceAsStream(resourceName);
×
46
            out = new BufferOutputStream();
×
47
            IOUtils.copy(in, out);
×
48
            getContext().response().write(out.getBuffer());
×
49
            logger.info("Served resource {} (type={})", resourceName, resourceType);
×
50
        } finally {
51
            if (in != null) {
×
52
                in.close();
×
53
            }
54
            if (out != null) {
×
55
                out.close();
×
56
            }
57
        }
58
    }
×
59

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