Revision 5387
Added by berkley over 14 years ago
test/edu/ucsb/nceas/metacat/dataone/CrudServiceTest.java | ||
---|---|---|
95 | 95 |
suite.addTest(new CrudServiceTest("testAccessControl")); |
96 | 96 |
suite.addTest(new CrudServiceTest("testGenerateMissingSystemMetadata")); |
97 | 97 |
suite.addTest(new CrudServiceTest("testGetLogRecords")); |
98 |
suite.addTest(new CrudServiceTest("testChecksumError")); |
|
98 | 99 |
return suite; |
99 | 100 |
} |
100 | 101 |
|
101 | 102 |
/** |
103 |
* test for an error where the checksum algorithm gets appended onto the checksum. |
|
104 |
*/ |
|
105 |
public void testChecksumError() |
|
106 |
{ |
|
107 |
printTestHeader("testChecksumError"); |
|
108 |
try |
|
109 |
{ |
|
110 |
Date d1 = new Date(); |
|
111 |
CrudService cs = CrudService.getInstance(); |
|
112 |
AuthToken token = getToken(); |
|
113 |
ObjectFormat of1 = ObjectFormat.convert("eml://ecoinformatics.org/eml-2.1.0"); |
|
114 |
//create docs at different times |
|
115 |
|
|
116 |
Identifier id = new Identifier(); |
|
117 |
String docid = generateDocumentId(); |
|
118 |
id.setValue(docid); |
|
119 |
|
|
120 |
//create the system metadata then run the create method |
|
121 |
String testDoc = getTestDoc(); |
|
122 |
StringBufferInputStream sbis = new StringBufferInputStream(testDoc); |
|
123 |
SystemMetadata sm = createSystemMetadata(id, testDoc, of1); |
|
124 |
assertFalse(sm.getChecksum().getValue().startsWith("MD5")); |
|
125 |
//create the doc |
|
126 |
Identifier idC = cs.create(token, id, sbis, sm); |
|
127 |
assertTrue(idC.getValue().equals(id.getValue())); |
|
128 |
SystemMetadata smC = getSystemMetadata(token, idC); |
|
129 |
assertFalse(smC.getChecksum().getValue().startsWith("MD5")); |
|
130 |
|
|
131 |
Date d2 = new Date(); |
|
132 |
ObjectList ol = cs.listObjects(token, d1, d2, of1); |
|
133 |
assertTrue(ol.sizeObjectInfoList() == 1); |
|
134 |
ObjectInfo oi = ol.getObjectInfo(0); |
|
135 |
//this will fail if the error state exists. |
|
136 |
assertFalse(oi.getChecksum().getValue().startsWith("MD5")); |
|
137 |
} |
|
138 |
catch(Exception e) |
|
139 |
{ |
|
140 |
fail("Unexpected exception: " + e.getMessage()); |
|
141 |
} |
|
142 |
|
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
102 | 146 |
* test CrudService.getLogRecords |
103 | 147 |
*/ |
104 | 148 |
public void testGetLogRecords() |
... | ... | |
253 | 297 |
|
254 | 298 |
ObjectList list = cs.listObjects(token, null, null, null); |
255 | 299 |
//System.out.println("list size: " + list.sizeObjectInfoList()); |
256 |
|
|
300 |
|
|
257 | 301 |
//should return sm1 and sm2 |
258 | 302 |
ObjectList list1 = cs.listObjects(token, d1, d3, null); |
259 | 303 |
assertTrue(list1.sizeObjectInfoList() == 2); |
260 | 304 |
assertTrue(idInObjectList(id1, list1)); |
261 | 305 |
assertTrue(idInObjectList(id2, list1)); |
262 | 306 |
|
307 |
ObjectInfo info = list1.getObjectInfo(0); |
|
308 |
|
|
309 |
|
|
263 | 310 |
//should only return sm1 |
264 | 311 |
ObjectList list2 = cs.listObjects(token, d1, d3, of1); |
265 | 312 |
assertTrue(list2.sizeObjectInfoList() == 1); |
src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java | ||
---|---|---|
618 | 618 |
objectFormat, replicaStatus, start, count); |
619 | 619 |
ol = cs.listObjects(token, null, null, null, false, 0, 1000); |
620 | 620 |
|
621 |
//StringReader sr = new StringReader(ol.toString()); |
|
621 |
StringReader sr = new StringReader(ol.toString()); |
|
622 |
System.out.println("ol: " + sr.toString()); |
|
622 | 623 |
//IOUtils.copy(sr, response.getOutputStream()); |
623 | 624 |
|
624 | 625 |
out = response.getOutputStream(); |
src/edu/ucsb/nceas/metacat/DBQuery.java | ||
---|---|---|
1216 | 1216 |
//try merging the data |
1217 | 1217 |
ReturnFieldValue existingRFV = |
1218 | 1218 |
getArrayValue(parentidList, parentId); |
1219 |
if (existingRFV != null) { |
|
1219 |
|
|
1220 |
if (existingRFV != null && !existingRFV.getFieldType().equals("ATTRIBUTE")) { |
|
1220 | 1221 |
fielddata = existingRFV.getFieldValue() + fielddata; |
1221 | 1222 |
} |
1222 | 1223 |
} |
1224 |
//System.out.println("fieldname: " + fieldname + " fielddata: " + fielddata); |
|
1223 | 1225 |
value.append("<param name=\""); |
1224 | 1226 |
value.append(fieldname); |
1225 | 1227 |
value.append("\">"); |
... | ... | |
1423 | 1425 |
|
1424 | 1426 |
Vector tempVector = null; |
1425 | 1427 |
|
1426 |
for (int count = 0; count < parentidList.size(); count++) { |
|
1428 |
for (int count = 0; count < parentidList.size(); count++) |
|
1429 |
{ |
|
1427 | 1430 |
tempVector = (Vector) parentidList.get(count); |
1428 | 1431 |
|
1429 |
if (key.compareTo((String) tempVector.get(0)) == 0) { return (ReturnFieldValue) tempVector |
|
1430 |
.get(1); } |
|
1432 |
if (key.compareTo((String) tempVector.get(0)) == 0) |
|
1433 |
{ |
|
1434 |
return (ReturnFieldValue) tempVector.get(1); |
|
1435 |
} |
|
1431 | 1436 |
} |
1432 | 1437 |
return null; |
1433 | 1438 |
} |
src/edu/ucsb/nceas/metacat/dataone/CrudService.java | ||
---|---|---|
223 | 223 |
for(int i=0; i<l.size(); i++) |
224 | 224 |
{ //for each id, add a system metadata doc |
225 | 225 |
String localId = l.get(i); |
226 |
System.out.println("Creating SystemMetadata for localId " + localId); |
|
226 |
//System.out.println("Creating SystemMetadata for localId " + localId);
|
|
227 | 227 |
//get the document |
228 | 228 |
try |
229 | 229 |
{ |
... | ... | |
449 | 449 |
params.put("returndoctype", new String[] {"http://dataone.org/service/types/SystemMetadata/0.1"}); |
450 | 450 |
params.put("qformat", new String[] {"xml"}); |
451 | 451 |
params.put("returnfield", new String[] {"size", "originMemberNode", |
452 |
"identifier", "objectFormat", "dateSysMetadataModified", "checksum", "@algorithm"}); |
|
452 |
"identifier", "objectFormat", "dateSysMetadataModified", "checksum", "checksum/@algorithm"});
|
|
453 | 453 |
params.put("anyfield", new String[] {"%"}); |
454 | 454 |
|
455 | 455 |
MetacatResultSet rs = handler.query(metacatUrl, params, sessionData.getUserName(), |
... | ... | |
510 | 510 |
ChecksumAlgorithm ca = ChecksumAlgorithm.convert(csalg); |
511 | 511 |
cs.setAlgorithm(ca); |
512 | 512 |
info.setChecksum(cs); |
513 |
//System.out.println("info.checksum: " + info.getChecksum().getValue()); |
|
513 | 514 |
info.setDateSysMetadataModified(dateSysMetadataModified); |
514 | 515 |
Identifier id = new Identifier(); |
515 | 516 |
id.setValue(d.getField("identifier")); |
Also available in: Unified diff
fixed bug in metacat that allowed attribute data to be appended to element data in returnfields