Skip to content

Stop passing Item.ANY as the language when writing metadata #1404

Description

@kosarko

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

  1. 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.

  2. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions