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

knowledgepixels / nanodash / 21299952920

23 Jan 2026 08:19PM UTC coverage: 14.261% (-1.0%) from 15.237%
21299952920

push

github

tkuhn
fix: Prevent pages from prematurely be discarded from the page store

545 of 5064 branches covered (10.76%)

Branch coverage included in aggregate %.

1502 of 9290 relevant lines covered (16.17%)

2.12 hits per line

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

86.49
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.apache.wicket.util.lang.Bytes;
25
import org.slf4j.Logger;
26
import org.slf4j.LoggerFactory;
27

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

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

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

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

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

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

99
        getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
15✔
100

101
        getExceptionSettings().setUnexpectedExceptionDisplay(ExceptionSettings.SHOW_NO_EXCEPTION_PAGE);
15✔
102

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

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

146
        getCspSettings().blocking().disabled();
15✔
147
        getStoreSettings().setMaxSizePerSession(Bytes.MAX);
15✔
148
    }
3✔
149

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

160

161
    private static String latestVersion = null;
6✔
162

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

177
            Gson gson = new Gson();
12✔
178
            Type nanopubReleasesType = new TypeToken<List<NanodashRelease>>() {
18✔
179
            }.getType();
6✔
180

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

191
    /**
192
     * Properties object to hold application properties.
193
     */
194
    public final static Properties properties = new Properties();
12✔
195

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

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

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

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