4Science / DSpace

This repository contains the 4Science optimized DSpace & DSpace-CRIS distribution.
https://wiki.lyrasis.org/display/DSPACECRIS/
BSD 3-Clause "New" or "Revised" License
42 stars 61 forks source link

Cannot select/sort relationships if more than one hidden relationship exists #375

Closed floriangantner closed 10 months ago

floriangantner commented 1 year ago

Describe the bug In case you have some profile with more than one hidden item/researchoutput, you cannot select/deselect/sort any other relationships To Reproduce Steps to reproduce the behavior:

  1. Configure relationship between person and publication (e.g. use default configuration). Go to profile page.
  2. Select two publications/items as selected.
  3. Now select two publications as hidden.
  4. From now on you should only be able to add more hidden publications, but you cannot select more items or deselect/sort existing values.
  5. No error response should occur. in the logs some line similar to this should occur (maybe shortened):
    Caused by: java.lang.IllegalArgumentException: List length = -1
    at java.base/java.util.Collections.nCopies(Collections.java:5027)
    at org.dspace.content.RelationshipPlacesIndexingServiceImpl.addRightItemsReferences(RelationshipPlacesIndexingServiceImpl.java:105)
    at org.dspace.content.RelationshipPlacesIndexingServiceImpl.updateRelationReferences(RelationshipPlacesIndexingServiceImpl.java:76)
    at org.dspace.content.RelationshipServiceImpl.updatePlaceInRelationship(RelationshipServiceImpl.java:342)
    at org.dspace.content.RelationshipServiceImpl.deleteRelationshipAndCopyToItem(RelationshipServiceImpl.java:822)

There seems to be some error calculation the places being indexed between relationships.

Expected behavior We expect the user to be able to select/sort/hide existing Relationships without limitations on the amount of relations per relationshiptype.

Related work Workaround: occurences of Collections.nCopies in the above mentioned class RelationshipPlacesIndexingServiceImpl might only be called of there are more than 0 entries to copy

PR https://github.com/4Science/DSpace/pull/377 proofes the behaviour in some test-based manner.