From 20c67d4289faa7f9c87634271918a5358a38376d Mon Sep 17 00:00:00 2001 From: Mattia Vianelli Date: Tue, 6 Feb 2024 09:50:39 +0100 Subject: [PATCH] DSC-1526 We now have a check for which if the workspace item is a correction request we check if it is submission correction or a simple submission --- .../app/util/SubmissionConfigReader.java | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/dspace-api/src/main/java/org/dspace/app/util/SubmissionConfigReader.java b/dspace-api/src/main/java/org/dspace/app/util/SubmissionConfigReader.java index 2f591b6e7a8c..02d7429b4112 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/SubmissionConfigReader.java +++ b/dspace-api/src/main/java/org/dspace/app/util/SubmissionConfigReader.java @@ -30,7 +30,11 @@ import org.dspace.core.Context; import org.dspace.discovery.SearchServiceException; import org.dspace.handle.factory.HandleServiceFactory; +import org.dspace.services.RequestService; import org.dspace.services.factory.DSpaceServicesFactory; +import org.dspace.versioning.ItemCorrectionService; +import org.dspace.web.ContextUtil; +import org.springframework.beans.factory.annotation.Autowired; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; @@ -58,6 +62,13 @@ */ public class SubmissionConfigReader { + + @Autowired + private ItemCorrectionService itemCorrectionService; + + @Autowired + RequestService requestService; + /** * The ID of the default collection. Will never be the ID of a named * collection @@ -430,6 +441,21 @@ private void doNodes(Node n) throws SAXException, SearchServiceException, Submis } } + + private boolean isCorrectionItem(Item item) { + Context context = ContextUtil.obtainCurrentRequestContext(); + ItemCorrectionService itemCorrectionService = + DSpaceServicesFactory.getInstance().getServiceManager() + .getServicesByType(ItemCorrectionService.class) + .get(0); + try { + return itemCorrectionService.checkIfIsCorrectionItem(context, item); + } catch (Exception ex) { + log.error("An error occurs checking if the given item is a correction item.", ex); + return false; + } + } + /** * Process the submission-map section of the XML file. Each element looks * like: Extract @@ -764,6 +790,13 @@ public SubmissionConfig getSubmissionConfigByInProgressSubmission(InProgressSubm return getSubmissionConfigByName(submissionDefinition); } - return getSubmissionConfigByCollection(object.getCollection()); + if (isCorrectionItem(object.getItem())) { + return getCorrectionSubmissionConfigByCollection(object.getCollection()); + } else { + return getSubmissionConfigByCollection(object.getCollection()); + } + } + + } \ No newline at end of file