Project

General

Profile

« Previous | Next » 

Revision 6527

Added by Matt Jones about 13 years ago

Bug fix for access control rules coming in from the dataone system metadata. Previously, the code used getLocalId() to get the docid to insert into the XML access table, but that docid included the revision number (e.g., foo.1.1), which it shouldn't. Now use the AccessionNumber class to strip off the rev to get a real docid for insertion into the table.

View differences:

src/edu/ucsb/nceas/metacat/accesscontrol/XMLAccessAccess.java
36 36
import org.apache.log4j.Logger;
37 37

  
38 38
import edu.ucsb.nceas.metacat.AccessionNumber;
39
import edu.ucsb.nceas.metacat.AccessionNumberException;
39 40
import edu.ucsb.nceas.metacat.DBUtil;
40 41
import edu.ucsb.nceas.metacat.IdentifierManager;
41 42
import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
......
413 414
			if (idAttribute.equals(GUID)) {
414 415
				guid = id;
415 416
				try {
416
					docid = IdentifierManager.getInstance().getLocalId(id);
417
					String localId = IdentifierManager.getInstance().getLocalId(id);
418
					// Parse the localId into scope and rev parts, strip off the rev
419
		            AccessionNumber acc = new AccessionNumber(localId, "NOACTION");
420
		            docid = acc.getDocid();
417 421
				} catch (McdbDocNotFoundException e) {
418 422
					//ignore
419 423
					logMetacat.warn("No local id mapping found for guid: " + id);
420
				}
424
				} catch (NumberFormatException e) {
425
                    logMetacat.warn("LocalId could not be parsed for guid: " + id);
426
                } catch (AccessionNumberException e) {
427
                    logMetacat.warn("LocalId could not be parsed for guid: " + id);
428
                }
421 429
			} else {
422 430
				int rev = DBUtil.getLatestRevisionInDocumentTable(id);
423 431
				try {

Also available in: Unified diff