mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-11 20:13:17 +00:00
[DS-3179] Collection admin, edit item no authorization to remove file in JSPUI: Additional fixes to delete item as collection admin
This commit is contained in:
@@ -550,14 +550,15 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
// Check authorisation
|
||||
authorizeService.authorizeAction(context, collection, Constants.REMOVE);
|
||||
|
||||
//Remove the item from the collection
|
||||
item.removeCollection(collection);
|
||||
|
||||
//Check if we orphaned our poor item
|
||||
if (item.getCollections().isEmpty())
|
||||
if (item.getCollections().size() == 1)
|
||||
{
|
||||
// Orphan; delete it
|
||||
itemService.delete(context, item);
|
||||
} else {
|
||||
//Remove the item from the collection if we have multiple collections
|
||||
item.removeCollection(collection);
|
||||
|
||||
}
|
||||
|
||||
context.addEvent(new Event(Event.REMOVE, Constants.COLLECTION,
|
||||
|
@@ -578,8 +578,6 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
@Override
|
||||
public void delete(Context context, Item item) throws SQLException, AuthorizeException, IOException {
|
||||
authorizeService.authorizeAction(context, item, Constants.DELETE);
|
||||
item.getCollections().clear();
|
||||
item.setOwningCollection(null);
|
||||
rawDelete(context, item);
|
||||
}
|
||||
|
||||
@@ -603,14 +601,19 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
// Remove bundles
|
||||
removeAllBundles(context, item);
|
||||
|
||||
// remove version attached to the item
|
||||
removeVersion(context, item);
|
||||
|
||||
//Only clear collections after we have removed everything else from the item
|
||||
item.getCollections().clear();
|
||||
item.setOwningCollection(null);
|
||||
|
||||
// remove all of our authorization policies
|
||||
authorizeService.removeAllPolicies(context, item, false);
|
||||
|
||||
// Remove any Handle
|
||||
handleService.unbindHandle(context, item);
|
||||
|
||||
// remove version attached to the item
|
||||
removeVersion(context, item);
|
||||
|
||||
// Finally remove item row
|
||||
itemDAO.delete(context, item);
|
||||
|
Reference in New Issue
Block a user