diff --git a/dspace-api/src/main/java/org/dspace/submit/step/UploadStep.java b/dspace-api/src/main/java/org/dspace/submit/step/UploadStep.java index 7ba2ab0d94..3b7cafd675 100644 --- a/dspace-api/src/main/java/org/dspace/submit/step/UploadStep.java +++ b/dspace-api/src/main/java/org/dspace/submit/step/UploadStep.java @@ -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"); diff --git a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/SubmissionController.java b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/SubmissionController.java index 7b43d4495a..cf1bf8edfb 100644 --- a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/SubmissionController.java +++ b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/SubmissionController.java @@ -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); diff --git a/dspace-jspui/src/main/java/org/dspace/app/webui/submit/step/JSPUploadStep.java b/dspace-jspui/src/main/java/org/dspace/app/webui/submit/step/JSPUploadStep.java index 8a52e45d6c..109044cc0d 100644 --- a/dspace-jspui/src/main/java/org/dspace/app/webui/submit/step/JSPUploadStep.java +++ b/dspace-jspui/src/main/java/org/dspace/app/webui/submit/step/JSPUploadStep.java @@ -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)) diff --git a/dspace-jspui/src/main/webapp/submit/choose-file.jsp b/dspace-jspui/src/main/webapp/submit/choose-file.jsp index 2136d616e5..b786188b2a 100644 --- a/dspace-jspui/src/main/webapp/submit/choose-file.jsp +++ b/dspace-jspui/src/main/webapp/submit/choose-file.jsp @@ -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 @@ <% } %>
diff --git a/dspace-jspui/src/main/webapp/submit/upload-error.jsp b/dspace-jspui/src/main/webapp/submit/upload-error.jsp
index b41c6c2f60..575594b784 100644
--- a/dspace-jspui/src/main/webapp/submit/upload-error.jsp
+++ b/dspace-jspui/src/main/webapp/submit/upload-error.jsp
@@ -96,7 +96,7 @@
<%-- HACK: - " /> + " /> 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 Configuring the File Upload step+ +The Upload step in the DSpace submission process has two configuration options
+ which can be set with your
Creating new Submission Steps |