| 1 |
|
package com.atlassian.xwork; |
| 2 |
|
|
| 3 |
|
import com.opensymphony.webwork.config.Configuration; |
| 4 |
|
import com.opensymphony.webwork.dispatcher.multipart.MultiPartRequest; |
| 5 |
|
import http.utils.multipartrequest.ServletMultipartRequest; |
| 6 |
|
|
| 7 |
|
import javax.servlet.http.HttpServletRequest; |
| 8 |
|
import java.io.File; |
| 9 |
|
import java.io.IOException; |
| 10 |
|
import java.io.UnsupportedEncodingException; |
| 11 |
|
import java.util.ArrayList; |
| 12 |
|
import java.util.Enumeration; |
| 13 |
|
import java.util.List; |
| 14 |
|
|
| 15 |
|
|
| 16 |
|
@link |
| 17 |
|
@link |
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
|
|
|
| 0% |
Uncovered Elements: 46 (46) |
Complexity: 16 |
Complexity Density: 0.57 |
|
| 22 |
|
public class PellMultiPartRequest extends MultiPartRequest |
| 23 |
|
{ |
| 24 |
|
|
| 25 |
|
|
| 26 |
|
private ServletMultipartRequest multi; |
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
@param |
| 35 |
|
@param |
| 36 |
|
@param |
| 37 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 38 |
0
|
public PellMultiPartRequest(HttpServletRequest servletRequest, String saveDir, int maxSize) throws IOException {... |
| 39 |
|
|
| 40 |
|
|
| 41 |
0
|
synchronized (this) { |
| 42 |
0
|
setEncoding(); |
| 43 |
0
|
multi = new ServletMultipartRequest(servletRequest, saveDir, maxSize); |
| 44 |
|
} |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 49 |
0
|
public Enumeration getFileParameterNames() {... |
| 50 |
0
|
return multi.getFileParameterNames(); |
| 51 |
|
} |
| 52 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 53 |
0
|
public String[] getContentType(String fieldName) {... |
| 54 |
0
|
return new String[]{multi.getContentType(fieldName)}; |
| 55 |
|
} |
| 56 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 57 |
0
|
public File[] getFile(String fieldName) {... |
| 58 |
0
|
return new File[]{multi.getFile(fieldName)}; |
| 59 |
|
} |
| 60 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 61 |
0
|
public String[] getFileNames(String fieldName) {... |
| 62 |
|
|
| 63 |
|
|
| 64 |
0
|
File file = multi.getFile(fieldName); |
| 65 |
0
|
if (file == null) |
| 66 |
0
|
return null; |
| 67 |
|
|
| 68 |
0
|
return new String[]{file.getName()}; |
| 69 |
|
} |
| 70 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 71 |
0
|
public String[] getFilesystemName(String fieldName) {... |
| 72 |
0
|
return new String[]{multi.getFileSystemName(fieldName)}; |
| 73 |
|
} |
| 74 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 75 |
0
|
public String getParameter(String name) {... |
| 76 |
0
|
return multi.getURLParameter(name); |
| 77 |
|
} |
| 78 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 79 |
0
|
public Enumeration getParameterNames() {... |
| 80 |
0
|
return multi.getParameterNames(); |
| 81 |
|
} |
| 82 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 83 |
0
|
public String[] getParameterValues(String name) {... |
| 84 |
0
|
Enumeration enumeration = multi.getURLParameters(name); |
| 85 |
|
|
| 86 |
0
|
if (!enumeration.hasMoreElements()) { |
| 87 |
0
|
return null; |
| 88 |
|
} |
| 89 |
|
|
| 90 |
0
|
List values = new ArrayList(); |
| 91 |
|
|
| 92 |
0
|
while (enumeration.hasMoreElements()) { |
| 93 |
0
|
values.add(enumeration.nextElement()); |
| 94 |
|
} |
| 95 |
|
|
| 96 |
0
|
return (String[]) values.toArray(new String[values.size()]); |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 106 |
0
|
private static void setEncoding() {... |
| 107 |
0
|
String encoding = null; |
| 108 |
|
|
| 109 |
0
|
try { |
| 110 |
0
|
encoding = Configuration.getString("webwork.i18n.encoding"); |
| 111 |
|
|
| 112 |
0
|
if (encoding != null) { |
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
0
|
http.utils.multipartrequest.MultipartRequest.setEncoding(encoding); |
| 117 |
|
} else { |
| 118 |
0
|
http.utils.multipartrequest.MultipartRequest.setEncoding("UTF-8"); |
| 119 |
|
} |
| 120 |
|
} catch (IllegalArgumentException e) { |
| 121 |
0
|
log.info("Could not get encoding property 'webwork.i18n.encoding' for file upload. Using system default"); |
| 122 |
|
} catch (UnsupportedEncodingException e) { |
| 123 |
0
|
log.error("Encoding " + encoding + " is not a valid encoding. Please check your webwork.properties file."); |
| 124 |
|
} |
| 125 |
|
} |
| 126 |
|
} |
| 127 |
|
|