Revision 6027
Added by ben leinfelder almost 14 years ago
src/edu/ucsb/nceas/metacat/MetacatHandler.java | ||
---|---|---|
1022 | 1022 |
* @throws ClassNotFoundException |
1023 | 1023 |
* @throws IOException |
1024 | 1024 |
*/ |
1025 |
public InputStream read(String docid, String username, String[] groups)
|
|
1026 |
throws InsufficientKarmaException, ParseLSIDException,
|
|
1025 |
private InputStream read(String docid)
|
|
1026 |
throws ParseLSIDException, |
|
1027 | 1027 |
PropertyNotFoundException, McdbException, SQLException, |
1028 | 1028 |
ClassNotFoundException, IOException |
1029 | 1029 |
{ |
... | ... | |
1048 | 1048 |
docid = appendRev(docid); |
1049 | 1049 |
|
1050 | 1050 |
DocumentImpl doc = new DocumentImpl(docid, false); |
1051 |
//check the permission for read |
|
1052 |
if (!DocumentImpl.hasReadPermission(username, groups, docid)) { |
|
1053 |
|
|
1054 |
throw new InsufficientKarmaException( |
|
1055 |
"User " + username + |
|
1056 |
" does not have permission" + |
|
1057 |
" to read the document with the docid " + docid); |
|
1058 |
} |
|
1059 | 1051 |
|
1060 | 1052 |
// deal with data or metadata cases |
1061 | 1053 |
if (doc.getRootNodeID() == 0) { |
... | ... | |
1105 | 1097 |
// Try to get the metadata file from disk. If it isn't |
1106 | 1098 |
// found, create it from the db and write it to disk then. |
1107 | 1099 |
try { |
1108 |
doc.toXml(out, username, groups, true);
|
|
1100 |
doc.toXml(out, null, null, true);
|
|
1109 | 1101 |
|
1110 | 1102 |
} catch (McdbException e) { |
1111 | 1103 |
// any exceptions in reading the xml from disc, and we go back to the |
... | ... | |
1114 | 1106 |
"- could not read from document file " + |
1115 | 1107 |
docid + ": " + e.getMessage()); |
1116 | 1108 |
e.printStackTrace(System.out); |
1117 |
doc.toXmlFromDb(out, username, groups, true);
|
|
1109 |
doc.toXmlFromDb(out, null, null, true);
|
|
1118 | 1110 |
} |
1119 | 1111 |
|
1120 | 1112 |
// set the input stream |
... | ... | |
3498 | 3490 |
|
3499 | 3491 |
// get the data or metadata object |
3500 | 3492 |
try { |
3501 |
inputStream = this.read(localId, username, groups);
|
|
3493 |
inputStream = this.read(localId); |
|
3502 | 3494 |
|
3503 |
} catch ( InsufficientKarmaException ike ) { |
|
3504 |
logMetacat.debug("There was an access problem reading " + |
|
3505 |
localId + ". The error message was: " + ike.getMessage()); |
|
3506 |
throw ike; |
|
3507 |
|
|
3508 | 3495 |
} catch ( ParseLSIDException ple ) { |
3509 | 3496 |
logMetacat.debug("There was a problem parsing the LSID from " + |
3510 | 3497 |
localId + ". The error message was: " + ple.getMessage()); |
... | ... | |
3696 | 3683 |
|
3697 | 3684 |
|
3698 | 3685 |
//create the checksum |
3699 |
inputStream = this.read(localId, username, groups);
|
|
3686 |
inputStream = this.read(localId); |
|
3700 | 3687 |
ChecksumAlgorithm algorithm = ChecksumAlgorithm.convert("MD5"); |
3701 | 3688 |
Checksum checksum = ServiceTypeUtil.checksum(inputStream, algorithm); |
3702 | 3689 |
sysMeta.setChecksum(checksum); |
3703 | 3690 |
|
3704 | 3691 |
//set the size |
3705 |
inputStream = this.read(localId, username, groups);
|
|
3692 |
inputStream = this.read(localId); |
|
3706 | 3693 |
sysMeta.setSize(sizeOfStream(inputStream)); |
3707 | 3694 |
|
3708 | 3695 |
//submitter |
... | ... | |
3919 | 3906 |
String localId = im.getSystemMetadataLocalId(guid.getValue()); |
3920 | 3907 |
|
3921 | 3908 |
try { |
3922 |
inputStream = this.read(localId, user, groups);
|
|
3909 |
inputStream = this.read(localId); |
|
3923 | 3910 |
|
3924 | 3911 |
} catch ( McdbDocNotFoundException dnfe ) { |
3925 | 3912 |
throw dnfe; |
3926 | 3913 |
|
3927 |
} catch ( InsufficientKarmaException ike ) { |
|
3928 |
throw ike; |
|
3929 |
|
|
3930 | 3914 |
} catch ( ParseLSIDException ple ) { |
3931 | 3915 |
throw ple; |
3932 | 3916 |
|
Also available in: Unified diff
do not attempt to check permissions when reading documents for systemMetadata generation (unless I completely do not understand this feature - please verify!).