Revision 7092
Added by Chris Jones almost 13 years ago
src/edu/ucsb/nceas/metacat/restservice/D1ResourceHandler.java | ||
---|---|---|
257 | 257 |
return failure; |
258 | 258 |
|
259 | 259 |
} |
260 |
|
|
261 |
/** |
|
262 |
* Parse string parameters from the mime multipart entity of the request. |
|
263 |
* Populates the multipartparams map |
|
264 |
* |
|
265 |
* @throws IOException |
|
266 |
* @throws FileUploadException |
|
267 |
* @throws Exception |
|
268 |
*/ |
|
269 |
protected void collectMultipartParams() |
|
270 |
throws IOException, FileUploadException, Exception { |
|
271 |
|
|
272 |
File tmpDir = getTempDirectory(); |
|
273 |
MultipartRequest mr = null; |
|
274 |
|
|
275 |
// Read the incoming data from its Mime Multipart encoding |
|
276 |
logMetacat.debug("Parsing rights holder info from the mime multipart entity"); |
|
277 |
|
|
278 |
// handle MMP inputs |
|
279 |
MultipartRequestResolver mrr = |
|
280 |
new MultipartRequestResolver(tmpDir.getAbsolutePath(),1000000000, 0); |
|
281 |
|
|
282 |
mr = mrr.resolveMultipart(request); |
|
283 |
logMetacat.debug("Resolved the rights holder info from the mime multipart entity."); |
|
284 |
|
|
285 |
// we only have params in this MMP entity |
|
286 |
multipartparams = mr.getMultipartParameters(); |
|
287 |
|
|
288 |
} |
|
260 | 289 |
|
290 |
|
|
261 | 291 |
/** |
262 | 292 |
* Parse the replication policy document out of the mime-multipart form data |
263 | 293 |
* |
... | ... | |
552 | 582 |
|
553 | 583 |
/** |
554 | 584 |
* Process the MMP request that includes files for each param |
555 |
* @return map of param key and the tem pfile that contains the encoded information
|
|
585 |
* @return map of param key and the temp file that contains the encoded information
|
|
556 | 586 |
* @throws ServiceFailure |
557 | 587 |
* @throws InvalidRequest |
558 | 588 |
*/ |
... | ... | |
568 | 598 |
MultipartRequestResolver mrr = |
569 | 599 |
new MultipartRequestResolver(tmpDir.getAbsolutePath(), 1000000000, 0); |
570 | 600 |
MultipartRequest mr = null; |
571 |
try { |
|
572 |
mr = mrr.resolveMultipart(request); |
|
573 |
} catch (Exception e) { |
|
574 |
throw new ServiceFailure("1202", |
|
575 |
"Could not resolve multipart files: " + e.getMessage()); |
|
576 |
} |
|
601 |
try { |
|
602 |
mr = mrr.resolveMultipart(request); |
|
603 |
|
|
604 |
} catch (Exception e) { |
|
605 |
throw new ServiceFailure("1202", |
|
606 |
"Could not resolve multipart files: " + e.getMessage()); |
|
607 |
} |
|
577 | 608 |
logMetacat.debug("resolved multipart request"); |
578 | 609 |
Map<String, File> files = mr.getMultipartFiles(); |
579 | 610 |
if (files == null) { |
... | ... | |
588 | 619 |
|
589 | 620 |
multipartparams = mr.getMultipartParameters(); |
590 | 621 |
|
591 |
// for logging purposes, dump out the key-value pairs that constitute the request |
|
592 |
// 3 types exist: request params, multipart params, and multipart files |
|
622 |
// for logging purposes, dump out the key-value pairs that constitute the request
|
|
623 |
// 3 types exist: request params, multipart params, and multipart files
|
|
593 | 624 |
if (logMetacat.isDebugEnabled()) { |
594 | 625 |
Iterator<String> it = files.keySet().iterator(); |
595 | 626 |
logMetacat.debug("iterating through files"); |
Also available in: Unified diff
Add a collectMultipartParams() convenience method to D1ResourceHandler to parse multipart parameters from the entity when the entity contains no file parts.