Commit 3505ee9
DSpace9.3/Fix CLARIN link rels returning 404: register link repositories under plural model names (#1404)
* Register CLARIN link repositories under plural model names (DSpace 9 contract)
Six CLARIN LinkRestRepository beans are still registered under the singular model
name, so all six advertised sub-resources return 404 on the v9 base while they
return 200 on 7.6.5.
DSpace 7 singularized the URL segment before the bean lookup --
Utils.getLinkResourceRepository() called makeSingular(modelPlural). DSpace 9
removed that step and looks the bean up under the plural segment verbatim, so a
link repository must now be registered as <category>.<typePlural>.<rel>. The
upstream migration renamed its own 71 link repositories accordingly and added
PLURAL_NAME to the REST models, but these six CLARIN ones were missed.
Note ClarinLicenseResourceUserAllowanceRestRepository (the MAIN repository) *was*
migrated to PLURAL_NAME, which is why GET /core/clarinlruallowances/242 returns
200 while every one of its rels 404s. Migrating a main repository without its
link repositories leaves all its sub-resources dead.
Why this is easy to misread: a missing bean raises RepositoryNotFoundException,
and a missing route resolves BEFORE any authorization check. The one defect
therefore surfaces as "404 != 200" for an admin, "404 != 401" for anonymous and
"404 != 403" for a non-owner -- it reads like an authorization problem, and the
404 body names the plural type that is not how the bean is registered:
{"status":404,"message":"The repository type core.clarinlruallowances was not found"}
Meanwhile the allowance JSON keeps advertising all three _links, so the API
describes endpoints it cannot serve.
Measured, admin token, dev-6.pc:8603 (9.3) vs dev-5.pc:88 (7.6.5):
core/clarinlruallowances/242 200 200
core/clarinlruallowances/242/userMetadata *404* 200
core/clarinlruallowances/242/userRegistration *404* 200
core/clarinlruallowances/242/resourceMapping *404* 200
core/clarinuserregistrations/1/userMetadata *404* 200
core/clarinuserregistrations/1/clarinLicenses *404* 200
core/clarinlicenseresourcemappings/1383/clarinLicense *404* 200
Audit backing the "six and only six" claim: of 77 LinkRestRepository
implementations on this branch, 71 already use PLURAL_NAME, these 6 used NAME,
and none uses a literal bean-name string. Every main (non-link) repository is
already plural. So this closes the gap completely.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Add regression test for the CLARIN link-repository bean naming contract
Nothing in the suite caught the previous commit's bug: no IT traverses any of the
six rels as a URL sub-path, so all six could 404 in production while CI stayed
green. It surfaced only in the external dspace-rest-test suite, as 8 failing
test_endpoints tests whose messages looked like an authorization problem.
The test asserts the invariant directly through
Utils.getLinkResourceRepository() -- the same lookup RestResourceController
performs when a client traverses a rel -- rather than over HTTP. Going over HTTP
could not isolate this defect: these link repositories also raise
ResourceNotFoundException, another 404, when the linked data simply does not
exist, so telling "route missing" from "no data" would need fixtures for a
bitstream, a licence, a resource mapping, a user registration and user metadata
per rel, and would still conflate the two on failure.
It is driven off the @LinksRest annotation instead of a hardcoded rel list, so a
rel added to any of these three models is covered automatically.
Covers all six rels: clarinlruallowances {resourceMapping, userRegistration,
userMetadata}, clarinuserregistrations {clarinLicenses, userMetadata},
clarinlicenseresourcemappings {clarinLicense}.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Report an actionable failure when a link repository bean is missing
Addresses Copilot review feedback on #1404.
utils.getLinkResourceRepository() throws RepositoryNotFoundException rather than
returning null, so the assertNotNull message was unreachable: the test would have
failed with a raw exception instead.
That mattered more than it looks, because RepositoryNotFoundException.getMessage()
formats only "<apiCategory>.<model>":
"The repository type core.clarinlruallowances was not found"
It never names the rel, so on ClarinLicenseResourceUserAllowanceRest -- which has
three -- the failure could not say whether resourceMapping, userRegistration or
userMetadata was the unregistered one. The wording is also misleading in this
context: it claims the repository *type* is missing when the main repository
resolves fine and only the link repository bean is absent, which is exactly the
confusion this test exists to prevent.
The lookup failure is now caught and rethrown as an AssertionError naming the
expected bean and the required fix, with the original exception chained as the
cause so nothing is lost (Assert.fail would have discarded it).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Matus Kasak <matus.kasak@dataquest.sk>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 854cd94 commit 3505ee9
7 files changed
Lines changed: 109 additions & 6 deletions
File tree
- dspace-server-webapp/src
- main/java/org/dspace/app/rest/repository
- test/java/org/dspace/app/rest
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
Lines changed: 103 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
0 commit comments