mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 13:03:11 +00:00
Added the base Configurable Submission code to dspace-api. This includes updates to the following:
- Added a new "list" type to the input-forms.xml, which will allow you to display metadata options in radio buttons or checboxes - Added the base Configurable Submission step processing classes (org.dspace.submit.step.*) which perform all processing for both the JSP-UI and XML-UI - Added the classes which read the configuration file (item-submission.xml) git-svn-id: http://scm.dspace.org/svn/repo/trunk@2079 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -120,7 +120,8 @@ public class DCInput
|
||||
label = (String) fieldMap.get("label");
|
||||
inputType = (String) fieldMap.get("input-type");
|
||||
// these types are list-controlled
|
||||
if ("dropdown".equals(inputType) || "qualdrop_value".equals(inputType))
|
||||
if ("dropdown".equals(inputType) || "qualdrop_value".equals(inputType)
|
||||
|| "list".equals(inputType))
|
||||
{
|
||||
valueListName = (String) fieldMap.get("value-pairs-name");
|
||||
valueList = (List) listMap.get(valueListName);
|
||||
@@ -209,8 +210,7 @@ public class DCInput
|
||||
*/
|
||||
public String getWarning()
|
||||
{
|
||||
return "<tr><td colspan=\"4\" class=\"submitFormWarn\">" + warning
|
||||
+ "</td></tr>";
|
||||
return warning;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,8 +240,7 @@ public class DCInput
|
||||
*/
|
||||
public String getHints()
|
||||
{
|
||||
return "<tr><td colspan=\"4\" class=\"submitFormHelp\">" + hint
|
||||
+ "</td></tr>";
|
||||
return hint;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -79,8 +79,11 @@ import org.dspace.core.ConfigurationManager;
|
||||
|
||||
public class DCInputsReader
|
||||
{
|
||||
/** The ID of the default collection. Will never be the ID of a named collection */
|
||||
static final String DEFAULT_COLLECTION = "default";
|
||||
/**
|
||||
* The ID of the default collection. Will never be the ID of a named
|
||||
* collection
|
||||
*/
|
||||
public static final String DEFAULT_COLLECTION = "default";
|
||||
|
||||
/** Name of the form definition XML file */
|
||||
static final String FORM_DEF_FILE = "input-forms.xml";
|
||||
@@ -92,36 +95,44 @@ public class DCInputsReader
|
||||
private static Logger log = Logger.getLogger(DCInputsReader.class);
|
||||
|
||||
/** The fully qualified pathname of the form definition XML file */
|
||||
private String defsFile = ConfigurationManager.getProperty("dspace.dir") +
|
||||
File.separator + "config" + File.separator + FORM_DEF_FILE;
|
||||
private String defsFile = ConfigurationManager.getProperty("dspace.dir")
|
||||
+ File.separator + "config" + File.separator + FORM_DEF_FILE;
|
||||
|
||||
/** Reference to the collections to forms map,
|
||||
* computed from the forms definition file
|
||||
/**
|
||||
* Reference to the collections to forms map, computed from the forms
|
||||
* definition file
|
||||
*/
|
||||
private HashMap whichForms = null;
|
||||
|
||||
/** Reference to the forms definitions map,
|
||||
* computed from the forms definition file
|
||||
/**
|
||||
* Reference to the forms definitions map, computed from the forms
|
||||
* definition file
|
||||
*/
|
||||
private HashMap formDefns = null;
|
||||
|
||||
/** Reference to the value-pairs map,
|
||||
* computed from the forms defition file
|
||||
/**
|
||||
* Reference to the forms which allow, disallow or mandate files to be
|
||||
* uploaded.
|
||||
*/
|
||||
private HashMap formFileUploadDefns = null;
|
||||
|
||||
/**
|
||||
* Reference to the value-pairs map, computed from the forms defition file
|
||||
*/
|
||||
private HashMap valuePairs = null; // Holds display/storage pairs
|
||||
|
||||
/**
|
||||
* Mini-cache of last DCInputSet requested. If submissions are not
|
||||
* typically form-interleaved, there will be a modest win.
|
||||
* Mini-cache of last DCInputSet requested. If submissions are not typically
|
||||
* form-interleaved, there will be a modest win.
|
||||
*/
|
||||
private DCInputSet lastInputSet = null;
|
||||
|
||||
/**
|
||||
* Parse an XML encoded submission forms template file, and create
|
||||
* a hashmap containing all the form information. This
|
||||
* hashmap will contain three top level structures: a map between
|
||||
* collections and forms, the definition for each page of each form,
|
||||
* and lists of pairs of values that populate selection boxes.
|
||||
* Parse an XML encoded submission forms template file, and create a hashmap
|
||||
* containing all the form information. This hashmap will contain three top
|
||||
* level structures: a map between collections and forms, the definition for
|
||||
* each page of each form, and lists of pairs of values that populate
|
||||
* selection boxes.
|
||||
*/
|
||||
|
||||
public DCInputsReader()
|
||||
@@ -170,11 +181,14 @@ public class DCInputsReader
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the set of DC inputs used for a particular collection,
|
||||
* or the default set if no inputs defined for the collection
|
||||
* @param collectionHandle collection's unique Handle
|
||||
* Returns the set of DC inputs used for a particular collection, or the
|
||||
* default set if no inputs defined for the collection
|
||||
*
|
||||
* @param collectionHandle
|
||||
* collection's unique Handle
|
||||
* @return DC input set
|
||||
* @throws ServletException if no default set defined
|
||||
* @throws ServletException
|
||||
* if no default set defined
|
||||
*/
|
||||
public DCInputSet getInputs(String collectionHandle)
|
||||
throws ServletException
|
||||
@@ -216,9 +230,9 @@ public class DCInputsReader
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the top level child nodes in the passed top-level node.
|
||||
* These should correspond to the collection-form maps, the form
|
||||
* definitions, and the display/storage word pairs.
|
||||
* Process the top level child nodes in the passed top-level node. These
|
||||
* should correspond to the collection-form maps, the form definitions, and
|
||||
* the display/storage word pairs.
|
||||
*/
|
||||
private void doNodes(Node n)
|
||||
throws SAXException, ServletException
|
||||
@@ -304,11 +318,11 @@ public class DCInputsReader
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form-definitions section of the XML file.
|
||||
* Each element is formed thusly: <form name="formname">...pages...</form>
|
||||
* Each pages subsection is formed: <page number="#"> ...fields... </page>
|
||||
* Each field is formed from: dc-element, dc-qualifier, label, hint,
|
||||
* input-type name, required text, and repeatable flag.
|
||||
* Process the form-definitions section of the XML file. Each element is
|
||||
* formed thusly: <form name="formname">...pages...</form> Each pages
|
||||
* subsection is formed: <page number="#"> ...fields... </page> Each field
|
||||
* is formed from: dc-element, dc-qualifier, label, hint, input-type name,
|
||||
* required text, and repeatable flag.
|
||||
*/
|
||||
private void processDefinition(Node e)
|
||||
throws SAXException, ServletException
|
||||
@@ -370,18 +384,6 @@ public class DCInputsReader
|
||||
{
|
||||
throw new ServletException("Form " + formName + " has no pages");
|
||||
}
|
||||
|
||||
// FIXME: Because this file needed to be removed from the jspui it
|
||||
// can no longer depend upon the submit servlet. There fore we're replacing this
|
||||
// line with a static value so that it does not depened upon this. This will be
|
||||
// fixed in the future by Tim's Configurable Submission patch which reads
|
||||
// this value from a configuration page.
|
||||
//int maxPages = SubmitServlet.EDIT_METADATA_2 - SubmitServlet.EDIT_METADATA_1 + 1;
|
||||
int maxPages = 5;
|
||||
if ( pages.size() > maxPages)
|
||||
{
|
||||
throw new ServletException("Form " + formName + " exceeds maximum pages: " + maxPages);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (numForms == 0)
|
||||
@@ -411,7 +413,9 @@ public class DCInputsReader
|
||||
field.put(tagName, value);
|
||||
if (tagName.equals("input-type"))
|
||||
{
|
||||
if (value.equals("dropdown") || value.equals("qualdrop_value"))
|
||||
if (value.equals("dropdown")
|
||||
|| value.equals("qualdrop_value")
|
||||
|| value.equals("list"))
|
||||
{
|
||||
String pairTypeName = getAttribute(nd, PAIR_TYPE_NAME);
|
||||
if (pairTypeName == null)
|
||||
@@ -626,7 +630,9 @@ public class DCInputsReader
|
||||
HashMap fld = (HashMap)page.get(j);
|
||||
// verify reference in certain input types
|
||||
String type = (String)fld.get("input-type");
|
||||
if (type.equals("dropdown") || type.equals("qualdrop_value"))
|
||||
if (type.equals("dropdown")
|
||||
|| type.equals("qualdrop_value")
|
||||
|| type.equals("list"))
|
||||
{
|
||||
String pairsName = (String)fld.get(PAIR_TYPE_NAME);
|
||||
Vector v = (Vector)valuePairs.get(pairsName);
|
||||
|
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* SubmissionConfig.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
|
||||
package org.dspace.app.util;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Class representing a single Item Submission config definition, organized into
|
||||
* steps. This class represents the structure of a single 'submission-process'
|
||||
* node in the item-submission.xml configuration file.
|
||||
*
|
||||
* @see org.dspace.app.util.SubmissionConfigReader
|
||||
* @see org.dspace.app.util.SubmissionStepConfig
|
||||
*
|
||||
* @author Tim Donohue, based on DCInputSet by Brian S. Hughes
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
public class SubmissionConfig
|
||||
{
|
||||
/** name of the item submission process */
|
||||
private String submissionName = null;
|
||||
|
||||
/** the configuration classes for the steps in this submission process */
|
||||
private SubmissionStepConfig[] submissionSteps = null;
|
||||
|
||||
/** whether or not this submission process is being used in a workflow * */
|
||||
private boolean isWorkflow = false;
|
||||
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(SubmissionConfig.class);
|
||||
|
||||
/**
|
||||
* Constructs a new Submission Configuration object, based on the XML
|
||||
* configuration file (item-submission.xml)
|
||||
*
|
||||
* @param submissionName
|
||||
* the submission process name
|
||||
* @param steps
|
||||
* the vector listing of step information to build
|
||||
* SubmissionStepConfig objects for this submission process
|
||||
* @param isWorkflowProcess
|
||||
* whether this submission process is being used in a workflow or
|
||||
* not. If it is a workflow process this may limit the steps that
|
||||
* are available for editing.
|
||||
*/
|
||||
public SubmissionConfig(String submissionName, Vector steps,
|
||||
boolean isWorkflowProcess)
|
||||
{
|
||||
this.submissionName = submissionName;
|
||||
this.isWorkflow = isWorkflowProcess;
|
||||
|
||||
// initialize a vector of SubmissionStepConfig objects
|
||||
Vector stepConfigs = new Vector();
|
||||
|
||||
// loop through our steps, and create SubmissionStepConfig objects
|
||||
for (int stepNum = 0; stepNum < steps.size(); stepNum++)
|
||||
{
|
||||
Map stepInfo = (Map) 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)
|
||||
|| ((this.isWorkflow) && step.isWorkflowEditable()))
|
||||
{
|
||||
// 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 = (SubmissionStepConfig[]) stepConfigs
|
||||
.toArray(new SubmissionStepConfig[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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).
|
||||
* <p>
|
||||
* 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)
|
||||
{
|
||||
if (getStep(stepNum + 1) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,686 @@
|
||||
/*
|
||||
* SubmissionConfigReader.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
|
||||
package org.dspace.app.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.lang.Exception;
|
||||
import javax.servlet.ServletException;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.w3c.dom.*;
|
||||
import javax.xml.parsers.*;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
|
||||
/**
|
||||
* 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 definiton 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 org.dspace.app.util.SubmissionConfig
|
||||
* @see org.dspace.app.util.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";
|
||||
|
||||
/** Name of the item submission definition XML file */
|
||||
static final String SUBMIT_DEF_FILE = "item-submission.xml";
|
||||
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(SubmissionConfigReader.class);
|
||||
|
||||
/** The fully qualified pathname of the item submission definition XML file */
|
||||
private String defsFile = ConfigurationManager.getProperty("dspace.dir")
|
||||
+ File.separator + "config" + File.separator + SUBMIT_DEF_FILE;
|
||||
|
||||
/**
|
||||
* 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 HashMap collectionToSubmissionConfig = null;
|
||||
|
||||
/**
|
||||
* Reference to the global submission step definitions defined in the
|
||||
* "step-definitions" section
|
||||
*/
|
||||
private HashMap stepDefns = null;
|
||||
|
||||
/**
|
||||
* Reference to the item submission definitions defined in the
|
||||
* "submission-definitions" section
|
||||
*/
|
||||
private HashMap submitDefns = null;
|
||||
|
||||
/**
|
||||
* Mini-cache of last SubmissionConfig object requested (so that we don't
|
||||
* always reload from scratch)
|
||||
*/
|
||||
private SubmissionConfig lastSubmissionConfig = null;
|
||||
|
||||
/**
|
||||
* Parse an XML encoded submission forms template file, and create a hashmap
|
||||
* containing all the form information. This hashmap will contain three top
|
||||
* level structures: a map between collections and forms, the definition for
|
||||
* each page of each form, and lists of pairs of values that populate
|
||||
* selection boxes.
|
||||
*/
|
||||
|
||||
public SubmissionConfigReader() throws ServletException
|
||||
{
|
||||
buildInputs(defsFile);
|
||||
}
|
||||
|
||||
public SubmissionConfigReader(String fileName) throws ServletException
|
||||
{
|
||||
buildInputs(fileName);
|
||||
}
|
||||
|
||||
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,
|
||||
boolean isWorkflow) throws ServletException
|
||||
{
|
||||
// get the name of the submission process config for this collection
|
||||
String submitName = (String) collectionToSubmissionConfig
|
||||
.get(collectionHandle);
|
||||
if (submitName == null)
|
||||
{
|
||||
submitName = (String) 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 miss - construct new SubmissionConfig
|
||||
Vector steps = (Vector) submitDefns.get(submitName);
|
||||
|
||||
if (steps == null)
|
||||
{
|
||||
throw new ServletException(
|
||||
"Missing the Item Submission process config '" + submitName
|
||||
+ "' (or unable to load).");
|
||||
}
|
||||
|
||||
log.debug("Submission process config '" + submitName
|
||||
+ "' not in cache. Reloading from scratch.");
|
||||
|
||||
lastSubmissionConfig = new SubmissionConfig(submitName, steps,
|
||||
isWorkflow);
|
||||
|
||||
log.debug("Submission process config has "
|
||||
+ lastSubmissionConfig.getNumberOfSteps() + " steps listed.");
|
||||
|
||||
return lastSubmissionConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a particular global step definition based on its ID.
|
||||
* <P>
|
||||
* Global step definitions are those defined in the <step-definitions>
|
||||
* section of the configuration file.
|
||||
*
|
||||
* @param stepID
|
||||
* step's identifier
|
||||
*
|
||||
* @return the SubmissionStepConfig representing the step
|
||||
*
|
||||
* @throws ServletException
|
||||
* if no default submission process configuration defined
|
||||
*/
|
||||
public SubmissionStepConfig getStepConfig(String stepID)
|
||||
throws ServletException
|
||||
{
|
||||
// We should already have the step definitions loaded
|
||||
if (stepDefns != null)
|
||||
{
|
||||
// retreive step info
|
||||
Map stepInfo = (Map) stepDefns.get(stepID);
|
||||
|
||||
if (stepInfo != null)
|
||||
return new SubmissionStepConfig(stepInfo);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the top level child nodes in the passed top-level node. These
|
||||
* should correspond to the collection-form maps, the form definitions, and
|
||||
* the display/storage word pairs.
|
||||
*/
|
||||
private void doNodes(Node n) throws SAXException, ServletException
|
||||
{
|
||||
if (n == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Node e = getElement(n);
|
||||
NodeList nl = e.getChildNodes();
|
||||
int len = nl.getLength();
|
||||
boolean foundMap = false;
|
||||
boolean foundStepDefs = false;
|
||||
boolean foundSubmitDefs = false;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
Node nd = nl.item(i);
|
||||
if ((nd == null) || isEmptyTextNode(nd))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String tagName = nd.getNodeName();
|
||||
if (tagName.equals("submission-map"))
|
||||
{
|
||||
processMap(nd);
|
||||
foundMap = true;
|
||||
}
|
||||
else if (tagName.equals("step-definitions"))
|
||||
{
|
||||
processStepDefinition(nd);
|
||||
foundStepDefs = true;
|
||||
}
|
||||
else if (tagName.equals("submission-definitions"))
|
||||
{
|
||||
processSubmissionDefinition(nd);
|
||||
foundSubmitDefs = true;
|
||||
}
|
||||
// Ignore unknown nodes
|
||||
}
|
||||
if (!foundMap)
|
||||
{
|
||||
throw new ServletException(
|
||||
"No collection to item submission map ('submission-map') found");
|
||||
}
|
||||
if (!foundStepDefs)
|
||||
{
|
||||
throw new ServletException("No 'step-definitions' section found");
|
||||
}
|
||||
if (!foundSubmitDefs)
|
||||
{
|
||||
throw new ServletException(
|
||||
"No 'submission-definitions' section found");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the submission-map section of the XML file. Each element looks
|
||||
* like: <name-map collection-handle="hdl" submission-name="name" /> Extract
|
||||
* the collection handle and item submission name, put name in hashmap keyed
|
||||
* by the collection handle.
|
||||
*/
|
||||
private void processMap(Node e) throws SAXException
|
||||
{
|
||||
NodeList nl = e.getChildNodes();
|
||||
int len = nl.getLength();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
Node nd = nl.item(i);
|
||||
if (nd.getNodeName().equals("name-map"))
|
||||
{
|
||||
String id = getAttribute(nd, "collection-handle");
|
||||
String value = getAttribute(nd, "submission-name");
|
||||
String content = getValue(nd);
|
||||
if (id == null)
|
||||
{
|
||||
throw new SAXException(
|
||||
"name-map element is missing collection-handle attribute");
|
||||
}
|
||||
if (value == null)
|
||||
{
|
||||
throw new SAXException(
|
||||
"name-map element is missing submission-name attribute");
|
||||
}
|
||||
if (content != null && content.length() > 0)
|
||||
{
|
||||
throw new SAXException(
|
||||
"name-map element has content, it should be empty.");
|
||||
}
|
||||
collectionToSubmissionConfig.put(id, value);
|
||||
} // ignore any child node that isn't a "name-map"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the "step-definition" section of the XML file. Each element is
|
||||
* formed thusly: <step id="unique-id"> ...step_fields... </step> The valid
|
||||
* step_fields are: heading, processing-servlet.
|
||||
* <P>
|
||||
* Extract the step information (from the step_fields) and place in a
|
||||
* HashMap whose key is the step's unique id.
|
||||
*/
|
||||
private void processStepDefinition(Node e) throws SAXException,
|
||||
ServletException
|
||||
{
|
||||
int numStepDefns = 0;
|
||||
stepDefns = new HashMap();
|
||||
|
||||
NodeList nl = e.getChildNodes();
|
||||
int len = nl.getLength();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
Node nd = nl.item(i);
|
||||
// process each step definition
|
||||
if (nd.getNodeName().equals("step"))
|
||||
{
|
||||
numStepDefns++;
|
||||
String stepID = getAttribute(nd, "id");
|
||||
if (stepID == null)
|
||||
{
|
||||
throw new SAXException(
|
||||
"step element has no 'id' attribute, which is required in the 'step-definitions' section");
|
||||
}
|
||||
else if (stepDefns.containsKey(stepID))
|
||||
{
|
||||
throw new SAXException(
|
||||
"There are two step elements with the id " + stepID);
|
||||
}
|
||||
|
||||
HashMap stepInfo = processStepChildNodes("step-definition", nd);
|
||||
|
||||
stepDefns.put(stepID, stepInfo);
|
||||
} // ignore any child that is not a 'step'
|
||||
}
|
||||
|
||||
// Sanity check number of step definitions
|
||||
if (stepDefns.size() < 1)
|
||||
{
|
||||
throw new ServletException(
|
||||
"step-definition section has no steps! A step with id='collection' is required!");
|
||||
}
|
||||
|
||||
// Sanity check to see that the required "collection" step is defined
|
||||
if (!stepDefns.containsKey(SubmissionStepConfig.SELECT_COLLECTION_STEP))
|
||||
{
|
||||
throw new ServletException(
|
||||
"The step-definition section is REQUIRED to have a step with id='"
|
||||
+ SubmissionStepConfig.SELECT_COLLECTION_STEP
|
||||
+ "'! This step is used to ensure that a new item submission is assigned to a collection.");
|
||||
}
|
||||
|
||||
// Sanity check to see that the required "complete" step is defined
|
||||
if (!stepDefns.containsKey(SubmissionStepConfig.COMPLETE_STEP))
|
||||
{
|
||||
throw new ServletException(
|
||||
"The step-definition section is REQUIRED to have a step with id='"
|
||||
+ SubmissionStepConfig.COMPLETE_STEP
|
||||
+ "'! This step is used to perform all processing necessary at the completion of the submission (e.g. starting workflow).");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the "submission-definition" section of the XML file. Each element
|
||||
* is formed thusly: <submission-process name="submitName">...steps...</submit-process>
|
||||
* Each step subsection is formed: <step> ...step_fields... </step> (with
|
||||
* optional "id" attribute, to reference a step from the <step-definition>
|
||||
* section). The valid step_fields are: heading, class-name.
|
||||
* <P>
|
||||
* Extract the submission-process name and steps and place in a HashMap
|
||||
* whose key is the submission-process's unique name.
|
||||
*/
|
||||
private void processSubmissionDefinition(Node e) throws SAXException,
|
||||
ServletException
|
||||
{
|
||||
int numSubmitProcesses = 0;
|
||||
Vector submitNames = new Vector();
|
||||
|
||||
// find all child nodes of the 'submission-definition' node and loop
|
||||
// through
|
||||
NodeList nl = e.getChildNodes();
|
||||
int len = nl.getLength();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
Node nd = nl.item(i);
|
||||
|
||||
// process each 'submission-process' node
|
||||
if (nd.getNodeName().equals("submission-process"))
|
||||
{
|
||||
numSubmitProcesses++;
|
||||
String submitName = getAttribute(nd, "name");
|
||||
if (submitName == null)
|
||||
{
|
||||
throw new SAXException(
|
||||
"'submission-process' element has no 'name' attribute");
|
||||
}
|
||||
else if (submitNames.contains(submitName))
|
||||
{
|
||||
throw new SAXException(
|
||||
"There are two 'submission-process' elements with the name '"
|
||||
+ submitName + "'.");
|
||||
}
|
||||
submitNames.add(submitName);
|
||||
|
||||
// the 'submission-process' definition contains steps
|
||||
Vector steps = new Vector();
|
||||
submitDefns.put(submitName, steps);
|
||||
|
||||
// loop through all the 'step' nodes of the 'submission-process'
|
||||
int stepNum = 0;
|
||||
NodeList pl = nd.getChildNodes();
|
||||
int lenStep = pl.getLength();
|
||||
for (int j = 0; j < lenStep; j++)
|
||||
{
|
||||
Node nStep = pl.item(j);
|
||||
stepNum++;
|
||||
|
||||
// process each 'step' definition
|
||||
if (nStep.getNodeName().equals("step"))
|
||||
{
|
||||
// check for an 'id' attribute
|
||||
String stepID = getAttribute(nStep, "id");
|
||||
|
||||
HashMap stepInfo;
|
||||
|
||||
// if this step has an id, load its information from the
|
||||
// step-definition section
|
||||
if ((stepID != null) && (stepID.length() > 0))
|
||||
{
|
||||
if (stepDefns.containsKey(stepID))
|
||||
{
|
||||
// load the step information from the
|
||||
// step-definition
|
||||
stepInfo = (HashMap) stepDefns.get(stepID);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new SAXException(
|
||||
"The Submission process config named "
|
||||
+ submitName
|
||||
+ " contains a step with id="
|
||||
+ stepID
|
||||
+ ". There is no step with this 'id' defined in the 'step-definition' section.");
|
||||
}
|
||||
|
||||
// Ignore all children of a step element with an
|
||||
// "id"
|
||||
}
|
||||
else
|
||||
{
|
||||
// get information about step from its children
|
||||
// nodes
|
||||
stepInfo = processStepChildNodes(
|
||||
"submission-process", nStep);
|
||||
}
|
||||
|
||||
steps.add(stepInfo);
|
||||
|
||||
} // ignore any child that is not a 'step'
|
||||
}
|
||||
|
||||
// sanity check number of steps
|
||||
if (steps.size() < 1)
|
||||
{
|
||||
throw new ServletException(
|
||||
"Item Submission process config named "
|
||||
+ submitName + " has no steps");
|
||||
}
|
||||
|
||||
// ALL Item Submission processes MUST BEGIN with selecting a
|
||||
// Collection. So, automatically insert in the "collection" step
|
||||
// (from the 'step-definition' section)
|
||||
// Note: we already did a sanity check that this "collection"
|
||||
// step exists.
|
||||
steps.add(0, (HashMap) stepDefns
|
||||
.get(SubmissionStepConfig.SELECT_COLLECTION_STEP));
|
||||
|
||||
// ALL Item Submission processes MUST END with the
|
||||
// "Complete" processing step.
|
||||
// So, automatically append in the "complete" step
|
||||
// (from the 'step-definition' section)
|
||||
// Note: we already did a sanity check that this "complete"
|
||||
// step exists.
|
||||
steps.add((HashMap) stepDefns
|
||||
.get(SubmissionStepConfig.COMPLETE_STEP));
|
||||
|
||||
}
|
||||
}
|
||||
if (numSubmitProcesses == 0)
|
||||
{
|
||||
throw new ServletException(
|
||||
"No 'submission-process' elements/definitions found");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the children of the "step" tag of the XML file. Returns a HashMap
|
||||
* of all the fields under that "step" tag, where the key is the field name,
|
||||
* and the value is the field value.
|
||||
*
|
||||
*/
|
||||
private HashMap processStepChildNodes(String configSection, Node nStep)
|
||||
throws SAXException, ServletException
|
||||
{
|
||||
// initialize the HashMap of step Info
|
||||
HashMap stepInfo = new HashMap();
|
||||
|
||||
NodeList flds = nStep.getChildNodes();
|
||||
int lenflds = flds.getLength();
|
||||
for (int k = 0; k < lenflds; k++)
|
||||
{
|
||||
// process each child node of a <step> tag
|
||||
Node nfld = flds.item(k);
|
||||
|
||||
if (!isEmptyTextNode(nfld))
|
||||
{
|
||||
String tagName = nfld.getNodeName();
|
||||
String value = getValue(nfld);
|
||||
stepInfo.put(tagName, value);
|
||||
}
|
||||
}// end for each field
|
||||
|
||||
// check for ID attribute & save to step info
|
||||
String stepID = getAttribute(nStep, "id");
|
||||
if (stepID != null && stepID.length() > 0)
|
||||
{
|
||||
stepInfo.put("id", stepID);
|
||||
}
|
||||
|
||||
// look for REQUIRED 'step' information
|
||||
String missing = null;
|
||||
if (stepInfo.get("processing-class") == null)
|
||||
{
|
||||
missing = "'processing-class'";
|
||||
}
|
||||
if (missing != null)
|
||||
{
|
||||
String msg = "Required field " + missing
|
||||
+ " missing in a 'step' in the " + configSection
|
||||
+ " of the item submission configuration file";
|
||||
throw new SAXException(msg);
|
||||
}
|
||||
|
||||
return stepInfo;
|
||||
}
|
||||
|
||||
private Node getElement(Node nd)
|
||||
{
|
||||
NodeList nl = nd.getChildNodes();
|
||||
int len = nl.getLength();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
Node n = nl.item(i);
|
||||
if (n.getNodeType() == Node.ELEMENT_NODE)
|
||||
{
|
||||
return n;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isEmptyTextNode(Node nd)
|
||||
{
|
||||
boolean isEmpty = false;
|
||||
if (nd.getNodeType() == Node.TEXT_NODE)
|
||||
{
|
||||
String text = nd.getNodeValue().trim();
|
||||
if (text.length() == 0)
|
||||
{
|
||||
isEmpty = true;
|
||||
}
|
||||
}
|
||||
return isEmpty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the node's attribute named <name>
|
||||
*/
|
||||
private String getAttribute(Node e, String name)
|
||||
{
|
||||
NamedNodeMap attrs = e.getAttributes();
|
||||
int len = attrs.getLength();
|
||||
if (len > 0)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
Node attr = attrs.item(i);
|
||||
if (name.equals(attr.getNodeName()))
|
||||
{
|
||||
return attr.getNodeValue().trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
// no such attribute
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value found in the Text node (if any) in the node list that's
|
||||
* passed in.
|
||||
*/
|
||||
private String getValue(Node nd)
|
||||
{
|
||||
NodeList nl = nd.getChildNodes();
|
||||
int len = nl.getLength();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
Node n = nl.item(i);
|
||||
short type = n.getNodeType();
|
||||
if (type == Node.TEXT_NODE)
|
||||
{
|
||||
return n.getNodeValue().trim();
|
||||
}
|
||||
}
|
||||
// Didn't find a text node
|
||||
return null;
|
||||
}
|
||||
}
|
735
dspace-api/src/main/java/org/dspace/app/util/SubmissionInfo.java
Normal file
735
dspace-api/src/main/java/org/dspace/app/util/SubmissionInfo.java
Normal file
@@ -0,0 +1,735 @@
|
||||
/*
|
||||
* SubmissionInfo.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package org.dspace.app.util;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
|
||||
import org.dspace.submit.AbstractProcessingStep;
|
||||
import org.dspace.workflow.WorkflowItem;
|
||||
|
||||
/**
|
||||
* Information about an item being editing with the submission UI
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class SubmissionInfo
|
||||
{
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(SubmissionInfo.class);
|
||||
|
||||
/** The item which is being submitted */
|
||||
private InProgressSubmission submissionItem = null;
|
||||
|
||||
/**
|
||||
* The Submission process config, which holds all info about the submission
|
||||
* process that this item is going through (including all steps, etc)
|
||||
*/
|
||||
private SubmissionConfig submissionConfig = null;
|
||||
|
||||
/**
|
||||
* Handle of the collection where this item is being submitted
|
||||
*/
|
||||
private String collectionHandle = null;
|
||||
|
||||
/***************************************************************************
|
||||
* Holds all information used to build the Progress Bar in a key,value set.
|
||||
* Keys are the number of the step, followed by the number of the page
|
||||
* within the step (e.g. "2.1" = The first page of Step 2) (e.g. "5.2" = The
|
||||
* second page of Step 5) Values are the Headings to display for each step
|
||||
* (e.g. "Describe")
|
||||
**************************************************************************/
|
||||
private HashMap progressBar = null;
|
||||
|
||||
/** The element or element_qualifier to show more input boxes for */
|
||||
private String moreBoxesFor;
|
||||
|
||||
/** The element or element_qualifier to scroll to initially using anchor */
|
||||
private String jumpToField;
|
||||
|
||||
/** If non-empty, form-relative indices of missing fields */
|
||||
private List missingFields;
|
||||
|
||||
/** Specific bundle we're dealing with */
|
||||
private Bundle bundle;
|
||||
|
||||
/** Specific bitstream we're dealing with */
|
||||
private Bitstream bitstream;
|
||||
|
||||
/** Reader for submission process configuration file * */
|
||||
private static SubmissionConfigReader submissionConfigReader;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*
|
||||
*/
|
||||
private SubmissionInfo()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all known submission information based on the given in progress
|
||||
* submission and request object.
|
||||
* <P>
|
||||
* If subItem is null, then just loads the default submission information
|
||||
* for a new submission.
|
||||
*
|
||||
* @param request
|
||||
* The HTTP Servlet Request object
|
||||
* @param subItem
|
||||
* The in-progress submission we are loading information for
|
||||
*
|
||||
* @return a SubmissionInfo object
|
||||
*
|
||||
* @throws ServletException
|
||||
* if an error occurs
|
||||
*/
|
||||
public static SubmissionInfo load(HttpServletRequest request,
|
||||
InProgressSubmission subItem) throws ServletException
|
||||
{
|
||||
SubmissionInfo subInfo = new SubmissionInfo();
|
||||
// load SubmissionConfigReader only the first time
|
||||
if (submissionConfigReader == null)
|
||||
{
|
||||
submissionConfigReader = new SubmissionConfigReader();
|
||||
}
|
||||
|
||||
// save the item which is going through the submission process
|
||||
subInfo.setSubmissionItem(subItem);
|
||||
|
||||
// Only if the submission item is created can we set its collection
|
||||
String collectionHandle = SubmissionConfigReader.DEFAULT_COLLECTION;
|
||||
if (subItem != null)
|
||||
{
|
||||
collectionHandle = subItem.getCollection().getHandle();
|
||||
}
|
||||
|
||||
// save this collection handle to this submission info object
|
||||
subInfo.setCollectionHandle(collectionHandle);
|
||||
|
||||
// load Submission Process config for this item's collection
|
||||
// (Note: this also loads the Progress Bar info, since it is
|
||||
// dependent on the Submission config)
|
||||
loadSubmissionConfig(request, subInfo, false);
|
||||
|
||||
return subInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this submission in the workflow process?
|
||||
*
|
||||
* @return true if the current submission is in the workflow process
|
||||
*/
|
||||
public boolean isInWorkflow()
|
||||
{
|
||||
return ((this.submissionItem != null) && this.submissionItem instanceof WorkflowItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current in progress submission
|
||||
*
|
||||
* @return the InProgressSubmission object representing the current
|
||||
* submission
|
||||
*/
|
||||
public InProgressSubmission getSubmissionItem()
|
||||
{
|
||||
return this.submissionItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the current in progress submission item
|
||||
*
|
||||
* @param subItem
|
||||
* the new InProgressSubmission object
|
||||
*/
|
||||
public void setSubmissionItem(InProgressSubmission subItem)
|
||||
{
|
||||
this.submissionItem = subItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current submission process config (which includes all steps
|
||||
* which need to be completed for the submission to be successful)
|
||||
*
|
||||
* @return the SubmissionConfig object, which contains info on all the steps
|
||||
* in the current submission process
|
||||
*/
|
||||
public SubmissionConfig getSubmissionConfig()
|
||||
{
|
||||
return this.submissionConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes the SubmissionConfig to be completely reloaded from the XML
|
||||
* configuration file (item-submission.xml).
|
||||
* <P>
|
||||
* Note: This also reloads the progress bar info, since the progress bar
|
||||
* depends entirely on the submission process (and its steps).
|
||||
*
|
||||
* @param request
|
||||
* The HTTP Servlet Request object
|
||||
*
|
||||
* @throws ServletException
|
||||
* if an error occurs
|
||||
*/
|
||||
public void reloadSubmissionConfig(HttpServletRequest request)
|
||||
throws ServletException
|
||||
{
|
||||
// Only if the submission item is created can we set its collection
|
||||
String collectionHandle = SubmissionConfigReader.DEFAULT_COLLECTION;
|
||||
if (this.submissionItem != null)
|
||||
{
|
||||
collectionHandle = submissionItem.getCollection().getHandle();
|
||||
}
|
||||
this.setCollectionHandle(collectionHandle);
|
||||
|
||||
// force a reload of the submission process configuration
|
||||
loadSubmissionConfig(request, this, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a particular global step definition based on its ID.
|
||||
* <P>
|
||||
* Global step definitions are those defined in the <step-definitions>
|
||||
* section of the configuration file.
|
||||
*
|
||||
* @param stepID
|
||||
* step's identifier
|
||||
*
|
||||
* @return the SubmissionStepConfig representing the step
|
||||
*
|
||||
* @throws ServletException
|
||||
* if no default submission process configuration defined
|
||||
*/
|
||||
public SubmissionStepConfig getStepConfig(String stepID)
|
||||
throws ServletException
|
||||
{
|
||||
if (submissionConfigReader == null)
|
||||
{
|
||||
submissionConfigReader = new SubmissionConfigReader();
|
||||
}
|
||||
|
||||
return submissionConfigReader.getStepConfig(stepID);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return text information suitable for logging.
|
||||
* <p>
|
||||
* This method is used by several of the Step classes
|
||||
* to log major events during the submission process (e.g. when
|
||||
* license agreement was accepted, when item was submitted,
|
||||
* when it was available in DSpace, etc.)
|
||||
*
|
||||
* @return the type and ID of the submission, bundle and/or bitstream for
|
||||
* logging
|
||||
*/
|
||||
public String getSubmissionLogInfo()
|
||||
{
|
||||
String info = "";
|
||||
|
||||
if (isInWorkflow())
|
||||
{
|
||||
info = info + "workflow_id=" + getSubmissionItem().getID();
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info + "workspace_item_id" + getSubmissionItem().getID();
|
||||
}
|
||||
|
||||
if (getBundle() != null)
|
||||
{
|
||||
info = info + ",bundle_id=" + getBundle().getID();
|
||||
}
|
||||
|
||||
if (getBitstream() != null)
|
||||
{
|
||||
info = info + ",bitstream_id=" + getBitstream().getID();
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the handle of the collection to which this item is being submitted
|
||||
*
|
||||
* @return the collection handle
|
||||
*/
|
||||
public String getCollectionHandle()
|
||||
{
|
||||
return this.collectionHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the handle of the collection to which this item is being submitted
|
||||
*
|
||||
* @param handle
|
||||
* the new collection handle
|
||||
*/
|
||||
public void setCollectionHandle(String handle)
|
||||
{
|
||||
this.collectionHandle = handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the information used to build the progress bar (this includes all
|
||||
* the steps in this submission, as well as the ordering and names of the
|
||||
* steps).
|
||||
* <p>
|
||||
* Returns a Hashmap, with the following specifics:
|
||||
* <p>
|
||||
* Keys are the number of the step, followed by the number of the page
|
||||
* within the step
|
||||
* <p>
|
||||
* (e.g. "2.1" = The first page of Step 2)
|
||||
* <p>
|
||||
* (e.g. "5.2" = The second page of Step 5)
|
||||
* <P>
|
||||
* Values are the Headings to display for each step (e.g. "Describe")
|
||||
*
|
||||
* @return a Hashmap of Progress Bar information.
|
||||
*/
|
||||
public Map getProgressBarInfo()
|
||||
{
|
||||
return this.progressBar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current bitstream we're working with (This is used during
|
||||
* upload processes, or user interfaces that are dealing with bitstreams)
|
||||
*
|
||||
* @return the Bitstream object for the bitstream
|
||||
*/
|
||||
public Bitstream getBitstream()
|
||||
{
|
||||
return this.bitstream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current bitstream we're working with (This is used during upload
|
||||
* processes, or user interfaces that are dealing with bitstreams)
|
||||
*
|
||||
* @param bits
|
||||
* the bitstream
|
||||
*/
|
||||
public void setBitstream(Bitstream bits)
|
||||
{
|
||||
this.bitstream = bits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current bundle we're working with (This is used during upload
|
||||
* processes, or user interfaces that are dealing with bundles/bitstreams)
|
||||
*
|
||||
* @return the Bundle object for the bundle
|
||||
*/
|
||||
public Bundle getBundle()
|
||||
{
|
||||
return this.bundle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current bundle we're working with (This is used during upload
|
||||
* processes, or user interfaces that are dealing with bundles/bitstreams)
|
||||
*
|
||||
* @param bund
|
||||
* the bundle
|
||||
*/
|
||||
public void setBundle(Bundle bund)
|
||||
{
|
||||
this.bundle = bund;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return form related indices of the required fields which were not filled
|
||||
* out by the user.
|
||||
*
|
||||
* @return a List of empty fields which are required
|
||||
*/
|
||||
public List getMissingFields()
|
||||
{
|
||||
return this.missingFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the form related indices of the required fields which were not
|
||||
* filled out by the user.
|
||||
*
|
||||
* @param missing
|
||||
* the List of empty fields which are required
|
||||
*/
|
||||
public void setMissingFields(List missing)
|
||||
{
|
||||
this.missingFields = missing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return metadata field which user has requested more input boxes be
|
||||
* displayed (by pressing "Add More" on one of the "Describe" pages)
|
||||
*
|
||||
* @return the String name of the field element
|
||||
*/
|
||||
public String getMoreBoxesFor()
|
||||
{
|
||||
return this.moreBoxesFor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the metadata field which user has requested more input boxes be
|
||||
* displayed (by pressing "Add More" on one of the "Describe" pages)
|
||||
*
|
||||
* @param fieldname
|
||||
* the name of the field element on the page
|
||||
*/
|
||||
public void setMoreBoxesFor(String fieldname)
|
||||
{
|
||||
this.moreBoxesFor = fieldname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return metadata field which JSP should "jump to" (i.e. set focus on) when
|
||||
* the JSP next loads. This is used during the Describe step.
|
||||
*
|
||||
* @return the String name of the field element
|
||||
*/
|
||||
public String getJumpToField()
|
||||
{
|
||||
return this.jumpToField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets metadata field which JSP should "jump to" (i.e. set focus on) when
|
||||
* the JSP next loads. This is used during the Describe step.
|
||||
*
|
||||
* @param fieldname
|
||||
* the name of the field on the page
|
||||
*/
|
||||
public void setJumpToField(String fieldname)
|
||||
{
|
||||
this.jumpToField = fieldname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load necessary information to build the Progress Bar for the Item
|
||||
* Submission Progress.
|
||||
*
|
||||
* This information is returned in the form of a HashMap (which is then
|
||||
* stored as a part of the SubmissionInfo). The HashMap takes the following
|
||||
* form:
|
||||
*
|
||||
* Keys - the number of the step, followed by the number of the page within
|
||||
* the step (e.g. "2.1" = The first page of Step 2) (e.g. "5.2" = The second
|
||||
* page of Step 5)
|
||||
*
|
||||
* Values - the headings to display for each step (e.g. "Describe",
|
||||
* "Verify")
|
||||
*
|
||||
* @param request
|
||||
* The HTTP Servlet Request object
|
||||
* @param subInfo
|
||||
* the SubmissionInfo object we are loading into
|
||||
* @param forceReload
|
||||
* If true, this method reloads from stratch (and overwrites
|
||||
* cached progress bar info)
|
||||
*
|
||||
*/
|
||||
private static void loadProgressBar(HttpServletRequest request,
|
||||
SubmissionInfo subInfo, boolean forceReload)
|
||||
{
|
||||
LinkedHashMap progressBarInfo = null;
|
||||
|
||||
log.debug("Loading Progress Bar Info");
|
||||
|
||||
if (!forceReload)
|
||||
{
|
||||
// first, attempt to load from cache
|
||||
progressBarInfo = (LinkedHashMap) loadProgressBarFromCache(request
|
||||
.getSession());
|
||||
}
|
||||
|
||||
if (progressBarInfo != null && log.isDebugEnabled())
|
||||
{
|
||||
log.debug("Found Progress Bar Info in cache: "
|
||||
+ progressBarInfo.size()
|
||||
+ " pages to display in progress bar");
|
||||
}
|
||||
// if unable to load from cache, must load from scratch
|
||||
else
|
||||
{
|
||||
progressBarInfo = new LinkedHashMap();
|
||||
|
||||
// loop through all steps
|
||||
for (int i = 0; i < subInfo.submissionConfig.getNumberOfSteps(); i++)
|
||||
{
|
||||
// get the current step info
|
||||
SubmissionStepConfig currentStep = subInfo.submissionConfig
|
||||
.getStep(i);
|
||||
String stepNumber = Integer.toString(currentStep
|
||||
.getStepNumber());
|
||||
String stepHeading = currentStep.getHeading();
|
||||
|
||||
// as long as this step is visible, include it in
|
||||
// the Progress Bar
|
||||
if (currentStep.isVisible())
|
||||
{
|
||||
// default to just one page in this step
|
||||
int numPages = 1;
|
||||
|
||||
try
|
||||
{
|
||||
// load the processing class for this step
|
||||
ClassLoader loader = subInfo.getClass()
|
||||
.getClassLoader();
|
||||
Class stepClass = loader.loadClass(currentStep
|
||||
.getProcessingClassName());
|
||||
|
||||
// call the "getNumberOfPages()" method of the class
|
||||
// to get it's number of pages
|
||||
AbstractProcessingStep step = (AbstractProcessingStep) stepClass
|
||||
.newInstance();
|
||||
|
||||
// get number of pages from servlet
|
||||
numPages = step.getNumberOfPages(request, subInfo);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error(
|
||||
"Error loading progress bar information from Step Class '"
|
||||
+ currentStep.getProcessingClassName()
|
||||
+ "' Error:", e);
|
||||
}
|
||||
|
||||
// save each of the step's pages to the progress bar
|
||||
for (int j = 1; j <= numPages; j++)
|
||||
{
|
||||
String pageNumber = Integer.toString(j);
|
||||
|
||||
// store ("stepNumber.pageNumber", Heading) for each
|
||||
// page in the step
|
||||
progressBarInfo.put(stepNumber + "." + pageNumber,
|
||||
stepHeading);
|
||||
}// end for each page
|
||||
}
|
||||
}// end for each step
|
||||
|
||||
log.debug("Loaded Progress Bar Info from scratch: "
|
||||
+ progressBarInfo.size()
|
||||
+ " pages to display in progress bar");
|
||||
|
||||
// cache this new progress bar
|
||||
saveProgressBarToCache(request.getSession(), progressBarInfo);
|
||||
}// end if null
|
||||
|
||||
// save progressBarInfo to submission Info
|
||||
subInfo.progressBar = progressBarInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves all progress bar information into session cache. This saves us from
|
||||
* having to reload this same progress bar over and over again.
|
||||
*
|
||||
* @param session
|
||||
* The HTTP Session object
|
||||
* @param progressBarInfo
|
||||
* The progress bar info to cache
|
||||
*
|
||||
*/
|
||||
private static void saveProgressBarToCache(HttpSession session,
|
||||
HashMap progressBarInfo)
|
||||
{
|
||||
// cache progress bar info to Session
|
||||
session.setAttribute("submission.progressbar", progressBarInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to retrieve progress bar information (for a particular
|
||||
* collection) from session cache.
|
||||
*
|
||||
* If the progress bar info cannot be found, returns null
|
||||
*
|
||||
* @param session
|
||||
* The HTTP Session object
|
||||
*
|
||||
* @return progressBarInfo HashMap (if found), or null (if not)
|
||||
*
|
||||
*/
|
||||
private static HashMap loadProgressBarFromCache(HttpSession session)
|
||||
{
|
||||
return (HashMap) session.getAttribute("submission.progressbar");
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads SubmissionConfig object for the given submission info object. If a
|
||||
* SubmissionConfig object cannot be loaded, a Servlet Error is thrown.
|
||||
* <p>
|
||||
* This method just loads this SubmissionConfig object internally, so that
|
||||
* it is available via a call to "getSubmissionConfig()"
|
||||
*
|
||||
* @param request
|
||||
* The HTTP Servlet Request object
|
||||
* @param subInfo
|
||||
* the SubmissionInfo object we are loading into
|
||||
* @param forceReload
|
||||
* If true, this method reloads from stratch (and overwrites
|
||||
* cached SubmissionConfig)
|
||||
*
|
||||
*/
|
||||
private static void loadSubmissionConfig(HttpServletRequest request,
|
||||
SubmissionInfo subInfo, boolean forceReload)
|
||||
throws ServletException
|
||||
{
|
||||
|
||||
log.debug("Loading Submission Config information");
|
||||
|
||||
if (!forceReload)
|
||||
{
|
||||
// first, try to load from cache
|
||||
subInfo.submissionConfig = loadSubmissionConfigFromCache(request
|
||||
.getSession(), subInfo.getCollectionHandle(), subInfo
|
||||
.isInWorkflow());
|
||||
}
|
||||
|
||||
if (subInfo.submissionConfig == null || forceReload)
|
||||
{
|
||||
// reload the proper Submission process config
|
||||
// (by reading the XML config file)
|
||||
subInfo.submissionConfig = submissionConfigReader
|
||||
.getSubmissionConfig(subInfo.getCollectionHandle(), subInfo
|
||||
.isInWorkflow());
|
||||
|
||||
// cache this new submission process configuration
|
||||
saveSubmissionConfigToCache(request.getSession(),
|
||||
subInfo.submissionConfig, subInfo.getCollectionHandle(),
|
||||
subInfo.isInWorkflow());
|
||||
|
||||
// also must force reload Progress Bar info,
|
||||
// since it's based on the Submission config
|
||||
loadProgressBar(request, subInfo, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.debug("Found Submission Config in session cache!");
|
||||
|
||||
// try and reload progress bar from cache
|
||||
loadProgressBar(request, subInfo, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves SubmissionConfig object into session cache. This saves us from
|
||||
* having to reload this object during every "Step".
|
||||
*
|
||||
* @param session
|
||||
* The HTTP Session object
|
||||
* @param subConfig
|
||||
* The SubmissionConfig to cache
|
||||
* @param collectionHandle
|
||||
* The Collection handle this SubmissionConfig corresponds to
|
||||
* @param isWorkflow
|
||||
* Whether this SubmissionConfig corresponds to a workflow
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static void saveSubmissionConfigToCache(HttpSession session,
|
||||
SubmissionConfig subConfig, String collectionHandle,
|
||||
boolean isWorkflow)
|
||||
{
|
||||
// cache the submission process config
|
||||
// and the collection it corresponds to
|
||||
session.setAttribute("submission.config", subConfig);
|
||||
session.setAttribute("submission.config.collection", collectionHandle);
|
||||
session.setAttribute("submission.config.isWorkflow", new Boolean(
|
||||
isWorkflow));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads SubmissionConfig object from session cache for the given
|
||||
* Collection. If a SubmissionConfig object cannot be found, null is
|
||||
* returned.
|
||||
*
|
||||
* @param session
|
||||
* The HTTP Session object
|
||||
* @param collectionHandle
|
||||
* The Collection handle of the SubmissionConfig to load
|
||||
* @param isWorkflow
|
||||
* whether or not we loading the Submission process for a
|
||||
* workflow item
|
||||
*
|
||||
* @return The cached SubmissionConfig for this collection
|
||||
*/
|
||||
private static SubmissionConfig loadSubmissionConfigFromCache(
|
||||
HttpSession session, String collectionHandle, boolean isWorkflow)
|
||||
{
|
||||
// attempt to load submission process config
|
||||
// from cache for the current collection
|
||||
String cachedHandle = (String) session
|
||||
.getAttribute("submission.config.collection");
|
||||
|
||||
Boolean cachedIsWorkflow = (Boolean) session
|
||||
.getAttribute("submission.config.isWorkflow");
|
||||
|
||||
// only load from cache if the collection handle and
|
||||
// workflow item status both match!
|
||||
if (collectionHandle.equals(cachedHandle)
|
||||
&& isWorkflow == cachedIsWorkflow.booleanValue())
|
||||
|
||||
{
|
||||
return (SubmissionConfig) session.getAttribute("submission.config");
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* SubmissionStepConfig.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
|
||||
package org.dspace.app.util;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Class representing configuration for a single step within an Item Submission
|
||||
* Process. In other words, this is a single step in the SubmissionConfig class.
|
||||
* This class represents the structure of a single 'step' node in the
|
||||
* item-submission.xml configuration file.
|
||||
*
|
||||
* @see org.dspace.app.util.SubmissionConfigReader
|
||||
* @see org.dspace.app.util.SubmissionConfig
|
||||
*
|
||||
* @author Tim Donohue
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class SubmissionStepConfig
|
||||
{
|
||||
/*
|
||||
* The identifier for the Select Collection step
|
||||
*/
|
||||
public static String SELECT_COLLECTION_STEP = "collection";
|
||||
|
||||
/*
|
||||
* The identifier for the Completion step
|
||||
*/
|
||||
public static String COMPLETE_STEP = "complete";
|
||||
|
||||
/**
|
||||
* the id for this step ('id' only exists if this step is defined in the
|
||||
* <step-definitions> section)
|
||||
*/
|
||||
private String id = null;
|
||||
|
||||
/** the heading for this step */
|
||||
private String heading = null;
|
||||
|
||||
/** the name of the java processing class for this step */
|
||||
private String processingClassName = null;
|
||||
|
||||
/** the review-jsp for this step */
|
||||
private String reviewJSP = null;
|
||||
|
||||
/** whether or not this step is editable during workflow (default=true) */
|
||||
private boolean workflowEditable = true;
|
||||
|
||||
/**
|
||||
* The full name of the Manakin XML-UI Transformer class which will generate
|
||||
* the necessary DRI for displaying this class in Manakin. This field is
|
||||
* ONLY used by the Manakin XML-UI.
|
||||
*/
|
||||
private String xmlUIClassName = null;
|
||||
|
||||
/** The number of this step in the current SubmissionConfig */
|
||||
private int number = -1;
|
||||
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(SubmissionStepConfig.class);
|
||||
|
||||
/**
|
||||
* Class constructor for creating an empty SubmissionStepConfig object
|
||||
*/
|
||||
public SubmissionStepConfig()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Class constructor for creating a SubmissionStepConfig object based on the
|
||||
* contents of a HashMap initialized by the SubmissionConfig object.
|
||||
*
|
||||
* @param stepMap
|
||||
* the HashMap containing all required information about this
|
||||
* step
|
||||
*/
|
||||
public SubmissionStepConfig(Map stepMap)
|
||||
{
|
||||
id = (String) stepMap.get("id");
|
||||
heading = (String) stepMap.get("heading");
|
||||
processingClassName = (String) stepMap.get("processing-class");
|
||||
reviewJSP = (String) stepMap.get("review-jsp");
|
||||
xmlUIClassName = (String) stepMap.get("xml-ui-class");
|
||||
|
||||
String wfEditString = (String) stepMap.get("workflow-editable");
|
||||
if (wfEditString != null && wfEditString.length() > 0)
|
||||
{
|
||||
workflowEditable = new Boolean(wfEditString).booleanValue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID for this step. An ID is only defined if the step exists in the
|
||||
* <step-definitions> section. This ID field is used to reference special
|
||||
* steps (like the required step with id="collection")
|
||||
*
|
||||
* @return the step ID
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the heading for this step. This can either be a property from
|
||||
* Messages.properties, or the actual heading text. If this "heading"
|
||||
* contains a period(.) it is assumed to reference Messages.properties.
|
||||
*
|
||||
* @return the heading
|
||||
*/
|
||||
public String getHeading()
|
||||
{
|
||||
return heading;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class which handles all processing for this step.
|
||||
* <p>
|
||||
* This class must extend either the org.dspace.submit.SubmissionStep class
|
||||
* (for JSP UI) or org.dspace.submit.AbstractProcessingStep class (for
|
||||
* Manakin XML UI).
|
||||
*
|
||||
* @return the class's full class path (e.g.
|
||||
* "org.dspace.submit.step.MySampleStep")
|
||||
*/
|
||||
public String getProcessingClassName()
|
||||
{
|
||||
return processingClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the review jsp for this step. The "review jsp" is a JSP page which
|
||||
* will load all the user's answers given for this step to allow the user to
|
||||
* review his/her answers.
|
||||
*
|
||||
* This "review jsp" is used by the "Verify" step to allow the user to
|
||||
* verify/review all of his/her answers.
|
||||
*
|
||||
* @return the JSPs full path
|
||||
*/
|
||||
public String getReviewJSP()
|
||||
{
|
||||
return reviewJSP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the full class name of the Manakin Transformer which will
|
||||
* generate this step's DRI, for display in Manakin XML-UI.
|
||||
* <P>
|
||||
* This class must extend the
|
||||
* org.dspace.app.xmlui.submit.step.SubmissionStep class.
|
||||
* <P>
|
||||
* This property is only used by the Manakin XML-UI, and therefore is not
|
||||
* relevant if you are using JSPs.
|
||||
*
|
||||
* @return the full java class name of the Transformer for this class
|
||||
*/
|
||||
public String getXMLUIClassName()
|
||||
{
|
||||
return xmlUIClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of this step in the current Submission process config.
|
||||
* Step numbers start with #0 (although step #0 is ALWAYS the special
|
||||
* "select collection" step)
|
||||
*
|
||||
* @return the number of this step in the current SubmissionConfig
|
||||
*/
|
||||
public int getStepNumber()
|
||||
{
|
||||
return number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of this step in the current Submission process config.
|
||||
* Step numbers start with #0 (although step #0 is ALWAYS the special
|
||||
* "select collection" step)
|
||||
*
|
||||
* @param stepNum
|
||||
* the step number.
|
||||
*/
|
||||
protected void setStepNumber(int stepNum)
|
||||
{
|
||||
this.number = stepNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this step is editable during workflow processing. If
|
||||
* "true", then this step will appear in the "Edit Metadata" stage of the
|
||||
* workflow process.
|
||||
*
|
||||
* @return if step is editable in a workflow process
|
||||
*/
|
||||
public boolean isWorkflowEditable()
|
||||
{
|
||||
return workflowEditable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this step is visible within the Progress Bar. A step is
|
||||
* only visible if it has been assigned a Heading, otherwise it's invisible
|
||||
*
|
||||
* @return if step is visible within the progress bar
|
||||
*/
|
||||
public boolean isVisible()
|
||||
{
|
||||
return ((heading != null) && (heading.length() > 0));
|
||||
}
|
||||
}
|
@@ -41,8 +41,11 @@ package org.dspace.app.util;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.core.Constants;
|
||||
|
||||
@@ -220,4 +223,120 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a parameter from the given request as an int. <code>-1</code> is
|
||||
* returned if the parameter is garbled or does not exist.
|
||||
*
|
||||
* @param request
|
||||
* the HTTP request
|
||||
* @param param
|
||||
* the name of the parameter
|
||||
*
|
||||
* @return the integer value of the parameter, or -1
|
||||
*/
|
||||
public static int getIntParameter(HttpServletRequest request, String param)
|
||||
{
|
||||
String val = request.getParameter(param);
|
||||
|
||||
try
|
||||
{
|
||||
return Integer.parseInt(val.trim());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Problem with parameter
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain an array of int parameters from the given request as an int. null
|
||||
* is returned if parameter doesn't exist. <code>-1</code> is returned in
|
||||
* array locations if that particular value is garbled.
|
||||
*
|
||||
* @param request
|
||||
* the HTTP request
|
||||
* @param param
|
||||
* the name of the parameter
|
||||
*
|
||||
* @return array of integers or null
|
||||
*/
|
||||
public static int[] getIntParameters(HttpServletRequest request,
|
||||
String param)
|
||||
{
|
||||
String[] request_values = request.getParameterValues(param);
|
||||
|
||||
if (request_values == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int[] return_values = new int[request_values.length];
|
||||
|
||||
for (int x = 0; x < return_values.length; x++)
|
||||
{
|
||||
try
|
||||
{
|
||||
return_values[x] = Integer.parseInt(request_values[x]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Problem with parameter, stuff -1 in this slot
|
||||
return_values[x] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return return_values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a parameter from the given request as a boolean.
|
||||
* <code>false</code> is returned if the parameter is garbled or does not
|
||||
* exist.
|
||||
*
|
||||
* @param request
|
||||
* the HTTP request
|
||||
* @param param
|
||||
* the name of the parameter
|
||||
*
|
||||
* @return the integer value of the parameter, or -1
|
||||
*/
|
||||
public static boolean getBoolParameter(HttpServletRequest request,
|
||||
String param)
|
||||
{
|
||||
return ((request.getParameter(param) != null) && request.getParameter(
|
||||
param).equals("true"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the button the user pressed on a submitted form. All buttons should
|
||||
* start with the text <code>submit</code> for this to work. A default
|
||||
* should be supplied, since often the browser will submit a form with no
|
||||
* submit button pressed if the user presses enter.
|
||||
*
|
||||
* @param request
|
||||
* the HTTP request
|
||||
* @param def
|
||||
* the default button
|
||||
*
|
||||
* @return the button pressed
|
||||
*/
|
||||
public static String getSubmitButton(HttpServletRequest request, String def)
|
||||
{
|
||||
Enumeration e = request.getParameterNames();
|
||||
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
String parameterName = (String) e.nextElement();
|
||||
|
||||
if (parameterName.startsWith("submit"))
|
||||
{
|
||||
return parameterName;
|
||||
}
|
||||
}
|
||||
|
||||
return def;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -48,7 +48,6 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
@@ -57,7 +56,6 @@ import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.AuthorizeManager;
|
||||
import org.dspace.authorize.ResourcePolicy;
|
||||
import org.dspace.browse.Browse;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
@@ -1315,6 +1313,32 @@ public class Item extends DSpaceObject
|
||||
b.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove just the DSpace license from an item This is useful to update the
|
||||
* current DSpace license, in case the user must accept the DSpace license
|
||||
* again (either the item was rejected, or resumed after saving)
|
||||
* <p>
|
||||
* This method is used by the org.dspace.submit.step.LicenseStep class
|
||||
*
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void removeDSpaceLicense() throws SQLException, AuthorizeException,
|
||||
IOException
|
||||
{
|
||||
// get all bundles with name "LICENSE" (these are the DSpace license
|
||||
// bundles)
|
||||
Bundle[] bunds = getBundles("LICENSE");
|
||||
|
||||
for (int i = 0; i < bunds.length; i++)
|
||||
{
|
||||
// FIXME: probably serious troubles with Authorizations
|
||||
// fix by telling system not to check authorization?
|
||||
removeBundle(bunds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all licenses from an item - it was rejected
|
||||
*
|
||||
|
@@ -453,6 +453,29 @@ public class WorkspaceItem implements InProgressSubmission
|
||||
wiRow.setColumn("stage_reached", v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the page reached column (which represents the page
|
||||
* reached within a stage/step)
|
||||
*
|
||||
* @return the value of the page reached column
|
||||
*/
|
||||
public int getPageReached()
|
||||
{
|
||||
return wiRow.getIntColumn("page_reached");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of the page reached column (which represents the page
|
||||
* reached within a stage/step)
|
||||
*
|
||||
* @param v
|
||||
* the value of the page reached column
|
||||
*/
|
||||
public void setPageReached(int v)
|
||||
{
|
||||
wiRow.setColumn("page_reached", v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the workspace item, including the unarchived item.
|
||||
*/
|
||||
|
@@ -0,0 +1,340 @@
|
||||
/*
|
||||
* AbstractProcessingStep.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package org.dspace.submit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.core.Context;
|
||||
|
||||
/**
|
||||
* Abstract processing class for DSpace Submission Steps. This defines the base
|
||||
* methods which are required for any Step processing class.
|
||||
* <P>
|
||||
* This abstract class defines the base methods which are used by both the
|
||||
* Manakin XML UI and the JSP UI to perform submission step processing.
|
||||
* <P>
|
||||
* This includes the following methods:
|
||||
* <ul>
|
||||
* <li>doProcessing() method - called to perform any step processing</li>
|
||||
* <li>getErrorFields() method - called to determine the fields which errored
|
||||
* out during processing</li>
|
||||
* <li>getErrorMessage() method - called to determine any error message
|
||||
* returned after processing</li>
|
||||
* </ul>
|
||||
* <P>
|
||||
* If you are using the JSP UI (with the SubmissionController servlet) you
|
||||
* should extend the org.dspace.submit.SubmissionStep class, which defines
|
||||
* additional methods used to maintain the context of the submission within a
|
||||
* JSP environment!
|
||||
*
|
||||
* @see org.dspace.app.webui.submit.JSPStepManager
|
||||
* @see org.dspace.app.webui.servlet.SubmissionController
|
||||
* @see org.dspace.app.util.SubmissionConfig
|
||||
* @see org.dspace.app.util.SubmissionStepConfig
|
||||
*
|
||||
* @author Tim Donohue
|
||||
* @version $Revision$
|
||||
*/
|
||||
public abstract class AbstractProcessingStep
|
||||
{
|
||||
/***************************************************************************
|
||||
* Constant - Name of the "<-Previous" button
|
||||
**************************************************************************/
|
||||
public static String PREVIOUS_BUTTON = "submit_prev";
|
||||
|
||||
/***************************************************************************
|
||||
* Constant - Name of the "Next->" button
|
||||
**************************************************************************/
|
||||
public static String NEXT_BUTTON = "submit_next";
|
||||
|
||||
/***************************************************************************
|
||||
* Constant - Name of the "Cancel/Save" button
|
||||
**************************************************************************/
|
||||
public static String CANCEL_BUTTON = "submit_cancel";
|
||||
|
||||
/***************************************************************************
|
||||
* Constant - Prefix of all buttons in the Progress Bar
|
||||
**************************************************************************/
|
||||
public static String PROGRESS_BAR_PREFIX = "submit_jump_";
|
||||
|
||||
/***************************************************************************
|
||||
* Flag which specifies that the LAST PAGE of a step has been reached. This
|
||||
* flag is used when a Workflow Item is rejected (and returned to the
|
||||
* workspace) to specify that the LAST PAGE of the LAST STEP has already
|
||||
* been reached
|
||||
**************************************************************************/
|
||||
public static int LAST_PAGE_REACHED = Integer.MAX_VALUE;
|
||||
|
||||
/***************************************************************************
|
||||
* STATUS / ERROR FLAGS (returned by doProcessing() if an error occurs or
|
||||
* additional user interaction may be required)
|
||||
**************************************************************************/
|
||||
public static int STATUS_COMPLETE = 0;
|
||||
|
||||
/** Maps each status/error flag to a textual, human understandable message * */
|
||||
private Map errorMessages = null;
|
||||
|
||||
/** List of all user interface fields which had errors during processing * */
|
||||
private List errorFields = null;
|
||||
|
||||
/**
|
||||
* Do any processing of the information input by the user, and/or perform
|
||||
* step processing (if no user interaction required)
|
||||
* <P>
|
||||
* It is this method's job to save any data to the underlying database, as
|
||||
* necessary, and return error messages (if any) which can then be processed
|
||||
* by the doPostProcessing() method.
|
||||
* <P>
|
||||
* NOTE: If this step is a non-interactive step (i.e. requires no UI), then
|
||||
* it should perform *all* of its processing in this method!
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
* @return Status or error flag which will be processed by
|
||||
* doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
public abstract int doProcessing(Context context,
|
||||
HttpServletRequest request, HttpServletResponse response,
|
||||
SubmissionInfo subInfo) throws ServletException, IOException,
|
||||
SQLException, AuthorizeException;
|
||||
|
||||
/**
|
||||
* Return a list of all UI fields which had errors that occurred during the
|
||||
* step processing. This list is for usage in generating the appropriate
|
||||
* error message(s) in the UI.
|
||||
* <P>
|
||||
* The list of fields which had errors should be set by the step's
|
||||
* doProcessing() method, so that it can be accessed later by whatever UI is
|
||||
* generated.
|
||||
*
|
||||
* @return List of error fields (as Strings)
|
||||
*/
|
||||
public final List getErrorFields()
|
||||
{
|
||||
return this.errorFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a single UI field to the internal list of all error fields (which can
|
||||
* later be retrieved using getErrorFields())
|
||||
* <P>
|
||||
* The list of fields which had errors should be set by the step's
|
||||
* doProcessing() method, so that it can be accessed later by whatever UI is
|
||||
* generated.
|
||||
*
|
||||
* @param fieldName
|
||||
* the name of the field which had an error
|
||||
*/
|
||||
protected final void addErrorField(String fieldName)
|
||||
{
|
||||
if (this.errorFields == null)
|
||||
{
|
||||
this.errorFields = new ArrayList();
|
||||
}
|
||||
|
||||
this.errorFields.add(fieldName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the list of all fields that errored out during the previous step's
|
||||
* processing.
|
||||
*
|
||||
*/
|
||||
protected final void clearErrorFields()
|
||||
{
|
||||
if (this.errorFields != null)
|
||||
this.errorFields.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the text of an error message based on the passed in error flag.
|
||||
* These error messages are used for non-interactive steps (so that they can
|
||||
* log something more specific than just an error flag)
|
||||
* <P>
|
||||
* Since each step can define its own error messages and flags, this method
|
||||
* depends on all the error messages being initialized by using the
|
||||
* "addErrorMessage()" method within the constructor for the step class!
|
||||
*
|
||||
* @param errorFlag
|
||||
* The error flag defined in this step which represents an error
|
||||
* message.
|
||||
* @return String which contains the text of the error message, or null if
|
||||
* error message not found
|
||||
*/
|
||||
public final String getErrorMessage(int errorFlag)
|
||||
{
|
||||
if (this.errorMessages == null || this.errorMessages.size() == 0)
|
||||
return null;
|
||||
else
|
||||
return (String) this.errorMessages.get(Integer.valueOf(errorFlag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an error message to the internal map for this step.
|
||||
* <P>
|
||||
* This method associates a specific error message with an error flag
|
||||
* defined in this step.
|
||||
* <P>
|
||||
* This is extremely useful to define the error message which will be logged
|
||||
* for a non-interactive step.
|
||||
*
|
||||
* @param fieldName
|
||||
* the name of the field which had an error
|
||||
*/
|
||||
protected final void addErrorMessage(int errorFlag, String errorMessage)
|
||||
{
|
||||
if (this.errorMessages == null)
|
||||
this.errorMessages = new HashMap();
|
||||
|
||||
errorMessages.put(Integer.valueOf(errorFlag), errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the number of pages that this "step" extends over. This method
|
||||
* is used by the SubmissionController to build the progress bar.
|
||||
* <P>
|
||||
* This method may just return 1 for most steps (since most steps consist of
|
||||
* a single page). But, it should return a number greater than 1 for any
|
||||
* "step" which spans across a number of HTML pages. For example, the
|
||||
* configurable "Describe" step (configured using input-forms.xml) overrides
|
||||
* this method to return the number of pages that are defined by its
|
||||
* configuration file.
|
||||
* <P>
|
||||
* Steps which are non-interactive (i.e. they do not display an interface to
|
||||
* the user) should return a value of 1, so that they are only processed
|
||||
* once!
|
||||
*
|
||||
* @param request
|
||||
* The HTTP Request
|
||||
* @param subInfo
|
||||
* The current submission information object
|
||||
*
|
||||
* @return the number of pages in this step
|
||||
*/
|
||||
public abstract int getNumberOfPages(HttpServletRequest request,
|
||||
SubmissionInfo subInfo) throws ServletException;
|
||||
|
||||
/**
|
||||
* Find out which page a user is currently viewing
|
||||
*
|
||||
* @param request
|
||||
* HTTP request
|
||||
*
|
||||
* @return current page
|
||||
*/
|
||||
public static final int getCurrentPage(HttpServletRequest request)
|
||||
{
|
||||
int pageNum = -1;
|
||||
|
||||
// try to retrieve cached page from request attribute
|
||||
Integer currentPage = (Integer) request.getAttribute("submission.page");
|
||||
|
||||
if (currentPage == null)
|
||||
{
|
||||
// try and get it as a 'page' parameter
|
||||
String val = request.getParameter("page");
|
||||
|
||||
try
|
||||
{
|
||||
pageNum = Integer.parseInt(val.trim());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Problem with parameter
|
||||
pageNum = -1;
|
||||
}
|
||||
|
||||
// if couldn't find page in request parameter
|
||||
if (pageNum < 0)
|
||||
{
|
||||
// default to page #1, since no other optionsc
|
||||
pageNum = 1;
|
||||
|
||||
setCurrentPage(request, pageNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
// save to request attribute
|
||||
setCurrentPage(request, pageNum);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pageNum = currentPage.intValue();
|
||||
}
|
||||
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set which page a user is currently viewing
|
||||
*
|
||||
* @param request
|
||||
* HTTP request
|
||||
* @param pageNumber
|
||||
* new current page
|
||||
*/
|
||||
public static final void setCurrentPage(HttpServletRequest request,
|
||||
int pageNumber)
|
||||
{
|
||||
// set info to request
|
||||
request.setAttribute("submission.page", new Integer(pageNumber));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* CompleteStep.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package org.dspace.submit.step;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
import org.dspace.submit.AbstractProcessingStep;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
import org.dspace.workflow.WorkflowManager;
|
||||
|
||||
/**
|
||||
* This is the class which defines what happens once a submission completes!
|
||||
* <P>
|
||||
* This class performs all the behind-the-scenes processing that
|
||||
* this particular step requires. This class's methods are utilized
|
||||
* by both the JSP-UI and the Manakin XML-UI
|
||||
* <P>
|
||||
* This step is non-interactive (i.e. no user interface), and simply performs
|
||||
* the processing that is necessary after a submission has been completed!
|
||||
*
|
||||
* @see org.dspace.app.util.SubmissionConfig
|
||||
* @see org.dspace.app.util.SubmissionStepConfig
|
||||
* @see org.dspace.submit.AbstractProcessingStep
|
||||
*
|
||||
* @author Tim Donohue
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class CompleteStep extends AbstractProcessingStep
|
||||
{
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(CompleteStep.class);
|
||||
|
||||
/**
|
||||
* Do any processing of the information input by the user, and/or perform
|
||||
* step processing (if no user interaction required)
|
||||
* <P>
|
||||
* It is this method's job to save any data to the underlying database, as
|
||||
* necessary, and return error messages (if any) which can then be processed
|
||||
* by the appropriate user interface (JSP-UI or XML-UI)
|
||||
* <P>
|
||||
* NOTE: If this step is a non-interactive step (i.e. requires no UI), then
|
||||
* it should perform *all* of its processing in this method!
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
* @return Status or error flag which will be processed by
|
||||
* doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
public int doProcessing(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
// The Submission is COMPLETE!!
|
||||
log.info(LogManager.getHeader(context, "submission_complete",
|
||||
"Completed submission with id="
|
||||
+ subInfo.getSubmissionItem().getID()));
|
||||
|
||||
// Start the workflow for this Submission
|
||||
WorkflowManager.start(context, (WorkspaceItem) subInfo
|
||||
.getSubmissionItem());
|
||||
|
||||
// commit changes to database
|
||||
context.commit();
|
||||
|
||||
return STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the number of pages that this "step" extends over. This method
|
||||
* is used to build the progress bar.
|
||||
* <P>
|
||||
* This method may just return 1 for most steps (since most steps consist of
|
||||
* a single page). But, it should return a number greater than 1 for any
|
||||
* "step" which spans across a number of HTML pages. For example, the
|
||||
* configurable "Describe" step (configured using input-forms.xml) overrides
|
||||
* this method to return the number of pages that are defined by its
|
||||
* configuration file.
|
||||
* <P>
|
||||
* Steps which are non-interactive (i.e. they do not display an interface to
|
||||
* the user) should return a value of 1, so that they are only processed
|
||||
* once!
|
||||
*
|
||||
* @param request
|
||||
* The HTTP Request
|
||||
* @param subInfo
|
||||
* The current submission information object
|
||||
*
|
||||
* @return the number of pages in this step
|
||||
*/
|
||||
public int getNumberOfPages(HttpServletRequest request,
|
||||
SubmissionInfo subInfo) throws ServletException
|
||||
{
|
||||
// This class represents the non-interactive processing step
|
||||
// that occurs just *before* the final confirmation page!
|
||||
// (so it should only be processed once!)
|
||||
return 1;
|
||||
}
|
||||
}
|
@@ -0,0 +1,826 @@
|
||||
/*
|
||||
* DescribeStep.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package org.dspace.submit.step;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.app.util.DCInputsReader;
|
||||
import org.dspace.app.util.DCInput;
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
import org.dspace.app.util.Util;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.DCDate;
|
||||
import org.dspace.content.DCPersonName;
|
||||
import org.dspace.content.DCSeriesNumber;
|
||||
import org.dspace.content.DCValue;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.submit.AbstractProcessingStep;
|
||||
|
||||
/**
|
||||
* Describe step for DSpace submission process. Handles the gathering of
|
||||
* descriptive information (i.e. metadata) for an item being submitted into
|
||||
* DSpace.
|
||||
* <P>
|
||||
* This class performs all the behind-the-scenes processing that
|
||||
* this particular step requires. This class's methods are utilized
|
||||
* by both the JSP-UI and the Manakin XML-UI
|
||||
* <P>
|
||||
*
|
||||
* @see org.dspace.app.util.SubmissionConfig
|
||||
* @see org.dspace.app.util.SubmissionStepConfig
|
||||
* @see org.dspace.submit.AbstractProcessingStep
|
||||
*
|
||||
* @author Tim Donohue
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class DescribeStep extends AbstractProcessingStep
|
||||
{
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(DescribeStep.class);
|
||||
|
||||
/** hash of all submission forms details */
|
||||
private static DCInputsReader inputsReader;
|
||||
|
||||
/***************************************************************************
|
||||
* STATUS / ERROR FLAGS (returned by doProcessing() if an error occurs or
|
||||
* additional user interaction may be required)
|
||||
*
|
||||
* (Do NOT use status of 0, since it corresponds to STATUS_COMPLETE flag
|
||||
* defined in the JSPStepManager class)
|
||||
**************************************************************************/
|
||||
// user requested an extra input field to be displayed
|
||||
public static final int STATUS_MORE_INPUT_REQUESTED = 1;
|
||||
|
||||
// there were required fields that were not filled out
|
||||
public static final int STATUS_MISSING_REQUIRED_FIELDS = 2;
|
||||
|
||||
/** Constructor */
|
||||
public DescribeStep() throws ServletException
|
||||
{
|
||||
// load inputsReader only the first time
|
||||
if (inputsReader == null)
|
||||
{
|
||||
// read configurable submissions forms data
|
||||
inputsReader = new DCInputsReader();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Do any processing of the information input by the user, and/or perform
|
||||
* step processing (if no user interaction required)
|
||||
* <P>
|
||||
* It is this method's job to save any data to the underlying database, as
|
||||
* necessary, and return error messages (if any) which can then be processed
|
||||
* by the appropriate user interface (JSP-UI or XML-UI)
|
||||
* <P>
|
||||
* NOTE: If this step is a non-interactive step (i.e. requires no UI), then
|
||||
* it should perform *all* of its processing in this method!
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
* @return Status or error flag which will be processed by
|
||||
* doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
public int doProcessing(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
// check what submit button was pressed in User Interface
|
||||
String buttonPressed = Util.getSubmitButton(request, NEXT_BUTTON);
|
||||
|
||||
// get the item and current page
|
||||
Item item = subInfo.getSubmissionItem().getItem();
|
||||
int currentPage = getCurrentPage(request);
|
||||
|
||||
// lookup applicable inputs
|
||||
Collection c = subInfo.getSubmissionItem().getCollection();
|
||||
DCInput[] inputs = inputsReader.getInputs(c.getHandle()).getPageRows(
|
||||
currentPage - 1,
|
||||
subInfo.getSubmissionItem().hasMultipleTitles(),
|
||||
subInfo.getSubmissionItem().isPublishedBefore());
|
||||
|
||||
// Step 1:
|
||||
// clear out all item metadata defined on this page
|
||||
for (int i = 0; i < inputs.length; i++)
|
||||
{
|
||||
String qualifier = inputs[i].getQualifier();
|
||||
if (qualifier == null
|
||||
&& inputs[i].getInputType().equals("qualdrop_value"))
|
||||
{
|
||||
qualifier = Item.ANY;
|
||||
}
|
||||
item.clearMetadata(inputs[i].getSchema(), inputs[i].getElement(),
|
||||
qualifier, Item.ANY);
|
||||
}
|
||||
|
||||
// Step 2:
|
||||
// now update the item metadata.
|
||||
String fieldName;
|
||||
boolean moreInput = false;
|
||||
for (int j = 0; j < inputs.length; j++)
|
||||
{
|
||||
String element = inputs[j].getElement();
|
||||
String qualifier = inputs[j].getQualifier();
|
||||
String schema = inputs[j].getSchema();
|
||||
if (qualifier != null && !qualifier.equals(Item.ANY))
|
||||
{
|
||||
fieldName = schema + "_" + element + '_' + qualifier;
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldName = schema + "_" + element;
|
||||
}
|
||||
|
||||
String inputType = inputs[j].getInputType();
|
||||
if (inputType.equals("name"))
|
||||
{
|
||||
readNames(request, item, schema, element, qualifier, inputs[j]
|
||||
.getRepeatable());
|
||||
}
|
||||
else if (inputType.equals("date"))
|
||||
{
|
||||
readDate(request, item, schema, element, qualifier);
|
||||
}
|
||||
else if (inputType.equals("series"))
|
||||
{
|
||||
readSeriesNumbers(request, item, schema, element, qualifier,
|
||||
inputs[j].getRepeatable());
|
||||
}
|
||||
else if (inputType.equals("qualdrop_value"))
|
||||
{
|
||||
List quals = getRepeatedParameter(request, schema + "_"
|
||||
+ element, schema + "_" + element + "_qualifier");
|
||||
List vals = getRepeatedParameter(request, schema + "_"
|
||||
+ element, schema + "_" + element + "_value");
|
||||
for (int z = 0; z < vals.size(); z++)
|
||||
{
|
||||
String thisQual = (String) quals.get(z);
|
||||
if ("".equals(thisQual))
|
||||
{
|
||||
thisQual = null;
|
||||
}
|
||||
String thisVal = (String) vals.get(z);
|
||||
if (!buttonPressed.equals("submit_" + schema + "_"
|
||||
+ element + "_remove_" + z)
|
||||
&& !thisVal.equals(""))
|
||||
{
|
||||
item.addMetadata(schema, element, thisQual, null,
|
||||
thisVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (inputType.equals("dropdown") || inputType.equals("list"))
|
||||
{
|
||||
String[] vals = request.getParameterValues(fieldName);
|
||||
if (vals != null)
|
||||
{
|
||||
for (int z = 0; z < vals.length; z++)
|
||||
{
|
||||
if (!vals[z].equals(""))
|
||||
{
|
||||
item.addMetadata(schema, element, qualifier, "en",
|
||||
vals[z]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((inputType.equals("onebox"))
|
||||
|| (inputType.equals("twobox"))
|
||||
|| (inputType.equals("textarea")))
|
||||
{
|
||||
readText(request, item, schema, element, qualifier, inputs[j]
|
||||
.getRepeatable(), "en");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ServletException("Field " + fieldName
|
||||
+ " has an unknown input type: " + inputType);
|
||||
}
|
||||
|
||||
// determine if more input fields were requested
|
||||
if (!moreInput
|
||||
&& buttonPressed.equals("submit_" + fieldName + "_add"))
|
||||
{
|
||||
subInfo.setMoreBoxesFor(fieldName);
|
||||
subInfo.setJumpToField(fieldName);
|
||||
moreInput = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3:
|
||||
// Check to see if any fields are missing
|
||||
clearErrorFields();
|
||||
for (int i = 0; i < inputs.length; i++)
|
||||
{
|
||||
DCValue[] values = item.getMetadata(inputs[i].getSchema(),
|
||||
inputs[i].getElement(), inputs[i].getQualifier(), Item.ANY);
|
||||
|
||||
if (inputs[i].isRequired() && values.length == 0)
|
||||
{
|
||||
// since this field is missing add to list of error fields
|
||||
addErrorField(getFieldName(inputs[i]));
|
||||
}
|
||||
}
|
||||
|
||||
// Step 4:
|
||||
// Save changes to database
|
||||
subInfo.getSubmissionItem().update();
|
||||
|
||||
// commit changes
|
||||
context.commit();
|
||||
|
||||
// check for request for more input fields, first
|
||||
if (moreInput)
|
||||
{
|
||||
return STATUS_MORE_INPUT_REQUESTED;
|
||||
}
|
||||
// if one or more fields errored out, return
|
||||
else if (getErrorFields() != null && getErrorFields().size() > 0)
|
||||
{
|
||||
return STATUS_MISSING_REQUIRED_FIELDS;
|
||||
}
|
||||
|
||||
// completed without errors
|
||||
return STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the number of pages that this "step" extends over. This method
|
||||
* is used to build the progress bar.
|
||||
* <P>
|
||||
* This method may just return 1 for most steps (since most steps consist of
|
||||
* a single page). But, it should return a number greater than 1 for any
|
||||
* "step" which spans across a number of HTML pages. For example, the
|
||||
* configurable "Describe" step (configured using input-forms.xml) overrides
|
||||
* this method to return the number of pages that are defined by its
|
||||
* configuration file.
|
||||
* <P>
|
||||
* Steps which are non-interactive (i.e. they do not display an interface to
|
||||
* the user) should return a value of 1, so that they are only processed
|
||||
* once!
|
||||
*
|
||||
* @param request
|
||||
* The HTTP Request
|
||||
* @param subInfo
|
||||
* The current submission information object
|
||||
*
|
||||
* @return the number of pages in this step
|
||||
*/
|
||||
public int getNumberOfPages(HttpServletRequest request,
|
||||
SubmissionInfo subInfo) throws ServletException
|
||||
{
|
||||
if (inputsReader == null)
|
||||
{
|
||||
// read configurable submissions forms data
|
||||
inputsReader = new DCInputsReader();
|
||||
}
|
||||
|
||||
// by default, use the "default" collection handle
|
||||
String collectionHandle = DCInputsReader.DEFAULT_COLLECTION;
|
||||
|
||||
if (subInfo.getSubmissionItem() != null)
|
||||
{
|
||||
collectionHandle = subInfo.getSubmissionItem().getCollection()
|
||||
.getHandle();
|
||||
}
|
||||
|
||||
// get number of input pages (i.e. "Describe" pages)
|
||||
return inputsReader.getNumberInputPages(collectionHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the current DCInputsReader
|
||||
*/
|
||||
public static DCInputsReader getInputsReader()
|
||||
{
|
||||
return inputsReader;
|
||||
}
|
||||
|
||||
// ****************************************************************
|
||||
// ****************************************************************
|
||||
// METHODS FOR FILLING DC FIELDS FROM METADATA FORMS
|
||||
// ****************************************************************
|
||||
// ****************************************************************
|
||||
|
||||
/**
|
||||
* Set relevant metadata fields in an item from name values in the form.
|
||||
* Some fields are repeatable in the form. If this is the case, and the
|
||||
* field is "dc.contributor.author", the names in the request will be from
|
||||
* the fields as follows:
|
||||
*
|
||||
* dc_contributor_author_last -> last name of first author
|
||||
* dc_contributor_author_first -> first name(s) of first author
|
||||
* dc_contributor_author_last_1 -> last name of second author
|
||||
* dc_contributor_author_first_1 -> first name(s) of second author
|
||||
*
|
||||
* and so on. If the field is unqualified:
|
||||
*
|
||||
* dc_contributor_last -> last name of first contributor
|
||||
* dc_contributor_first -> first name(s) of first contributor
|
||||
*
|
||||
* If the parameter "submit_dc_contributor_author_remove_n" is set, that
|
||||
* value is removed.
|
||||
*
|
||||
* Otherwise the parameters are of the form:
|
||||
*
|
||||
* dc_contributor_author_last dc_contributor_author_first
|
||||
*
|
||||
* The values will be put in separate DCValues, in the form "last name,
|
||||
* first name(s)", ordered as they appear in the list. These will replace
|
||||
* any existing values.
|
||||
*
|
||||
* @param request
|
||||
* the request object
|
||||
* @param item
|
||||
* the item to update
|
||||
* @param schema
|
||||
* the metadata schema
|
||||
* @param element
|
||||
* the metadata element
|
||||
* @param qualifier
|
||||
* the metadata qualifier, or null if unqualified
|
||||
* @param repeated
|
||||
* set to true if the field is repeatable on the form
|
||||
*/
|
||||
private void readNames(HttpServletRequest request, Item item,
|
||||
String schema, String element, String qualifier, boolean repeated)
|
||||
{
|
||||
String metadataField = MetadataField
|
||||
.formKey(schema, element, qualifier);
|
||||
|
||||
// Names to add
|
||||
List firsts = new LinkedList();
|
||||
List lasts = new LinkedList();
|
||||
|
||||
if (repeated)
|
||||
{
|
||||
firsts = getRepeatedParameter(request, metadataField, metadataField
|
||||
+ "_first");
|
||||
lasts = getRepeatedParameter(request, metadataField, metadataField
|
||||
+ "_last");
|
||||
|
||||
// Find out if the relevant "remove" button was pressed
|
||||
// TODO: These separate remove buttons are only relevant
|
||||
// for DSpace JSP UI, and the code below can be removed
|
||||
// once the DSpace JSP UI is obsolete!
|
||||
String buttonPressed = Util.getSubmitButton(request, "");
|
||||
String removeButton = "submit_" + metadataField + "_remove_";
|
||||
|
||||
if (buttonPressed.startsWith(removeButton))
|
||||
{
|
||||
int valToRemove = Integer.parseInt(buttonPressed
|
||||
.substring(removeButton.length()));
|
||||
|
||||
firsts.remove(valToRemove);
|
||||
lasts.remove(valToRemove);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just a single name
|
||||
String lastName = request.getParameter(metadataField + "_last");
|
||||
String firstNames = request.getParameter(metadataField + "_first");
|
||||
|
||||
if (lastName != null)
|
||||
lasts.add(lastName);
|
||||
if (firstNames != null)
|
||||
firsts.add(firstNames);
|
||||
}
|
||||
|
||||
// Remove existing values
|
||||
item.clearMetadata(schema, element, qualifier, Item.ANY);
|
||||
|
||||
// Put the names in the correct form
|
||||
for (int i = 0; i < lasts.size(); i++)
|
||||
{
|
||||
String f = (String) firsts.get(i);
|
||||
String l = (String) lasts.get(i);
|
||||
|
||||
// only add if lastname is non-empty
|
||||
if ((l != null) && !((l.trim()).equals("")))
|
||||
{
|
||||
// Ensure first name non-null
|
||||
if (f == null)
|
||||
{
|
||||
f = "";
|
||||
}
|
||||
|
||||
// If there is a comma in the last name, we take everything
|
||||
// after that comma, and add it to the right of the
|
||||
// first name
|
||||
int comma = l.indexOf(',');
|
||||
|
||||
if (comma >= 0)
|
||||
{
|
||||
f = f + l.substring(comma + 1);
|
||||
l = l.substring(0, comma);
|
||||
|
||||
// Remove leading whitespace from first name
|
||||
while (f.startsWith(" "))
|
||||
{
|
||||
f = f.substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Add to the database
|
||||
item.addMetadata(schema, element, qualifier, null,
|
||||
new DCPersonName(l, f).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill out an item's metadata values from a plain standard text field. If
|
||||
* the field isn't repeatable, the input field name is called:
|
||||
*
|
||||
* element_qualifier
|
||||
*
|
||||
* or for an unqualified element:
|
||||
*
|
||||
* element
|
||||
*
|
||||
* Repeated elements are appended with an underscore then an integer. e.g.:
|
||||
*
|
||||
* dc_title_alternative dc_title_alternative_1
|
||||
*
|
||||
* The values will be put in separate DCValues, ordered as they appear in
|
||||
* the list. These will replace any existing values.
|
||||
*
|
||||
* @param request
|
||||
* the request object
|
||||
* @param item
|
||||
* the item to update
|
||||
* @param schema
|
||||
* the short schema name
|
||||
* @param element
|
||||
* the metadata element
|
||||
* @param qualifier
|
||||
* the metadata qualifier, or null if unqualified
|
||||
* @param repeated
|
||||
* set to true if the field is repeatable on the form
|
||||
* @param lang
|
||||
* language to set (ISO code)
|
||||
*/
|
||||
private void readText(HttpServletRequest request, Item item, String schema,
|
||||
String element, String qualifier, boolean repeated, String lang)
|
||||
{
|
||||
// FIXME: Of course, language should be part of form, or determined
|
||||
// some other way
|
||||
String metadataField = MetadataField
|
||||
.formKey(schema, element, qualifier);
|
||||
|
||||
// Values to add
|
||||
List vals = new LinkedList();
|
||||
|
||||
if (repeated)
|
||||
{
|
||||
vals = getRepeatedParameter(request, metadataField, metadataField);
|
||||
|
||||
// Find out if the relevant "remove" button was pressed
|
||||
// TODO: These separate remove buttons are only relevant
|
||||
// for DSpace JSP UI, and the code below can be removed
|
||||
// once the DSpace JSP UI is obsolete!
|
||||
String buttonPressed = Util.getSubmitButton(request, "");
|
||||
String removeButton = "submit_" + metadataField + "_remove_";
|
||||
|
||||
if (buttonPressed.startsWith(removeButton))
|
||||
{
|
||||
int valToRemove = Integer.parseInt(buttonPressed
|
||||
.substring(removeButton.length()));
|
||||
|
||||
vals.remove(valToRemove);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just a single name
|
||||
String value = request.getParameter(metadataField);
|
||||
|
||||
if (value != null)
|
||||
vals.add(value.trim());
|
||||
}
|
||||
|
||||
// Remove existing values
|
||||
item.clearMetadata(schema, element, qualifier, Item.ANY);
|
||||
|
||||
// Put the names in the correct form
|
||||
for (int i = 0; i < vals.size(); i++)
|
||||
{
|
||||
// Add to the database if non-empty
|
||||
String s = (String) vals.get(i);
|
||||
|
||||
if ((s != null) && !s.equals(""))
|
||||
{
|
||||
item.addMetadata(schema, element, qualifier, lang, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill out a metadata date field with the value from a form. The date is
|
||||
* taken from the three parameters:
|
||||
*
|
||||
* element_qualifier_year element_qualifier_month element_qualifier_day
|
||||
*
|
||||
* The granularity is determined by the values that are actually set. If the
|
||||
* year isn't set (or is invalid)
|
||||
*
|
||||
* @param request
|
||||
* the request object
|
||||
* @param item
|
||||
* the item to update
|
||||
* @param schema
|
||||
* the metadata schema
|
||||
* @param element
|
||||
* the metadata element
|
||||
* @param qualifier
|
||||
* the metadata qualifier, or null if unqualified
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void readDate(HttpServletRequest request, Item item, String schema,
|
||||
String element, String qualifier) throws SQLException
|
||||
{
|
||||
String metadataField = MetadataField
|
||||
.formKey(schema, element, qualifier);
|
||||
|
||||
int year = Util.getIntParameter(request, metadataField + "_year");
|
||||
int month = Util.getIntParameter(request, metadataField + "_month");
|
||||
int day = Util.getIntParameter(request, metadataField + "_day");
|
||||
|
||||
// FIXME: Probably should be some more validation
|
||||
// Make a standard format date
|
||||
DCDate d = new DCDate();
|
||||
|
||||
d.setDateLocal(year, month, day, -1, -1, -1);
|
||||
|
||||
item.clearMetadata(schema, element, qualifier, Item.ANY);
|
||||
|
||||
if (year > 0)
|
||||
{
|
||||
// Only put in date if there is one!
|
||||
item.addMetadata(schema, element, qualifier, null, d.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set relevant metadata fields in an item from series/number values in the
|
||||
* form. Some fields are repeatable in the form. If this is the case, and
|
||||
* the field is "relation.ispartof", the names in the request will be from
|
||||
* the fields as follows:
|
||||
*
|
||||
* dc_relation_ispartof_series dc_relation_ispartof_number
|
||||
* dc_relation_ispartof_series_1 dc_relation_ispartof_number_1
|
||||
*
|
||||
* and so on. If the field is unqualified:
|
||||
*
|
||||
* dc_relation_series dc_relation_number
|
||||
*
|
||||
* Otherwise the parameters are of the form:
|
||||
*
|
||||
* dc_relation_ispartof_series dc_relation_ispartof_number
|
||||
*
|
||||
* The values will be put in separate DCValues, in the form "last name,
|
||||
* first name(s)", ordered as they appear in the list. These will replace
|
||||
* any existing values.
|
||||
*
|
||||
* @param request
|
||||
* the request object
|
||||
* @param item
|
||||
* the item to update
|
||||
* @param schema
|
||||
* the metadata schema
|
||||
* @param element
|
||||
* the metadata element
|
||||
* @param qualifier
|
||||
* the metadata qualifier, or null if unqualified
|
||||
* @param repeated
|
||||
* set to true if the field is repeatable on the form
|
||||
*/
|
||||
private void readSeriesNumbers(HttpServletRequest request, Item item,
|
||||
String schema, String element, String qualifier, boolean repeated)
|
||||
{
|
||||
String metadataField = MetadataField
|
||||
.formKey(schema, element, qualifier);
|
||||
|
||||
// Names to add
|
||||
List series = new LinkedList();
|
||||
List numbers = new LinkedList();
|
||||
|
||||
if (repeated)
|
||||
{
|
||||
series = getRepeatedParameter(request, metadataField, metadataField
|
||||
+ "_series");
|
||||
numbers = getRepeatedParameter(request, metadataField,
|
||||
metadataField + "_number");
|
||||
|
||||
// Find out if the relevant "remove" button was pressed
|
||||
String buttonPressed = Util.getSubmitButton(request, "");
|
||||
String removeButton = "submit_" + metadataField + "_remove_";
|
||||
|
||||
if (buttonPressed.startsWith(removeButton))
|
||||
{
|
||||
int valToRemove = Integer.parseInt(buttonPressed
|
||||
.substring(removeButton.length()));
|
||||
|
||||
series.remove(valToRemove);
|
||||
numbers.remove(valToRemove);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just a single name
|
||||
String s = request.getParameter(metadataField + "_series");
|
||||
String n = request.getParameter(metadataField + "_number");
|
||||
|
||||
// Only put it in if there was a name present
|
||||
if ((s != null) && !s.equals(""))
|
||||
{
|
||||
// if number is null, just set to a nullstring
|
||||
if (n == null)
|
||||
n = "";
|
||||
|
||||
series.add(s);
|
||||
numbers.add(n);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove existing values
|
||||
item.clearMetadata(schema, element, qualifier, Item.ANY);
|
||||
|
||||
// Put the names in the correct form
|
||||
for (int i = 0; i < series.size(); i++)
|
||||
{
|
||||
String s = ((String) series.get(i)).trim();
|
||||
String n = ((String) numbers.get(i)).trim();
|
||||
|
||||
// Only add non-empty
|
||||
if (!s.equals("") || !n.equals(""))
|
||||
{
|
||||
item.addMetadata(schema, element, qualifier, null,
|
||||
new DCSeriesNumber(s, n).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get repeated values from a form. If "foo" is passed in as the parameter,
|
||||
* values in the form of parameters "foo", "foo_1", "foo_2", etc. are
|
||||
* returned.
|
||||
* <P>
|
||||
* This method can also handle "composite fields" (metadata fields which may
|
||||
* require multiple params, etc. a first name and last name).
|
||||
*
|
||||
* @param request
|
||||
* the HTTP request containing the form information
|
||||
* @param metadataField
|
||||
* the metadata field which can store repeated values
|
||||
* @param param
|
||||
* the repeated parameter on the page (used to fill out the
|
||||
* metadataField)
|
||||
*
|
||||
* @return a List of Strings
|
||||
*/
|
||||
private List getRepeatedParameter(HttpServletRequest request,
|
||||
String metadataField, String param)
|
||||
{
|
||||
List vals = new LinkedList();
|
||||
|
||||
int i = 0;
|
||||
boolean foundLast = false;
|
||||
|
||||
log.debug("getRepeatedParameter: metadataField=" + metadataField
|
||||
+ " param=" + metadataField);
|
||||
|
||||
// Iterate through the values in the form.
|
||||
while (!foundLast)
|
||||
{
|
||||
String s = null;
|
||||
if (i == 0)
|
||||
s = request.getParameter(param);
|
||||
else
|
||||
s = request.getParameter(param + "_" + i);
|
||||
|
||||
// We're only going to add non-null values
|
||||
if (s != null)
|
||||
{
|
||||
boolean addValue = true;
|
||||
|
||||
// Check to make sure that this value was not selected to be
|
||||
// removed.
|
||||
// (This is for the "remove multiple" option available in
|
||||
// Manakin)
|
||||
String[] selected = request.getParameterValues(metadataField
|
||||
+ "_selected");
|
||||
|
||||
if (selected != null)
|
||||
{
|
||||
for (int j = 0; j < selected.length; j++)
|
||||
{
|
||||
if (selected[j].equals(metadataField + "_" + i))
|
||||
{
|
||||
addValue = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addValue)
|
||||
vals.add(s.trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the value was null (as opposed to present,
|
||||
// but empty) we've reached the last name
|
||||
foundLast = true;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return vals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the HTML / DRI field name for the given input.
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static String getFieldName(DCInput input)
|
||||
{
|
||||
String dcSchema = input.getSchema();
|
||||
String dcElement = input.getElement();
|
||||
String dcQualifier = input.getQualifier();
|
||||
if (dcQualifier != null && !dcQualifier.equals(Item.ANY))
|
||||
{
|
||||
return dcSchema + "_" + dcElement + '_' + dcQualifier;
|
||||
}
|
||||
else
|
||||
{
|
||||
return dcSchema + "_" + dcElement;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,347 @@
|
||||
/*
|
||||
* InitialQuestionsStep.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package org.dspace.submit.step;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
import org.dspace.app.util.Util;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.dspace.content.DCValue;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.submit.AbstractProcessingStep;
|
||||
|
||||
/**
|
||||
* Initial Submission servlet for DSpace. Handles the initial questions which
|
||||
* are asked to users to gather information regarding what metadata needs to be
|
||||
* gathered.
|
||||
* <P>
|
||||
* This class performs all the behind-the-scenes processing that
|
||||
* this particular step requires. This class's methods are utilized
|
||||
* by both the JSP-UI and the Manakin XML-UI
|
||||
* <P>
|
||||
*
|
||||
* @see org.dspace.app.util.SubmissionConfig
|
||||
* @see org.dspace.app.util.SubmissionStepConfig
|
||||
* @see org.dspace.submit.AbstractProcessingStep
|
||||
*
|
||||
* @author Tim Donohue
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class InitialQuestionsStep extends AbstractProcessingStep
|
||||
{
|
||||
/***************************************************************************
|
||||
* STATUS / ERROR FLAGS (returned by doProcessing() if an error occurs or
|
||||
* additional user interaction may be required)
|
||||
*
|
||||
* (Do NOT use status of 0, since it corresponds to STATUS_COMPLETE flag
|
||||
* defined in the JSPStepManager class)
|
||||
**************************************************************************/
|
||||
// pruning of metadata needs to take place
|
||||
public static final int STATUS_VERIFY_PRUNE = 1;
|
||||
|
||||
// pruning was cancelled by user
|
||||
public static final int STATUS_CANCEL_PRUNE = 2;
|
||||
|
||||
// user attempted to upload a thesis, when theses are not accepted
|
||||
public static final int STATUS_THESIS_REJECTED = 3;
|
||||
|
||||
/**
|
||||
* Global flags to determine if we need to prune anything
|
||||
*/
|
||||
protected boolean willRemoveTitles = false;
|
||||
|
||||
protected boolean willRemoveDate = false;
|
||||
|
||||
protected boolean willRemoveFiles = false;
|
||||
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(InitialQuestionsStep.class);
|
||||
|
||||
/**
|
||||
* Do any processing of the information input by the user, and/or perform
|
||||
* step processing (if no user interaction required)
|
||||
* <P>
|
||||
* It is this method's job to save any data to the underlying database, as
|
||||
* necessary, and return error messages (if any) which can then be processed
|
||||
* by the appropriate user interface (JSP-UI or XML-UI)
|
||||
* <P>
|
||||
* NOTE: If this step is a non-interactive step (i.e. requires no UI), then
|
||||
* it should perform *all* of its processing in this method!
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
* @return Status or error flag which will be processed by
|
||||
* doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
public int doProcessing(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
// Get the values from the initial questions form
|
||||
boolean multipleTitles = Util.getBoolParameter(request,
|
||||
"multiple_titles");
|
||||
boolean publishedBefore = Util.getBoolParameter(request,
|
||||
"published_before");
|
||||
boolean multipleFiles = Util.getBoolParameter(request,
|
||||
"multiple_files");
|
||||
boolean isThesis = ConfigurationManager
|
||||
.getBooleanProperty("webui.submit.blocktheses")
|
||||
&& Util.getBoolParameter(request, "is_thesis");
|
||||
|
||||
if (subInfo.isInWorkflow())
|
||||
{
|
||||
// Thesis question does not appear in workflow mode..
|
||||
isThesis = false;
|
||||
|
||||
// Pretend "multiple files" is true in workflow mode
|
||||
// (There will always be the license file)
|
||||
multipleFiles = true;
|
||||
}
|
||||
|
||||
// First and foremost - if it's a thesis, reject the submission
|
||||
if (isThesis)
|
||||
{
|
||||
WorkspaceItem wi = (WorkspaceItem) subInfo.getSubmissionItem();
|
||||
wi.deleteAll();
|
||||
subInfo.setSubmissionItem(null);
|
||||
|
||||
// Remember that we've removed a thesis in the session
|
||||
request.getSession().setAttribute("removed_thesis",
|
||||
new Boolean(true));
|
||||
|
||||
return STATUS_THESIS_REJECTED; // since theses are disabled, throw
|
||||
// an error!
|
||||
}
|
||||
|
||||
// Next, check if we are pruning some existing metadata
|
||||
if (request.getParameter("do_not_prune") != null)
|
||||
{
|
||||
return STATUS_CANCEL_PRUNE; // cancelled pruning!
|
||||
}
|
||||
else if (request.getParameter("prune") != null)
|
||||
{
|
||||
processVerifyPrune(context, request, response, subInfo,
|
||||
multipleTitles, publishedBefore, multipleFiles);
|
||||
}
|
||||
else
|
||||
// otherwise, check if pruning is necessary
|
||||
{
|
||||
// Now check to see if the changes will remove any values
|
||||
// (i.e. multiple files, titles or an issue date.)
|
||||
|
||||
// shouldn't need to check if submission is null, but just in case!
|
||||
if ((multipleTitles == false)
|
||||
&& (subInfo.getSubmissionItem() != null))
|
||||
{
|
||||
DCValue[] altTitles = subInfo.getSubmissionItem().getItem()
|
||||
.getDC("title", "alternative", Item.ANY);
|
||||
|
||||
willRemoveTitles = altTitles.length > 0;
|
||||
}
|
||||
|
||||
if ((publishedBefore == false)
|
||||
&& (subInfo.getSubmissionItem() != null))
|
||||
{
|
||||
DCValue[] dateIssued = subInfo.getSubmissionItem().getItem()
|
||||
.getDC("date", "issued", Item.ANY);
|
||||
DCValue[] citation = subInfo.getSubmissionItem().getItem()
|
||||
.getDC("identifier", "citation", Item.ANY);
|
||||
DCValue[] publisher = subInfo.getSubmissionItem().getItem()
|
||||
.getDC("publisher", null, Item.ANY);
|
||||
|
||||
willRemoveDate = (dateIssued.length > 0)
|
||||
|| (citation.length > 0) || (publisher.length > 0);
|
||||
}
|
||||
|
||||
if ((multipleFiles == false)
|
||||
&& (subInfo.getSubmissionItem() != null))
|
||||
{
|
||||
// see if number of bitstreams in "ORIGINAL" bundle > 1
|
||||
// FIXME: Assumes multiple bundles, clean up someday...
|
||||
Bundle[] bundles = subInfo.getSubmissionItem().getItem()
|
||||
.getBundles("ORIGINAL");
|
||||
|
||||
if (bundles.length > 0)
|
||||
{
|
||||
Bitstream[] bitstreams = bundles[0].getBitstreams();
|
||||
|
||||
willRemoveFiles = bitstreams.length > 1;
|
||||
}
|
||||
}
|
||||
|
||||
// If anything is going to be removed from the item as a result
|
||||
// of changing the answer to one of the questions, we need
|
||||
// to inform the user and make sure that's OK, before saving!
|
||||
if (willRemoveTitles || willRemoveDate || willRemoveFiles)
|
||||
{
|
||||
return STATUS_VERIFY_PRUNE; // we will need to do pruning!
|
||||
}
|
||||
}
|
||||
|
||||
// If step is complete, save the changes
|
||||
subInfo.getSubmissionItem().setMultipleTitles(multipleTitles);
|
||||
subInfo.getSubmissionItem().setPublishedBefore(publishedBefore);
|
||||
|
||||
// "Multiple files" irrelevant in workflow mode
|
||||
if (!subInfo.isInWorkflow())
|
||||
{
|
||||
subInfo.getSubmissionItem().setMultipleFiles(multipleFiles);
|
||||
}
|
||||
|
||||
// commit all changes to DB
|
||||
subInfo.getSubmissionItem().update();
|
||||
context.commit();
|
||||
|
||||
return STATUS_COMPLETE; // no errors!
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the number of pages that this "step" extends over. This method
|
||||
* is used to build the progress bar.
|
||||
* <P>
|
||||
* This method may just return 1 for most steps (since most steps consist of
|
||||
* a single page). But, it should return a number greater than 1 for any
|
||||
* "step" which spans across a number of HTML pages. For example, the
|
||||
* configurable "Describe" step (configured using input-forms.xml) overrides
|
||||
* this method to return the number of pages that are defined by its
|
||||
* configuration file.
|
||||
* <P>
|
||||
* Steps which are non-interactive (i.e. they do not display an interface to
|
||||
* the user) should return a value of 1, so that they are only processed
|
||||
* once!
|
||||
*
|
||||
* @param request
|
||||
* The HTTP Request
|
||||
* @param subInfo
|
||||
* The current submission information object
|
||||
*
|
||||
* @return the number of pages in this step
|
||||
*/
|
||||
public int getNumberOfPages(HttpServletRequest request,
|
||||
SubmissionInfo subInfo) throws ServletException
|
||||
{
|
||||
// always just one page of initial questions
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process input from "verify prune" page
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
* @param multipleTitles
|
||||
* if there is multiple titles
|
||||
* @param publishedBefore
|
||||
* if published before
|
||||
* @param multipleFiles
|
||||
* if there will be multiple files
|
||||
*/
|
||||
private void processVerifyPrune(Context context,
|
||||
HttpServletRequest request, HttpServletResponse response,
|
||||
SubmissionInfo subInfo, boolean multipleTitles,
|
||||
boolean publishedBefore, boolean multipleFiles)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
// get the item to prune
|
||||
Item item = subInfo.getSubmissionItem().getItem();
|
||||
|
||||
if (multipleTitles == false
|
||||
&& subInfo.getSubmissionItem().hasMultipleTitles())
|
||||
{
|
||||
item.clearDC("title", "alternative", Item.ANY);
|
||||
}
|
||||
|
||||
if (publishedBefore == false
|
||||
&& subInfo.getSubmissionItem().isPublishedBefore())
|
||||
{
|
||||
item.clearDC("date", "issued", Item.ANY);
|
||||
item.clearDC("identifier", "citation", Item.ANY);
|
||||
item.clearDC("publisher", null, Item.ANY);
|
||||
}
|
||||
|
||||
if (multipleFiles == false
|
||||
&& subInfo.getSubmissionItem().hasMultipleFiles())
|
||||
{
|
||||
// remove all but first bitstream from bundle[0]
|
||||
// FIXME: Assumes multiple bundles, clean up someday...
|
||||
// (only messes with the first bundle.)
|
||||
Bundle[] bundles = item.getBundles("ORIGINAL");
|
||||
|
||||
if (bundles.length > 0)
|
||||
{
|
||||
Bitstream[] bitstreams = bundles[0].getBitstreams();
|
||||
|
||||
// Remove all but the first bitstream
|
||||
for (int i = 1; i < bitstreams.length; i++)
|
||||
{
|
||||
bundles[0].removeBitstream(bitstreams[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
302
dspace-api/src/main/java/org/dspace/submit/step/LicenseStep.java
Normal file
302
dspace-api/src/main/java/org/dspace/submit/step/LicenseStep.java
Normal file
@@ -0,0 +1,302 @@
|
||||
/*
|
||||
* LicenseStep.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package org.dspace.submit.step;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
import org.dspace.app.util.Util;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.license.CreativeCommons;
|
||||
import org.dspace.submit.AbstractProcessingStep;
|
||||
|
||||
/**
|
||||
* License step for DSpace Submission Process. Processes the
|
||||
* user response to the license.
|
||||
* <P>
|
||||
* This class performs all the behind-the-scenes processing that
|
||||
* this particular step requires. This class's methods are utilized
|
||||
* by both the JSP-UI and the Manakin XML-UI
|
||||
* <P>
|
||||
*
|
||||
* @see org.dspace.app.util.SubmissionConfig
|
||||
* @see org.dspace.app.util.SubmissionStepConfig
|
||||
* @see org.dspace.submit.AbstractProcessingStep
|
||||
*
|
||||
* @author Tim Donohue
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class LicenseStep extends AbstractProcessingStep
|
||||
{
|
||||
/***************************************************************************
|
||||
* STATUS / ERROR FLAGS (returned by doProcessing() if an error occurs or
|
||||
* additional user interaction may be required)
|
||||
*
|
||||
* (Do NOT use status of 0, since it corresponds to STATUS_COMPLETE flag
|
||||
* defined in the JSPStepManager class)
|
||||
**************************************************************************/
|
||||
// user rejected the license
|
||||
public static final int STATUS_LICENSE_REJECTED = 1;
|
||||
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(LicenseStep.class);
|
||||
|
||||
|
||||
/**
|
||||
* Do any processing of the information input by the user, and/or perform
|
||||
* step processing (if no user interaction required)
|
||||
* <P>
|
||||
* It is this method's job to save any data to the underlying database, as
|
||||
* necessary, and return error messages (if any) which can then be processed
|
||||
* by the appropriate user interface (JSP-UI or XML-UI)
|
||||
* <P>
|
||||
* NOTE: If this step is a non-interactive step (i.e. requires no UI), then
|
||||
* it should perform *all* of its processing in this method!
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
* @return Status or error flag which will be processed by
|
||||
* doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
public int doProcessing(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
// If creative commons licensing is enabled, then it is page #1
|
||||
if (CreativeCommons.isEnabled()
|
||||
&& AbstractProcessingStep.getCurrentPage(request) == 1)
|
||||
{
|
||||
// process Creative Commons license
|
||||
// (and return any error messages encountered)
|
||||
return processCC(context, request, response, subInfo);
|
||||
}
|
||||
// otherwise, if we came from general DSpace license
|
||||
else
|
||||
{
|
||||
// process DSpace license (and return any error messages
|
||||
// encountered)
|
||||
return processLicense(context, request, response, subInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process the input from the license page
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
*
|
||||
* @return Status or error flag which will be processed by
|
||||
* UI-related code! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
private int processLicense(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
String buttonPressed = Util.getSubmitButton(request, CANCEL_BUTTON);
|
||||
|
||||
boolean licenseGranted = false;
|
||||
|
||||
// For Manakin:
|
||||
// Accepting the license means checking a box and clicking Next
|
||||
String decision = request.getParameter("decision");
|
||||
if (decision != null && decision.equalsIgnoreCase("accept")
|
||||
&& buttonPressed.equals(NEXT_BUTTON))
|
||||
{
|
||||
licenseGranted = true;
|
||||
}
|
||||
// For JSP-UI: User just needed to click "I Accept" button
|
||||
else if (buttonPressed.equals("submit_grant"))
|
||||
{
|
||||
licenseGranted = true;
|
||||
}// JSP-UI: License was explicitly rejected
|
||||
else if (buttonPressed.equals("submit_reject"))
|
||||
{
|
||||
licenseGranted = false;
|
||||
}// Manakin UI: user didn't make a decision and clicked Next->
|
||||
else if (buttonPressed.equals(NEXT_BUTTON))
|
||||
{
|
||||
// no decision made (this will cause Manakin to display an error)
|
||||
return STATUS_LICENSE_REJECTED;
|
||||
}
|
||||
|
||||
if (licenseGranted
|
||||
&& (buttonPressed.equals("submit_grant") || buttonPressed
|
||||
.equals(NEXT_BUTTON)))
|
||||
{
|
||||
// License granted
|
||||
log.info(LogManager.getHeader(context, "accept_license",
|
||||
subInfo.getSubmissionLogInfo()));
|
||||
|
||||
// Add the license to the item
|
||||
Item item = subInfo.getSubmissionItem().getItem();
|
||||
EPerson submitter = context.getCurrentUser();
|
||||
|
||||
// remove any existing DSpace license (just in case the user
|
||||
// accepted it previously)
|
||||
item.removeDSpaceLicense();
|
||||
|
||||
// FIXME: Probably need to take this from the form at some point
|
||||
String license = subInfo.getSubmissionItem().getCollection()
|
||||
.getLicense();
|
||||
|
||||
item.licenseGranted(license, submitter);
|
||||
|
||||
// commit changes
|
||||
context.commit();
|
||||
}
|
||||
|
||||
// completed without errors
|
||||
return STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the input from the CC license page
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
*
|
||||
* @return Status or error flag which will be processed by
|
||||
* doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
private int processCC(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
String buttonPressed = Util.getSubmitButton(request, NEXT_BUTTON);
|
||||
|
||||
// RLR hack - need to distinguish between progress bar real submission
|
||||
// (if cc_license_url exists, then users has accepted the CC License)
|
||||
String ccLicenseUrl = request.getParameter("cc_license_url");
|
||||
|
||||
if (buttonPressed.equals("submit_no_cc"))
|
||||
{
|
||||
// Skipping the CC license - remove any existing license selection
|
||||
CreativeCommons.removeLicense(context, subInfo.getSubmissionItem()
|
||||
.getItem());
|
||||
}
|
||||
else if ((ccLicenseUrl != null) && (ccLicenseUrl.length() > 0))
|
||||
{
|
||||
Item item = subInfo.getSubmissionItem().getItem();
|
||||
|
||||
// save the CC license
|
||||
CreativeCommons.setLicense(context, item, ccLicenseUrl);
|
||||
}
|
||||
|
||||
// commit changes
|
||||
context.commit();
|
||||
|
||||
// completed without errors
|
||||
return STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the number of pages that this "step" extends over. This method
|
||||
* is used to build the progress bar.
|
||||
* <P>
|
||||
* This method may just return 1 for most steps (since most steps consist of
|
||||
* a single page). But, it should return a number greater than 1 for any
|
||||
* "step" which spans across a number of HTML pages. For example, the
|
||||
* configurable "Describe" step (configured using input-forms.xml) overrides
|
||||
* this method to return the number of pages that are defined by its
|
||||
* configuration file.
|
||||
* <P>
|
||||
* Steps which are non-interactive (i.e. they do not display an interface to
|
||||
* the user) should return a value of 1, so that they are only processed
|
||||
* once!
|
||||
*
|
||||
* @param request
|
||||
* The HTTP Request
|
||||
* @param subInfo
|
||||
* The current submission information object
|
||||
*
|
||||
* @return the number of pages in this step
|
||||
*/
|
||||
public int getNumberOfPages(HttpServletRequest request,
|
||||
SubmissionInfo subInfo) throws ServletException
|
||||
{
|
||||
// if creative commons licensing is enabled,
|
||||
// then there are 2 license pages
|
||||
if (CreativeCommons.isEnabled())
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
211
dspace-api/src/main/java/org/dspace/submit/step/SampleStep.java
Normal file
211
dspace-api/src/main/java/org/dspace/submit/step/SampleStep.java
Normal file
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* SampleStep.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package org.dspace.submit.step;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.submit.AbstractProcessingStep;
|
||||
|
||||
/**
|
||||
* This is a Sample Step class which can be used as template for creating new
|
||||
* custom Step processing classes!
|
||||
* <p>
|
||||
* Please Note: The basic methods you will want to override are described below.
|
||||
* However, obviously, you are completely free to create your own methods for
|
||||
* this Step, or override other methods. For more examples, look at the code
|
||||
* from one of the provided DSpace step classes in the "org.dspace.submit.step"
|
||||
* package.
|
||||
* <P>
|
||||
* This class performs all the behind-the-scenes processing that
|
||||
* this particular step requires. This class's methods are utilized
|
||||
* by both the JSP-UI and the Manakin XML-UI
|
||||
* <P>
|
||||
* If you are utilizing the JSP-UI, you will also be required to create
|
||||
* a class which implements org.dspace.app.webui.submit.JSPStep, and provide
|
||||
* the necessary JSP-related methods. There is a corresponding sample
|
||||
* of such a class at org.dspace.app.webui.submit.step.JSPSampleStep.
|
||||
*
|
||||
* @see org.dspace.app.util.SubmissionConfig
|
||||
* @see org.dspace.app.util.SubmissionStepConfig
|
||||
* @see org.dspace.submit.AbstractProcessingStep
|
||||
*
|
||||
* @author Tim Donohue
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class SampleStep extends AbstractProcessingStep
|
||||
{
|
||||
|
||||
/***************************************************************************
|
||||
* STATUS / ERROR FLAGS (returned by doProcessing() if an error occurs or
|
||||
* additional user interaction may be required)
|
||||
*
|
||||
* (Do NOT use status of 0, since it corresponds to STATUS_COMPLETE flag
|
||||
* defined in the JSPStepManager class)
|
||||
**************************************************************************/
|
||||
public static final int STATUS_USER_INPUT_ERROR = 1;
|
||||
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(SampleStep.class);
|
||||
|
||||
|
||||
/**
|
||||
* Do any processing of the information input by the user, and/or perform
|
||||
* step processing (if no user interaction required)
|
||||
* <P>
|
||||
* It is this method's job to save any data to the underlying database, as
|
||||
* necessary, and return error messages (if any) which can then be processed
|
||||
* by the appropriate user interface (JSP-UI or XML-UI)
|
||||
* <P>
|
||||
* NOTE: If this step is a non-interactive step (i.e. requires no UI), then
|
||||
* it should perform *all* of its processing in this method!
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
* @return Status or error flag which will be processed by
|
||||
* doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
public int doProcessing(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
/*
|
||||
* In this method, you should do any processing of any user input (if
|
||||
* this step requires user input). If this step does not require user
|
||||
* interaction (i.e. it has no UI), then ALL of the backend processing
|
||||
* should occur in this method.
|
||||
*
|
||||
* Processing may include, but is not limited to:
|
||||
*
|
||||
* 1) Saving user input data to the database (e.g. saving metadata from
|
||||
* a web form that a user filled out) 2) Performing ALL backend
|
||||
* processing for non-interactive steps 3) Determine if any errors
|
||||
* occurred during processing, and if so, return those error flags.
|
||||
*
|
||||
* For steps with user interaction, this method is called right after
|
||||
* the web form or page is submitted. For steps without user
|
||||
* interaction, this method is called whenever the step itself is
|
||||
* supposed to be processed.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* HINT:
|
||||
*
|
||||
* If any errors occurred, its recommended to create a global "flag" to
|
||||
* represent that error. It's much easier then for the
|
||||
* JSP-UI or Manakin XML-UI to determine what to do with that error.
|
||||
*
|
||||
* For example, if an error occurred, you may specify the following
|
||||
* return call:
|
||||
*
|
||||
* return USER_INPUT_ERROR_FLAG;
|
||||
*
|
||||
* (Note: this flag is defined at the top of this class)
|
||||
*/
|
||||
|
||||
// If no errors occurred, and there were no other special messages to
|
||||
// report to the doPostProcessing() method, just return STATUS_COMPLETE!
|
||||
return STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the number of pages that this "step" extends over. This method
|
||||
* is used to build the progress bar.
|
||||
* <P>
|
||||
* This method may just return 1 for most steps (since most steps consist of
|
||||
* a single page). But, it should return a number greater than 1 for any
|
||||
* "step" which spans across a number of HTML pages. For example, the
|
||||
* configurable "Describe" step (configured using input-forms.xml) overrides
|
||||
* this method to return the number of pages that are defined by its
|
||||
* configuration file.
|
||||
* <P>
|
||||
* Steps which are non-interactive (i.e. they do not display an interface to
|
||||
* the user) should return a value of 1, so that they are only processed
|
||||
* once!
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
* The HTTP Request
|
||||
* @param subInfo
|
||||
* The current submission information object
|
||||
*
|
||||
* @return the number of pages in this step
|
||||
*/
|
||||
public int getNumberOfPages(HttpServletRequest request,
|
||||
SubmissionInfo subInfo) throws ServletException
|
||||
{
|
||||
/*
|
||||
* This method reports how many "pages" to put in
|
||||
* the Progress Bar for this Step.
|
||||
*
|
||||
* Most steps should just return 1 (which means the Step only appears
|
||||
* once in the Progress Bar).
|
||||
*
|
||||
* If this Step should be shown as multiple "Pages" in the Progress Bar,
|
||||
* then return a value higher than 1. For example, return 2 in order to
|
||||
* have this Step appear twice in a row within the Progress Bar.
|
||||
*
|
||||
* If you return 0, this Step will not appear in the Progress Bar at
|
||||
* ALL! Therefore it is important for non-interactive steps to return 0.
|
||||
*/
|
||||
|
||||
// in most cases, you'll want to just return 1
|
||||
return 1;
|
||||
}
|
||||
}
|
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* SelectCollectionStep.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package org.dspace.submit.step;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
import org.dspace.app.util.Util;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.submit.AbstractProcessingStep;
|
||||
|
||||
/**
|
||||
* SelectCollection Step which processes the collection that the user selected
|
||||
* in that step of the DSpace Submission process
|
||||
* <P>
|
||||
* This class performs all the behind-the-scenes processing that
|
||||
* this particular step requires. This class's methods are utilized
|
||||
* by both the JSP-UI and the Manakin XML-UI
|
||||
*
|
||||
* @see org.dspace.app.util.SubmissionConfig
|
||||
* @see org.dspace.app.util.SubmissionStepConfig
|
||||
* @see org.dspace.submit.AbstractProcessingStep
|
||||
*
|
||||
* @author Tim Donohue
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class SelectCollectionStep extends AbstractProcessingStep
|
||||
{
|
||||
/***************************************************************************
|
||||
* STATUS / ERROR FLAGS (returned by doProcessing() if an error occurs or
|
||||
* additional user interaction may be required)
|
||||
*
|
||||
* (Do NOT use status of 0, since it corresponds to STATUS_COMPLETE flag
|
||||
* defined in the JSPStepManager class)
|
||||
**************************************************************************/
|
||||
// no collection was selected
|
||||
public static final int STATUS_NO_COLLECTION = 1;
|
||||
|
||||
// invalid collection or error finding collection
|
||||
public static final int STATUS_INVALID_COLLECTION = 2;
|
||||
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(SelectCollectionStep.class);
|
||||
|
||||
/**
|
||||
* Do any processing of the information input by the user, and/or perform
|
||||
* step processing (if no user interaction required)
|
||||
* <P>
|
||||
* It is this method's job to save any data to the underlying database, as
|
||||
* necessary, and return error messages (if any) which can then be processed
|
||||
* by the appropriate user interface (JSP-UI or XML-UI)
|
||||
* <P>
|
||||
* NOTE: If this step is a non-interactive step (i.e. requires no UI), then
|
||||
* it should perform *all* of its processing in this method!
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
* @return Status or error flag which will be processed by
|
||||
* doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
public int doProcessing(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
// First we find the collection which was selected
|
||||
int id = Util.getIntParameter(request, "collection");
|
||||
|
||||
// if the user didn't select a collection,
|
||||
// send him/her back to "select a collection" page
|
||||
if (id < 0)
|
||||
{
|
||||
return STATUS_NO_COLLECTION;
|
||||
}
|
||||
|
||||
// try to load the collection
|
||||
Collection col = Collection.find(context, id);
|
||||
|
||||
// Show an error if the collection is invalid
|
||||
if (col == null)
|
||||
{
|
||||
return STATUS_INVALID_COLLECTION;
|
||||
}
|
||||
else
|
||||
{
|
||||
// create our new Workspace Item
|
||||
WorkspaceItem wi = WorkspaceItem.create(context, col, true);
|
||||
|
||||
// update Submission Information with this Workspace Item
|
||||
subInfo.setSubmissionItem(wi);
|
||||
|
||||
// commit changes to database
|
||||
context.commit();
|
||||
|
||||
// need to reload current submission process config,
|
||||
// since it is based on the Collection selected
|
||||
subInfo.reloadSubmissionConfig(request);
|
||||
}
|
||||
|
||||
// no errors occurred
|
||||
return STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the number of pages that this "step" extends over. This method
|
||||
* is used to build the progress bar.
|
||||
* <P>
|
||||
* This method may just return 1 for most steps (since most steps consist of
|
||||
* a single page). But, it should return a number greater than 1 for any
|
||||
* "step" which spans across a number of HTML pages. For example, the
|
||||
* configurable "Describe" step (configured using input-forms.xml) overrides
|
||||
* this method to return the number of pages that are defined by its
|
||||
* configuration file.
|
||||
* <P>
|
||||
* Steps which are non-interactive (i.e. they do not display an interface to
|
||||
* the user) should return a value of 1, so that they are only processed
|
||||
* once!
|
||||
*
|
||||
* @param request
|
||||
* The HTTP Request
|
||||
* @param subInfo
|
||||
* The current submission information object
|
||||
*
|
||||
* @return the number of pages in this step
|
||||
*/
|
||||
public int getNumberOfPages(HttpServletRequest request,
|
||||
SubmissionInfo subInfo) throws ServletException
|
||||
{
|
||||
// there is always just one page in the "select a collection" step!
|
||||
return 1;
|
||||
}
|
||||
}
|
681
dspace-api/src/main/java/org/dspace/submit/step/UploadStep.java
Normal file
681
dspace-api/src/main/java/org/dspace/submit/step/UploadStep.java
Normal file
@@ -0,0 +1,681 @@
|
||||
/*
|
||||
* UploadStep.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package org.dspace.submit.step;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
import org.dspace.app.util.Util;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.BitstreamFormat;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.dspace.content.FormatIdentifier;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.submit.AbstractProcessingStep;
|
||||
|
||||
/**
|
||||
* Upload step for DSpace. Processes the actual upload of files
|
||||
* for an item being submitted into DSpace.
|
||||
* <P>
|
||||
* This class performs all the behind-the-scenes processing that
|
||||
* this particular step requires. This class's methods are utilized
|
||||
* by both the JSP-UI and the Manakin XML-UI
|
||||
*
|
||||
* @see org.dspace.app.util.SubmissionConfig
|
||||
* @see org.dspace.app.util.SubmissionStepConfig
|
||||
* @see org.dspace.submit.AbstractProcessingStep
|
||||
*
|
||||
* @author Tim Donohue
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class UploadStep extends AbstractProcessingStep
|
||||
{
|
||||
/** Button to upload a file * */
|
||||
public static final String SUBMIT_UPLOAD_BUTTON = "submit_upload";
|
||||
|
||||
/** Button to submit more files * */
|
||||
public static final String SUBMIT_MORE_BUTTON = "submit_more";
|
||||
|
||||
/** Button to cancel editing of file info * */
|
||||
public static final String CANCEL_EDIT_BUTTON = "submit_edit_cancel";
|
||||
|
||||
/***************************************************************************
|
||||
* STATUS / ERROR FLAGS (returned by doProcessing() if an error occurs or
|
||||
* additional user interaction may be required)
|
||||
*
|
||||
* (Do NOT use status of 0, since it corresponds to STATUS_COMPLETE flag
|
||||
* defined in the JSPStepManager class)
|
||||
**************************************************************************/
|
||||
// integrity error occurred
|
||||
public static final int STATUS_INTEGRITY_ERROR = 1;
|
||||
|
||||
// error in uploading file
|
||||
public static final int STATUS_UPLOAD_ERROR = 2;
|
||||
|
||||
// error - no files uploaded!
|
||||
public static final int STATUS_NO_FILES_ERROR = 5;
|
||||
|
||||
// format of uploaded file is unknown
|
||||
public static final int STATUS_UNKNOWN_FORMAT = 10;
|
||||
|
||||
// edit file information
|
||||
public static final int STATUS_EDIT_BITSTREAM = 20;
|
||||
|
||||
// return from editing file information
|
||||
public static final int STATUS_EDIT_COMPLETE = 25;
|
||||
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(UploadStep.class);
|
||||
|
||||
|
||||
/**
|
||||
* Do any processing of the information input by the user, and/or perform
|
||||
* step processing (if no user interaction required)
|
||||
* <P>
|
||||
* It is this method's job to save any data to the underlying database, as
|
||||
* necessary, and return error messages (if any) which can then be processed
|
||||
* by the appropriate user interface (JSP-UI or XML-UI)
|
||||
* <P>
|
||||
* NOTE: If this step is a non-interactive step (i.e. requires no UI), then
|
||||
* it should perform *all* of its processing in this method!
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
* @return Status or error flag which will be processed by
|
||||
* doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
public int doProcessing(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
// get button user pressed
|
||||
String buttonPressed = Util.getSubmitButton(request, NEXT_BUTTON);
|
||||
|
||||
// get reference to item
|
||||
Item item = subInfo.getSubmissionItem().getItem();
|
||||
|
||||
// if user pressed jump-to button in process bar,
|
||||
// return success (so that jump will occur)
|
||||
if (buttonPressed.startsWith(PROGRESS_BAR_PREFIX))
|
||||
{
|
||||
return STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
// Step #1: Check if this was just a request to
|
||||
// edit file information.
|
||||
// (or canceled editing information)
|
||||
// ---------------------------------------------
|
||||
// check if we're already editing a specific bitstream
|
||||
if (request.getParameter("bitstream_id") != null)
|
||||
{
|
||||
if (buttonPressed.equals(CANCEL_EDIT_BUTTON))
|
||||
{
|
||||
// canceled an edit bitstream request
|
||||
subInfo.setBitstream(null);
|
||||
|
||||
// this flag will just return us to the normal upload screen
|
||||
return STATUS_EDIT_COMPLETE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// load info for bitstream we are editing
|
||||
Bitstream b = Bitstream.find(context, Integer.parseInt(request
|
||||
.getParameter("bitstream_id")));
|
||||
|
||||
// save bitstream to submission info
|
||||
subInfo.setBitstream(b);
|
||||
}
|
||||
}
|
||||
else if (buttonPressed.startsWith("submit_edit_"))
|
||||
{
|
||||
// get ID of bitstream that was requested for editing
|
||||
String bitstreamID = buttonPressed.substring("submit_edit_"
|
||||
.length());
|
||||
|
||||
Bitstream b = Bitstream
|
||||
.find(context, Integer.parseInt(bitstreamID));
|
||||
|
||||
// save bitstream to submission info
|
||||
subInfo.setBitstream(b);
|
||||
|
||||
// return appropriate status flag to say we are now editing the
|
||||
// bitstream
|
||||
return STATUS_EDIT_BITSTREAM;
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
// Step #2: Process any remove file request(s)
|
||||
// ---------------------------------------------
|
||||
// Remove-selected requests come from Manakin
|
||||
if (buttonPressed.equalsIgnoreCase("submit_remove_selected"))
|
||||
{
|
||||
// this is a remove multiple request!
|
||||
|
||||
if (request.getParameter("remove") != null)
|
||||
{
|
||||
// get all files to be removed
|
||||
String[] removeIDs = request.getParameterValues("remove");
|
||||
|
||||
// remove each file in the list
|
||||
for (int i = 0; i < removeIDs.length; i++)
|
||||
{
|
||||
int id = Integer.parseInt(removeIDs[i]);
|
||||
|
||||
int status = processRemoveFile(context, item, id);
|
||||
|
||||
// if error occurred, return immediately
|
||||
if (status != STATUS_COMPLETE)
|
||||
return status;
|
||||
}
|
||||
|
||||
// remove current bitstream from Submission Info
|
||||
subInfo.setBitstream(null);
|
||||
}
|
||||
}
|
||||
else if (buttonPressed.startsWith("submit_remove_"))
|
||||
{
|
||||
// A single file "remove" button must have been pressed
|
||||
|
||||
int id = Integer.parseInt(buttonPressed.substring(14));
|
||||
int status = processRemoveFile(context, item, id);
|
||||
|
||||
// if error occurred, return immediately
|
||||
if (status != STATUS_COMPLETE)
|
||||
return status;
|
||||
|
||||
// remove current bitstream from Submission Info
|
||||
subInfo.setBitstream(null);
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
// Step #3: Upload new files (if any)
|
||||
// -----------------------------------
|
||||
String contentType = request.getContentType();
|
||||
|
||||
if (buttonPressed.equalsIgnoreCase(SUBMIT_UPLOAD_BUTTON))
|
||||
{
|
||||
// if multipart form, then we are uploading a file
|
||||
if ((contentType != null)
|
||||
&& (contentType.indexOf("multipart/form-data") != -1))
|
||||
{
|
||||
// This is a multipart request, so it's a file upload
|
||||
// (return any status messages or errors reported)
|
||||
int status = processUploadFile(context, request, response,
|
||||
subInfo);
|
||||
|
||||
// if error occurred, return immediately
|
||||
if (status != STATUS_COMPLETE)
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
// Step #4: Check for a change in file description
|
||||
// -------------------------------------------------
|
||||
String fileDescription = request.getParameter("description");
|
||||
|
||||
if (fileDescription != null && fileDescription.length() > 0)
|
||||
{
|
||||
// save this file description
|
||||
int status = processSaveFileDescription(context, request, response,
|
||||
subInfo);
|
||||
|
||||
// if error occurred, return immediately
|
||||
if (status != STATUS_COMPLETE)
|
||||
return status;
|
||||
}
|
||||
|
||||
// ------------------------------------------
|
||||
// Step #5: Check for a file format change
|
||||
// (if user had to manually specify format)
|
||||
// ------------------------------------------
|
||||
int formatTypeID = Util.getIntParameter(request, "format");
|
||||
String formatDesc = request.getParameter("format_description");
|
||||
|
||||
// if a format id or description was found, then save this format!
|
||||
if (formatTypeID >= 0
|
||||
|| (formatDesc != null && formatDesc.length() > 0))
|
||||
{
|
||||
// save this specified format
|
||||
int status = processSaveFileFormat(context, request, response,
|
||||
subInfo);
|
||||
|
||||
// if error occurred, return immediately
|
||||
if (status != STATUS_COMPLETE)
|
||||
return status;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
// Step #6: Check if primary bitstream has changed
|
||||
// -------------------------------------------------
|
||||
if (request.getParameter("primary_bitstream_id") != null)
|
||||
{
|
||||
Bundle[] bundles = item.getBundles("ORIGINAL");
|
||||
bundles[0].setPrimaryBitstreamID(new Integer(request
|
||||
.getParameter("primary_bitstream_id")).intValue());
|
||||
bundles[0].update();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
// Step #7: Determine if there is an error because no
|
||||
// files have been uploaded.
|
||||
// ---------------------------------------------------
|
||||
// if "submit_skip" is unspecified, then a file is required!
|
||||
boolean allowEmptyItems = (request.getParameter("submit_skip") != null);
|
||||
if (!allowEmptyItems)
|
||||
{
|
||||
Bundle[] bundles = item.getBundles("ORIGINAL");
|
||||
if (bundles.length == 0)
|
||||
{
|
||||
// if no ORIGINAL bundle,
|
||||
// throw an error that there is no file!
|
||||
return STATUS_NO_FILES_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
Bitstream[] bitstreams = bundles[0].getBitstreams();
|
||||
if (bitstreams.length == 0)
|
||||
{
|
||||
// no files in ORIGINAL bundle!
|
||||
return STATUS_NO_FILES_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// commit all changes to database
|
||||
context.commit();
|
||||
|
||||
return STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the number of pages that this "step" extends over. This method
|
||||
* is used to build the progress bar.
|
||||
* <P>
|
||||
* This method may just return 1 for most steps (since most steps consist of
|
||||
* a single page). But, it should return a number greater than 1 for any
|
||||
* "step" which spans across a number of HTML pages. For example, the
|
||||
* configurable "Describe" step (configured using input-forms.xml) overrides
|
||||
* this method to return the number of pages that are defined by its
|
||||
* configuration file.
|
||||
* <P>
|
||||
* Steps which are non-interactive (i.e. they do not display an interface to
|
||||
* the user) should return a value of 1, so that they are only processed
|
||||
* once!
|
||||
*
|
||||
* @param request
|
||||
* The HTTP Request
|
||||
* @param subInfo
|
||||
* The current submission information object
|
||||
*
|
||||
* @return the number of pages in this step
|
||||
*/
|
||||
public int getNumberOfPages(HttpServletRequest request,
|
||||
SubmissionInfo subInfo) throws ServletException
|
||||
{
|
||||
// Despite using many JSPs, this step only appears
|
||||
// ONCE in the Progress Bar, so it's only ONE page
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ****************************************************************
|
||||
// ****************************************************************
|
||||
// METHODS FOR UPLOADING FILES (and associated information)
|
||||
// ****************************************************************
|
||||
// ****************************************************************
|
||||
|
||||
/**
|
||||
* Remove a file from an item
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param item
|
||||
* Item where file should be removed from
|
||||
* @param bitstreamID
|
||||
* The id of bitstream representing the file to remove
|
||||
* @return Status or error flag which will be processed by
|
||||
* UI-related code! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
private int processRemoveFile(Context context, Item item, int bitstreamID)
|
||||
throws IOException, SQLException, AuthorizeException
|
||||
{
|
||||
Bitstream bitstream;
|
||||
|
||||
// Try to find bitstream
|
||||
try
|
||||
{
|
||||
bitstream = Bitstream.find(context, bitstreamID);
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
bitstream = null;
|
||||
}
|
||||
|
||||
if (bitstream == null)
|
||||
{
|
||||
// Invalid or mangled bitstream ID
|
||||
// throw an error and return immediately
|
||||
return STATUS_INTEGRITY_ERROR;
|
||||
}
|
||||
|
||||
// remove bitstream from bundle..
|
||||
// delete bundle if it's now empty
|
||||
Bundle[] bundles = bitstream.getBundles();
|
||||
|
||||
bundles[0].removeBitstream(bitstream);
|
||||
|
||||
Bitstream[] bitstreams = bundles[0].getBitstreams();
|
||||
|
||||
// remove bundle if it's now empty
|
||||
if (bitstreams.length < 1)
|
||||
{
|
||||
item.removeBundle(bundles[0]);
|
||||
item.update();
|
||||
}
|
||||
|
||||
// no errors occurred
|
||||
return STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the upload of a new file!
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
*
|
||||
* @return Status or error flag which will be processed by
|
||||
* UI-related code! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
private int processUploadFile(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
boolean formatKnown = true;
|
||||
boolean fileOK = false;
|
||||
BitstreamFormat bf = null;
|
||||
Bitstream b = null;
|
||||
|
||||
//NOTE: File should already be uploaded.
|
||||
//Manakin does this automatically.
|
||||
//For JSP-UI, the JSPUploadStep.doProcessing() does the actual upload
|
||||
|
||||
Enumeration attNames = request.getAttributeNames();
|
||||
|
||||
//loop through our request attributes
|
||||
while(attNames.hasMoreElements())
|
||||
{
|
||||
String attr = (String) attNames.nextElement();
|
||||
|
||||
//if this ends with "-path", this attribute
|
||||
//represents a newly uploaded file
|
||||
if(attr.endsWith("-path"))
|
||||
{
|
||||
//strip off the -path to get the actual parameter
|
||||
//that the file was uploaded as
|
||||
String param = attr.replace("-path", "");
|
||||
|
||||
// Load the file's path and input stream and description
|
||||
String filePath = (String) request.getAttribute(param + "-path");
|
||||
InputStream fileInputStream = (InputStream) request
|
||||
.getAttribute(param + "-inputstream");
|
||||
|
||||
//attempt to get description from attribute first, then direct from a parameter
|
||||
String fileDescription = (String) request
|
||||
.getAttribute(param + "-description");
|
||||
if(fileDescription==null ||fileDescription.length()==0)
|
||||
request.getParameter("description");
|
||||
|
||||
// if information wasn't passed by User Interface, we had a problem
|
||||
// with the upload
|
||||
if (filePath == null || fileInputStream == null)
|
||||
return STATUS_UPLOAD_ERROR;
|
||||
|
||||
if (subInfo != null)
|
||||
{
|
||||
// Create the bitstream
|
||||
Item item = subInfo.getSubmissionItem().getItem();
|
||||
|
||||
// do we already have a bundle?
|
||||
Bundle[] bundles = item.getBundles("ORIGINAL");
|
||||
|
||||
if (bundles.length < 1)
|
||||
{
|
||||
// set bundle's name to ORIGINAL
|
||||
b = item.createSingleBitstream(fileInputStream, "ORIGINAL");
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have a bundle already, just add bitstream
|
||||
b = bundles[0].createBitstream(fileInputStream);
|
||||
}
|
||||
|
||||
// Strip all but the last filename. It would be nice
|
||||
// to know which OS the file came from.
|
||||
String noPath = filePath;
|
||||
|
||||
while (noPath.indexOf('/') > -1)
|
||||
{
|
||||
noPath = noPath.substring(noPath.indexOf('/') + 1);
|
||||
}
|
||||
|
||||
while (noPath.indexOf('\\') > -1)
|
||||
{
|
||||
noPath = noPath.substring(noPath.indexOf('\\') + 1);
|
||||
}
|
||||
|
||||
b.setName(noPath);
|
||||
b.setSource(filePath);
|
||||
b.setDescription(fileDescription);
|
||||
|
||||
// Identify the format
|
||||
bf = FormatIdentifier.guessFormat(context, b);
|
||||
b.setFormat(bf);
|
||||
|
||||
// Update to DB
|
||||
b.update();
|
||||
item.update();
|
||||
|
||||
if (bf == null || !bf.isInternal())
|
||||
{
|
||||
fileOK = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.warn("Attempt to upload file format marked as internal system use only");
|
||||
}
|
||||
}// if subInfo not null
|
||||
else
|
||||
{
|
||||
// In any event, if we don't have the submission info, the request
|
||||
// was malformed
|
||||
return STATUS_INTEGRITY_ERROR;
|
||||
}
|
||||
|
||||
// as long as everything completed ok, commit changes. Otherwise show
|
||||
// error page.
|
||||
if (fileOK)
|
||||
{
|
||||
context.commit();
|
||||
|
||||
// save this bitstream to the submission info, as the
|
||||
// bitstream we're currently working with
|
||||
subInfo.setBitstream(b);
|
||||
|
||||
//if format was not identified
|
||||
if (bf == null)
|
||||
{
|
||||
// the bitstream format is unknown!
|
||||
formatKnown=false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we get here there was a problem uploading the file!
|
||||
return STATUS_UPLOAD_ERROR;
|
||||
}
|
||||
}//end if attribute ends with "-path"
|
||||
}//end while
|
||||
|
||||
if(!formatKnown)
|
||||
{
|
||||
//return that the bitstream format is unknown!
|
||||
return STATUS_UNKNOWN_FORMAT;
|
||||
}
|
||||
else
|
||||
return STATUS_COMPLETE;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Process input from get file type page
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
*
|
||||
* @return Status or error flag which will be processed by
|
||||
* UI-related code! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
private int processSaveFileFormat(Context context,
|
||||
HttpServletRequest request, HttpServletResponse response,
|
||||
SubmissionInfo subInfo) throws ServletException, IOException,
|
||||
SQLException, AuthorizeException
|
||||
{
|
||||
if (subInfo.getBitstream() != null)
|
||||
{
|
||||
// Did the user select a format?
|
||||
int typeID = Util.getIntParameter(request, "format");
|
||||
|
||||
BitstreamFormat format = BitstreamFormat.find(context, typeID);
|
||||
|
||||
if (format != null)
|
||||
{
|
||||
subInfo.getBitstream().setFormat(format);
|
||||
}
|
||||
else
|
||||
{
|
||||
String userDesc = request.getParameter("format_description");
|
||||
|
||||
subInfo.getBitstream().setUserFormatDescription(userDesc);
|
||||
}
|
||||
|
||||
// update database
|
||||
subInfo.getBitstream().update();
|
||||
}
|
||||
else
|
||||
{
|
||||
return STATUS_INTEGRITY_ERROR;
|
||||
}
|
||||
|
||||
return STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process input from the "change file description" page
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
*
|
||||
* @return Status or error flag which will be processed by
|
||||
* UI-related code! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
private int processSaveFileDescription(Context context,
|
||||
HttpServletRequest request, HttpServletResponse response,
|
||||
SubmissionInfo subInfo) throws ServletException, IOException,
|
||||
SQLException, AuthorizeException
|
||||
{
|
||||
if (subInfo.getBitstream() != null)
|
||||
{
|
||||
subInfo.getBitstream().setDescription(
|
||||
request.getParameter("description"));
|
||||
subInfo.getBitstream().update();
|
||||
|
||||
context.commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
return STATUS_INTEGRITY_ERROR;
|
||||
}
|
||||
|
||||
return STATUS_COMPLETE;
|
||||
}
|
||||
}
|
137
dspace-api/src/main/java/org/dspace/submit/step/VerifyStep.java
Normal file
137
dspace-api/src/main/java/org/dspace/submit/step/VerifyStep.java
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* VerifyStep.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package org.dspace.submit.step;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.submit.AbstractProcessingStep;
|
||||
|
||||
/**
|
||||
* Verify step for DSpace. Processes the user response to the
|
||||
* information they are presented with on the Review/Verify page.
|
||||
* <P>
|
||||
* This class performs all the behind-the-scenes processing that
|
||||
* this particular step requires. This class's methods are utilized
|
||||
* by both the JSP-UI and the Manakin XML-UI
|
||||
*
|
||||
* @see org.dspace.app.util.SubmissionConfig
|
||||
* @see org.dspace.app.util.SubmissionStepConfig
|
||||
* @see org.dspace.submit.AbstractProcessingStep
|
||||
*
|
||||
* @author Tim Donohue
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class VerifyStep extends AbstractProcessingStep
|
||||
{
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(VerifyStep.class);
|
||||
|
||||
/**
|
||||
* Do any processing of the information input by the user, and/or perform
|
||||
* step processing (if no user interaction required)
|
||||
* <P>
|
||||
* It is this method's job to save any data to the underlying database, as
|
||||
* necessary, and return error messages (if any) which can then be processed
|
||||
* by the appropriate user interface (JSP-UI or XML-UI)
|
||||
* <P>
|
||||
* NOTE: If this step is a non-interactive step (i.e. requires no UI), then
|
||||
* it should perform *all* of its processing in this method!
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
* @return Status or error flag which will be processed by
|
||||
* doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
public int doProcessing(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
// nothing to process/save from the Verify Step.
|
||||
return STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the number of pages that this "step" extends over. This method
|
||||
* is used to build the progress bar.
|
||||
* <P>
|
||||
* This method may just return 1 for most steps (since most steps consist of
|
||||
* a single page). But, it should return a number greater than 1 for any
|
||||
* "step" which spans across a number of HTML pages. For example, the
|
||||
* configurable "Describe" step (configured using input-forms.xml) overrides
|
||||
* this method to return the number of pages that are defined by its
|
||||
* configuration file.
|
||||
* <P>
|
||||
* Steps which are non-interactive (i.e. they do not display an interface to
|
||||
* the user) should return a value of 1, so that they are only processed
|
||||
* once!
|
||||
*
|
||||
* @param request
|
||||
* The HTTP Request
|
||||
* @param subInfo
|
||||
* The current submission information object
|
||||
*
|
||||
* @return the number of pages in this step
|
||||
*/
|
||||
public int getNumberOfPages(HttpServletRequest request,
|
||||
SubmissionInfo subInfo) throws ServletException
|
||||
{
|
||||
// always just one page for verify step
|
||||
return 1;
|
||||
}
|
||||
}
|
@@ -87,8 +87,8 @@ import org.dspace.storage.rdbms.TableRowIterator;
|
||||
* determined by looking at WorkflowItem.getState()
|
||||
*
|
||||
* When a submission is complete, the WorkflowItem pointing to the item is
|
||||
* destroyed and SubmitServlet.insertItem() is called, which hooks the item up
|
||||
* to the archive.
|
||||
* destroyed and the archive() method is called, which hooks the item up to the
|
||||
* archive.
|
||||
*
|
||||
* Notification: When an item enters a state that requires notification,
|
||||
* (WFSTATE_STEP1POOL, WFSTATE_STEP2POOL, WFSTATE_STEP3POOL,) the workflow needs
|
||||
@@ -326,8 +326,8 @@ public class WorkflowManager
|
||||
* approveAction() sends an item forward in the workflow (reviewers,
|
||||
* approvers, and editors all do an 'approve' to move the item forward) if
|
||||
* the item arrives at the submit state, then remove the WorkflowItem and
|
||||
* call SubmitServlet.insertItem() to put it in the archive, and email
|
||||
* notify the submitter of a successful submission
|
||||
* call the archive() method to put it in the archive, and email notify the
|
||||
* submitter of a successful submission
|
||||
*
|
||||
* @param c
|
||||
* Context
|
||||
@@ -736,9 +736,6 @@ public class WorkflowManager
|
||||
wi.setPublishedBefore(wfi.isPublishedBefore());
|
||||
wi.update();
|
||||
|
||||
// remove any licenses that the item may have been given
|
||||
myitem.removeLicenses();
|
||||
|
||||
//myitem.update();
|
||||
log.info(LogManager.getHeader(c, "return_to_workspace",
|
||||
"workflow_item_id=" + wfi.getID() + "workspace_item_id="
|
||||
|
@@ -2,6 +2,7 @@
|
||||
help.collection-admin = /help/collection-admin.html
|
||||
help.index = /help/index.html
|
||||
help.site-admin = /help/site-admin.html
|
||||
help.formats = /help/formats.jsp
|
||||
|
||||
itemlist.dc.contributor.* = Author(s)
|
||||
itemlist.dc.contributor.author = Author(s)
|
||||
@@ -735,6 +736,7 @@ jsp.submit.choose-file.info6 = Please also no
|
||||
jsp.submit.choose-file.info7 = Information about file types and levels of support for each are available.
|
||||
jsp.submit.choose-file.info9 = Please give a brief description of the contents of this file, for example "Main article", or "Experiment data readings".
|
||||
jsp.submit.choose-file.title = Upload a File
|
||||
jsp.submit.choose-file.skip = Skip file upload >
|
||||
jsp.submit.complete.heading = Submit: Submission Complete!
|
||||
jsp.submit.complete.info = Your submission will now go through the workflow process designated for the collection to which you are submitting. You will receive e-mail notification as soon as your submission has become a part of the collection, or if for some reason there is a problem with your submission. You can also check on the status of your submission by going to the My DSpace page.
|
||||
jsp.submit.complete.link = Go to My DSpace
|
||||
@@ -838,6 +840,8 @@ jsp.submit.select-collection.heading = Submit: Choose
|
||||
jsp.submit.select-collection.info1 = Select the collection you wish to submit an item to from the list below, then click "Next".
|
||||
jsp.submit.select-collection.none-authorized = You are not authorized to submit to any collections
|
||||
jsp.submit.select-collection.title = Select Collection to Submit to
|
||||
jsp.submit.select-collection.no-collection = You must select a collection for this item.
|
||||
jsp.submit.select-collection.cancel = Cancel
|
||||
jsp.submit.show-license.grant.button = I Grant the License
|
||||
jsp.submit.show-license.heading1 = Submit: Grant DSpace Distribution License
|
||||
jsp.submit.show-license.info1 = <strong>There is one last step:</strong> In order for DSpace to reproduce, translate and distribute your submission worldwide, your agreement to the following terms is necessary. Please take a moment to read the terms of this license, and click on one of the buttons at the bottom of the page. By clicking on the "Grant License" button, you indicate that you grant the following terms of the license.
|
||||
|
Reference in New Issue
Block a user