Revision 5427
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 |
suite.addTest(new CrudServiceTest("testUpdate")); |
|
94 |
suite.addTest(new CrudServiceTest("testUpdate"));*/
|
|
95 | 95 |
suite.addTest(new CrudServiceTest("testListObjects")); |
96 |
suite.addTest(new CrudServiceTest("testAccessControl")); |
|
96 |
/*suite.addTest(new CrudServiceTest("testAccessControl"));
|
|
97 | 97 |
suite.addTest(new CrudServiceTest("testGenerateMissingSystemMetadata")); |
98 | 98 |
suite.addTest(new CrudServiceTest("testGetLogRecords")); |
99 | 99 |
suite.addTest(new CrudServiceTest("testChecksumError")); |
100 |
suite.addTest(new CrudServiceTest("testPublicAccess")); |
|
100 |
suite.addTest(new CrudServiceTest("testPublicAccess"));*/
|
|
101 | 101 |
return suite; |
102 | 102 |
} |
103 | 103 |
|
... | ... | |
137 | 137 |
{ |
138 | 138 |
|
139 | 139 |
} |
140 |
|
|
141 |
//create a legit doc |
|
142 |
token = getToken(); |
|
143 |
Identifier id = new Identifier(); |
|
144 |
String docid = generateDocumentId(); |
|
145 |
id.setValue(docid); |
|
146 |
String testDoc = getTestDoc(); |
|
147 |
StringBufferInputStream sbis = new StringBufferInputStream(testDoc); |
|
148 |
ObjectFormat of1 = ObjectFormat.convert("eml://ecoinformatics.org/eml-2.1.0"); |
|
149 |
SystemMetadata sm = createSystemMetadata(id, testDoc, of1); |
|
150 |
assertFalse(sm.getChecksum().getValue().startsWith("MD5")); |
|
151 |
//create the doc |
|
152 |
Identifier idC = cs.create(token, id, sbis, sm); |
|
153 |
//make it public, then use a public token to try to get it |
|
154 |
InputStream data = null; |
|
155 |
try |
|
156 |
{ |
|
157 |
AuthToken publicToken = new AuthToken("public"); |
|
158 |
data = cs.get(publicToken, id); |
|
159 |
fail("should have thrown an exception"); |
|
160 |
} |
|
161 |
catch(Exception e) |
|
162 |
{ |
|
163 |
data.close(); |
|
164 |
|
|
165 |
} |
|
166 |
makeDocPublic(token, id, true); |
|
167 |
token = new AuthToken("public"); |
|
168 |
data = cs.get(token, id); |
|
140 | 169 |
} |
141 | 170 |
catch(Exception e) |
142 | 171 |
{ |
... | ... | |
709 | 738 |
throws Exception |
710 | 739 |
{ |
711 | 740 |
CrudService cs = CrudService.getInstance(); |
712 |
IdentifierManager im = IdentifierManager.getInstance(); |
|
713 | 741 |
cs.setAccess(token, id, "public", "read", "allow", "allowFirst", systemMetadataToo); |
714 | 742 |
} |
715 | 743 |
|
src/edu/ucsb/nceas/metacat/dataone/CrudService.java | ||
---|---|---|
472 | 472 |
int totalAfterQuery = 0; |
473 | 473 |
try |
474 | 474 |
{ |
475 |
|
|
475 | 476 |
params.clear(); |
476 | 477 |
params.put("returndoctype", new String[] {"http://dataone.org/service/types/SystemMetadata/0.1"}); |
477 | 478 |
params.put("qformat", new String[] {"xml"}); |
... | ... | |
542 | 543 |
System.out.println("dateSysMetadataModified: " + dateSysMetadataModified); |
543 | 544 |
System.out.println("startTime: " + startTime); |
544 | 545 |
System.out.println("endtime: " + endTime);*/ |
546 |
|
|
545 | 547 |
int startDateComparison = 0; |
546 | 548 |
int endDateComparison = 0; |
547 | 549 |
if(startTime != null) |
548 | 550 |
{ |
551 |
Calendar zTime = Calendar.getInstance(TimeZone.getTimeZone("GMT-0")); |
|
552 |
zTime.setTime(startTime); |
|
553 |
startTime = zTime.getTime(); |
|
554 |
|
|
549 | 555 |
if(dateSysMetadataModified == null) |
550 | 556 |
{ |
551 | 557 |
startDateComparison = -1; |
... | ... | |
563 | 569 |
|
564 | 570 |
if(endTime != null) |
565 | 571 |
{ |
572 |
Calendar zTime = Calendar.getInstance(TimeZone.getTimeZone("GMT-0")); |
|
573 |
zTime.setTime(endTime); |
|
574 |
endTime = zTime.getTime(); |
|
575 |
|
|
566 | 576 |
if(dateSysMetadataModified == null) |
567 | 577 |
{ |
568 | 578 |
endDateComparison = 1; |
... | ... | |
761 | 771 |
return "Completed"; |
762 | 772 |
} |
763 | 773 |
}; |
764 |
|
|
774 |
System.out.println("1"); |
|
765 | 775 |
String username = sessionData.getUserName(); |
766 | 776 |
EventLog.getInstance().log(metacatUrl, |
767 | 777 |
username, im.getLocalId(guid.getValue()), "read"); |
Also available in: Unified diff
changed date comparison to compare to gmt only