[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:
KevinVdV
2016-05-09 13:03:42 +02:00
parent 20012c3081
commit b2260c48e9
2 changed files with 13 additions and 9 deletions

View File

@@ -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,

View File

@@ -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);