[Port to dtq-dev] Issue dspace-customers#903: make REST root version prefix configurable - #1405
[Port to dtq-dev] Issue dspace-customers#903: make REST root version prefix configurable#1405jr-rk wants to merge 2 commits into
Conversation
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>
dspace-skills improvements suggestionsOne efficiency pass over the skills, helper scripts, and reference facts, ranked by how often the bottleneck is hit times what it costs each time; the recurring theme is redundant High impact1. 2. Backend 3. The facts that decide how to backport are still marked unconfirmed. 4. A fan-out has no resumable state — it lives only in agent context and worktrees. Medium impact5. 6. The front-door and link scripts make duplicate 7. 8. 9. Low impact
Coverage gaps (workflows with no skill)
Quick wins (do these first)
Posted from the issue dataquest-dev/dspace-customers#903 port session — a background agent audited the dspace-skills repo in parallel with the backend backports. |
There was a problem hiding this comment.
Pull request overview
This PR makes the REST-root dspaceVersion prefix configurable via a new dspace.version.prefix property, allowing CLARIN/customer deployments to brand the version string without forking RootConverter, while keeping the default behavior unchanged for standard deployments.
Changes:
- Update
RootConverterto read the version prefix from configuration (default:"DSpace"). - Document the new
dspace.version.prefixproperty indspace.cfg. - Extend
RootConverterTestwith a new test verifying a"CLARIN-DSpace"override.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
dspace/config/dspace.cfg |
Documents the new dspace.version.prefix configuration option and its default behavior. |
dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java |
Builds the REST-root version string using a configurable prefix instead of a hardcoded literal. |
dspace-server-webapp/src/test/java/org/dspace/app/rest/converter/RootConverterTest.java |
Stubs the new config property and adds coverage for a custom prefix override. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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>
|
Addressed the Copilot review: |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (3)
dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java:49
"DSpace"is duplicated as both the configuration default and the blank fallback. Using a single local constant avoids accidental drift if the default ever changes and makes the intent clearer.
String versionPrefix = StringUtils.defaultIfBlank(
configurationService.getProperty("dspace.version.prefix", "DSpace"), "DSpace");
rootRest.setDspaceVersion(versionPrefix + " " + getSourceVersion());
dspace/config/dspace.cfg:48
- The comment says the property defaults when "unset", but the implementation also falls back when the property is present but blank. Updating the wording will match the actual behavior and help operators avoid confusion.
# Prefix for the version string exposed at the REST root (/server/api), rendered by the UI as
# the HTML <meta name="Generator"> value. Defaults to "DSpace" when unset; CLARIN/customer
# deployments may set e.g. "CLARIN-DSpace".
# dspace.version.prefix = DSpace
dspace-server-webapp/src/test/java/org/dspace/app/rest/converter/RootConverterTest.java:100
- The new blank-value guard (
defaultIfBlank) is a key behavior change but isn’t directly covered by a test (current tests only cover default + non-blank override). Add a unit test asserting that an empty configured prefix falls back to the default "DSpace" prefix.
@Test
public void testConfigurableVersionPrefix() throws Exception {
when(configurationService.getProperty("dspace.version.prefix", "DSpace")).thenReturn("CLARIN-DSpace");
request.setScheme("https");
request.setServerName("dspace-rest");
request.setServerPort(443);
request.setRequestURI("/server/api");
RootRest rootRest = rootConverter.convert(request);
assertEquals("CLARIN-DSpace " + Util.getSourceVersion(), rootRest.getDspaceVersion());
}
| # Prefix for the version string exposed at the REST root (/server/api), rendered by the UI as | ||
| # the HTML <meta name="Generator"> value. Defaults to "DSpace" when unset; CLARIN/customer | ||
| # deployments may set e.g. "CLARIN-DSpace". | ||
| # dspace.version.prefix = DSpace |
There was a problem hiding this comment.
Change it to "CLARIN-DSpace" as it is here: https://github.com/dataquest-dev/DSpace/pull/985/changes#diff-755dfa87d0fb57ba5cca52d0544119a7425a1669150dee2bcf60f7ccebd0c032R39
Problem
The version string exposed at the REST root (
GET /server/api→dspaceVersion, rendered by the UI as<meta name="Generator">) is hardcoded to the"DSpace "prefix inRootConverter. CLARIN deployments need the"CLARIN-DSpace"identity, which was introduced by #985 and then accidentally dropped by the #1031 7.6.5 upgrade merge. Hardcoding it back would mis-brand the nine non-customer branches that should read"DSpace".Port of dataquest-dev/dspace-customers#903 (item 6). References
customer/lindat563ef4f366/0fea1de43cfor where the CLARIN prefix lived; reimplemented as a configurable property rather than a hardcode.Root cause
RootConverter.convert()built the version string as the literal"DSpace " + getSourceVersion(), so the prefix could only be changed by forking the converter per deployment — which is exactly what caused the identity to be lost across a merge.Change set
RootConverter.java— read the prefix from a newdspace.version.prefixproperty, defaulting to"DSpace", with a blank-value guard:StringUtils.defaultIfBlank(configurationService.getProperty("dspace.version.prefix", "DSpace"), "DSpace").getProperty(key, default)only returns the default when the key is absent, so thedefaultIfBlankwrapper also collapses a present-but-empty value back to"DSpace"(avoids a malformed leading-space version string). Behaviour is byte-for-byte unchanged unless a deployment sets a non-blank prefix.dspace.cfg— document the new property (commented-out default) next todspace.name.RootConverterTest.java— stub the new property insetUp(existing assertions unchanged) and addtestConfigurableVersionPrefix, asserting a"CLARIN-DSpace"override.Scope: this PR makes only the REST-root generator string configurable (item 6's target). Other DSpace-branded surfaces (AIP/METS agent name, OpenAIRE
User-Agent) remain hardcoded and are out of scope. Thedtq-devHttpServletRequest/dspace.server.ssr.urlSSR-URL logic inRootConverteris untouched.Test evidence
Note: the blank/absent fallback path is not yet covered by a dedicated test (the tests mock the 2-arg
getPropertyoverload directly).Risk & rollback
Minimal. Default path is unchanged (
"DSpace"). Revert = single commit revert; the config property is inert when unset.Notes / assumptions
Property name
dspace.version.prefixchosen to sit alongsidedspace.name/dspace.shortname. CLARIN branches opt in vialocal.cfg(dspace.version.prefix = CLARIN-DSpace); no code fork required going forward.Follow-up (not in this PR):
customer/lindatstill hardcodes"CLARIN-DSpace " + getSourceVersion()in itsRootConverterand setsdspace.version.prefixnowhere. Until it is migrated to consume the new property (drop the hardcode + set the value in cfg), this PR restores the CLARIN identity on zero deployments and the nextdtq-dev→lindatmerge will conflict on the same line again. That migration should be tracked as a separate task under dataquest-dev/dspace-customers#903.