stepInfo = steps.get(stepNum);
+ SubmissionStepConfig step = new SubmissionStepConfig(stepInfo);
+
+ // Only add this step to the process if either:
+ // (a) this is not a workflow process OR
+ // (b) this is a workflow process, and this step is editable in a
+ // workflow
+ if ((!this.isWorkflow && step.isSubmissionEditable())
+ || ((this.isWorkflow) && step.isWorkflowEditable()))
+ {
+ boolean typeBoundAndValid = true;
+ if(StringUtils.isNotBlank(step.getTypeBindingConfig())){
+ String typeBindingConfig = step.getTypeBindingConfig();
+ SubmissionStepConditionCheck conditionCheck = new org.dspace.utils.DSpace().getServiceManager().getServiceByName("SubmissionStepConditionCheck",SubmissionStepConditionCheck.class);
+ typeBoundAndValid= conditionCheck.allConditionsMet(subInfo.getSubmissionItem().getItem(), typeBindingConfig);
+ }
+ if (typeBoundAndValid) {
+
+ // set the number of the step (starts at 0) and add it
+ step.setStepNumber(stepConfigs.size());
+ stepConfigs.add(step);
+
+ log.debug("Added step '" + step.getProcessingClassName()
+ + "' as step #" + step.getStepNumber()
+ + " of submission process " + submissionName);
+ }
+
+ }
+ }
+
+ // get steps as an array of Strings
+ submissionSteps = stepConfigs
+ .toArray(new SubmissionStepConfig[stepConfigs.size()]);
+ }
+
+ /**
+ * Return the name of the item submission process definition
+ *
+ * @return the name of the submission process
+ */
+ public String getSubmissionName()
+ {
+ return submissionName;
+ }
+
+ /**
+ * Return the number of steps in this submission process
+ *
+ * @return number of steps
+ */
+ public int getNumberOfSteps()
+ {
+ return submissionSteps.length;
+ }
+
+ /**
+ * Return whether or not this submission process is being used in a
+ * workflow!
+ *
+ * @return true, if it's a workflow process. false, otherwise.
+ */
+ public boolean isWorkflow()
+ {
+ return isWorkflow;
+ }
+
+ /**
+ * Retrieve a particular Step configuration in this Item Submission Process
+ * configuration. The first step is numbered "0" (although step #0 is the
+ * implied "select collection" step).
+ *
+ * If you want to retrieve the step after the "select collection" step, you
+ * should retrieve step #1.
+ *
+ * If the specified step isn't found, null is returned.
+ *
+ * @param stepNum
+ * desired step to retrieve
+ *
+ * @return the SubmissionStepConfig object for the step
+ */
+
+ public SubmissionStepConfig getStep(int stepNum)
+ {
+ if ((stepNum > submissionSteps.length - 1) || (stepNum < 0))
+ {
+ return null;
+ }
+ else
+ {
+ return submissionSteps[stepNum];
+ }
+ }
+
+ /**
+ * Returns whether or not there are more steps which follow the specified
+ * "stepNum". For example, if you specify stepNum=4, then this method checks
+ * to see if there is a Step #5. The first step is numbered "0".
+ *
+ * @param stepNum
+ * the current step.
+ *
+ * @return true, if a step at "stepNum+1" exists. false, otherwise.
+ */
+
+ public boolean hasMoreSteps(int stepNum)
+ {
+ return (getStep(stepNum + 1) != null);
+ }
+}
diff --git a/dspace/modules/additions/src/main/java/org/dspace/app/util/SubmissionConfigReader.java b/dspace/modules/additions/src/main/java/org/dspace/app/util/SubmissionConfigReader.java
new file mode 100644
index 0000000..40f1efd
--- /dev/null
+++ b/dspace/modules/additions/src/main/java/org/dspace/app/util/SubmissionConfigReader.java
@@ -0,0 +1,651 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.util;
+
+import java.io.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.xml.parsers.*;
+import org.apache.log4j.*;
+import org.dspace.core.*;
+import org.w3c.dom.*;
+import org.xml.sax.*;
+
+/**
+ * Item Submission configuration generator for DSpace. Reads and parses the
+ * installed submission process configuration file, item-submission.xml, from
+ * the configuration directory. This submission process definition details the
+ * ordering of the steps (and number of steps) that occur during the Item
+ * Submission Process. There may be multiple Item Submission processes defined,
+ * where each definition is assigned a unique name.
+ *
+ * The file also specifies which collections use which Item Submission process.
+ * At a minimum, the definitions file must define a default mapping from the
+ * placeholder collection # to the distinguished submission process 'default'.
+ * Any collections that use a custom submission process are listed paired with
+ * the name of the item submission process they use.
+ *
+ * @see SubmissionConfig
+ * @see SubmissionStepConfig
+ *
+ * @author Tim Donohue based on DCInputsReader by Brian S. Hughes
+ * @version $Revision$
+ */
+
+public class SubmissionConfigReader
+{
+ /**
+ * The ID of the default collection. Will never be the ID of a named
+ * collection
+ */
+ public static final String DEFAULT_COLLECTION = "default";
+
+ /** Prefix of the item submission definition XML file */
+ static final String SUBMIT_DEF_FILE_PREFIX = "item-submission";
+
+ /** Suffix of the item submission definition XML file */
+ static final String SUBMIT_DEF_FILE_SUFFIX = ".xml";
+
+ /** log4j logger */
+ private static Logger log = Logger.getLogger(SubmissionConfigReader.class);
+
+ /** The fully qualified pathname of the directory containing the Item Submission Configuration file */
+ private String configDir = ConfigurationManager.getProperty("dspace.dir")
+ + File.separator + "config" + File.separator;
+
+ /**
+ * Hashmap which stores which submission process configuration is used by
+ * which collection, computed from the item submission config file
+ * (specifically, the 'submission-map' tag)
+ */
+ private Map collectionToSubmissionConfig = null;
+
+ /**
+ * Reference to the global submission step definitions defined in the
+ * "step-definitions" section
+ */
+ private Map> stepDefns = null;
+
+ /**
+ * Reference to the item submission definitions defined in the
+ * "submission-definitions" section
+ */
+ private Map>> submitDefns = null;
+
+ /**
+ * Mini-cache of last SubmissionConfig object requested (so that we don't
+ * always reload from scratch)
+ */
+ private SubmissionConfig lastSubmissionConfig = null;
+
+ /**
+ * Load Submission Configuration from the
+ * item-submission.xml configuration file
+ */
+ public SubmissionConfigReader() throws ServletException
+ {
+ buildInputs(configDir + SUBMIT_DEF_FILE_PREFIX + SUBMIT_DEF_FILE_SUFFIX);
+ }
+
+ /**
+ * Parse an XML encoded item submission configuration file.
+ *
+ * Creates two main hashmaps:
+ *
+ * - Hashmap of Collection to Submission definition mappings -
+ * defines which Submission process a particular collection uses
+ *
- Hashmap of all Submission definitions. List of all valid
+ * Submision Processes by name.
+ *
+ */
+ private void buildInputs(String fileName) throws ServletException
+ {
+ collectionToSubmissionConfig = new HashMap();
+ submitDefns = new HashMap>>();
+
+ String uri = "file:" + new File(fileName).getAbsolutePath();
+
+ try
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ factory.setValidating(false);
+ factory.setIgnoringComments(true);
+ factory.setIgnoringElementContentWhitespace(true);
+
+ DocumentBuilder db = factory.newDocumentBuilder();
+ Document doc = db.parse(uri);
+ doNodes(doc);
+ }
+ catch (FactoryConfigurationError fe)
+ {
+ throw new ServletException(
+ "Cannot create Item Submission Configuration parser", fe);
+ }
+ catch (Exception e)
+ {
+ throw new ServletException(
+ "Error creating Item Submission Configuration: " + e);
+ }
+ }
+
+ /**
+ * Returns the Item Submission process config used for a particular
+ * collection, or the default if none is defined for the collection
+ *
+ * @param collectionHandle
+ * collection's unique Handle
+ * @param isWorkflow
+ * whether or not we are loading the submission process for a
+ * workflow
+ * @return the SubmissionConfig representing the item submission config
+ *
+ * @throws ServletException
+ * if no default submission process configuration defined
+ */
+ public SubmissionConfig getSubmissionConfig(String collectionHandle,
+ SubmissionInfo subInfo) throws ServletException
+ {
+ // get the name of the submission process config for this collection
+ String submitName = collectionToSubmissionConfig
+ .get(collectionHandle);
+ if (submitName == null)
+ {
+ submitName = collectionToSubmissionConfig
+ .get(DEFAULT_COLLECTION);
+ }
+ if (submitName == null)
+ {
+ throw new ServletException(
+ "No item submission process configuration designated as 'default' in 'submission-map' section of 'item-submission.xml'.");
+ }
+
+ log.debug("Loading submission process config named '" + submitName
+ + "'");
+
+ // check mini-cache, and return if match
+// if (lastSubmissionConfig != null
+// && lastSubmissionConfig.getSubmissionName().equals(submitName)
+// && lastSubmissionConfig.isWorkflow() == isWorkflow)
+// {
+// log.debug("Found submission process config '" + submitName
+// + "' in cache.");
+//
+// return lastSubmissionConfig;
+// }
+
+ // cache disabled - construct new SubmissionConfig
+ List