Description
In several CLARIN-specific code paths we call addMetadata(...) /
setMetadataSingleValue(...) with Item.ANY ("*") in the language
parameter. Item.ANY is a read wildcard ("match any language"); as a value it
is not a legal language and ends up stored verbatim in
metadatavalue.text_lang.
Consequences of the rows this produced:
Since the 7.6.5 upgrade (#1031) MetadataValue.setLanguage() normalizes "*" → null,
so new writes are harmless. The call sites are still wrong, they mislead the
next reader, and the historical rows they created need a separate data fix (#1406).
Call sites
All verified absent from upstream dspace-7.6.5 — these are ours.
| file |
lines |
field(s) written |
dspace-api/.../content/clarin/ClarinLicenseServiceImpl.java |
120, 122, 124 |
dc.rights.uri, dc.rights, dc.rights.label |
dspace-api/.../content/clarin/ClarinItemServiceImpl.java |
183, 185, 187, 188 |
local.has.files, local.files.count, local.files.size |
dspace-api/.../content/clarin/ClarinItemServiceImpl.java |
249, 253 |
dc.date.issued |
dspace-api/.../app/itemupdate/ItemFilesMetadataRepair.java |
221, 223, 225 |
local.has.files, local.files.count, local.files.size |
dspace-api/.../app/itemimport/ItemImportServiceImpl.java |
730 |
dc.rights.label |
dspace-api/.../versioning/DefaultItemVersionProvider.java |
146 |
dc.title |
dspace-server-webapp/.../app/rest/repository/HandleRestRepository.java |
261, 270 |
dc.identifier.other, dc.identifier.uri |
dspace-server-webapp/.../app/rest/submit/step/DescribeStep.java |
151 |
default <value> of any submission-form field |
Two things to watch when fixing
-
clearMetadata(..., Item.ANY) is correct and must stay. There Item.ANY is
the wildcard "delete in every language" — e.g.
ClarinLicenseServiceImpl.clearLicenseMetadataFromItem(). A find/replace across
these files would narrow those deletes and strand old values. Only the
write argument is wrong.
-
DefaultItemVersionProvider.java:146 is not a simple swap.
setMetadataSingleValue(ctx, dso, schema, element, qualifier, language, value)
(DSpaceObjectServiceImpl:471-474) passes the single language argument to
both the clear and the add, so Item.ANY currently means "clear the title in
every language, then add it with language *". Replacing it with null also
narrows the clear. It should be split into an explicit
clearMetadata(..., Item.ANY) followed by addMetadata(..., null, ...).
Definition of done
- No
Item.ANY remains in a language argument of addMetadata /
setMetadataSingleValue / addAndShiftRightMetadata in src/main.
DefaultItemVersionProvider keeps its "clear all languages" behaviour.
- A checkstyle/CI-visible guard would be nice-to-have but is not required.
Related: #1402 (the symptom), upstream DSpace#9701 / DSpace#9710.
#1406 covers normalizing the text_lang = '*' rows already in the DB.
Description
In several CLARIN-specific code paths we call
addMetadata(...)/setMetadataSingleValue(...)withItem.ANY("*") in the languageparameter.
Item.ANYis a read wildcard ("match any language"); as a value itis not a legal language and ends up stored verbatim in
metadatavalue.text_lang.Consequences of the rows this produced:
metadata-exportwrites those columns asdc.rights[*],local.files.count[*], …metadata-importrejects such a header outright since DSpace 7.6.3(
MetadataImportInvalidHeadingException: Language ANY (*) was found in the heading …), so an export → import round trip of an affected item fails — see Not able to import metadata with metadata-import script - for the CSV file, exported with metadata-export. #1402.field had both a
[*]and a no-language column(upstream CSV Import / Export can clear metadata if there are metadata values with language * DSpace/DSpace#9701).
Since the 7.6.5 upgrade (#1031)
MetadataValue.setLanguage()normalizes"*"→null,so new writes are harmless. The call sites are still wrong, they mislead the
next reader, and the historical rows they created need a separate data fix (#1406).
Call sites
All verified absent from upstream
dspace-7.6.5— these are ours.dspace-api/.../content/clarin/ClarinLicenseServiceImpl.javadc.rights.uri,dc.rights,dc.rights.labeldspace-api/.../content/clarin/ClarinItemServiceImpl.javalocal.has.files,local.files.count,local.files.sizedspace-api/.../content/clarin/ClarinItemServiceImpl.javadc.date.issueddspace-api/.../app/itemupdate/ItemFilesMetadataRepair.javalocal.has.files,local.files.count,local.files.sizedspace-api/.../app/itemimport/ItemImportServiceImpl.javadc.rights.labeldspace-api/.../versioning/DefaultItemVersionProvider.javadc.titledspace-server-webapp/.../app/rest/repository/HandleRestRepository.javadc.identifier.other,dc.identifier.uridspace-server-webapp/.../app/rest/submit/step/DescribeStep.java<value>of any submission-form fieldTwo things to watch when fixing
clearMetadata(..., Item.ANY)is correct and must stay. ThereItem.ANYisthe wildcard "delete in every language" — e.g.
ClarinLicenseServiceImpl.clearLicenseMetadataFromItem(). A find/replace acrossthese files would narrow those deletes and strand old values. Only the
write argument is wrong.
DefaultItemVersionProvider.java:146is not a simple swap.setMetadataSingleValue(ctx, dso, schema, element, qualifier, language, value)(
DSpaceObjectServiceImpl:471-474) passes the singlelanguageargument toboth the clear and the add, so
Item.ANYcurrently means "clear the title inevery language, then add it with language
*". Replacing it withnullalsonarrows the clear. It should be split into an explicit
clearMetadata(..., Item.ANY)followed byaddMetadata(..., null, ...).Definition of done
Item.ANYremains in a language argument ofaddMetadata/setMetadataSingleValue/addAndShiftRightMetadatainsrc/main.DefaultItemVersionProviderkeeps its "clear all languages" behaviour.Related: #1402 (the symptom), upstream DSpace#9701 / DSpace#9710.
#1406 covers normalizing the
text_lang = '*'rows already in the DB.