Uploaded image for project: 'DSpace'
  1. DSpace
  2. DS-3824

Bitstream metadata duplicated when creating a version

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Code Review Needed (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 6.0, 6.1, 6.2
    • Fix Version/s: None
    • Component/s: None
    • Attachments:
      0
    • Comments:
      1
    • Documentation Status:
      Not Required

      Description

      When a new version is created the clone method is called followed by a copy of the metadata:

      Bitstream newBitstream = bitstreamStorageService.clone(context, nativeBitstream);
      List<MetadataValue> bitstreamMeta = bitstreamService.getMetadata(nativeBitstream, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
      for (MetadataValue value : bitstreamMeta) {
         bitstreamService.addMetadata(context, newBitstream,    value.getMetadataField(), value.getLanguage(), value.getValue(), value.getAuthority(), value.getConfidence());
      }
      return newBitstream;

      But this addMetadata is not needed because the metadata is already copied in the clone method:

      public Bitstream clone(Context context, Bitstream bitstream) throws SQLException, IOException, AuthorizeException {
          Bitstream clonedBitstream = bitstreamService.create(context,     bitstreamService.retrieve(context, bitstream));
          List<MetadataValue> metadataValues =   bitstreamService.getMetadata(bitstream, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
          for (MetadataValue metadataValue : metadataValues) {
            bitstreamService.addMetadata(context, clonedBitstream,  metadataValue.getMetadataField(), metadataValue.getLanguage(),  metadataValue.getValue(), metadataValue.getAuthority(),  metadataValue.getConfidence());
      }
      return clonedBitstream;
      }
      

      Because the addMetadata is called twice, all metadata is duplicated in all files for which a new version was created.

        Attachments

          Activity

            People

            Assignee:
            kevin van de velde Kevin Van de Velde (Atmire)
            Reporter:
            kevin van de velde Kevin Van de Velde (Atmire)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: