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 @@ <% } %> " /> - + + <% + //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)) + { + %> + + " /> + + <% + } + %> +     " /> diff --git a/dspace-jspui/src/main/webapp/submit/review-init.jsp b/dspace-jspui/src/main/webapp/submit/review-init.jsp index c31d9102e5..f4b8532984 100644 --- a/dspace-jspui/src/main/webapp/submit/review-init.jsp +++ b/dspace-jspui/src/main/webapp/submit/review-init.jsp @@ -74,7 +74,7 @@ <%-- ====================================================== --%> - +
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:
tag needed for broken Netscape 4.78 behaviour --%>

- " /> + " />

diff --git a/dspace/config/dspace.cfg b/dspace/config/dspace.cfg index c9d7000f78..7f6ebca06f 100644 --- a/dspace/config/dspace.cfg +++ b/dspace/config/dspace.cfg @@ -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 ##### diff --git a/dspace/docs/submission.html b/dspace/docs/submission.html index 3f3b110a9b..0867c2f412 100644 --- a/dspace/docs/submission.html +++ b/dspace/docs/submission.html @@ -24,6 +24,7 @@
  • Reordering/Removing Submission Steps
  • Assigning a custom Submission Process to a Collection
  • Customizing the Metadata-entry pages
  • +
  • Configuring the File Upload step
  • Creating new Submission Steps
  • @@ -661,6 +662,18 @@

    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 dspace.log 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.

    + +

    Configuring the File Upload step

    + +

    The Upload step in the DSpace submission process has two configuration options + which can be set with your [dspace]/config/dspace.cfg configuration file. They are as follows:

    +
      +
    • upload.max - 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. +
      • Note: Increasing this value or setting to -1 does not 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.
      +
    • +
    • webui.submit.upload.required - Whether or not all users are required 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.
    • +
    +

    Creating new Submission Steps