Revision 6285
Added by Chris Jones over 13 years ago
src/edu/ucsb/nceas/metacat/restservice/MNResourceHandler.java | ||
---|---|---|
420 | 420 |
* @throws NotFound |
421 | 421 |
* @throws InvalidRequest |
422 | 422 |
*/ |
423 |
private void checksum(String guid) throws NotImplemented, JiBXException, IOException, InvalidToken, ServiceFailure, NotAuthorized, NotFound, InvalidRequest {
|
|
423 |
private void checksum(String pid) throws NotImplemented, JiBXException, IOException, InvalidToken, ServiceFailure, NotAuthorized, NotFound, InvalidRequest {
|
|
424 | 424 |
String checksumAlgorithm = "MD5"; |
425 | 425 |
|
426 |
Identifier guidid = new Identifier();
|
|
427 |
guidid.setValue(guid);
|
|
426 |
Identifier pidid = new Identifier();
|
|
427 |
pidid.setValue(pid);
|
|
428 | 428 |
try { |
429 | 429 |
checksumAlgorithm = params.get("checksumAlgorithm")[0]; |
430 | 430 |
} catch(Exception e) { |
431 | 431 |
//do nothing. default to MD5 |
432 | 432 |
logMetacat.warn("No algorithm specified, using default: " + checksumAlgorithm); |
433 | 433 |
} |
434 |
logMetacat.debug("getting checksum for object " + guid + " with algorithm " + checksumAlgorithm);
|
|
434 |
logMetacat.debug("getting checksum for object " + pid + " with algorithm " + checksumAlgorithm);
|
|
435 | 435 |
|
436 |
Checksum c = MNodeService.getInstance().getChecksum(session, guidid, checksumAlgorithm);
|
|
436 |
Checksum c = MNodeService.getInstance().getChecksum(session, pidid, checksumAlgorithm);
|
|
437 | 437 |
logMetacat.debug("got checksum " + c.getValue()); |
438 | 438 |
response.setStatus(200); |
439 | 439 |
logMetacat.debug("serializing response"); |
... | ... | |
498 | 498 |
/** |
499 | 499 |
* MN_crud.describe() |
500 | 500 |
* http://mule1.dataone.org/ArchitectureDocs/mn_api_crud.html#MN_crud.describe |
501 |
* @param guid
|
|
501 |
* @param pid
|
|
502 | 502 |
* @throws InvalidRequest |
503 | 503 |
* @throws NotImplemented |
504 | 504 |
* @throws NotFound |
... | ... | |
506 | 506 |
* @throws ServiceFailure |
507 | 507 |
* @throws InvalidToken |
508 | 508 |
*/ |
509 |
private void describeObject(String guid) throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented, InvalidRequest
|
|
509 |
private void describeObject(String pid) throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented, InvalidRequest
|
|
510 | 510 |
{ |
511 | 511 |
response.setStatus(200); |
512 | 512 |
response.setContentType("text/xml"); |
513 | 513 |
|
514 | 514 |
Identifier id = new Identifier(); |
515 |
id.setValue(guid);
|
|
515 |
id.setValue(pid);
|
|
516 | 516 |
|
517 | 517 |
DescribeResponse dr = MNodeService.getInstance().describe(session, id); |
518 | 518 |
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SZ"); |
519 |
response.addHeader("guid", guid);
|
|
519 |
response.addHeader("pid", pid);
|
|
520 | 520 |
response.addHeader("checksum", dr.getDataONE_Checksum().getValue()); |
521 | 521 |
response.addHeader("checksum_algorithm", dr.getDataONE_Checksum().getAlgorithm().name()); |
522 | 522 |
response.addHeader("content_length", dr.getContent_Length() + ""); |
... | ... | |
592 | 592 |
|
593 | 593 |
/** |
594 | 594 |
* Implements REST version of DataONE CRUD API --> get |
595 |
* @param guid ID of data object to be read
|
|
595 |
* @param pid ID of data object to be read
|
|
596 | 596 |
* @throws NotImplemented |
597 | 597 |
* @throws InvalidRequest |
598 | 598 |
* @throws NotFound |
... | ... | |
602 | 602 |
* @throws IOException |
603 | 603 |
* @throws JiBXException |
604 | 604 |
*/ |
605 |
protected void getObject(String guid) throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, InvalidRequest, NotImplemented, IOException, JiBXException {
|
|
605 |
protected void getObject(String pid) throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, InvalidRequest, NotImplemented, IOException, JiBXException {
|
|
606 | 606 |
OutputStream out = null; |
607 | 607 |
|
608 |
if (guid != null) { //get a specific document
|
|
608 |
if (pid != null) { //get a specific document
|
|
609 | 609 |
Identifier id = new Identifier(); |
610 |
id.setValue(guid);
|
|
610 |
id.setValue(pid);
|
|
611 | 611 |
|
612 | 612 |
SystemMetadata sm = MNodeService.getInstance().getSystemMetadata(session, id); |
613 | 613 |
|
... | ... | |
727 | 727 |
|
728 | 728 |
/** |
729 | 729 |
* Retrieve System Metadata |
730 |
* @param guid
|
|
730 |
* @param pid
|
|
731 | 731 |
* @throws InvalidToken |
732 | 732 |
* @throws ServiceFailure |
733 | 733 |
* @throws NotAuthorized |
... | ... | |
737 | 737 |
* @throws IOException |
738 | 738 |
* @throws JiBXException |
739 | 739 |
*/ |
740 |
protected void getSystemMetadataObject(String guid) throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, InvalidRequest, NotImplemented, IOException, JiBXException {
|
|
740 |
protected void getSystemMetadataObject(String pid) throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, InvalidRequest, NotImplemented, IOException, JiBXException {
|
|
741 | 741 |
|
742 | 742 |
Identifier id = new Identifier(); |
743 |
id.setValue(guid);
|
|
743 |
id.setValue(pid);
|
|
744 | 744 |
SystemMetadata sysmeta = MNodeService.getInstance().getSystemMetadata(session, id); |
745 | 745 |
|
746 | 746 |
response.setContentType("text/xml"); |
... | ... | |
755 | 755 |
/** |
756 | 756 |
* Inserts or updates the object |
757 | 757 |
* |
758 |
* @param guid - ID of data object to be inserted or updated. If action is update, the pid
|
|
758 |
* @param pid - ID of data object to be inserted or updated. If action is update, the pid
|
|
759 | 759 |
* is the existing pid. If insert, the pid is the new one |
760 | 760 |
* @throws InvalidRequest |
761 | 761 |
* @throws ServiceFailure |
... | ... | |
830 | 830 |
|
831 | 831 |
/** |
832 | 832 |
* Handle delete |
833 |
* @param guid ID of data object to be deleted
|
|
833 |
* @param pid ID of data object to be deleted
|
|
834 | 834 |
* @throws IOException |
835 | 835 |
* @throws InvalidRequest |
836 | 836 |
* @throws NotImplemented |
... | ... | |
840 | 840 |
* @throws InvalidToken |
841 | 841 |
* @throws JiBXException |
842 | 842 |
*/ |
843 |
private void deleteObject(String guid) throws IOException, InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented, InvalidRequest, JiBXException
|
|
843 |
private void deleteObject(String pid) throws IOException, InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented, InvalidRequest, JiBXException
|
|
844 | 844 |
{ |
845 | 845 |
|
846 | 846 |
OutputStream out = response.getOutputStream(); |
... | ... | |
848 | 848 |
response.setContentType("text/xml"); |
849 | 849 |
|
850 | 850 |
Identifier id = new Identifier(); |
851 |
id.setValue(guid);
|
|
851 |
id.setValue(pid);
|
|
852 | 852 |
|
853 | 853 |
logMetacat.debug("Calling delete"); |
854 | 854 |
MNodeService.getInstance().delete(session, id); |
... | ... | |
870 | 870 |
protected void setAccess() throws UnsupportedEncodingException, JiBXException, InvalidToken, ServiceFailure, NotFound, NotAuthorized, NotImplemented, InvalidRequest |
871 | 871 |
{ |
872 | 872 |
|
873 |
String guid = params.get("guid")[0];
|
|
873 |
String pid = params.get("pid")[0];
|
|
874 | 874 |
Identifier id = new Identifier(); |
875 |
id.setValue(guid);
|
|
875 |
id.setValue(pid);
|
|
876 | 876 |
String accesspolicy = params.get("accesspolicy")[0]; |
877 | 877 |
AccessPolicy accessPolicy = (AccessPolicy) deserializeServiceType(AccessPolicy.class, new ByteArrayInputStream(accesspolicy.getBytes("UTF-8"))); |
878 | 878 |
MNodeService.getInstance().setAccessPolicy(session, id, accessPolicy); |
Also available in: Unified diff
Changed 'guid' to 'pid' to be in line with the D1 API.