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 * */
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 * */
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
// files have been uploaded.
// ---------------------------------------------------
// if "submit_skip" is unspecified, then a file is required!
boolean allowEmptyItems = (request.getParameter("submit_skip") != null);
// if "submit_skip" button was not pressed, then a file is required!
boolean allowEmptyItems = (request.getParameter(SUBMIT_SKIP_BUTTON) != null);
if (!allowEmptyItems)
{
Bundle[] bundles = item.getBundles("ORIGINAL");

View File

@@ -224,6 +224,8 @@ public class JSPUploadStep extends UploadStep implements JSPStep
}
File temp = wrapper.getFile("file");
//if file exists and has a size greater than zero
if (temp != null && temp.length() > 0)
{
// Read the temp file into an inputstream
@@ -231,10 +233,8 @@ public class JSPUploadStep extends UploadStep implements JSPStep
new FileInputStream(temp));
filePath = wrapper.getFilesystemName("file");
}
if (temp != null)
{
// remove our temp file
// cleanup our temp file
temp.delete();
}
@@ -290,7 +290,7 @@ public class JSPUploadStep extends UploadStep implements JSPStep
String buttonPressed = UIUtil.getSubmitButton(request, NEXT_BUTTON);
// 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()
.getBundles("ORIGINAL");
@@ -305,6 +305,13 @@ public class JSPUploadStep extends UploadStep implements JSPStep
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!
// ------------------------------
@@ -318,20 +325,28 @@ public class JSPUploadStep extends UploadStep implements JSPStep
UIUtil.getRequestLogInfo(request)));
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!
// So, we need to show the file upload error page
if (subInfo != null)
//First, check if we just removed our uploaded file
if(buttonPressed.startsWith("submit_remove_"))
{
Collection c = subInfo.getSubmissionItem().getCollection();
DCInputsReader inputsReader = new DCInputsReader();
request.setAttribute("submission.inputs", inputsReader
.getInputs(c.getIdentifier().getCanonicalForm()));
//if file was just removed, go back to upload page
showUploadPage(context, request, response, subInfo, false);
}
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)
{

View File

@@ -47,6 +47,7 @@
<%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %>
<%@ page import="org.dspace.core.ConfigurationManager" %>
<%@ page import="org.dspace.core.Context" %>
<%@ page import="org.dspace.app.webui.servlet.SubmissionController" %>
<%@ page import="org.dspace.submit.AbstractProcessingStep" %>
@@ -66,6 +67,8 @@
//get submission information object
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);
%>
@@ -157,7 +160,19 @@
<% } %>
<td>
<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 align="right">
<input type="submit" name="<%=AbstractProcessingStep.CANCEL_BUTTON%>" value="<fmt:message key="jsp.submit.general.cancel-or-save.button"/>" />

View File

@@ -1,41 +1,41 @@
<%--
- review-init.jsp
-
- Version: $Revision$
-
- Date: $Date$
-
- Copyright (c) 2002, 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.
<%--
- review-init.jsp
-
- Version: $Revision$
-
- Date: $Date$
-
- Copyright (c) 2002, 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.
--%>
<%--
@@ -74,7 +74,7 @@
<%-- ====================================================== --%>
<tr>
<td class="oddRowOddCol">
<td class="evenRowOddCol">
<table>
<tr>
<td width="100%">
@@ -99,4 +99,4 @@
</tr>
</table>
</td>
</tr>
</tr>

View File

@@ -96,7 +96,7 @@
<%-- HACK: <center> tag needed for broken Netscape 4.78 behaviour --%>
<center>
<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>
</center>
</form>

View File

@@ -176,6 +176,9 @@ log.init.config = ${dspace.dir}/config/log4j.properties
# Where to put the logs (used in configuration only)
log.dir = ${dspace.dir}/log
##### Upload File settings #####
# Where to temporarily store uploaded files
upload.temp.dir = ${dspace.dir}/upload
@@ -183,6 +186,10 @@ upload.temp.dir = ${dspace.dir}/upload
# 512Mb
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 #####

View File

@@ -24,6 +24,7 @@
<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="#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>
</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>
<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>
<H2>Creating new Submission Steps</H2>