1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.blossom.multipart; |
35 |
|
|
36 |
|
import java.util.LinkedHashMap; |
37 |
|
import java.util.Map; |
38 |
|
import javax.servlet.http.HttpServletRequest; |
39 |
|
|
40 |
|
import org.slf4j.Logger; |
41 |
|
import org.slf4j.LoggerFactory; |
42 |
|
import org.springframework.http.HttpHeaders; |
43 |
|
import org.springframework.util.Assert; |
44 |
|
import org.springframework.web.multipart.MultipartFile; |
45 |
|
|
46 |
|
import info.magnolia.cms.beans.runtime.Document; |
47 |
|
import info.magnolia.cms.beans.runtime.MultipartForm; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
@see |
55 |
|
@see |
56 |
|
@since |
57 |
|
|
|
|
| 39.3% |
Uncovered Elements: 17 (28) |
Complexity: 7 |
Complexity Density: 0.35 |
|
58 |
|
public class BlossomMultipartRequestWrapper extends CompatibleAbstractMultipartHttpServletRequest { |
59 |
|
|
60 |
|
private static final String CONTENT_TYPE = "Content-Type"; |
61 |
|
|
62 |
|
private static final Logger log = LoggerFactory.getLogger(BlossomMultipartRequestWrapper.class); |
63 |
|
|
64 |
|
private MultipartForm multipartForm; |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
66 |
1 |
public BlossomMultipartRequestWrapper(HttpServletRequest request) {... |
67 |
1 |
super(request); |
68 |
|
|
69 |
1 |
multipartForm = (MultipartForm) request.getAttribute(MultipartForm.REQUEST_ATTRIBUTE_NAME); |
70 |
|
|
71 |
|
|
72 |
1 |
Assert.notNull(multipartForm, "Request is not multipart or not already parsed"); |
73 |
|
} |
74 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
75 |
1 |
@Override... |
76 |
|
protected void initializeMultipart() { |
77 |
1 |
Map<String, MultipartFile> multipartFiles = new LinkedHashMap<String, MultipartFile>(); |
78 |
1 |
for (Object o : multipartForm.getDocuments().entrySet()) { |
79 |
1 |
Map.Entry entry = (Map.Entry) o; |
80 |
1 |
multipartFiles.put((String) entry.getKey(), new BlossomMultipartFile((Document) entry.getValue())); |
81 |
|
} |
82 |
1 |
try { |
83 |
1 |
setSingleValueMultipartFiles(multipartFiles); |
84 |
|
} catch (Exception e) { |
85 |
0 |
log.error("Unable to initialize multipart request wrapper.", e); |
86 |
|
} |
87 |
|
} |
88 |
|
|
89 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
90 |
0 |
public HttpHeaders getMultipartHeaders(String paramOrFileName) {... |
91 |
0 |
String contentType = getMultipartContentType(paramOrFileName); |
92 |
0 |
if (contentType == null) { |
93 |
0 |
return null; |
94 |
|
} |
95 |
0 |
HttpHeaders headers = new HttpHeaders(); |
96 |
0 |
headers.add(CONTENT_TYPE, contentType); |
97 |
0 |
return headers; |
98 |
|
} |
99 |
|
|
100 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
101 |
0 |
public String getMultipartContentType(String paramOrFileName) {... |
102 |
0 |
MultipartFile file = getFile(paramOrFileName); |
103 |
0 |
if (file == null) { |
104 |
0 |
return null; |
105 |
|
} |
106 |
0 |
return file.getContentType(); |
107 |
|
} |
108 |
|
} |