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

knowledgepixels / nanodash / 17673342238

12 Sep 2025 11:37AM UTC coverage: 13.739% (+0.06%) from 13.684%
17673342238

Pull #253

github

web-flow
Merge 7a163d593 into d7481ada9
Pull Request #253: Replace TypePage with ListPage

432 of 3972 branches covered (10.88%)

Branch coverage included in aggregate %.

1104 of 7208 relevant lines covered (15.32%)

0.68 hits per line

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

86.11
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 org.apache.http.HttpResponse;
14
import org.apache.http.client.methods.HttpGet;
15
import org.apache.http.impl.client.CloseableHttpClient;
16
import org.apache.http.impl.client.HttpClientBuilder;
17
import org.apache.wicket.RuntimeConfigurationType;
18
import org.apache.wicket.Session;
19
import org.apache.wicket.protocol.http.WebApplication;
20
import org.apache.wicket.request.Request;
21
import org.apache.wicket.request.Response;
22
import org.apache.wicket.settings.ExceptionSettings;
23
import org.slf4j.Logger;
24
import org.slf4j.LoggerFactory;
25

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

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

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

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

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

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

96
        getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
5✔
97

98
        getExceptionSettings().setUnexpectedExceptionDisplay(ExceptionSettings.SHOW_NO_EXCEPTION_PAGE);
5✔
99

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

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

142
        getCspSettings().blocking().disabled();
5✔
143
    }
1✔
144

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

155

156
    private static String latestVersion = null;
2✔
157

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

172
            Gson gson = new Gson();
4✔
173
            Type nanopubReleasesType = new TypeToken<List<NanodashRelease>>() {
6✔
174
            }.getType();
2✔
175

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

186
    /**
187
     * Properties object to hold application properties.
188
     */
189
    public final static Properties properties = new Properties();
4✔
190

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

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

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

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