Revision 5418
Added by berkley over 14 years ago
test/edu/ucsb/nceas/metacat/dataone/CrudServiceTest.java | ||
---|---|---|
87 | 87 |
public static Test suite() |
88 | 88 |
{ |
89 | 89 |
TestSuite suite = new TestSuite(); |
90 |
suite.addTest(new CrudServiceTest("initialize")); |
|
90 |
/*suite.addTest(new CrudServiceTest("initialize"));
|
|
91 | 91 |
suite.addTest(new CrudServiceTest("testSingletonAccessor")); |
92 | 92 |
suite.addTest(new CrudServiceTest("testCreateAndGet")); |
93 | 93 |
suite.addTest(new CrudServiceTest("testGetSystemMetadata")); |
94 | 94 |
suite.addTest(new CrudServiceTest("testUpdate")); |
95 | 95 |
suite.addTest(new CrudServiceTest("testListObjects")); |
96 | 96 |
suite.addTest(new CrudServiceTest("testAccessControl")); |
97 |
suite.addTest(new CrudServiceTest("testGenerateMissingSystemMetadata")); |
|
97 |
suite.addTest(new CrudServiceTest("testGenerateMissingSystemMetadata"));*/
|
|
98 | 98 |
suite.addTest(new CrudServiceTest("testGetLogRecords")); |
99 |
suite.addTest(new CrudServiceTest("testChecksumError")); |
|
100 |
suite.addTest(new CrudServiceTest("testPublicAccess")); |
|
99 |
//suite.addTest(new CrudServiceTest("testChecksumError"));
|
|
100 |
//suite.addTest(new CrudServiceTest("testPublicAccess"));
|
|
101 | 101 |
return suite; |
102 | 102 |
} |
103 | 103 |
|
src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java | ||
---|---|---|
396 | 396 |
out = response.getOutputStream(); |
397 | 397 |
AuthToken token = new AuthToken(sessionId); |
398 | 398 |
String fromDateS = params.get("fromDate")[0]; |
399 |
System.out.println("param fromDateS: " + fromDateS); |
|
399 | 400 |
Date fromDate = null; |
400 | 401 |
String toDateS = params.get("toDate")[0]; |
402 |
System.out.println("param toDateS: " + toDateS); |
|
401 | 403 |
Date toDate = null; |
402 | 404 |
String eventS = params.get("event")[0]; |
403 | 405 |
Event event = null; |
404 | 406 |
SimpleDateFormat sdf = new SimpleDateFormat(); |
405 | 407 |
if(fromDateS != null) |
406 | 408 |
{ |
407 |
//fromDate = new Date(new Long(fromDateS).longValue());//sdf.parse(fromDateS, new ParsePosition(0));
|
|
408 |
fromDate = dateFormat.parse(fromDateS); |
|
409 |
fromDate = CrudService.getInstance().parseDate(fromDateS);
|
|
410 |
//fromDate = dateFormat.parse(fromDateS);
|
|
409 | 411 |
} |
410 | 412 |
if(toDateS != null) |
411 | 413 |
{ |
412 |
//toDate = new Date(new Long(toDateS).longValue());//sdf.parse(toDateS, new ParsePosition(0));
|
|
413 |
toDate = dateFormat.parse(toDateS); |
|
414 |
toDate = CrudService.getInstance().parseDate(toDateS);
|
|
415 |
//toDate = dateFormat.parse(toDateS);
|
|
414 | 416 |
} |
415 | 417 |
if(eventS != null) |
416 | 418 |
{ |
417 | 419 |
event = Event.convert(eventS); |
418 | 420 |
} |
421 |
System.out.println("fromDate: " + fromDate + " toDate: " + toDate); |
|
419 | 422 |
|
423 |
System.out.println("calling crudservice.getLogRecords"); |
|
420 | 424 |
Log log = CrudService.getInstance().getLogRecords(token, fromDate, toDate, event); |
421 | 425 |
serializeServiceType(Log.class, log, out); |
422 | 426 |
} |
src/edu/ucsb/nceas/metacat/dataone/CrudService.java | ||
---|---|---|
770 | 770 |
EventLog el = EventLog.getInstance(); |
771 | 771 |
if(fromDate == null) |
772 | 772 |
{ |
773 |
System.out.println("setting fromdate from null"); |
|
773 | 774 |
fromDate = new Date(1); |
774 | 775 |
} |
775 | 776 |
if(toDate == null) |
776 | 777 |
{ |
778 |
System.out.println("setting todate from null"); |
|
777 | 779 |
toDate = new Date(); |
778 | 780 |
} |
781 |
|
|
782 |
System.out.println("fromDate: " + fromDate); |
|
783 |
System.out.println("toDate: " + toDate); |
|
784 |
|
|
779 | 785 |
String report = el.getReport(null, null, null, null, |
780 | 786 |
new java.sql.Timestamp(fromDate.getTime()), |
781 | 787 |
new java.sql.Timestamp(toDate.getTime())); |
782 | 788 |
|
789 |
//System.out.println("report: " + report); |
|
790 |
|
|
783 | 791 |
String logEntry = "<logEntry>"; |
784 | 792 |
String endLogEntry = "</logEntry>"; |
785 | 793 |
int startIndex = 0; |
... | ... | |
954 | 962 |
* @return |
955 | 963 |
* @throws Exception |
956 | 964 |
*/ |
957 |
private Date parseDate(String s)
|
|
965 |
public Date parseDate(String s)
|
|
958 | 966 |
throws Exception |
959 | 967 |
{ |
960 | 968 |
Date d = null; |
... | ... | |
982 | 990 |
seconds = time.substring(time.lastIndexOf(":") + 1, time.indexOf(".")); |
983 | 991 |
milliseconds = time.substring(time.indexOf(".") + 1, time.length()); |
984 | 992 |
} |
993 |
else |
|
994 |
{ |
|
995 |
seconds = time.substring(time.lastIndexOf(":") + 1, time.length()); |
|
996 |
} |
|
985 | 997 |
/*System.out.println("time: " + "hour: " + new Integer(hour).intValue() + |
986 | 998 |
" minute: " + new Integer(minute).intValue() + " seconds: " + |
987 | 999 |
new Integer(seconds).intValue() + " milli: " + |
988 | 1000 |
new Integer(milliseconds).intValue());*/ |
989 | 1001 |
|
990 | 1002 |
//d = DateFormat.getDateTimeInstance().parse(date + " " + time); |
991 |
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT-0"));
|
|
1003 |
Calendar c = Calendar.getInstance(/*TimeZone.getTimeZone("GMT-0")*/TimeZone.getDefault());
|
|
992 | 1004 |
c.set(new Integer(year).intValue(), new Integer(month).intValue() - 1, |
993 | 1005 |
new Integer(day).intValue(), new Integer(hour).intValue(), |
994 | 1006 |
new Integer(minute).intValue(), new Integer(seconds).intValue()); |
Also available in: Unified diff
fixed some bugs in time handling for listObjects and getLogRecords