Revision 5966
Added by Chris Jones almost 14 years ago
src/edu/ucsb/nceas/metacat/MetacatHandler.java | ||
---|---|---|
3294 | 3294 |
throws McdbException, McdbDocNotFoundException, SQLException, |
3295 | 3295 |
IOException, AccessionNumberException, ClassNotFoundException, |
3296 | 3296 |
InsufficientKarmaException, ParseLSIDException, PropertyNotFoundException, |
3297 |
BaseException, NoSuchAlgorithmException |
|
3297 |
BaseException, NoSuchAlgorithmException, JiBXException
|
|
3298 | 3298 |
{ |
3299 | 3299 |
logMetacat.debug("MetacatHandler.createSystemMetadata() called."); |
3300 | 3300 |
|
... | ... | |
3413 | 3413 |
try { |
3414 | 3414 |
logMetacat.debug("Checking for existing system metadata for " + |
3415 | 3415 |
dataDocId.getValue()); |
3416 |
dataSysMeta = this.getSystemMetadata(dataDocId); |
|
3416 |
dataSysMeta = this.getSystemMetadata(dataDocId, username, groups);
|
|
3417 | 3417 |
// add describedBy sysmeta |
3418 | 3418 |
logMetacat.debug("Setting describedBy for " + dataDocId.getValue() + |
3419 | 3419 |
" to " + identifier.getValue()); |
... | ... | |
3421 | 3421 |
dataSysMeta.setObjectFormat(ObjectFormat.convert(dataDocMimeType)); |
3422 | 3422 |
this.updateSystemMetadata(dataSysMeta, username, groups); |
3423 | 3423 |
|
3424 |
} catch ( NotFound nf ) {
|
|
3424 |
} catch ( McdbDocNotFoundException nf ) {
|
|
3425 | 3425 |
// System metadata for data doesn't exist |
3426 | 3426 |
logMetacat.debug("There was not an existing system metadata " + |
3427 | 3427 |
"document for " + dataDocId.getValue()); |
... | ... | |
3469 | 3469 |
throw be; |
3470 | 3470 |
|
3471 | 3471 |
} |
3472 |
|
|
3473 |
} |
|
3472 |
|
|
3473 |
} catch ( InsufficientKarmaException ike ) { |
|
3474 |
logMetacat.debug("There was an access problem reading " + |
|
3475 |
localId + ". The error message was: " + ike.getMessage()); |
|
3476 |
throw ike; |
|
3477 |
|
|
3478 |
} catch ( McdbException me ) { |
|
3479 |
logMetacat.debug("There was a Metacat problem. " + |
|
3480 |
"The error message was: " + me.getMessage()); |
|
3481 |
throw me; |
|
3482 |
|
|
3483 |
} catch ( JiBXException jxe ) { |
|
3484 |
logMetacat.debug("There was a problem deserializing the system " + |
|
3485 |
"metadata XML. The error message was: " + jxe.getMessage()); |
|
3486 |
throw jxe; |
|
3487 |
|
|
3488 |
} // end try() |
|
3474 | 3489 |
|
3475 | 3490 |
} // end if() |
3476 | 3491 |
|
... | ... | |
3657 | 3672 |
* |
3658 | 3673 |
* @return sysMeta The desired SystemMetadata object |
3659 | 3674 |
*/ |
3660 |
public SystemMetadata getSystemMetadata(Identifier guid) |
|
3661 |
throws NotFound { |
|
3675 |
public SystemMetadata getSystemMetadata(Identifier guid, |
|
3676 |
String user, String[] groups) |
|
3677 |
throws McdbDocNotFoundException, InsufficientKarmaException, |
|
3678 |
JiBXException, ParseLSIDException, PropertyNotFoundException, |
|
3679 |
McdbException, SQLException, IOException, ClassNotFoundException { |
|
3680 |
|
|
3681 |
logMetacat.debug("MetacatHandler.getSystemMetadata() called."); |
|
3682 |
|
|
3662 | 3683 |
SystemMetadata sysMeta = new SystemMetadata(); |
3684 |
InputStream inputStream; |
|
3663 | 3685 |
|
3664 |
return sysMeta; |
|
3686 |
try { |
|
3687 |
IdentifierManager im = IdentifierManager.getInstance(); |
|
3688 |
String localId = im.getSystemMetadataLocalId(guid.getValue()); |
|
3689 |
|
|
3690 |
try { |
|
3691 |
inputStream = this.read(localId, user, groups); |
|
3692 |
|
|
3693 |
} catch ( McdbDocNotFoundException dnfe ) { |
|
3694 |
throw dnfe; |
|
3695 |
|
|
3696 |
} catch ( InsufficientKarmaException ike ) { |
|
3697 |
throw ike; |
|
3698 |
|
|
3699 |
} catch ( ParseLSIDException ple ) { |
|
3700 |
throw ple; |
|
3701 |
|
|
3702 |
} catch ( PropertyNotFoundException pnfe ) { |
|
3703 |
throw pnfe; |
|
3704 |
|
|
3705 |
} catch ( McdbException me ) { |
|
3706 |
throw me; |
|
3707 |
|
|
3708 |
} catch ( SQLException sqle ) { |
|
3709 |
throw sqle; |
|
3710 |
|
|
3711 |
} catch ( ClassNotFoundException cnfe ) { |
|
3712 |
throw cnfe; |
|
3713 |
|
|
3714 |
} catch ( IOException ioe ) { |
|
3715 |
throw ioe; |
|
3716 |
|
|
3717 |
} // end try() |
|
3718 |
|
|
3719 |
try { |
|
3720 |
sysMeta = deserializeSystemMetadata(inputStream); |
|
3721 |
return sysMeta; |
|
3722 |
|
|
3723 |
} catch ( JiBXException jxe ) { |
|
3724 |
logMetacat.debug("There was a problem deserializing the system " + |
|
3725 |
"metadata XML. The error message was: " + jxe.getMessage()); |
|
3726 |
throw jxe; |
|
3727 |
|
|
3728 |
} |
|
3729 |
} catch ( McdbDocNotFoundException dnfe ) { |
|
3730 |
logMetacat.debug("There was a problem getting the system " + |
|
3731 |
"metadata local id. The error was: " + dnfe.getMessage()); |
|
3732 |
throw dnfe; |
|
3733 |
|
|
3734 |
} |
|
3665 | 3735 |
} |
3666 | 3736 |
|
3667 | 3737 |
/* |
Also available in: Unified diff
Modified MetacatHandler, updated the getSystemMetadata() method to now use read() and deserializeSystemMetadata() to produce the SystemMetadata object. Exceptions are pushed up the stack, and so accordingly, modified createSystemMetadata() to reflect the changes.