203 |
203 |
private static final String RESOURCE_SESSION = "session";
|
204 |
204 |
private static final String RESOURCE_IDENTIFIER = "identifier";
|
205 |
205 |
private static final String RESOURCE_LOG = "log";
|
|
206 |
private static final String RESOURCE_CHECKSUM = "checksum";
|
206 |
207 |
|
207 |
208 |
/*
|
208 |
209 |
* API Functions used as URL parameters
|
... | ... | |
380 |
381 |
status = true;
|
381 |
382 |
}
|
382 |
383 |
|
|
384 |
} else if(resource.equals(RESOURCE_CHECKSUM)) {
|
|
385 |
//handle checksum requests
|
|
386 |
System.out.println("Handling getChecksum request");
|
|
387 |
if(httpVerb == GET)
|
|
388 |
{
|
|
389 |
String guid = null;
|
|
390 |
String checksumAlgorithm = "MD5";
|
|
391 |
|
|
392 |
try
|
|
393 |
{
|
|
394 |
guid = params.get("id")[0];
|
|
395 |
}
|
|
396 |
catch(Exception e)
|
|
397 |
{
|
|
398 |
throw new InvalidRequest("1402", "Incorrect parameters passed to getChecksum");
|
|
399 |
}
|
|
400 |
|
|
401 |
Identifier guidid = new Identifier();
|
|
402 |
guidid.setValue(guid);
|
|
403 |
AuthToken token = new AuthToken(sessionId);
|
|
404 |
try
|
|
405 |
{
|
|
406 |
checksumAlgorithm = params.get("checksumAlgorithm")[0];
|
|
407 |
}
|
|
408 |
catch(Exception e)
|
|
409 |
{
|
|
410 |
//do nothing. default to MD5
|
|
411 |
}
|
|
412 |
System.out.println("getting checksum for object " + guid +
|
|
413 |
" with algorithm " + checksumAlgorithm);
|
|
414 |
try
|
|
415 |
{
|
|
416 |
Checksum c = CrudService.getInstance().getChecksum(token, guidid, checksumAlgorithm);
|
|
417 |
System.out.println("got checksum " + c.getValue());
|
|
418 |
response.setStatus(200);
|
|
419 |
System.out.println("serializing response");
|
|
420 |
serializeServiceType(Checksum.class, c, response.getOutputStream());
|
|
421 |
System.out.println("done serializing response.");
|
|
422 |
}
|
|
423 |
catch(NotAuthorized na)
|
|
424 |
{
|
|
425 |
na.setDetail_code("1400");
|
|
426 |
serializeException(na, response.getOutputStream());
|
|
427 |
}
|
|
428 |
catch(NotFound nf)
|
|
429 |
{
|
|
430 |
nf.setDetail_code("1420");
|
|
431 |
serializeException(nf, response.getOutputStream());
|
|
432 |
}
|
|
433 |
catch(InvalidRequest ir)
|
|
434 |
{
|
|
435 |
ir.setDetail_code("1402");
|
|
436 |
serializeException(ir, response.getOutputStream());
|
|
437 |
}
|
|
438 |
catch(ServiceFailure sf)
|
|
439 |
{
|
|
440 |
sf.setDetail_code("1410");
|
|
441 |
serializeException(sf, response.getOutputStream());
|
|
442 |
}
|
|
443 |
catch(InvalidToken it)
|
|
444 |
{
|
|
445 |
it.setDetail_code("1430");
|
|
446 |
serializeException(it, response.getOutputStream());
|
|
447 |
}
|
|
448 |
}
|
383 |
449 |
}
|
384 |
|
|
|
450 |
|
385 |
451 |
if (!status)
|
386 |
452 |
{
|
387 |
453 |
response.setStatus(400);
|
adding getChecksum method