01: /*
02: * Created on 04-May-2006
03: */
04: package uk.org.ponder.servletutil;
05:
06: import java.util.Map;
07:
08: import javax.servlet.http.HttpServletRequest;
09:
10: import org.springframework.web.multipart.MultipartException;
11: import org.springframework.web.multipart.MultipartResolver;
12:
13: import uk.org.ponder.springutil.MultipartResolverBean;
14:
15: /** A multipart file upload resolver suitable for use in a Servlet
16: * environment. Simply express a dependency, and make a call to
17: * "getMultipartMap" from within a suitable request context.
18: * @author Antranig Basman (amb26@ponder.org.uk)
19: *
20: */
21:
22: public class ServletMultipartResolverBean implements
23: MultipartResolverBean {
24: private HttpServletRequest request;
25: private MultipartResolver resolver;
26:
27: public void setHttpServletRequest(HttpServletRequest request) {
28: this .request = request;
29: }
30:
31: public void setMultipartResolver(MultipartResolver resolver) {
32: this .resolver = resolver;
33: }
34:
35: public Map getMultipartMap() throws MultipartException {
36: if (resolver.isMultipart(request)) {
37: return resolver.resolveMultipart(request).getFileMap();
38: } else
39: return null;
40: }
41: }
|