mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-12 04:23:13 +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
|
// Check authorisation
|
||||||
authorizeService.authorizeAction(context, collection, Constants.REMOVE);
|
authorizeService.authorizeAction(context, collection, Constants.REMOVE);
|
||||||
|
|
||||||
//Remove the item from the collection
|
|
||||||
item.removeCollection(collection);
|
|
||||||
|
|
||||||
//Check if we orphaned our poor item
|
//Check if we orphaned our poor item
|
||||||
if (item.getCollections().isEmpty())
|
if (item.getCollections().size() == 1)
|
||||||
{
|
{
|
||||||
// Orphan; delete it
|
// Orphan; delete it
|
||||||
itemService.delete(context, item);
|
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,
|
context.addEvent(new Event(Event.REMOVE, Constants.COLLECTION,
|
||||||
|
@@ -578,8 +578,6 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
@Override
|
@Override
|
||||||
public void delete(Context context, Item item) throws SQLException, AuthorizeException, IOException {
|
public void delete(Context context, Item item) throws SQLException, AuthorizeException, IOException {
|
||||||
authorizeService.authorizeAction(context, item, Constants.DELETE);
|
authorizeService.authorizeAction(context, item, Constants.DELETE);
|
||||||
item.getCollections().clear();
|
|
||||||
item.setOwningCollection(null);
|
|
||||||
rawDelete(context, item);
|
rawDelete(context, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -603,14 +601,19 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
// Remove bundles
|
// Remove bundles
|
||||||
removeAllBundles(context, item);
|
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
|
// remove all of our authorization policies
|
||||||
authorizeService.removeAllPolicies(context, item, false);
|
authorizeService.removeAllPolicies(context, item, false);
|
||||||
|
|
||||||
// Remove any Handle
|
// Remove any Handle
|
||||||
handleService.unbindHandle(context, item);
|
handleService.unbindHandle(context, item);
|
||||||
|
|
||||||
// remove version attached to the item
|
|
||||||
removeVersion(context, item);
|
|
||||||
|
|
||||||
// Finally remove item row
|
// Finally remove item row
|
||||||
itemDAO.delete(context, item);
|
itemDAO.delete(context, item);
|
||||||
|
Reference in New Issue
Block a user