diff --git a/dspace-api/src/main/java/org/dspace/content/RelationshipPlacesIndexingServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/RelationshipPlacesIndexingServiceImpl.java index 1ed14b4fbe1f..f29e209d7790 100644 --- a/dspace-api/src/main/java/org/dspace/content/RelationshipPlacesIndexingServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/RelationshipPlacesIndexingServiceImpl.java @@ -55,7 +55,9 @@ public void updateRelationReferences(final Context context, final Relationship r if (singleDirectionRelationship("right", relationship.getRelationshipType())) { times = relation.getLeftPlace() - relation.getRightPlace(); } - rightItemsIdsToAdd.addAll(Collections.nCopies(times, relation.getRightItem().getID().toString())); + if (times > 0) { + rightItemsIdsToAdd.addAll(Collections.nCopies(times, relation.getRightItem().getID().toString())); + } } if (!rightItemsIdsToAdd.isEmpty()) { @@ -79,7 +81,9 @@ public void updateRelationReferences(final Context context, final Relationship r if (singleDirectionRelationship("left", relationship.getRelationshipType())) { times = relation.getRightPlace() - relation.getLeftPlace(); } - leftItemsIdsToAdd.addAll(Collections.nCopies(times, relation.getLeftItem().getID().toString())); + if (times > 0) { + leftItemsIdsToAdd.addAll(Collections.nCopies(times, relation.getLeftItem().getID().toString())); + } } if (!leftItemsIdsToAdd.isEmpty()) { @@ -102,7 +106,9 @@ private void addRightItemsReferences(final Context context, final Relationship r if (singleDirectionRelationship("right", relationship.getRelationshipType())) { times = leftItemRelation.getLeftPlace() - leftItemRelation.getRightPlace(); } - rightItemsToAdd.addAll(Collections.nCopies(times, leftItemRelation.getRightItem().getID().toString())); + if (times > 0) { + rightItemsToAdd.addAll(Collections.nCopies(times, leftItemRelation.getRightItem().getID().toString())); + } } if (!rightItemsToAdd.isEmpty()) { indexingService.updateRelationForItem(leftItem.getID().toString(), @@ -122,7 +128,9 @@ private void addLeftItemsReferences(final Context context, final Relationship re if (singleDirectionRelationship("left", relationship.getRelationshipType())) { times = leftItemRelation.getRightPlace() - leftItemRelation.getLeftPlace(); } - rightItemsToAdd.addAll(Collections.nCopies(times, leftItemRelation.getLeftItem().getID().toString())); + if (times > 0) { + rightItemsToAdd.addAll(Collections.nCopies(times, leftItemRelation.getLeftItem().getID().toString())); + } } if (!rightItemsToAdd.isEmpty()) { indexingService.updateRelationForItem(rightItem.getID().toString(), diff --git a/dspace/config/modules/rest.cfg b/dspace/config/modules/rest.cfg index ea955c183663..b95609fbeb22 100644 --- a/dspace/config/modules/rest.cfg +++ b/dspace/config/modules/rest.cfg @@ -238,4 +238,4 @@ rest.search.max.results = 100 # Patterns associated with uri for which do not set the context in read-only mode for GET calls rest.get-in-read-only-mode.exception-patterns = /api/authn/** -rest.get-in-read-only-mode.exception-patterns = /api/cris/orcid/** \ No newline at end of file +rest.get-in-read-only-mode.exception-patterns = /api/cris/orcid/**