Unsuccessful deleting documents when revision number not specified
This is regarding the delete functionality in Metacat. I tried deleting
documents without entering the revision number and I was not able to do it.
So I tried deleting obfs.2 document and I just gave obfs.2 as the docid and I
got a 'Document deleted.' message. But I was still able to read obfs.2. Then I
tried deleting by giving obfs.2.1 as the docid and I got a 'Document deleted.'
message. I was not able to read obfs.2 after that.
Now as far as I remember, specifying obfs.2 should have worked also as per the
functionality coded. In case, that is not what the functionality is supposed to
be, 'Document deleted' should not have been returned.
I went through the code and found the following:
// NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV
// IN IT
//AccessionNumber ac = new AccessionNumber(accnum, "DELETE");
String docid = MetaCatUtil.getDocIdFromAccessionNumber(accnum);
//String rev = ac.getRev();
I am not sure who added the comment. Maybe the person who added the document
can explain what is the expected behavior.
When obfs.2 is specified as docid, getDocIdFromAccessionNumber(accnum) returns
docid as 'obfs' and hence is not able to delete anything. As none of the sql
statements return any error, 'Document deleted' message is returned.
The bug can be fixed by replacing MetaCatUtil.getDocIdFromAccessionNumber
(accnum) with MetaCatUtil.getDocIdFromString(accnum).
But I am not sure what the person who added the comment had in mind. So please
explain it to me so that I can change the code accordingly.