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

knowledgepixels / nanodash / 17925397785

22 Sep 2025 06:52PM UTC coverage: 13.484% (-0.08%) from 13.566%
17925397785

push

github

web-flow
Merge pull request #259 from knowledgepixels/257-update-listpage

Update `ListPage`: add filtering section for filtering by type, user, date

436 of 4082 branches covered (10.68%)

Branch coverage included in aggregate %.

1124 of 7487 relevant lines covered (15.01%)

0.67 hits per line

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

86.24
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(PublishConfirmPage.MOUNT_PATH, PublishConfirmPage.class);
5✔
112
        mountPage(ProfilePage.MOUNT_PATH, ProfilePage.class);
5✔
113
        mountPage(UserListPage.MOUNT_PATH, UserListPage.class);
5✔
114
        mountPage(GroupDemoPage.MOUNT_PATH, GroupDemoPage.class);
5✔
115
        mountPage(GroupDemoPageSoc.MOUNT_PATH, GroupDemoPageSoc.class);
5✔
116
        mountPage(OrcidLinkingPage.MOUNT_PATH, OrcidLinkingPage.class);
5✔
117
        mountPage(OrcidLoginPage.MOUNT_PATH, OrcidLoginPage.class);
5✔
118
        mountPage(SpaceListPage.MOUNT_PATH, SpaceListPage.class);
5✔
119
        mountPage(MyChannelPage.MOUNT_PATH, MyChannelPage.class);
5✔
120
        mountPage(TermForwarder.MOUNT_PATH, TermForwarder.class);
5✔
121
        mountPage(ViewPage.MOUNT_PATH, ViewPage.class);
5✔
122
        mountPage(GetViewPage.MOUNT_PATH, GetViewPage.class);
5✔
123
        mountPage(DsOverviewPage.MOUNT_PATH, DsOverviewPage.class);
5✔
124
        mountPage(DsNanopubPage.MOUNT_PATH, DsNanopubPage.class);
5✔
125
        mountPage(RioOverviewPage.MOUNT_PATH, RioOverviewPage.class);
5✔
126
        mountPage(RioNanopubPage.MOUNT_PATH, RioNanopubPage.class);
5✔
127
        mountPage(BdjOverviewPage.MOUNT_PATH, BdjOverviewPage.class);
5✔
128
        mountPage(BdjNanopubPage.MOUNT_PATH, BdjNanopubPage.class);
5✔
129
        mountPage(FdoForwarder.MOUNT_PATH, FdoForwarder.class);
5✔
130
        mountPage(GetNamePage.MOUNT_PATH, GetNamePage.class);
5✔
131
        mountPage(TestPage.MOUNT_PATH, TestPage.class);
5✔
132
        mountPage(ResultTablePage.MOUNT_PATH, ResultTablePage.class);
5✔
133
        mountPage(GenOverviewPage.MOUNT_PATH, GenOverviewPage.class);
5✔
134
        mountPage(GenSelectPage.MOUNT_PATH, GenSelectPage.class);
5✔
135
        mountPage(GenPublishPage.MOUNT_PATH, GenPublishPage.class);
5✔
136
        mountPage(GenConnectPage.MOUNT_PATH, GenConnectPage.class);
5✔
137
        mountPage(GenNanopubPage.MOUNT_PATH, GenNanopubPage.class);
5✔
138
        mountPage(ProjectPage.MOUNT_PATH, ProjectPage.class);
5✔
139
        mountPage(SpacePage.MOUNT_PATH, SpacePage.class);
5✔
140
        mountPage(QueryPage.MOUNT_PATH, QueryPage.class);
5✔
141
        mountPage(QueryListPage.MOUNT_PATH, QueryListPage.class);
5✔
142
        mountPage(ListPage.MOUNT_PATH, ListPage.class);
5✔
143

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

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

157

158
    private static String latestVersion = null;
2✔
159

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

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

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

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

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

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

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

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