mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
Merge pull request #1358 from tuub/DS-3136
DS-3136: Prevent the occurrence of internal server error while adding a bitstream to an item if the upload button is pressed without selecting a file
This commit is contained in:
@@ -1474,6 +1474,7 @@ jsp.tools.move-item.inheritpolicies = Inherit defaul
|
||||
jsp.tools.upload-bitstream.info = Select the bitstream to upload
|
||||
jsp.tools.upload-bitstream.title = Upload Bitstream
|
||||
jsp.tools.upload-bitstream.upload = Upload
|
||||
jsp.tools.upload-bitstream.select.file.msg = Please select a file first
|
||||
jsp.workspace.ws-error.errormsg1 = The system was unable to process your request correctly. You must specify an item.
|
||||
jsp.workspace.ws-error.errormsg2 = Go back to "My DSpace", and select "Open" for the WorkSpace Item that you wish to work with. If you are still experiencing problems please do not hesitate to contact us and we will do our best to solve the problem.
|
||||
jsp.workspace.ws-error.heading = Error - Workspace Item
|
||||
|
@@ -102,6 +102,9 @@ public class EditItemServlet extends DSpaceServlet
|
||||
|
||||
/** User confirms withdrawal of item */
|
||||
public static final int PUBLICIZE = 11;
|
||||
|
||||
/** JSP to upload bitstream */
|
||||
protected static final String UPLOAD_BITSTREAM_JSP = "/tools/upload-bitstream.jsp";
|
||||
|
||||
/** Logger */
|
||||
private static final Logger log = Logger.getLogger(EditCommunitiesServlet.class);
|
||||
@@ -832,7 +835,7 @@ public class EditItemServlet extends DSpaceServlet
|
||||
// Show upload bitstream page
|
||||
request.setAttribute("item", item);
|
||||
JSPManager
|
||||
.showJSP(request, response, "/tools/upload-bitstream.jsp");
|
||||
.showJSP(request, response, UPLOAD_BITSTREAM_JSP);
|
||||
}else
|
||||
if(button.equals("submit_update_order") || button.startsWith("submit_order_"))
|
||||
{
|
||||
@@ -908,7 +911,18 @@ public class EditItemServlet extends DSpaceServlet
|
||||
Bitstream b = null;
|
||||
Item item = itemService.find(context, UIUtil.getUUIDParameter(wrapper, "item_id"));
|
||||
File temp = wrapper.getFile("file");
|
||||
|
||||
|
||||
if(temp == null)
|
||||
{
|
||||
boolean noFileSelected = true;
|
||||
|
||||
// Show upload bitstream page
|
||||
request.setAttribute("noFileSelected", noFileSelected);
|
||||
request.setAttribute("item", item);
|
||||
JSPManager
|
||||
.showJSP(request, response, UPLOAD_BITSTREAM_JSP);
|
||||
return;
|
||||
}
|
||||
// Read the temp file as logo
|
||||
InputStream is = new BufferedInputStream(new FileInputStream(temp));
|
||||
|
||||
|
@@ -26,6 +26,8 @@
|
||||
<%
|
||||
Item item = (Item) request.getAttribute("item");
|
||||
request.setAttribute("LanguageSwitch", "hide");
|
||||
Boolean noFileSelected = (Boolean) request.getAttribute("noFileSelected");
|
||||
boolean isNoFileSelected = (noFileSelected == null ? false : noFileSelected.booleanValue());
|
||||
%>
|
||||
|
||||
<dspace:layout style="submission" titlekey="jsp.tools.upload-bitstream.title"
|
||||
@@ -39,8 +41,11 @@
|
||||
<h1><fmt:message key="jsp.tools.upload-bitstream.title"/></h1>
|
||||
|
||||
<%-- <p>Select the bitstream to upload</p> --%>
|
||||
<% if(isNoFileSelected){ %>
|
||||
<p class="alert alert-warning"><fmt:message key="jsp.tools.upload-bitstream.select.file.msg"/></p>
|
||||
<%} else {%>
|
||||
<p class="alert alert-info"><fmt:message key="jsp.tools.upload-bitstream.info"/></p>
|
||||
|
||||
<%}%>
|
||||
<form method="post" enctype="multipart/form-data" action="">
|
||||
<div class="container row">
|
||||
<input class="form-control" type="file" size="40" name="file"/>
|
||||
|
Reference in New Issue
Block a user