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

knowledgepixels / nanodash / 17319343703

29 Aug 2025 08:53AM UTC coverage: 12.007% (-0.3%) from 12.355%
17319343703

push

github

tkuhn
Fix forcedGet(...) also catching RuntimeExceptions

330 of 3844 branches covered (8.58%)

Branch coverage included in aggregate %.

949 of 6808 relevant lines covered (13.94%)

0.61 hits per line

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

0.0
src/main/java/com/knowledgepixels/nanodash/page/FdoForwarder.java
1
package com.knowledgepixels.nanodash.page;
2

3
import com.knowledgepixels.nanodash.Utils;
4
import jakarta.servlet.http.HttpServletRequest;
5
import org.apache.wicket.request.flow.RedirectToUrlException;
6
import org.apache.wicket.request.mapper.parameter.PageParameters;
7
import org.eclipse.rdf4j.model.Statement;
8
import org.nanopub.Nanopub;
9
import org.nanopub.vocabulary.FDOF;
10

11
import java.util.HashMap;
12
import java.util.Map;
13

14
/**
15
 * This page is used to forward requests for FDO.
16
 */
17
public class FdoForwarder extends NanodashPage {
18

19
    private static final long serialVersionUID = 1L;
20

21
    /**
22
     * The mount path for the FdoForwarder page.
23
     */
24
    public static final String MOUNT_PATH = "/fdo";
25

26
    /**
27
     * {@inheritDoc}
28
     */
29
    @Override
30
    public String getMountPath() {
31
        return MOUNT_PATH;
×
32
    }
33

34
    /**
35
     * Constructor for the FdoForwarder page.
36
     *
37
     * @param parameters Page parameters containing the request details.
38
     */
39
    public FdoForwarder(final PageParameters parameters) {
40
        super(parameters);
×
41

42
        String id = parameters.get("id").toString();
×
43

44
        if ("object".equals(parameters.get("get").toString())) {
×
45
            // TODO properly parse the nanopub content
46
            Nanopub np = Utils.getNanopub(id);
×
47
            Map<String, String> formatMaterializationMap = new HashMap<>();
×
48
            for (Statement st : np.getAssertion()) {
×
49
                String subj = st.getSubject().stringValue();
×
50
                String pred = st.getPredicate().stringValue();
×
51
                String obj = st.getObject().stringValue();
×
52
                if (pred.equals(FDOF.HAS_METADATA.stringValue()) && obj.equals(id)) {
×
53
                    // TODO
54
                }
55
                if (pred.equals(FDOF.HAS_ENCODING_FORMAT.stringValue())) {
×
56
                    String format = obj.replace("https://iana.org/assignments/media-types/", "");
×
57
                    formatMaterializationMap.put(format, subj);
×
58
                }
59
            }
×
60
            String acceptHeader = ((HttpServletRequest) getRequest().getContainerRequest()).getHeader("Accept");
×
61
            if (formatMaterializationMap.containsKey(acceptHeader)) {
×
62
                throw new RedirectToUrlException(formatMaterializationMap.get(acceptHeader), 302);
×
63
            }
64
            if (!formatMaterializationMap.isEmpty()) {
×
65
                throw new RedirectToUrlException(formatMaterializationMap.values().iterator().next(), 302);
×
66
            }
67
        }
68
        throw new RedirectToUrlException(Utils.getUrlWithParameters(ExplorePage.MOUNT_PATH, new PageParameters().add("id", id)));
×
69
    }
70

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