[DS-102] Submission without file possible with the skip upload functionality disabled

[DS-103] Use of the Progress bar button don't save the current page modification
[DS-104] Cancel/save button during edit of a workflow item doesn't work

git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@3625 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Andrea Bollini
2009-03-23 11:18:53 +00:00
parent e4a8bfff87
commit ef01a162c6
8 changed files with 280 additions and 128 deletions

View File

@@ -2164,6 +2164,35 @@ public class Item extends DSpaceObject
}
}
/**
* Check the bundle ORIGINAL to see if there are any uploaded files
*
* @param item
* @return true if there is a bundle named ORIGINAL with one or more
* bitstreams inside
* @throws SQLException
*/
public boolean hasUploadedFiles() throws SQLException
{
Bundle[] bundles = getBundles("ORIGINAL");
if (bundles.length == 0)
{
// if no ORIGINAL bundle,
// return false that there is no file!
return false;
}
else
{
Bitstream[] bitstreams = bundles[0].getBitstreams();
if (bitstreams.length == 0)
{
// no files in ORIGINAL bundle!
return false;
}
}
return true;
}
/**
* Get the collections this item is not in.
*

View File

@@ -268,10 +268,11 @@ public class DescribeStep extends AbstractProcessingStep
// Step 3:
// Check to see if any fields are missing
// Only check for required fields if user clicked the "next" button
// (or clicked progress bar)
// @TODO: It'd be better if we allowed them to click *backwards* in Progress bar, but not *forwards*
if (buttonPressed.equals(NEXT_BUTTON) || buttonPressed.startsWith(PROGRESS_BAR_PREFIX))
// Only check for required fields if user clicked the "next", the "previous" or the "progress bar" button
if (buttonPressed.equals(NEXT_BUTTON)
|| buttonPressed.startsWith(PROGRESS_BAR_PREFIX)
|| buttonPressed.equals(PREVIOUS_BUTTON)
|| buttonPressed.equals(CANCEL_BUTTON))
{
clearErrorFields(request);
for (int i = 0; i < inputs.length; i++)
@@ -864,5 +865,4 @@ public class DescribeStep extends AbstractProcessingStep
}
}
}

View File

@@ -119,6 +119,8 @@ public class UploadStep extends AbstractProcessingStep
/** log4j logger */
private static Logger log = Logger.getLogger(UploadStep.class);
/** is the upload required? */
private boolean fileRequired = ConfigurationManager.getBooleanProperty("webui.submit.upload.required", true);
/**
* Do any processing of the information input by the user, and/or perform
@@ -154,11 +156,37 @@ public class UploadStep extends AbstractProcessingStep
// get reference to item
Item item = subInfo.getSubmissionItem().getItem();
// -----------------------------------
// Step #0: Upload new files (if any)
// -----------------------------------
String contentType = request.getContentType();
// if multipart form, then we are uploading a file
if ((contentType != null)
&& (contentType.indexOf("multipart/form-data") != -1))
{
// This is a multipart request, so it's a file upload
// (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;
}
// if user pressed jump-to button in process bar,
// return success (so that jump will occur)
if (buttonPressed.startsWith(PROGRESS_BAR_PREFIX))
{
return STATUS_COMPLETE;
// check if a file is required to be uploaded
if (fileRequired && !item.hasUploadedFiles())
{
return STATUS_NO_FILES_ERROR;
}
else
{
return STATUS_COMPLETE;
}
}
// ---------------------------------------------
@@ -248,30 +276,8 @@ public class UploadStep extends AbstractProcessingStep
subInfo.setBitstream(null);
}
// -----------------------------------
// Step #3: Upload new files (if any)
// -----------------------------------
String contentType = request.getContentType();
if (buttonPressed.equalsIgnoreCase(SUBMIT_UPLOAD_BUTTON) || buttonPressed.equalsIgnoreCase(NEXT_BUTTON))
{
// if multipart form, then we are uploading a file
if ((contentType != null)
&& (contentType.indexOf("multipart/form-data") != -1))
{
// This is a multipart request, so it's a file upload
// (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;
}
}
// -------------------------------------------------
// Step #4: Check for a change in file description
// Step #3: Check for a change in file description
// -------------------------------------------------
String fileDescription = request.getParameter("description");
@@ -287,7 +293,7 @@ public class UploadStep extends AbstractProcessingStep
}
// ------------------------------------------
// Step #5: Check for a file format change
// Step #4: Check for a file format change
// (if user had to manually specify format)
// ------------------------------------------
int formatTypeID = Util.getIntParameter(request, "format");
@@ -307,7 +313,7 @@ public class UploadStep extends AbstractProcessingStep
}
// ---------------------------------------------------
// Step #6: Check if primary bitstream has changed
// Step #5: Check if primary bitstream has changed
// -------------------------------------------------
if (request.getParameter("primary_bitstream_id") != null)
{
@@ -318,29 +324,13 @@ public class UploadStep extends AbstractProcessingStep
}
// ---------------------------------------------------
// Step #7: Determine if there is an error because no
// Step #6: Determine if there is an error because no
// files have been uploaded.
// ---------------------------------------------------
//check if a file is required to be uploaded
boolean fileRequired = ConfigurationManager.getBooleanProperty("webui.submit.upload.required", true);
if (fileRequired)
if (fileRequired && !item.hasUploadedFiles())
{
Bundle[] bundles = item.getBundles("ORIGINAL");
if (bundles.length == 0)
{
// if no ORIGINAL bundle,
// throw an error that there is no file!
return STATUS_NO_FILES_ERROR;
}
else
{
Bitstream[] bitstreams = bundles[0].getBitstreams();
if (bitstreams.length == 0)
{
// no files in ORIGINAL bundle!
return STATUS_NO_FILES_ERROR;
}
}
return STATUS_NO_FILES_ERROR;
}
// commit all changes to database