Added null check before deletion

This commit is contained in:
dylan
2016-03-15 08:59:30 +01:00
parent cd03d3a55f
commit fd82899e7a

View File

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