111 |
111 |
suite.addTest(new MetacatRestClientTest("query"));
|
112 |
112 |
suite.addTest(new MetacatRestClientTest("authenticatedQuery"));
|
113 |
113 |
suite.addTest(new MetacatRestClientTest("crud"));
|
|
114 |
suite.addTest(new MetacatRestClientTest("delete"));
|
114 |
115 |
suite.addTest(new MetacatRestClientTest("getNextObject"));
|
115 |
116 |
suite.addTest(new MetacatRestClientTest("getNextRevision"));
|
116 |
117 |
suite.addTest(new MetacatRestClientTest("getAllDocids"));
|
... | ... | |
208 |
209 |
debug("\nStarting get test...");
|
209 |
210 |
debug("-------------------------------------------------------");
|
210 |
211 |
try {
|
211 |
|
IdentifierManager im = IdentifierManager.getInstance();
|
212 |
212 |
String guid = insertTestDocument();
|
213 |
213 |
Reader r = m.getObject(guid, null);
|
214 |
214 |
String doc = IOUtil.getAsString(r, true);
|
... | ... | |
351 |
351 |
*/
|
352 |
352 |
public void crud()
|
353 |
353 |
{
|
354 |
|
debug("\nStarting insert,update,delete document test ...");
|
|
354 |
debug("\nStarting insert and update document test ...");
|
355 |
355 |
debug("-------------------------------------------------------");
|
356 |
356 |
try {
|
357 |
357 |
String accessBlock = getAccessBlock("public", true, true,
|
... | ... | |
379 |
379 |
debug("response:\n"+response);
|
380 |
380 |
assertTrue(response.indexOf("success") != -1);
|
381 |
381 |
sr.close();
|
382 |
|
|
383 |
|
Thread.sleep(5000);
|
384 |
|
|
385 |
|
debug("\nFinally delete the document...");
|
386 |
|
response = m.deleteObject(docid + ".2");
|
387 |
|
debug("response:\n"+response);
|
388 |
|
assertTrue(response.indexOf("success") != -1);
|
389 |
382 |
|
390 |
383 |
} catch (MetacatAuthException mae) {
|
391 |
384 |
fail("Authorization failed:\n" + mae.getMessage());
|
... | ... | |
396 |
389 |
}
|
397 |
390 |
}
|
398 |
391 |
|
|
392 |
/**
|
|
393 |
* Test the delete function
|
|
394 |
*/
|
|
395 |
public void delete()
|
|
396 |
{
|
|
397 |
debug("\nStarting delete document test ...");
|
|
398 |
debug("-------------------------------------------------------");
|
|
399 |
try {
|
|
400 |
String guid = insertTestDocument();
|
|
401 |
try {
|
|
402 |
Thread.sleep(5000);
|
|
403 |
} catch (InterruptedException e) {
|
|
404 |
debug("Thread.sleep() failed to execute.");
|
|
405 |
}
|
|
406 |
|
|
407 |
debug("\nDelete the document...");
|
|
408 |
String response = m.deleteObject(guid);
|
|
409 |
debug("response:\n"+response);
|
|
410 |
assertTrue(response.indexOf("success") != -1);
|
|
411 |
|
|
412 |
} catch (MetacatInaccessibleException mie) {
|
|
413 |
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
|
414 |
} catch (InsufficientKarmaException e) {
|
|
415 |
fail("not Authorized:\n" + e.getMessage());
|
|
416 |
} catch (MetacatException e) {
|
|
417 |
fail("Metacat error:\n" + e.getMessage());
|
|
418 |
}
|
|
419 |
}
|
399 |
420 |
|
400 |
421 |
/**
|
401 |
422 |
* Get the most recent document id for a given scope and be sure
|
Modified ResourceHandler.deleteObject() to take a globally unique id (guid)
as input rather than a metacat-conformant docid. The guid is translated
into a metacat docid which is then used in the handleDelete() call. So now
Metacat supports use of arbitrary identifiers for delete operations, but
only through the MetacatRest REST service interface. Still need to handle
exceptions that should be generated when a guid is not found.