mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
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/branches/dspace-1_5_x@2481 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -81,6 +81,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";
|
||||
|
||||
@@ -259,7 +262,7 @@ public class UploadStep extends AbstractProcessingStep
|
||||
// (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;
|
||||
@@ -317,8 +320,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");
|
||||
@@ -484,7 +487,7 @@ public class UploadStep extends AbstractProcessingStep
|
||||
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");
|
||||
|
@@ -402,6 +402,13 @@ public class SubmissionController extends DSpaceServlet
|
||||
//if this step is finished, continue to next step
|
||||
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
|
||||
subInfo = getSubmissionInfo(context, request);
|
||||
|
||||
|
@@ -225,6 +225,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
|
||||
@@ -232,9 +234,10 @@ public class JSPUploadStep extends UploadStep implements JSPStep
|
||||
new FileInputStream(temp));
|
||||
|
||||
filePath = wrapper.getFilesystemName("file");
|
||||
|
||||
// cleanup our temp file
|
||||
temp.delete();
|
||||
}
|
||||
// remove our temp file
|
||||
temp.delete();
|
||||
|
||||
//save file info to request (for UploadStep class)
|
||||
request.setAttribute("file-path", filePath);
|
||||
@@ -288,7 +291,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");
|
||||
@@ -300,9 +303,16 @@ public class JSPUploadStep extends UploadStep implements JSPStep
|
||||
showUploadFileList(context, request, response, subInfo, true,
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
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!
|
||||
// ------------------------------
|
||||
@@ -316,20 +326,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.getHandle()));
|
||||
//if file was just removed, go back to upload page
|
||||
showUploadPage(context, request, response, subInfo, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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.getHandle()));
|
||||
}
|
||||
JSPStepManager.showJSP(request, response, subInfo, UPLOAD_ERROR_JSP);
|
||||
}
|
||||
JSPStepManager.showJSP(request, response, subInfo, UPLOAD_ERROR_JSP);
|
||||
|
||||
}
|
||||
else if (status == STATUS_UNKNOWN_FORMAT)
|
||||
{
|
||||
@@ -339,7 +357,7 @@ public class JSPUploadStep extends UploadStep implements JSPStep
|
||||
showGetFileFormat(context, request, response, subInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// As long as there are no errors, clicking Next
|
||||
// should immediately send them to the next step
|
||||
if (status == STATUS_COMPLETE && buttonPressed.equals(NEXT_BUTTON))
|
||||
|
@@ -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> </td>
|
||||
<td align="right">
|
||||
<input type="submit" name="<%=AbstractProcessingStep.CANCEL_BUTTON%>" value="<fmt:message key="jsp.submit.general.cancel-or-save.button"/>" />
|
||||
|
@@ -74,7 +74,7 @@
|
||||
<%-- ====================================================== --%>
|
||||
|
||||
<tr>
|
||||
<td class="oddRowOddCol">
|
||||
<td class="evenRowOddCol">
|
||||
<table>
|
||||
<tr>
|
||||
<td width="100%">
|
||||
|
@@ -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>
|
||||
|
@@ -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 #####
|
||||
|
||||
|
@@ -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>
|
||||
|
||||
|
Reference in New Issue
Block a user