mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 21:43:11 +00:00
Added null check before deletion
This commit is contained in:
@@ -77,6 +77,8 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
protected IdentifierService identifierService;
|
||||
@Autowired(required = true)
|
||||
protected VersioningService versioningService;
|
||||
@Autowired(required=true)
|
||||
protected HarvestedItemService harvestedItemService;
|
||||
|
||||
protected ItemServiceImpl()
|
||||
{
|
||||
@@ -583,9 +585,11 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
authorizeService.authorizeAction(context, item, Constants.DELETE);
|
||||
|
||||
// Also delete the item if it appears in a harvested collection.
|
||||
HarvestedItemService harvestedItemService = HarvestServiceFactory.getInstance().getHarvestedItemService(); // autowire this.
|
||||
HarvestedItem hi = harvestedItemService.find(context, item);
|
||||
harvestedItemService.delete(context,hi);
|
||||
if(hi!=null)
|
||||
{
|
||||
harvestedItemService.delete(context, hi);
|
||||
}
|
||||
|
||||
item.getCollections().clear();
|
||||
item.setOwningCollection(null);
|
||||
|
Reference in New Issue
Block a user