Added the comment to the context.turnOffAuthorizationSystem

This commit is contained in:
Raf Ponsaerts
2019-03-06 14:54:01 +01:00
parent e3fc9a52a7
commit 6056bf94e0

View File

@@ -112,6 +112,11 @@ public class RelationshipRestRepository extends DSpaceRestRepository<Relationshi
relationship.setRightItem(rightItem); relationship.setRightItem(rightItem);
relationship.setRelationshipType(relationshipType); relationship.setRelationshipType(relationshipType);
relationship = relationshipService.create(context, relationship); relationship = relationshipService.create(context, relationship);
// The above if check deals with the case that a Relationship can be created if the user has write
// rights on one of the two items. The following updateItem calls can however call the
// ItemService.update() functions which would fail if the user doesn't have permission on both items.
// Since we allow this creation to happen under these circumstances, we need to turn off the
// authorization system here so that this failure doesn't happen when the items need to be update
context.turnOffAuthorisationSystem(); context.turnOffAuthorisationSystem();
relationshipService.updateItem(context, relationship.getLeftItem()); relationshipService.updateItem(context, relationship.getLeftItem());
relationshipService.updateItem(context, relationship.getRightItem()); relationshipService.updateItem(context, relationship.getRightItem());