Revision 5395
Added by berkley over 14 years ago
src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java | ||
---|---|---|
391 | 391 |
OutputStream out = null; |
392 | 392 |
try |
393 | 393 |
{ |
394 |
System.out.println("getting logs."); |
|
395 | 394 |
out = response.getOutputStream(); |
396 | 395 |
AuthToken token = new AuthToken(sessionId); |
397 | 396 |
String fromDateS = params.get("fromDate")[0]; |
... | ... | |
403 | 402 |
SimpleDateFormat sdf = new SimpleDateFormat(); |
404 | 403 |
if(fromDateS != null) |
405 | 404 |
{ |
406 |
System.out.println("fromDate: " + fromDateS); |
|
407 | 405 |
fromDate = new Date(new Long(fromDateS).longValue());//sdf.parse(fromDateS, new ParsePosition(0)); |
408 | 406 |
} |
409 | 407 |
if(toDateS != null) |
410 | 408 |
{ |
411 |
System.out.println("toDate: " + toDateS); |
|
412 | 409 |
toDate = new Date(new Long(toDateS).longValue());//sdf.parse(toDateS, new ParsePosition(0)); |
413 | 410 |
} |
414 | 411 |
if(eventS != null) |
415 | 412 |
{ |
416 |
System.out.println("event: " + eventS); |
|
417 | 413 |
event = Event.convert(eventS); |
418 | 414 |
} |
419 |
System.out.println("calling CrudService.getLogRecords"); |
|
420 |
System.out.println("fromDate: " + fromDate); |
|
421 |
System.out.println("toDate: " + toDate); |
|
422 |
System.out.println("event: " + event); |
|
415 |
|
|
423 | 416 |
Log log = CrudService.getInstance().getLogRecords(token, fromDate, toDate, event); |
424 |
System.out.println("done with CrudService."); |
|
425 | 417 |
serializeServiceType(Log.class, log, out); |
426 |
System.out.println("Done serializing output."); |
|
427 | 418 |
} |
428 | 419 |
catch(Exception e) |
429 | 420 |
{ |
... | ... | |
695 | 686 |
objectFormat, replicaStatus, start, count); |
696 | 687 |
ol = cs.listObjects(token, null, null, null, false, 0, 1000); |
697 | 688 |
|
698 |
StringReader sr = new StringReader(ol.toString()); |
|
699 |
System.out.println("ol: " + sr.toString()); |
|
700 |
//IOUtils.copy(sr, response.getOutputStream()); |
|
701 |
|
|
689 |
StringReader sr = new StringReader(ol.toString()); |
|
702 | 690 |
out = response.getOutputStream(); |
703 | 691 |
// Serialize and write it to the output stream |
704 | 692 |
try { |
... | ... | |
886 | 874 |
InputStream object = null; |
887 | 875 |
InputStream sysmeta = null; |
888 | 876 |
|
877 |
//HACK: Since mmp seems to have a bug where large object parts get truncated, |
|
878 |
//parse the stream here. This has the disavantage of putting the |
|
879 |
//stream into memory. |
|
889 | 880 |
String s = streamToString(request.getInputStream()); |
890 | 881 |
String searchString = "Content-Disposition: attachment; filename=systemmetadata"; |
891 | 882 |
String endString = "------=_Part"; |
... | ... | |
894 | 885 |
s.substring(searchStringIndex + |
895 | 886 |
searchString.length(), |
896 | 887 |
s.indexOf(endString, searchStringIndex)).trim().getBytes()); |
897 |
String txt = streamToString(sysmeta); |
|
898 |
System.out.println("sysmeta: " + txt); |
|
899 |
sysmeta = stringToStream(txt); |
|
900 | 888 |
|
901 | 889 |
searchString = "Content-Disposition: attachment; filename=object"; |
902 | 890 |
searchStringIndex = s.indexOf(searchString); |
... | ... | |
904 | 892 |
s.substring(searchStringIndex + |
905 | 893 |
searchString.length(), |
906 | 894 |
s.indexOf(endString, searchStringIndex)).trim().getBytes()); |
907 |
txt = streamToString(object); |
|
908 |
System.out.println("object: " + txt); |
|
909 |
sysmeta = stringToStream(txt); |
|
910 |
//System.out.println("request stream: " + s); |
|
911 |
//Since mmp seems to have a bug where large object parts get truncated, |
|
912 |
//parse the stream here. This has the disavantage of putting the |
|
913 |
//stream into memory. |
|
914 | 895 |
|
915 | 896 |
/* |
897 |
//This code should work, however there seems to be a bug in part.getInputStream() |
|
898 |
//where it does not return the entire stream. Only about the first 6kB |
|
899 |
//are actually returned. |
|
916 | 900 |
MimeMultipart mmp = new MimeMultipart(new InputStreamDataSource("message", request.getInputStream())); |
917 | 901 |
logMetacat.debug("MMP created."); |
918 | 902 |
|
Also available in: Unified diff
cleanup of 'fixed' ResourceHandler