Merging recent Config Submission changes from 1.5.x Branch into Trunk:

(From Jan 4)
Various bug fixes to JSP-UI file upload step:
Fixed NPE when no file selected to upload.  Fixed small bug in processing of upload-error.jsp (was not returning to file upload screen).  Fixed ability to enable *skipping* uploading a file during JSPUI submission (some of the code never made it into 1.5 codebase during my original Config Submission patch, so this feature was not working properly).

git-svn-id: http://scm.dspace.org/svn/repo/trunk@2493 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Tim Donohue
2008-01-08 19:45:52 +00:00
parent cec1b19e54
commit 50cbccfd26
8 changed files with 1411 additions and 1351 deletions

View File

@@ -88,6 +88,9 @@ public class UploadStep extends AbstractProcessingStep
/** Button to upload a file * */ /** Button to upload a file * */
public static final String SUBMIT_UPLOAD_BUTTON = "submit_upload"; public static final String SUBMIT_UPLOAD_BUTTON = "submit_upload";
/** Button to skip uploading a file * */
public static final String SUBMIT_SKIP_BUTTON = "submit_skip";
/** Button to submit more files * */ /** Button to submit more files * */
public static final String SUBMIT_MORE_BUTTON = "submit_more"; public static final String SUBMIT_MORE_BUTTON = "submit_more";
@@ -326,8 +329,8 @@ public class UploadStep extends AbstractProcessingStep
// Step #7: Determine if there is an error because no // Step #7: Determine if there is an error because no
// files have been uploaded. // files have been uploaded.
// --------------------------------------------------- // ---------------------------------------------------
// if "submit_skip" is unspecified, then a file is required! // if "submit_skip" button was not pressed, then a file is required!
boolean allowEmptyItems = (request.getParameter("submit_skip") != null); boolean allowEmptyItems = (request.getParameter(SUBMIT_SKIP_BUTTON) != null);
if (!allowEmptyItems) if (!allowEmptyItems)
{ {
Bundle[] bundles = item.getBundles("ORIGINAL"); Bundle[] bundles = item.getBundles("ORIGINAL");

View File

@@ -402,6 +402,13 @@ public class SubmissionController extends DSpaceServlet
//if this step is finished, continue to next step //if this step is finished, continue to next step
if(stepFinished) if(stepFinished)
{ {
// If we finished up an upload, then we need to change
// the FileUploadRequest object back to a normal HTTPServletRequest
if(request instanceof FileUploadRequest)
{
request = ((FileUploadRequest)request).getOriginalRequest();
}
//retrieve any changes to the SubmissionInfo object //retrieve any changes to the SubmissionInfo object
subInfo = getSubmissionInfo(context, request); subInfo = getSubmissionInfo(context, request);

View File

@@ -224,6 +224,8 @@ public class JSPUploadStep extends UploadStep implements JSPStep
} }
File temp = wrapper.getFile("file"); File temp = wrapper.getFile("file");
//if file exists and has a size greater than zero
if (temp != null && temp.length() > 0) if (temp != null && temp.length() > 0)
{ {
// Read the temp file into an inputstream // Read the temp file into an inputstream
@@ -231,10 +233,8 @@ public class JSPUploadStep extends UploadStep implements JSPStep
new FileInputStream(temp)); new FileInputStream(temp));
filePath = wrapper.getFilesystemName("file"); filePath = wrapper.getFilesystemName("file");
}
if (temp != null) // cleanup our temp file
{
// remove our temp file
temp.delete(); temp.delete();
} }
@@ -290,7 +290,7 @@ public class JSPUploadStep extends UploadStep implements JSPStep
String buttonPressed = UIUtil.getSubmitButton(request, NEXT_BUTTON); String buttonPressed = UIUtil.getSubmitButton(request, NEXT_BUTTON);
// Do we need to skip the upload entirely? // Do we need to skip the upload entirely?
if (request.getParameter("submit_skip") != null) if (buttonPressed.equalsIgnoreCase(SUBMIT_SKIP_BUTTON))
{ {
Bundle[] bundles = subInfo.getSubmissionItem().getItem() Bundle[] bundles = subInfo.getSubmissionItem().getItem()
.getBundles("ORIGINAL"); .getBundles("ORIGINAL");
@@ -305,6 +305,13 @@ public class JSPUploadStep extends UploadStep implements JSPStep
return; // return immediately, since we are skipping upload return; // return immediately, since we are skipping upload
} }
//If upload failed in JSPUI (just came from upload-error.jsp), user can retry the upload
if(buttonPressed.equalsIgnoreCase("submit_retry"))
{
showUploadPage(context, request, response, subInfo, false);
}
// ------------------------------ // ------------------------------
// Check for Errors! // Check for Errors!
// ------------------------------ // ------------------------------
@@ -318,20 +325,28 @@ public class JSPUploadStep extends UploadStep implements JSPStep
UIUtil.getRequestLogInfo(request))); UIUtil.getRequestLogInfo(request)));
JSPManager.showIntegrityError(request, response); JSPManager.showIntegrityError(request, response);
} }
else if (status == STATUS_UPLOAD_ERROR) else if (status == STATUS_UPLOAD_ERROR || status == STATUS_NO_FILES_ERROR)
{ {
// There was a problem uploading the file! // There was a problem uploading the file!
// So, we need to show the file upload error page //First, check if we just removed our uploaded file
if (subInfo != null) if(buttonPressed.startsWith("submit_remove_"))
{ {
Collection c = subInfo.getSubmissionItem().getCollection(); //if file was just removed, go back to upload page
DCInputsReader inputsReader = new DCInputsReader(); showUploadPage(context, request, response, subInfo, false);
request.setAttribute("submission.inputs", inputsReader }
.getInputs(c.getIdentifier().getCanonicalForm())); else
{
// So, we need to show the file upload error page
if (subInfo != null)
{
Collection c = subInfo.getSubmissionItem().getCollection();
DCInputsReader inputsReader = new DCInputsReader();
request.setAttribute("submission.inputs", inputsReader
.getInputs(c.getIdentifier().getCanonicalForm()));
}
JSPStepManager.showJSP(request, response, subInfo, UPLOAD_ERROR_JSP);
} }
JSPStepManager.showJSP(request, response, subInfo, UPLOAD_ERROR_JSP);
} }
else if (status == STATUS_UNKNOWN_FORMAT) else if (status == STATUS_UNKNOWN_FORMAT)
{ {

View File

@@ -47,6 +47,7 @@
<%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %> <%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %>
<%@ page import="org.dspace.core.ConfigurationManager" %>
<%@ page import="org.dspace.core.Context" %> <%@ page import="org.dspace.core.Context" %>
<%@ page import="org.dspace.app.webui.servlet.SubmissionController" %> <%@ page import="org.dspace.app.webui.servlet.SubmissionController" %>
<%@ page import="org.dspace.submit.AbstractProcessingStep" %> <%@ page import="org.dspace.submit.AbstractProcessingStep" %>
@@ -66,6 +67,8 @@
//get submission information object //get submission information object
SubmissionInfo subInfo = SubmissionController.getSubmissionInfo(context, request); SubmissionInfo subInfo = SubmissionController.getSubmissionInfo(context, request);
// Determine whether a file is REQUIRED to be uploaded (default to true)
boolean fileRequired = ConfigurationManager.getBooleanProperty("webui.submit.upload.required", true);
%> %>
@@ -158,6 +161,18 @@
<td> <td>
<input type="submit" name="<%=UploadStep.SUBMIT_UPLOAD_BUTTON%>" value="<fmt:message key="jsp.submit.general.next"/>" /> <input type="submit" name="<%=UploadStep.SUBMIT_UPLOAD_BUTTON%>" value="<fmt:message key="jsp.submit.general.next"/>" />
</td> </td>
<%
//if upload is set to optional, or user returned to this page after pressing "Add Another File" button
if (!fileRequired || UIUtil.getSubmitButton(request, "").equals(UploadStep.SUBMIT_MORE_BUTTON))
{
%>
<td>
<input type="submit" name="<%=UploadStep.SUBMIT_SKIP_BUTTON%>" value="<fmt:message key="jsp.submit.choose-file.skip"/>" />
</td>
<%
}
%>
<td>&nbsp;&nbsp;&nbsp;</td> <td>&nbsp;&nbsp;&nbsp;</td>
<td align="right"> <td align="right">
<input type="submit" name="<%=AbstractProcessingStep.CANCEL_BUTTON%>" value="<fmt:message key="jsp.submit.general.cancel-or-save.button"/>" /> <input type="submit" name="<%=AbstractProcessingStep.CANCEL_BUTTON%>" value="<fmt:message key="jsp.submit.general.cancel-or-save.button"/>" />

View File

@@ -74,7 +74,7 @@
<%-- ====================================================== --%> <%-- ====================================================== --%>
<tr> <tr>
<td class="oddRowOddCol"> <td class="evenRowOddCol">
<table> <table>
<tr> <tr>
<td width="100%"> <td width="100%">

View File

@@ -96,7 +96,7 @@
<%-- HACK: <center> tag needed for broken Netscape 4.78 behaviour --%> <%-- HACK: <center> tag needed for broken Netscape 4.78 behaviour --%>
<center> <center>
<p> <p>
<input type="submit" name="submit" value="<fmt:message key="jsp.submit.upload-error.retry.button"/>" /> <input type="submit" name="submit_retry" value="<fmt:message key="jsp.submit.upload-error.retry.button"/>" />
</p> </p>
</center> </center>
</form> </form>

View File

@@ -176,6 +176,9 @@ log.init.config = ${dspace.dir}/config/log4j.properties
# Where to put the logs (used in configuration only) # Where to put the logs (used in configuration only)
log.dir = ${dspace.dir}/log log.dir = ${dspace.dir}/log
##### Upload File settings #####
# Where to temporarily store uploaded files # Where to temporarily store uploaded files
upload.temp.dir = ${dspace.dir}/upload upload.temp.dir = ${dspace.dir}/upload
@@ -183,6 +186,10 @@ upload.temp.dir = ${dspace.dir}/upload
# 512Mb # 512Mb
upload.max = 536870912 upload.max = 536870912
# Whether or not we REQUIRE that a file be uploaded
# during the 'Upload' step in the submission process
# Defaults to true; If set to 'false', submitter has option to skip upload
#webui.submit.upload.required = true
##### Search settings ##### ##### Search settings #####

View File

@@ -24,6 +24,7 @@
<li><a href="#stepOrdering">Reordering/Removing Submission Steps</a></li> <li><a href="#stepOrdering">Reordering/Removing Submission Steps</a></li>
<li><a href="#collectionSubmission">Assigning a custom Submission Process to a Collection</a></li> <li><a href="#collectionSubmission">Assigning a custom Submission Process to a Collection</a></li>
<li><a href="#metadataEntry">Customizing the Metadata-entry pages</a></li> <li><a href="#metadataEntry">Customizing the Metadata-entry pages</a></li>
<li><a href="#uploadStep">Configuring the File Upload step</a></li>
<li><a href="#createStep">Creating new Submission Steps</a></li> <li><a href="#createStep">Creating new Submission Steps</a></li>
</ul> </ul>
@@ -661,6 +662,18 @@
<P>Any mistake in the syntax or semantics of the form definitions, such as poorly formed XML or a reference to a nonexistent field name, will cause a fatal error in the DSpace UI. The exception message (at the top of the stack trace in the <CODE>dspace.log</CODE> file) usually has a concise and helpful explanation of what went wrong. Don't forget to stop and restart the servlet container before testing your fix to a bug.</P> <P>Any mistake in the syntax or semantics of the form definitions, such as poorly formed XML or a reference to a nonexistent field name, will cause a fatal error in the DSpace UI. The exception message (at the top of the stack trace in the <CODE>dspace.log</CODE> file) usually has a concise and helpful explanation of what went wrong. Don't forget to stop and restart the servlet container before testing your fix to a bug.</P>
<a name="uploadStep" id="uploadStep"></a>
<H2>Configuring the File Upload step</H2>
<P>The <em>Upload</em> step in the DSpace submission process has two configuration options
which can be set with your <code>[dspace]/config/dspace.cfg</code> configuration file. They are as follows:</P>
<UL>
<LI><code>upload.max</code> - The maximum size of a file (in bytes) that can be uploaded from the JSP-UI (not applicable for the XML-UI). It defaults to 536870912 bytes (512MB). You may set this to -1 to disable any file size limitation.
<UL><LI><em>Note:</em> Increasing this value or setting to -1 does <strong>not</strong> guarantee that DSpace will be able to successfully upload larger files via the web, as large uploads depend on many other factors including bandwidth, web server settings, internet connection speed, etc.</LI></UL>
</LI>
<LI><code>webui.submit.upload.required</code> - Whether or not all users are <em>required</em> to upload a file when they submit an item to DSpace. It defaults to 'true'. When set to 'false' users will see an option to skip the upload step when they submit a new item.</LI>
</UL>
<a name="createStep" id="createStep"></a> <a name="createStep" id="createStep"></a>
<H2>Creating new Submission Steps</H2> <H2>Creating new Submission Steps</H2>