throws ServletException, IOException, SQLException,
AuthorizeException
{
boolean formatKnown = true;
boolean fileOK = false;
BitstreamFormat bf = null;
Bitstream b = null;
//NOTE: File should already be uploaded.
//Manakin does this automatically via Cocoon.
//For JSP-UI, the SubmissionController.uploadFiles() does the actual upload
Enumeration attNames = request.getAttributeNames();
//loop through our request attributes
while(attNames.hasMoreElements())
{
String attr = (String) attNames.nextElement();
//if this ends with "-path", this attribute
//represents a newly uploaded file
if(attr.endsWith("-path"))
{
//strip off the -path to get the actual parameter
//that the file was uploaded as
String param = attr.replace("-path", "");
// Load the file's path and input stream and description
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");
if(fileDescription==null ||fileDescription.length()==0)
request.getParameter("description");
// if information wasn't passed by User Interface, we had a problem
// with the upload
if (filePath == null || fileInputStream == null)
return STATUS_UPLOAD_ERROR;
if (subInfo != null)
{
// Create the bitstream
Item item = subInfo.getSubmissionItem().getItem();
// do we already have a bundle?
Bundle[] bundles = item.getBundles("ORIGINAL");
if (bundles.length < 1)
{
// set bundle's name to ORIGINAL
b = item.createSingleBitstream(fileInputStream, "ORIGINAL");
}
else
{
// we have a bundle already, just add bitstream
b = bundles[0].createBitstream(fileInputStream);
}
// Strip all but the last filename. It would be nice
// to know which OS the file came from.
String noPath = filePath;
while (noPath.indexOf('/') > -1)
{
noPath = noPath.substring(noPath.indexOf('/') + 1);
}
while (noPath.indexOf('\\') > -1)
{
noPath = noPath.substring(noPath.indexOf('\\') + 1);
}
b.setName(noPath);
b.setSource(filePath);
b.setDescription(fileDescription);
// Identify the format
bf = FormatIdentifier.guessFormat(context, b);
b.setFormat(bf);
// Update to DB
b.update();
item.update();
if (bf == null || !bf.isInternal())
{
fileOK = true;
}
else
{