1 16 17 package org.springframework.web.portlet.multipart; 18 19 import java.util.Collections ; 20 import java.util.Enumeration ; 21 import java.util.HashMap ; 22 import java.util.HashSet ; 23 import java.util.Iterator ; 24 import java.util.Map ; 25 import java.util.Set ; 26 27 import javax.portlet.ActionRequest; 28 29 import org.springframework.web.multipart.MultipartFile; 30 import org.springframework.web.portlet.util.ActionRequestWrapper; 31 32 40 public class DefaultMultipartActionRequest extends ActionRequestWrapper implements MultipartActionRequest { 41 42 private Map multipartFiles; 43 44 private final Map multipartParameters; 45 46 47 54 public DefaultMultipartActionRequest(ActionRequest request, Map multipartFiles, Map multipartParameters) { 55 super(request); 56 this.multipartFiles = Collections.unmodifiableMap(multipartFiles); 57 this.multipartParameters = multipartParameters; 58 } 59 60 61 public Iterator getFileNames() { 62 return this.multipartFiles.keySet().iterator(); 63 } 64 65 public MultipartFile getFile(String name) { 66 return (MultipartFile) this.multipartFiles.get(name); 67 } 68 69 public Map getFileMap() { 70 return this.multipartFiles; 71 } 72 73 74 public Enumeration getParameterNames() { 75 Set paramNames = new HashSet (); 76 Enumeration paramEnum = super.getParameterNames(); 77 while (paramEnum.hasMoreElements()) { 78 paramNames.add(paramEnum.nextElement()); 79 } 80 paramNames.addAll(this.multipartParameters.keySet()); 81 return Collections.enumeration(paramNames); 82 } 83 84 public String getParameter(String name) { 85 String [] values = (String []) this.multipartParameters.get(name); 86 if (values != null) { 87 return (values.length > 0 ? values[0] : null); 88 } 89 return super.getParameter(name); 90 } 91 92 public String [] getParameterValues(String name) { 93 String [] values = (String []) this.multipartParameters.get(name); 94 if (values != null) { 95 return values; 96 } 97 return super.getParameterValues(name); 98 } 99 100 public Map getParameterMap() { 101 Map paramMap = new HashMap (); 102 paramMap.putAll(super.getParameterMap()); 103 paramMap.putAll(this.multipartParameters); 104 return paramMap; 105 } 106 107 } 108 | Popular Tags |