When an item is deleted from DSpace, any policies linked to it are not being removed as well in at least the following cases:
- A submitter deletes an in-progress submission of his own in "My DSpace".
- An admin deletes an item in the "Edit Item" form.
- a WorkspaceItem has temporary policies giving a submitter access to his own submission -> https://github.com/DSpace/DSpace/blob/dspace-6_x/dspace-api/src/main/java/org/dspace/content/WorkspaceItemServiceImpl.java#L99
- an item could have an embargo (temporarily) restricting access.
Links to relevant code:
In all those places, nothing is done about policies, as it should be. I would expect that to be in ItemServiceImpl.java in rawDelete() ( https://github.com/DSpace/DSpace/blob/dspace-6_x/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java#L632 ) ) but I can't see any code taking care of policies there.
I found this bug by trying to delete a user that had previously started and later deleted at least one submission. The user could not be deleted (interestingly without an internal server error), and the log files showed foreign key constraint violations on the resourcepolicy table.