mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
Unlink DOI from item on deletion even if no provider is configured
This commit is contained in:
@@ -64,7 +64,9 @@ import org.dspace.eperson.service.SubscribeService;
|
|||||||
import org.dspace.event.Event;
|
import org.dspace.event.Event;
|
||||||
import org.dspace.harvest.HarvestedItem;
|
import org.dspace.harvest.HarvestedItem;
|
||||||
import org.dspace.harvest.service.HarvestedItemService;
|
import org.dspace.harvest.service.HarvestedItemService;
|
||||||
|
import org.dspace.identifier.DOI;
|
||||||
import org.dspace.identifier.IdentifierException;
|
import org.dspace.identifier.IdentifierException;
|
||||||
|
import org.dspace.identifier.service.DOIService;
|
||||||
import org.dspace.identifier.service.IdentifierService;
|
import org.dspace.identifier.service.IdentifierService;
|
||||||
import org.dspace.orcid.OrcidHistory;
|
import org.dspace.orcid.OrcidHistory;
|
||||||
import org.dspace.orcid.OrcidQueue;
|
import org.dspace.orcid.OrcidQueue;
|
||||||
@@ -123,6 +125,8 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected IdentifierService identifierService;
|
protected IdentifierService identifierService;
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
|
protected DOIService doiService;
|
||||||
|
@Autowired(required = true)
|
||||||
protected VersioningService versioningService;
|
protected VersioningService versioningService;
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected HarvestedItemService harvestedItemService;
|
protected HarvestedItemService harvestedItemService;
|
||||||
@@ -786,6 +790,16 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
// Remove any Handle
|
// Remove any Handle
|
||||||
handleService.unbindHandle(context, item);
|
handleService.unbindHandle(context, item);
|
||||||
|
|
||||||
|
// Delete a DOI if linked to the item.
|
||||||
|
// If no DOI consumer or provider is configured, but a DOI remains linked to this item's uuid,
|
||||||
|
// hibernate will throw a foreign constraint exception.
|
||||||
|
// Here we use the DOI service directly as it is able to manage DOIs even without any configured
|
||||||
|
// consumer or provider.
|
||||||
|
DOI doi = doiService.findDOIByDSpaceObject(context, item);
|
||||||
|
if (doi != null) {
|
||||||
|
doi.setDSpaceObject(null);
|
||||||
|
}
|
||||||
|
|
||||||
// remove version attached to the item
|
// remove version attached to the item
|
||||||
removeVersion(context, item);
|
removeVersion(context, item);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user