throws TurbineException
{
String contentType = req.getHeader(CONTENT_TYPE);
if (!contentType.startsWith(MULTIPART_FORM_DATA))
{
throw new TurbineException("the request doesn't contain a " +
MULTIPART_FORM_DATA + " stream");
}
int requestSize = req.getContentLength();
if (requestSize == -1)
{
throw new TurbineException("the request was rejected because " +
"it's size is unknown");
}
if (requestSize > getSizeMax())
{
throw new TurbineException("the request was rejected because " +
"it's size exceeds allowed range");
}
try
{
List fileList = fileUpload
.parseRequest(req,
getSizeThreshold(),
getSizeMax(),
path);
if (fileList != null)
{
for (Iterator it = fileList.iterator(); it.hasNext();)
{
FileItem fi = (FileItem) it.next();
if (fi.isFormField())
{
log.debug("Found an simple form field: " + fi.getFieldName() +", adding value " + fi.getString());
String value = null;
try
{
value = fi.getString(params.getCharacterEncoding());
}
catch (UnsupportedEncodingException e)
{
log.error(params.getCharacterEncoding()
+ " encoding is not supported."
+ "Used the default when reading form data.");
value = fi.getString();
}
params.append(fi.getFieldName(), value);
}
else
{
log.debug("Found an uploaded file: " + fi.getFieldName());
log.debug("It has " + fi.getSize() + " Bytes and is " + (fi.isInMemory() ? "" : "not ") + "in Memory");
log.debug("Adding FileItem as " + fi.getFieldName() + " to the params");
params.append(fi.getFieldName(), fi);
}
}
}
}
catch (FileUploadException e)
{
throw new TurbineException(e);
}
}