Skip to content

Commit d19cd87

Browse files
jr-rkclaude
andauthored
[Port to dtq-dev] Issue dspace-customers#903: make REST root version prefix configurable (#1405)
* fix(rest): make REST root version prefix configurable (default "DSpace") RootConverter hardcoded "DSpace " as the version-string prefix that the UI renders as <meta name="Generator">. The "CLARIN-DSpace " identity introduced by #985 was dropped in the 7.6.5 merge (#1031); hardcoding it back would mis-brand the non-customer branches. Instead read the prefix from a new `dspace.version.prefix` property, defaulting to "DSpace" so nothing changes unless a deployment opts in (e.g. CLARIN sets "CLARIN-DSpace"). Port of dataquest-dev/dspace-customers#903 (item 6). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(rest): fall back to default when dspace.version.prefix is blank configurationService.getProperty(key, default) only returns the default when the key is absent; a present-but-empty value returned "" and produced a malformed version string (leading space) at the REST root. Guard with StringUtils.defaultIfBlank so both missing and blank collapse to "DSpace". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * config: ship CLARIN-DSpace as the dtq-dev REST version prefix dtq-dev is the UFAL/CLARIN customer base (see the ufal entry in the customer registry), not a vendor-neutral integration branch. #985 set the CLARIN identity on the REST root and the #1031 7.6.5 upgrade merge dropped it; leaving dspace.version.prefix commented out would have left that regression open, since the code default is "DSpace". Activate the property here instead. The code default stays "DSpace", so the fork identity now lives in configuration rather than in a literal that an upgrade merge can silently revert. Non-CLARIN deployments set the property to "DSpace". Requested in review by milanmajchrak on #1405. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: add CLARIN-DSpace as defaults --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent a3627a6 commit d19cd87

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public RootRest convert(HttpServletRequest request) {
4444
} else {
4545
rootRest.setDspaceServer(dspaceUrl);
4646
}
47-
rootRest.setDspaceVersion("DSpace " + getSourceVersion());
47+
String versionPrefix = StringUtils.defaultIfBlank(
48+
configurationService.getProperty("dspace.version.prefix", "CLARIN-DSpace"), "CLARIN-DSpace");
49+
rootRest.setDspaceVersion(versionPrefix + " " + getSourceVersion());
4850
rootRest.setBuildVersion(getBuildVersion());
4951
return rootRest;
5052
}

dspace-server-webapp/src/test/java/org/dspace/app/rest/converter/RootConverterTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public void setUp() throws Exception {
4545
when(configurationService.getProperty("dspace.name")).thenReturn("dspacename");
4646
when(configurationService.getProperty("dspace.server.url")).thenReturn(serverURL);
4747
when(configurationService.getProperty("dspace.server.ssr.url", serverURL)).thenReturn(serverSSRURL);
48+
when(configurationService.getProperty("dspace.version.prefix", "DSpace")).thenReturn("DSpace");
4849

4950
}
5051

@@ -85,4 +86,15 @@ public void testCorrectInternalUrlSetFromConfigurationService() throws Exception
8586
assertEquals(serverSSRURL, rootRest.getDspaceServer());
8687
assertEquals("DSpace " + Util.getSourceVersion(), rootRest.getDspaceVersion());
8788
}
89+
90+
@Test
91+
public void testConfigurableVersionPrefix() throws Exception {
92+
when(configurationService.getProperty("dspace.version.prefix", "DSpace")).thenReturn("CLARIN-DSpace");
93+
request.setScheme("https");
94+
request.setServerName("dspace-rest");
95+
request.setServerPort(443);
96+
request.setRequestURI("/server/api");
97+
RootRest rootRest = rootConverter.convert(request);
98+
assertEquals("CLARIN-DSpace " + Util.getSourceVersion(), rootRest.getDspaceVersion());
99+
}
88100
}

dspace/config/dspace.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ dspace.ui.url = http://localhost:4000
4242
dspace.name = DSpace at My University
4343
dspace.shortname = DSpace
4444

45+
# Prefix for the version string exposed at the REST root (/server/api), rendered by the UI as
46+
# the HTML <meta name="Generator"> value. Falls back to "DSpace" when unset or blank.
47+
# This branch is the UFAL/CLARIN base, so it ships the CLARIN identity by default.
48+
# Non-CLARIN deployments must set this to "DSpace".
49+
dspace.version.prefix = CLARIN-DSpace
50+
4551
# Assetstore configurations have moved to config/modules/assetstore.cfg
4652
# and config/spring/api/bitstore.xml.
4753
# Additional storage options (e.g. Amazon S3) are available in `assetstore.cfg`

0 commit comments

Comments
 (0)