NIHVIVO-160 make the map of FileItems available as an attribute as well as through a method call. That way, if the request is wrapped in a VitroRequest, the map is still accessible.
This commit is contained in:
parent
9237b7bd41
commit
cbda9a16cc
3 changed files with 13 additions and 1 deletions
|
@ -27,6 +27,14 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||||
* request parameters.
|
* request parameters.
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
|
* The request will have an attribute named by {@link #FILE_ITEM_MAP}. Either
|
||||||
|
* this attribute or the call to {@link #getFiles()} will produce a map that may
|
||||||
|
* be empty but is never null. The keys to the map are the field names for the
|
||||||
|
* file fields. Since a form may have multiple fields with the same name, each
|
||||||
|
* field name maps to a list of items. If a user does not provide a file to be
|
||||||
|
* uploaded in a given field, the length of the file will be 0.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
* Most methods are declared here, and simply delegate to the wrapped request.
|
* Most methods are declared here, and simply delegate to the wrapped request.
|
||||||
* Methods that have to do with parameters or files are handled differently for
|
* Methods that have to do with parameters or files are handled differently for
|
||||||
* simple requests and multipart request, and are implemented in the
|
* simple requests and multipart request, and are implemented in the
|
||||||
|
@ -35,6 +43,8 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public abstract class FileUploadServletRequest implements HttpServletRequest {
|
public abstract class FileUploadServletRequest implements HttpServletRequest {
|
||||||
|
public static final String FILE_ITEM_MAP = "file_item_map";
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// The factory method
|
// The factory method
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
|
@ -69,6 +69,7 @@ class MultipartHttpServletRequest extends FileUploadServletRequest {
|
||||||
LOG.debug("Parameters are: " + this.parameters);
|
LOG.debug("Parameters are: " + this.parameters);
|
||||||
this.files = Collections.unmodifiableMap(files);
|
this.files = Collections.unmodifiableMap(files);
|
||||||
LOG.debug("Files are: " + this.files);
|
LOG.debug("Files are: " + this.files);
|
||||||
|
request.setAttribute(FILE_ITEM_MAP, this.files);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,6 +20,7 @@ class SimpleHttpServletRequestWrapper extends FileUploadServletRequest {
|
||||||
|
|
||||||
SimpleHttpServletRequestWrapper(HttpServletRequest request) {
|
SimpleHttpServletRequestWrapper(HttpServletRequest request) {
|
||||||
super(request);
|
super(request);
|
||||||
|
request.setAttribute(FILE_ITEM_MAP, Collections.EMPTY_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
Loading…
Add table
Reference in a new issue