mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
99200: Delete items after copies have been requested fix
This commit is contained in:
@@ -27,6 +27,8 @@ import java.util.stream.Stream;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.requestitem.RequestItem;
|
||||
import org.dspace.app.requestitem.service.RequestItemService;
|
||||
import org.dspace.app.util.AuthorizeUtil;
|
||||
import org.dspace.authorize.AuthorizeConfiguration;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
@@ -158,6 +160,8 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
|
||||
@Autowired(required = true)
|
||||
private ResearcherProfileService researcherProfileService;
|
||||
@Autowired(required = true)
|
||||
private RequestItemService requestItemService;
|
||||
|
||||
protected ItemServiceImpl() {
|
||||
super();
|
||||
@@ -780,6 +784,8 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
// remove version attached to the item
|
||||
removeVersion(context, item);
|
||||
|
||||
removeRequest(context, item);
|
||||
|
||||
removeOrcidSynchronizationStuff(context, item);
|
||||
|
||||
// Also delete the item if it appears in a harvested collection.
|
||||
@@ -802,6 +808,15 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
itemDAO.delete(context, item);
|
||||
}
|
||||
|
||||
protected void removeRequest(Context context, Item item) throws SQLException {
|
||||
Iterator<RequestItem> requestItems = requestItemService.findByItem(context, item);
|
||||
while (requestItems.hasNext()) {
|
||||
RequestItem requestItem = requestItems.next();
|
||||
log.info("Remove Request Item: " + requestItem.getID());
|
||||
requestItemService.delete(context, requestItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllBundles(Context context, Item item) throws AuthorizeException, SQLException, IOException {
|
||||
Iterator<Bundle> bundles = item.getBundles().iterator();
|
||||
|
Reference in New Issue
Block a user