diff --git a/dspace-api/src/main/java/org/dspace/app/util/DCInputsReader.java b/dspace-api/src/main/java/org/dspace/app/util/DCInputsReader.java index ac8031880233..86b45c367941 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/DCInputsReader.java +++ b/dspace-api/src/main/java/org/dspace/app/util/DCInputsReader.java @@ -316,6 +316,9 @@ public List getInputsByGroup(String formName) // cache miss - construct new DCInputSet List>> pages = formDefns.get(formName); + if (pages == null) { + return results; + } Iterator>> iterator = pages.iterator(); diff --git a/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthorityServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthorityServiceImpl.java index 6e0800457397..cbc92c3be5f6 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthorityServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthorityServiceImpl.java @@ -7,6 +7,7 @@ */ package org.dspace.content.authority; +import static java.lang.Integer.MAX_VALUE; import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.util.ArrayList; @@ -21,6 +22,7 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.dspace.app.util.DCInput; import org.dspace.app.util.DCInputSet; @@ -64,7 +66,7 @@ * @see ChoiceAuthority */ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService { - private Logger log = org.apache.logging.log4j.LogManager.getLogger(ChoiceAuthorityServiceImpl.class); + private Logger log = LogManager.getLogger(ChoiceAuthorityServiceImpl.class); // map of field key to authority plugin protected Map controller = new HashMap(); @@ -343,16 +345,26 @@ private void loadChoiceAuthorityConfigurations() { */ private void autoRegisterChoiceAuthorityFromInputReader() { try { - List submissionConfigs = itemSubmissionConfigReader - .getAllSubmissionConfigs(Integer.MAX_VALUE, 0); + List submissionConfigs = itemSubmissionConfigReader.getAllSubmissionConfigs(MAX_VALUE, 0); DCInputsReader dcInputsReader = new DCInputsReader(); // loop over all the defined item submission configuration for (SubmissionConfig subCfg : submissionConfigs) { String submissionName = subCfg.getSubmissionName(); List inputsBySubmissionName = dcInputsReader.getInputsBySubmissionName(submissionName); - autoRegisterChoiceAuthorityFromSubmissionForms(Constants.ITEM, submissionName, - inputsBySubmissionName); + List inputsByGroupOfAllSteps = new ArrayList(); + try { + List inputsByGroup = dcInputsReader.getInputsByGroup(submissionName); + inputsByGroupOfAllSteps.addAll(inputsByGroup); + for (DCInputSet step : inputsBySubmissionName) { + List inputsByGroupOfStep = dcInputsReader.getInputsByGroup(step.getFormName()); + inputsByGroupOfAllSteps.addAll(inputsByGroupOfStep); + } + } catch (DCInputsReaderException e) { + log.warn("Cannot load the groups of the submission: " + submissionName, e); + } + inputsBySubmissionName.addAll(inputsByGroupOfAllSteps); + autoRegisterChoiceAuthorityFromSubmissionForms(Constants.ITEM, submissionName, inputsBySubmissionName); } // loop over all the defined bitstream metadata submission configuration for (UploadConfiguration uploadCfg : uploadConfigurationService.getMap().values()) { @@ -363,8 +375,7 @@ private void autoRegisterChoiceAuthorityFromInputReader() { } } catch (DCInputsReaderException e) { // the system is in an illegal state as the submission definition is not valid - throw new IllegalStateException("Error reading the item submission configuration: " + e.getMessage(), - e); + throw new IllegalStateException("Error reading the item submission configuration: " + e.getMessage(), e); } }