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

knowledgepixels / nanodash / 18834771957

27 Oct 2025 08:37AM UTC coverage: 13.674% (+0.01%) from 13.662%
18834771957

push

github

tkuhn
feat(MaintainedResources): Add resource part pages

481 of 4418 branches covered (10.89%)

Branch coverage included in aggregate %.

1255 of 8278 relevant lines covered (15.16%)

0.68 hits per line

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

86.36
src/main/java/com/knowledgepixels/nanodash/WicketApplication.java
1
package com.knowledgepixels.nanodash;
2

3
import com.google.gson.Gson;
4
import com.google.gson.reflect.TypeToken;
5
import com.knowledgepixels.nanodash.connector.*;
6
import com.knowledgepixels.nanodash.connector.ios.DsNanopubPage;
7
import com.knowledgepixels.nanodash.connector.ios.DsOverviewPage;
8
import com.knowledgepixels.nanodash.connector.pensoft.BdjNanopubPage;
9
import com.knowledgepixels.nanodash.connector.pensoft.BdjOverviewPage;
10
import com.knowledgepixels.nanodash.connector.pensoft.RioNanopubPage;
11
import com.knowledgepixels.nanodash.connector.pensoft.RioOverviewPage;
12
import com.knowledgepixels.nanodash.page.*;
13
import de.agilecoders.wicket.webjars.WicketWebjars;
14
import org.apache.http.HttpResponse;
15
import org.apache.http.client.methods.HttpGet;
16
import org.apache.http.impl.client.CloseableHttpClient;
17
import org.apache.http.impl.client.HttpClientBuilder;
18
import org.apache.wicket.RuntimeConfigurationType;
19
import org.apache.wicket.Session;
20
import org.apache.wicket.protocol.http.WebApplication;
21
import org.apache.wicket.request.Request;
22
import org.apache.wicket.request.Response;
23
import org.apache.wicket.settings.ExceptionSettings;
24
import org.slf4j.Logger;
25
import org.slf4j.LoggerFactory;
26

27
import java.awt.*;
28
import java.io.IOException;
29
import java.io.InputStreamReader;
30
import java.lang.reflect.Type;
31
import java.net.URI;
32
import java.net.URISyntaxException;
33
import java.util.List;
34
import java.util.Properties;
35

36
/**
37
 * WicketApplication is the main application class for the Nanodash web application.
38
 * It initializes the application, mounts pages, and provides version information.
39
 */
40
public class WicketApplication extends WebApplication {
41

42
    /**
43
     * URL to fetch the latest release information from GitHub.
44
     * This URL points to the releases of the Nanodash repository.
45
     */
46
    public static final String LATEST_RELEASE_URL = "https://api.github.com/repos/knowledgepixels/nanodash/releases";
47
    private static final Logger logger = LoggerFactory.getLogger(WicketApplication.class);
3✔
48

49
    /**
50
     * Constructor for the WicketApplication.
51
     * Displays version information and provides instructions for accessing the application.
52
     */
53
    public WicketApplication() {
2✔
54
        if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
2!
55
            try {
56
                Desktop.getDesktop().browse(new URI("http://localhost:37373"));
×
57
            } catch (IOException | URISyntaxException ex) {
×
58
                logger.error("Error in opening browser", ex);
×
59
            }
×
60
        }
61
        String v = getThisVersion();
2✔
62
        String lv = getLatestVersion();
2✔
63
        System.err.println("");
3✔
64
        System.err.println("----------------------------------------");
3✔
65
        System.err.println("               Nanodash");
3✔
66
        System.err.println("----------------------------------------");
3✔
67
        System.err.println(" You are using version: " + v);
4✔
68
        System.err.println(" Latest public version: " + lv);
4✔
69
        System.err.println("----------------------------------------");
3✔
70
        System.err.println(" Your browser should show the Nanodash");
3✔
71
        System.err.println(" interface in a few seconds.");
3✔
72
        System.err.println("");
3✔
73
        System.err.println(" If not, point your browser to:");
3✔
74
        System.err.println(" http://localhost:37373");
3✔
75
        System.err.println("----------------------------------------");
3✔
76
        System.err.println("");
3✔
77
    }
1✔
78

79
    /**
80
     * Returns the home page class for the application.
81
     *
82
     * @return The HomePage class.
83
     */
84
    public Class<HomePage> getHomePage() {
85
        return HomePage.class;
2✔
86
    }
87

88
    /**
89
     * {@inheritDoc}
90
     * <p>
91
     * Initializes the application settings and mounts pages.
92
     */
93
    @Override
94
    protected void init() {
95
        super.init();
2✔
96
        WicketWebjars.install(this);
2✔
97

98
        getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
5✔
99

100
        getExceptionSettings().setUnexpectedExceptionDisplay(ExceptionSettings.SHOW_NO_EXCEPTION_PAGE);
5✔
101

102
        mountPage(ErrorPage.MOUNT_PATH, ErrorPage.class);
5✔
103
        mountPage("/error/404", ErrorPage.class);
5✔
104
        mountPage("/error/500", ErrorPage.class);
5✔
105

106
        mountPage(UserPage.MOUNT_PATH, UserPage.class);
5✔
107
        mountPage(ChannelPage.MOUNT_PATH, ChannelPage.class);
5✔
108
        mountPage(SearchPage.MOUNT_PATH, SearchPage.class);
5✔
109
        mountPage(ExplorePage.MOUNT_PATH, ExplorePage.class);
5✔
110
        mountPage(PublishPage.MOUNT_PATH, PublishPage.class);
5✔
111
        mountPage(ProfilePage.MOUNT_PATH, ProfilePage.class);
5✔
112
        mountPage(UserListPage.MOUNT_PATH, UserListPage.class);
5✔
113
        mountPage(GroupDemoPage.MOUNT_PATH, GroupDemoPage.class);
5✔
114
        mountPage(GroupDemoPageSoc.MOUNT_PATH, GroupDemoPageSoc.class);
5✔
115
        mountPage(OrcidLinkingPage.MOUNT_PATH, OrcidLinkingPage.class);
5✔
116
        mountPage(OrcidLoginPage.MOUNT_PATH, OrcidLoginPage.class);
5✔
117
        mountPage(SpaceListPage.MOUNT_PATH, SpaceListPage.class);
5✔
118
        mountPage(MyChannelPage.MOUNT_PATH, MyChannelPage.class);
5✔
119
        mountPage(TermForwarder.MOUNT_PATH, TermForwarder.class);
5✔
120
        mountPage(ViewPage.MOUNT_PATH, ViewPage.class);
5✔
121
        mountPage(GetViewPage.MOUNT_PATH, GetViewPage.class);
5✔
122
        mountPage(DsOverviewPage.MOUNT_PATH, DsOverviewPage.class);
5✔
123
        mountPage(DsNanopubPage.MOUNT_PATH, DsNanopubPage.class);
5✔
124
        mountPage(RioOverviewPage.MOUNT_PATH, RioOverviewPage.class);
5✔
125
        mountPage(RioNanopubPage.MOUNT_PATH, RioNanopubPage.class);
5✔
126
        mountPage(BdjOverviewPage.MOUNT_PATH, BdjOverviewPage.class);
5✔
127
        mountPage(BdjNanopubPage.MOUNT_PATH, BdjNanopubPage.class);
5✔
128
        mountPage(FdoForwarder.MOUNT_PATH, FdoForwarder.class);
5✔
129
        mountPage(GetNamePage.MOUNT_PATH, GetNamePage.class);
5✔
130
        mountPage(TestPage.MOUNT_PATH, TestPage.class);
5✔
131
        mountPage(ResultTablePage.MOUNT_PATH, ResultTablePage.class);
5✔
132
        mountPage(GenOverviewPage.MOUNT_PATH, GenOverviewPage.class);
5✔
133
        mountPage(GenSelectPage.MOUNT_PATH, GenSelectPage.class);
5✔
134
        mountPage(GenPublishPage.MOUNT_PATH, GenPublishPage.class);
5✔
135
        mountPage(GenConnectPage.MOUNT_PATH, GenConnectPage.class);
5✔
136
        mountPage(GenNanopubPage.MOUNT_PATH, GenNanopubPage.class);
5✔
137
        mountPage(ProjectPage.MOUNT_PATH, ProjectPage.class);
5✔
138
        mountPage(SpacePage.MOUNT_PATH, SpacePage.class);
5✔
139
        mountPage(QueryPage.MOUNT_PATH, QueryPage.class);
5✔
140
        mountPage(QueryListPage.MOUNT_PATH, QueryListPage.class);
5✔
141
        mountPage(ListPage.MOUNT_PATH, ListPage.class);
5✔
142
        mountPage(MaintainedResourcePage.MOUNT_PATH, MaintainedResourcePage.class);
5✔
143
        mountPage(ResourcePartPage.MOUNT_PATH, ResourcePartPage.class);
5✔
144

145
        getCspSettings().blocking().disabled();
5✔
146
    }
1✔
147

148
    /**
149
     * {@inheritDoc}
150
     * <p>
151
     * Returns the runtime configuration type for the application.
152
     */
153
    @Override
154
    public RuntimeConfigurationType getConfigurationType() {
155
        return RuntimeConfigurationType.DEPLOYMENT;
2✔
156
    }
157

158

159
    private static String latestVersion = null;
2✔
160

161
    /**
162
     * Retrieves the latest version of the application from the GitHub API.
163
     *
164
     * @return The latest version as a string.
165
     */
166
    public static String getLatestVersion() {
167
        if (latestVersion != null) return latestVersion;
4✔
168
        try (CloseableHttpClient client = HttpClientBuilder.create().build()) {
3✔
169
            HttpResponse resp = client.execute(new HttpGet(LATEST_RELEASE_URL));
7✔
170
            int c = resp.getStatusLine().getStatusCode();
4✔
171
            if (c < 200 || c >= 300) {
6!
172
                throw new HttpStatusException(c);
×
173
            }
174

175
            Gson gson = new Gson();
4✔
176
            Type nanopubReleasesType = new TypeToken<List<NanodashRelease>>() {
6✔
177
            }.getType();
2✔
178

179
            List<NanodashRelease> releases = gson.fromJson(new InputStreamReader(resp.getEntity().getContent()), nanopubReleasesType);
11✔
180
            if (!releases.isEmpty()) {
3!
181
                latestVersion = releases.getFirst().getVersionNumber();
5✔
182
            }
183
        } catch (Exception ex) {
×
184
            logger.error("Error in fetching latest version", ex);
×
185
        }
1✔
186
        return latestVersion;
2✔
187
    }
188

189
    /**
190
     * Properties object to hold application properties.
191
     */
192
    public final static Properties properties = new Properties();
4✔
193

194
    static {
195
        try {
196
            properties.load(WicketApplication.class.getClassLoader().getResourceAsStream("nanodash.properties"));
6✔
197
        } catch (IOException ex) {
×
198
            logger.error("Error in loading properties", ex);
×
199
        }
1✔
200
    }
1✔
201

202
    /**
203
     * Retrieves the current version of the application.
204
     *
205
     * @return The current version as a string.
206
     */
207
    public static String getThisVersion() {
208
        return properties.getProperty("nanodash.version");
4✔
209
    }
210

211
    /**
212
     * {@inheritDoc}
213
     */
214
    @Override
215
    public Session newSession(Request request, Response response) {
216
        return new NanodashSession(request);
5✔
217
    }
218

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