// we have to add it as a bitstream to the
// appropriate item (or to be specific its
// bundle). Instead of rewriting this code,
// we should use the same code, that's used for
// the "old" file upload (which is not using JS).
SubmissionInfo si = getSubmissionInfo(context, request);
UploadStep us = new UploadStep();
request.setAttribute(fileName + "-path", filePath);
request.setAttribute(fileName + "-inputstream", fileInputStream);
request.setAttribute(fileName + "-description", request.getParameter("description"));
int uploadResult = us.processUploadFile(context, request, response, si);
// cleanup our temporary file
if (!completedFile.delete())
{
log.error("Unable to delete temporary file " + filePath);
}
// We already assembled the complete file.
// In case of any error it won't help to
// reupload the last chunk. That makes the error
// handling realy easy:
if (uploadResult != UploadStep.STATUS_COMPLETE)
{
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
context.commit();
}
return;
}
}
}
catch (FileSizeLimitExceededException e)
{
log.warn("Upload exceeded upload.max");
if (ConfigurationManager.getBooleanProperty("webui.submit.upload.progressbar", true))
{
Gson gson = new Gson();
// old browser need to see this response as html to work
response.setContentType("text/html");
JSONUploadResponse jsonResponse = new JSONUploadResponse();
jsonResponse.addUploadFileSizeLimitExceeded(
e.getActualSize(), e.getPermittedSize());
response.getWriter().print(gson.toJson(jsonResponse));
response.flushBuffer();
}
else
{
JSPManager.showFileSizeLimitExceededError(request, response, e.getMessage(), e.getActualSize(), e.getPermittedSize());
}
return;
}
//also, upload any files and save their contents to Request (for later processing by UploadStep)
uploadFiles(context, request);
}
// Reload submission info from request parameters
SubmissionInfo subInfo = getSubmissionInfo(context, request);
// a submission info object is necessary to continue
if (subInfo == null)
{
// Work around for problem where people select "is a thesis", see
// the error page, and then use their "back" button thinking they
// can start another submission - it's been removed so the ID in the
// form is invalid. If we detect the "removed_thesis" attribute we
// display a friendly message instead of an integrity error.
if (request.getSession().getAttribute("removed_thesis") != null)
{
request.getSession().removeAttribute("removed_thesis");
JSPManager.showJSP(request, response,
"/submit/thesis-removed-workaround.jsp");
return;
}
else
{
// If the submission info was invalid, throw an integrity error
log.warn(LogManager.getHeader(context, "integrity_error",
UIUtil.getRequestLogInfo(request)));
JSPManager.showIntegrityError(request, response);
return;
}
}
// First, check for a click on "Cancel/Save" button.
if (UIUtil.getSubmitButton(request, "").equals(AbstractProcessingStep.CANCEL_BUTTON))
{
// Get the current step
currentStepConfig = getCurrentStepConfig(request, subInfo);
// forward user to JSP which will confirm
// the cancel/save request.
doCancelOrSave(context, request, response, subInfo,
currentStepConfig);
}
// Special case - no InProgressSubmission yet
// If no submission, we assume we will be going
// to the "select collection" step.
else if (subInfo.getSubmissionItem() == null)
{
// we have just started this submission
// (or we have just resumed a saved submission)
// do the "Select Collection" step