[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

@@ -547,17 +547,18 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
@Override
public void removeItem(Context context, Collection collection, Item item) throws SQLException, AuthorizeException, IOException {
// Check authorisation
// 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,