Index: test/edu/ucsb/nceas/metacat/dataone/CNCoreTest.java
===================================================================
--- test/edu/ucsb/nceas/metacat/dataone/CNCoreTest.java	(nonexistent)
+++ test/edu/ucsb/nceas/metacat/dataone/CNCoreTest.java	(revision 6122)
@@ -0,0 +1,158 @@
+/**
+ *  '$RCSfile$'
+ *  Copyright: 2010 Regents of the University of California and the
+ *              National Center for Ecological Analysis and Synthesis
+ *  Purpose: To test the Access Controls in metacat by JUnit
+ *
+ *   '$Author$'
+ *     '$Date$'
+ * '$Revision$'
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+package edu.ucsb.nceas.metacat.dataone;
+
+import java.util.Date;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.dataone.service.types.Checksum;
+import org.dataone.service.types.ChecksumAlgorithm;
+import org.dataone.service.types.Identifier;
+import org.dataone.service.types.NodeReference;
+import org.dataone.service.types.ObjectFormat;
+import org.dataone.service.types.Session;
+import org.dataone.service.types.Subject;
+import org.dataone.service.types.SystemMetadata;
+
+import edu.ucsb.nceas.MCTestCase;
+
+/**
+ * A JUnit test for testing the dataone CNCore implementation
+ */
+public class CNCoreTest extends MCTestCase {   
+    
+    /**
+    * constructor for the test
+    */
+    public CNCoreTest(String name)
+    {
+        super(name);
+    }
+  
+    /**
+	 * Establish a testing framework by initializing appropriate objects
+	 */
+	public void setUp() throws Exception 
+	{
+		super.setUp();
+	}
+
+	/**
+	 * Release any objects after tests are complete
+	 */
+	public void tearDown() 
+	{
+	}
+
+	/**
+	 * Create a suite of tests to be run together
+	 */
+	public static Test suite() 
+	{
+		TestSuite suite = new TestSuite();
+		suite.addTest(new CNCoreTest("initialize"));
+		
+		suite.addTest(new CNCoreTest("testRegisterSystemMetadata"));
+	
+		return suite;
+	}
+	
+	/**
+	 * test for registering standalone system metadata
+	 */
+	public void testRegisterSystemMetadata()
+	{
+	    printTestHeader("testRegisterSystemMetadata");
+
+	    try {
+            Session session = new Session();
+            Subject subject = new Subject();
+            subject.setValue("cn=test,dc=dataone,dc=org");
+            session.setSubject(subject);
+			Identifier guid = new Identifier();
+			guid.setValue("testRegisterSystemMetadata." + System.currentTimeMillis());
+			SystemMetadata sysmeta = createSystemMetadata(guid, subject);
+			CNCoreImpl.getInstance().registerSystemMetaData(session, guid, sysmeta);
+        }
+        catch(Exception e)
+        {
+            fail("Unexpected error in testDescribe: " + e.getMessage());
+        }
+	}
+	
+	/**
+	 * Run an initial test that always passes to check that the test harness is
+	 * working.
+	 */
+	public void initialize() 
+	{
+	    printTestHeader("initialize");
+		assertTrue(1 == 1);
+	}
+	
+	
+	/**
+	 * create system metadata with a specified id
+	 */
+	private SystemMetadata createSystemMetadata(Identifier id, Subject owner)
+	  throws Exception
+	{
+	    SystemMetadata sm = new SystemMetadata();
+        //set the id
+        sm.setIdentifier(id);
+        sm.setObjectFormat(ObjectFormat.OCTET_STREAM);
+        //create the checksum
+        String checksumS = "test";
+        ChecksumAlgorithm ca = ChecksumAlgorithm.convert("MD5");
+        Checksum checksum = new Checksum();
+        checksum.setValue(checksumS);
+        checksum.setAlgorithm(ca);
+        sm.setChecksum(checksum);
+        //set the size
+        sm.setSize(0);
+        sm.setSubmitter(owner);
+        sm.setRightsHolder(owner);
+        sm.setDateUploaded(new Date());
+        sm.setDateSysMetadataModified(new Date());
+        NodeReference nr = new NodeReference();
+        nr.setValue("metacat");
+        sm.setOriginMemberNode(nr);
+        sm.setAuthoritativeMemberNode(nr);
+        return sm;
+	}
+	
+	/**
+	 * print a header to start each test
+	 */
+	private void printTestHeader(String testName)
+	{
+	    System.out.println();
+	    System.out.println("*************** " + testName + " ***************");
+	}
+ 
+}

Property changes on: test/edu/ucsb/nceas/metacat/dataone/CNCoreTest.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: src/xmltables-oracle.sql
===================================================================
--- src/xmltables-oracle.sql	(revision 6121)
+++ src/xmltables-oracle.sql	(revision 6122)
@@ -282,6 +282,7 @@
  */
 CREATE TABLE xml_access (
 	docid		VARCHAR2(250),	-- the document id #
+	guid   VARCHAR2(2000),    -- the globally unique string identifier
 	accessfileid	VARCHAR2(250),	-- the document id # for the access file
 	principal_name	VARCHAR2(100),	-- name of user, group, etc.
 	permission	NUMBER(1),	-- "read", "write", "all"
Index: src/xmltables-postgres.sql
===================================================================
--- src/xmltables-postgres.sql	(revision 6121)
+++ src/xmltables-postgres.sql	(revision 6122)
@@ -206,6 +206,7 @@
  */
 CREATE TABLE xml_access (
 	docid VARCHAR(250),	-- the document id #
+	guid text,	-- foreign key to system metadata
 	accessfileid VARCHAR(250),	-- the document id # for the access file
 	principal_name VARCHAR(100),	-- name of user, group, etc.
 	permission INT8,		-- "read", "write", "all"
@@ -226,6 +227,9 @@
 CREATE INDEX xml_access_idx3 ON xml_access (perm_type);
 CREATE INDEX xml_access_idx4 ON xml_access (perm_order);
 CREATE INDEX xml_access_idx5 ON xml_access (subtreeid);
+/*
+ * ALTER TABLE xml_access ADD COLUMN guid text;
+*/
 
 /*
  * Index of Nodes -- table to store precomputed paths through tree for
Index: src/edu/ucsb/nceas/metacat/accesscontrol/XMLAccessAccess.java
===================================================================
--- src/edu/ucsb/nceas/metacat/accesscontrol/XMLAccessAccess.java	(revision 6121)
+++ src/edu/ucsb/nceas/metacat/accesscontrol/XMLAccessAccess.java	(revision 6122)
@@ -44,21 +44,33 @@
 	
 	private Logger logMetacat = Logger.getLogger(XMLAccessAccess.class);
 	
+	private static String DOCID = "docid";
+	
+	private static String GUID = "guid";
+
+	private String idAttribute = DOCID;
+	
 	// Constructor
 	public XMLAccessAccess() throws AccessException {}
 	
+	public XMLAccessAccess(boolean useGuid) {
+		if (useGuid) {
+			idAttribute = GUID;
+		}
+	}
+
 	/**
 	 * Get all xml access for a document
 	 * 
-	 * @param docId
+	 * @param id
 	 *            the id of the document
 	 * @return an xml access DAO list
 	 */ 
-	public Vector<XMLAccessDAO> getXMLAccessForDoc(String docId) throws AccessException {
+	public Vector<XMLAccessDAO> getXMLAccessForDoc(String id) throws AccessException {
 
 		Vector<XMLAccessDAO> xmlAccessList = new Vector<XMLAccessDAO>();
 		
-		if (docId == null) {
+		if (id == null) {
 			throw new AccessException("XMLAccessAccess.getXMLAccessForDoc - doc id " + 
 					"must be specified when selecting xml_access record");
 		}
@@ -71,13 +83,13 @@
 			conn = DBConnectionPool.getDBConnection("XMLAccessAccess.getXMLAccessForDoc");
     		serialNumber = conn.getCheckOutSerialNumber();
 
-			String sql = "SELECT * FROM xml_access WHERE docid = ?";
+			String sql = "SELECT * FROM xml_access WHERE " + idAttribute + " = ?";
 			pstmt = conn.prepareStatement(sql);
 
-			pstmt.setString(1, docId);
+			pstmt.setString(1, id);
 			
 			String sqlReport = "XMLAccessAccess.getXMLAccessForDoc - SQL: " + sql;
-			sqlReport += " [" + docId + "]";
+			sqlReport += " [" + id + "]";
 			
 			logMetacat.info(sqlReport);
 			
@@ -96,10 +108,10 @@
 			
 		} catch (SQLException sqle) {
 			throw new AccessException("XMLAccessAccess.getXMLAccessForDoc - SQL error when getting access " + 
-					" for doc id: " + docId  + " : "  + sqle.getMessage());
+					" for id: " + id  + " : "  + sqle.getMessage());
 		} catch (PermOrderException poe) {
 			String errorStr = "XMLAccessAccess.getXMLAccessForDoc - Permission order error when getting " + 
-				"access record for doc id: " + docId + " : "  + poe.getMessage();
+				"access record for doc id: " + id + " : "  + poe.getMessage();
 			logMetacat.error(errorStr);
 			throw new AccessException(errorStr);
 		} finally {
@@ -110,18 +122,18 @@
 	/**
 	 * Get all xml access for a principal for a certain document
 	 * 
-	 * @param docId
+	 * @param id
 	 *            the id of the document
 	 * @param principalName
 	 *            the credentials of the principal in the database
 	 * @return an xml access DAO list
 	 */ 
-	public Vector<XMLAccessDAO> getXMLAccessForPrincipal(String docId, String principalName) 
+	public Vector<XMLAccessDAO> getXMLAccessForPrincipal(String id, String principalName) 
 			throws AccessException {
 
 		Vector<XMLAccessDAO> xmlAccessList = new Vector<XMLAccessDAO>();
 		
-		if (docId == null) { 
+		if (id == null) { 
 			throw new AccessException("XMLAccessAccess.getXMLAccessForPrincipal - doc id " + 
 					"must be specified when selecting xml_access record");
 		}
@@ -138,14 +150,14 @@
 			conn = DBConnectionPool.getDBConnection("XMLAccessAccess.getXMLAccessForPrincipal");
     		serialNumber = conn.getCheckOutSerialNumber();
 			
-			String sql = "SELECT * FROM xml_access WHERE docid = ? AND principal_name = ?";
+			String sql = "SELECT * FROM xml_access WHERE " + idAttribute + " = ? AND principal_name = ?";
 			pstmt = conn.prepareStatement(sql);
 
-			pstmt.setString(1, docId);
+			pstmt.setString(1, id);
 			pstmt.setString(2, principalName);
 			
 			String sqlReport = "XMLAccessAccess.getXMLAccessForPrincipal - SQL: " + sql;
-			sqlReport += " [" + docId + "," + principalName + "]";
+			sqlReport += " [" + id + "," + principalName + "]";
 			
 			logMetacat.info(sqlReport);
 			
@@ -164,10 +176,10 @@
 			
 		} catch (SQLException sqle) {
 			throw new AccessException("XMLAccessAccess.getXMLAccessForPrincipal - SQL error when getting access " + 
-					" for doc id: " + docId + ", principal: " + principalName  + " : "  + sqle.getMessage());
+					" for id: " + id + ", principal: " + principalName  + " : "  + sqle.getMessage());
 		} catch (PermOrderException poe) {
 			String errorStr = "XMLAccessAccess.getXMLAccessForPrincipal - Permission order error when getting " + 
-				"access record for doc id: " + docId + ", principal: " + principalName + " : "  + poe.getMessage();
+				"access record for id: " + id + ", principal: " + principalName + " : "  + poe.getMessage();
 			logMetacat.error(errorStr);
 			throw new AccessException(errorStr);
 		} finally {
@@ -178,18 +190,18 @@
 	/**
 	 * Get all xml access for a principal/permType/permOrder for a certain document
 	 * 
-	 * @param docId
+	 * @param id
 	 *            the id of the document
 	 * @param principalName
 	 *            the credentials of the principal in the database
 	 * @return an xml access DAO list
 	 */ 
-	public Vector<XMLAccessDAO> getXMLAccessForPrincipal(String docId, String principalName, String permType, String permOrder) 
+	public Vector<XMLAccessDAO> getXMLAccessForPrincipal(String id, String principalName, String permType, String permOrder) 
 			throws AccessException {
 
 		Vector<XMLAccessDAO> xmlAccessList = new Vector<XMLAccessDAO>();
 		
-		if (docId == null) { 
+		if (id == null) { 
 			throw new AccessException("XMLAccessAccess.getXMLAccessForPrincipal - doc id " + 
 					"must be specified when selecting xml_access record");
 		}
@@ -214,17 +226,17 @@
 			conn = DBConnectionPool.getDBConnection("XMLAccessAccess.getXMLAccessForPrincipal");
     		serialNumber = conn.getCheckOutSerialNumber();
     		
-			String sql = "SELECT * FROM xml_access WHERE docid = ? AND principal_name = ? " + 
+			String sql = "SELECT * FROM xml_access WHERE " + idAttribute + " = ? AND principal_name = ? " + 
 				"AND perm_type = ? AND perm_order = ?";
 			pstmt = conn.prepareStatement(sql);
 
-			pstmt.setString(1, docId);
+			pstmt.setString(1, id);
 			pstmt.setString(2, principalName);
 			pstmt.setString(3, permType);			
 			pstmt.setString(4, permOrder);
 			
 			String sqlReport = "XMLAccessAccess.getXMLAccessForPrincipal - SQL: " + sql;
-			sqlReport += " [" + docId + "," + principalName + "," +  permType + "," + permOrder + "]";
+			sqlReport += " [" + id + "," + principalName + "," +  permType + "," + permOrder + "]";
 			
 			logMetacat.info(sqlReport);
 			
@@ -242,10 +254,10 @@
 			
 		} catch (SQLException sqle) {
 			throw new AccessException("XMLAccessAccess.getXMLAccessForPrincipal - SQL error when getting access " + 
-					" for doc id: " + docId + ", principal: " + principalName  + " : "  + sqle.getMessage());
+					" for id: " + id + ", principal: " + principalName  + " : "  + sqle.getMessage());
 		} catch (PermOrderException poe) {
 			String errorStr = "XMLAccessAccess.getXMLAccessForPrincipal - Permission order error when getting " + 
-				"access record for doc id: " + docId + ", principal: " + principalName + " : "  + poe.getMessage();
+				"access record for id: " + id + ", principal: " + principalName + " : "  + poe.getMessage();
 			logMetacat.error(errorStr);
 			throw new AccessException(errorStr);
 		} finally {
@@ -258,7 +270,7 @@
 	 * principal already exists, bitwise OR the permission to the existing
 	 * permission and update.
 	 * 
-	 * @param docId
+	 * @param id
 	 *            document id
 	 * @param principalName
 	 *            principal credentials
@@ -269,30 +281,30 @@
 	 * @param permOrder
 	 *            permission order
 	 */
-	public void addXMLAccess(String docId, String principalName, Long permission, String permType, 
+	public void addXMLAccess(String id, String principalName, Long permission, String permType, 
 			String permOrder, String accessFileId, String subTreeId) throws AccessException, PermOrderException {
 		
-		permOrderConflict(docId, permOrder);
+		permOrderConflict(id, permOrder);
 		
 		Vector<XMLAccessDAO> xmlAccessList = 
-			getXMLAccessForPrincipal(docId, principalName, permType, permOrder);
+			getXMLAccessForPrincipal(id, principalName, permType, permOrder);
 		
 		// if more than one record exists for this principal on this document with the same
 		// access type / access order combination, call cleanup to combine common access and then
 		// re-retrieve the access list.
 		if (xmlAccessList.size() == 0) {
-			insertXMLAccess(docId, principalName, permission, permType, permOrder, accessFileId, subTreeId);
+			insertXMLAccess(id, principalName, permission, permType, permOrder, accessFileId, subTreeId);
 			return;
 		}
 		
 		if (xmlAccessList.size() > 1) {
 			cleanupXMLAccessForPrincipal(xmlAccessList);
-			xmlAccessList = getXMLAccessForPrincipal(docId, principalName, permType, permOrder);
+			xmlAccessList = getXMLAccessForPrincipal(id, principalName, permType, permOrder);
 		}
 		
 		if (xmlAccessList.size() == 0) {
 			throw new AccessException("XMLAccessAccess.addXMLAccess - xml access list is empty when " + 
-				"it shouldn't be for docid: " + docId + ", prinicpal name: " + principalName + ", perm type " + 
+				"it shouldn't be for id: " + id + ", prinicpal name: " + principalName + ", perm type " + 
 				permType + ", perm order: " + permOrder);	
 		}
 		
@@ -302,7 +314,7 @@
 		//trying to add, update the access record with the existing permission bitwis OR-ed with our
 		// new permission
 		if ((xmlAccessDAO.getPermission() & permission) != permission) {		
-			updateXMLAccessPermission(docId, principalName, xmlAccessDAO.getPermission() | permission);
+			updateXMLAccessPermission(id, principalName, xmlAccessDAO.getPermission() | permission);
 		}
 	}
 	
@@ -310,19 +322,19 @@
 	 * Set permissions for a given document. This means first removing all access control for the
 	 * document and then adding the given rules.
 	 * 
-	 * @param docId
+	 * @param id
 	 *            document id
 	 * @param xmlAccessList
 	 *            list of xml access dao objects that hold new access for the document
 	 */
-	public void replaceAccess(String docId, List<XMLAccessDAO> xmlAccessList) throws AccessException {
-		deleteXMLAccessForDoc(docId);
+	public void replaceAccess(String id, List<XMLAccessDAO> xmlAccessList) throws AccessException {
+		deleteXMLAccessForDoc(id);
 		
 		// if more than one record exists for this principal on this document with the same
 		// access type / access order combination, call cleanup to combine common access and then
 		// re-retrieve the access list.
 		for(XMLAccessDAO xmlAccessDAO : xmlAccessList) {
-			insertXMLAccess(docId, xmlAccessDAO.getPrincipalName(), xmlAccessDAO.getPermission(), 
+			insertXMLAccess(id, xmlAccessDAO.getPrincipalName(), xmlAccessDAO.getPermission(), 
 					xmlAccessDAO.getPermType(), xmlAccessDAO.getPermOrder(), xmlAccessDAO.getAccessFileId(), xmlAccessDAO.getSubTreeId());
 		}
 	}
@@ -332,7 +344,7 @@
 	 * make sure the principal does not already have an access record for this document.  If 
 	 * one does already exist, that record should be updated and this insert not called.
 	 * 
-	 * @param docId
+	 * @param id
 	 *            document id
 	 * @param principal
 	 *            principal credentials
@@ -343,7 +355,7 @@
 	 * @param permOrder
 	 *            permission order
 	 */
-	private void insertXMLAccess(String docId, String principalName, Long permission, String permType,
+	private void insertXMLAccess(String id, String principalName, Long permission, String permType,
 			String permOrder, String accessFileId, String subTreeId) throws AccessException {
 	    //System.out.println("permission in insertXMLAccess: " + permission);
 	    try
@@ -359,8 +371,8 @@
 	        logMetacat.warn(e.getMessage());
 	    }
 	    
-		if (docId == null) {
-			throw new AccessException("XMLAccessAccess.insertXMLAccess - docid is required when " + 
+		if (id == null) {
+			throw new AccessException("XMLAccessAccess.insertXMLAccess - id is required when " + 
 					"inserting XML access record");
 		}
 		if (principalName == null) {
@@ -388,12 +400,12 @@
 			serialNumber = conn.getCheckOutSerialNumber();
 			
 			String sql = "INSERT INTO xml_access " +
-				"(docid, principal_name, permission, perm_type, perm_order, accessfileid, subtreeid ) " + 
+				"(" + idAttribute + ", principal_name, permission, perm_type, perm_order, accessfileid, subtreeid ) " + 
 				"VALUES (?,?,?,?,?,?,?)";
 			pstmt = conn.prepareStatement(sql);
 
 			// Bind the values to the query
-			pstmt.setString(1, docId);
+			pstmt.setString(1, id);
 			pstmt.setString(2, principalName);
 			pstmt.setLong(3, permission);
 			pstmt.setString(4, permType);
@@ -402,7 +414,7 @@
 			pstmt.setString(7, subTreeId);
 			
 			String sqlReport = "XMLAccessAccess.insertXMLAccess - SQL: " + sql;
-			sqlReport += " [" + docId + "," + principalName + "," +  permission + "," +  permType + "," + permOrder + "]";
+			sqlReport += " [" + id + "," + principalName + "," +  permission + "," +  permType + "," + permOrder + "]";
 			
 			logMetacat.info(sqlReport);
 
@@ -409,7 +421,7 @@
 			pstmt.execute();
 		} catch (SQLException sqle) {
 			throw new AccessException("XMLAccessAccess.insertXMLAccess - SQL error when inserting"
-					+ "xml access permissions for doc id: " + docId + ", principal: " + 
+					+ "xml access permissions for id: " + id + ", principal: " + 
 					principalName + ":" + sqle.getMessage());
 		} finally {
 			closeDBObjects(pstmt, conn, serialNumber, logMetacat); 
@@ -420,7 +432,7 @@
 	 * Update existing xml access permissions in the db.  The permission value should be the combined
 	 * value of pre-existing permissions plus new permissions.
 	 * 
-	 * @param docId
+	 * @param id
 	 *            document id
 	 * @param principalName
 	 *            principal credentials
@@ -427,10 +439,10 @@
 	 * @param permission
 	 *            permission bitmap
 	 */
-	private void updateXMLAccessPermission(String docId, String principalName, Long permission)
+	private void updateXMLAccessPermission(String id, String principalName, Long permission)
 			throws AccessException {
-		if (docId == null) {
-			throw new AccessException("XMLAccessAccess.updateXMLAccessPermission - docid is required when " + 
+		if (id == null) {
+			throw new AccessException("XMLAccessAccess.updateXMLAccessPermission - id is required when " + 
 					"updating XML access record");
 		}
 		if (principalName == null) {
@@ -451,16 +463,16 @@
 			serialNumber = conn.getCheckOutSerialNumber();
 			
 			String sql = "UPDATE xml_access SET permission = ?" +
-				"WHERE docid = ? AND principal_name = ?";
+				"WHERE " + idAttribute + " = ? AND principal_name = ?";
 			pstmt = conn.prepareStatement(sql);
 
 			// Bind the values to the query
 			pstmt.setLong(1, permission);
-			pstmt.setString(2, docId);
+			pstmt.setString(2, id);
 			pstmt.setString(3, principalName);
 			
 			String sqlReport = "XMLAccessAccess.updateXMLAccessPermission - SQL: " + sql;
-			sqlReport += " [" + permission + "," + docId + "," + principalName + "]";
+			sqlReport += " [" + permission + "," + id + "," + principalName + "]";
 			
 			logMetacat.info(sqlReport);
 
@@ -467,7 +479,7 @@
 			pstmt.execute();
 		} catch (SQLException sqle) {
 			throw new AccessException("XMLAccessAccess.updateXMLAccessPermission - SQL error when updating"
-					+ "xml access permissions for doc id: " + docId + ", principal: " + 
+					+ "xml access permissions for id: " + id + ", principal: " + 
 					principalName + ":" + sqle.getMessage());
 		} finally {
 			closeDBObjects(pstmt, conn, serialNumber, logMetacat); 
@@ -480,14 +492,14 @@
 	 * for a given document.  If the provided permission is exactly the same as what 
 	 * the principal has, the record is deleted from the database.
 	 * 
-	 * @param docId
+	 * @param id
 	 *            document id
 	 * @param principalName
 	 *            principal credentials
 	 */
-	public void removeXMLAccessForPrincipal(String docId, String principalName, Long permission) throws AccessException {
-		if (docId == null) {
-			throw new AccessException("XMLAccessAccess.removeXMLAccessForPrincipal - docid is required when " + 
+	public void removeXMLAccessForPrincipal(String id, String principalName, Long permission) throws AccessException {
+		if (id == null) {
+			throw new AccessException("XMLAccessAccess.removeXMLAccessForPrincipal - id is required when " + 
 					"removing XML access");
 		}
 		if (principalName == null) {
@@ -499,10 +511,10 @@
 					"updating XML access");
 		}
 		
-		Vector<XMLAccessDAO> xmlAccessList = getXMLAccessForPrincipal(docId, principalName);
+		Vector<XMLAccessDAO> xmlAccessList = getXMLAccessForPrincipal(id, principalName);
 		if (xmlAccessList.size() == 0) {
 			logMetacat.warn("XMLAccessAccess.removeXMLAccessForPrincipal - attempting to remove access when no " +
-				"access record exists for docid: " + docId + ", principal: " + principalName);
+				"access record exists for id: " + id + ", principal: " + principalName);
 		} else {
 			long permissionMask = 0;
 			for (XMLAccessDAO xmlAccessDAO : xmlAccessList) {
@@ -513,13 +525,13 @@
 			// in this case, the only existing permissions are the ones we want to remove, so 
 			// delete the record(s) for this principal on this document
 			if ((permissionMask & permission) == permission) {
-				deleteXMLAccessForPrincipal(docId, principalName);
+				deleteXMLAccessForPrincipal(id, principalName);
 			}
 			
 			if (xmlAccessList.size() > 1) {
 				
 			} else {
-				updateXMLAccessPermission(docId, principalName, permission);
+				updateXMLAccessPermission(id, principalName, permission);
 			}
 		}
 	   
@@ -528,12 +540,12 @@
 	/**
 	 * Delete xml access.  This removes all access records from the database for a given document
 	 * 
-	 * @param docId
+	 * @param id
 	 *            document id
 	 */
-	public void deleteXMLAccessForDoc(String docId) throws AccessException {
-		if (docId == null) {
-			throw new AccessException("XMLAccessAccess.deleteXMLAccessForPrincipal - docid is required when " + 
+	public void deleteXMLAccessForDoc(String id) throws AccessException {
+		if (id == null) {
+			throw new AccessException("XMLAccessAccess.deleteXMLAccessForPrincipal - id is required when " + 
 					"deleting XML access record");
 		}
 		
@@ -545,14 +557,14 @@
 			conn = DBConnectionPool.getDBConnection("XMLAccessAccess.deleteXMLAccessForDoc");
     		serialNumber = conn.getCheckOutSerialNumber();
     		
-			String sql = "DELETE FROM xml_access WHERE docid = ?";
+			String sql = "DELETE FROM xml_access WHERE " + idAttribute + " = ?";
 			pstmt = conn.prepareStatement(sql);
 
 			// Bind the values to the query
-			pstmt.setString(1, docId);
+			pstmt.setString(1, id);
 
 			String sqlReport = "XMLAccessAccess.deleteXMLAccessForDoc - SQL: " + sql;
-			sqlReport += " [" + docId + "]";
+			sqlReport += " [" + id + "]";
 			
 			logMetacat.info(sqlReport);
 
@@ -559,7 +571,7 @@
 			pstmt.execute();
 		} catch (SQLException sqle) {
 			throw new AccessException("XMLAccessAccess.deleteXMLAccessForDoc - SQL error when deleting"
-					+ "xml access permissions for doc id: " + docId + ":" + sqle.getMessage());
+					+ "xml access permissions for id: " + id + ":" + sqle.getMessage());
 		} finally {
 			closeDBObjects(pstmt, conn, serialNumber, logMetacat); 
 		}	   
@@ -569,14 +581,14 @@
 	 * Delete xml access.  This removes all access records from the database for a principal 
 	 * for a given document
 	 * 
-	 * @param docId
+	 * @param id
 	 *            document id
 	 * @param principal
 	 *            principal credentials
 	 */
-	private void deleteXMLAccessForPrincipal(String docId, String principalName) throws AccessException {
-		if (docId == null) {
-			throw new AccessException("XMLAccessAccess.deleteXMLAccessForPrincipal - docid is required when " + 
+	private void deleteXMLAccessForPrincipal(String id, String principalName) throws AccessException {
+		if (id == null) {
+			throw new AccessException("XMLAccessAccess.deleteXMLAccessForPrincipal - id is required when " + 
 					"deleting XML access record");
 		}
 		if (principalName == null) {
@@ -592,15 +604,15 @@
 			conn = DBConnectionPool.getDBConnection("XMLAccessAccess.deleteXMLAccessForPrincipal");
     		serialNumber = conn.getCheckOutSerialNumber();
     		
-			String sql = "DELETE FROM xml_access WHERE docid = ? AND principal_name = ?";
+			String sql = "DELETE FROM xml_access WHERE " + idAttribute + " = ? AND principal_name = ?";
 			pstmt = conn.prepareStatement(sql);
 
 			// Bind the values to the query
-			pstmt.setString(1, docId);
+			pstmt.setString(1, id);
 			pstmt.setString(2, principalName);
 
 			String sqlReport = "XMLAccessAccess.deleteXMLAccessForPrincipal - SQL: " + sql;
-			sqlReport += " [" + docId + "," + principalName + "]";
+			sqlReport += " [" + id + "," + principalName + "]";
 			
 			logMetacat.info(sqlReport);
 
@@ -607,7 +619,7 @@
 			pstmt.execute();
 		} catch (SQLException sqle) {
 			throw new AccessException("XMLAccessAccess.deleteXMLAccessForPrincipal - SQL error when deleting"
-					+ "xml access permissions for doc id: " + docId + ", principal: " + 
+					+ "xml access permissions for id: " + id + ", principal: " + 
 					principalName + ":" + sqle.getMessage());
 		} finally {
 			closeDBObjects(pstmt, conn, serialNumber, logMetacat);
@@ -618,14 +630,14 @@
 	 * Checks to see if there is a permission order conflict for a given document.  Each 
 	 * document is only allowed to have a single permission order
 	 * 
-	 * @param docId
+	 * @param id
 	 *            document id
 	 * @param principal
 	 *            principal credentials
 	 */
-	private void permOrderConflict(String docId, String permOrder) throws AccessException, PermOrderException {
-		if (docId == null) {
-			throw new AccessException("XMLAccessAccess.permOrderConflict - docid is required when " + 
+	private void permOrderConflict(String id, String permOrder) throws AccessException, PermOrderException {
+		if (id == null) {
+			throw new AccessException("XMLAccessAccess.permOrderConflict - id is required when " + 
 					"determining perm order conflict");
 		}
 		if (permOrder == null) {
@@ -641,15 +653,15 @@
 			conn = DBConnectionPool.getDBConnection("XMLAccessAccess.permOrderConflict");
     		serialNumber = conn.getCheckOutSerialNumber();
     		
-			String sql = "SELECT * FROM xml_access WHERE docid = ? AND perm_order != ?";
+			String sql = "SELECT * FROM xml_access WHERE " + idAttribute + " = ? AND perm_order != ?";
 			pstmt = conn.prepareStatement(sql);
 
 			// Bind the values to the query
-			pstmt.setString(1, docId);
+			pstmt.setString(1, id);
 			pstmt.setString(2, permOrder);
 			
 			String sqlReport = "XMLAccessAccess.permOrderConflict - SQL: " + sql;
-			sqlReport += " [" + docId + "," + permOrder + "]";
+			sqlReport += " [" + id + "," + permOrder + "]";
 			
 			logMetacat.info(sqlReport);
 
@@ -658,11 +670,11 @@
 			ResultSet resultSet = pstmt.getResultSet();
 			if (resultSet.next()) {			
 				throw new PermOrderException("XMLAccessAccess.addXMLAccess - cannot add permission " + 
-					"record for doc id: " + docId + "with permOrder: " + permOrder + " due to permOrder conflict");
+					"record for id: " + id + "with permOrder: " + permOrder + " due to permOrder conflict");
 			}
 		} catch (SQLException sqle) {
 			throw new AccessException("XMLAccessAccess.permOrderConflict - SQL error when checking"
-					+ "for perm order conflict on: " + docId + ":" + sqle.getMessage());
+					+ "for perm order conflict on: " + id + ":" + sqle.getMessage());
 		} finally {
 			closeDBObjects(pstmt, conn, serialNumber, logMetacat); 
 		}
@@ -673,14 +685,14 @@
 	 * Delete xml access.  This removes all access records from the database for a principal 
 	 * for a given document, perm type and perm order
 	 * 
-	 * @param docId
+	 * @param id
 	 *            document id
 	 * @param principal
 	 *            principal credentials
 	 */
-	private void deleteXMLAccessForPrincipal(String docId, String principalName, String permType, String permOrder) throws AccessException {
-		if (docId == null) {
-			throw new AccessException("XMLAccessAccess.deleteXMLAccessForPrincipal - docid is required when " + 
+	private void deleteXMLAccessForPrincipal(String id, String principalName, String permType, String permOrder) throws AccessException {
+		if (id == null) {
+			throw new AccessException("XMLAccessAccess.deleteXMLAccessForPrincipal - id is required when " + 
 					"deleting XML access record");
 		}
 		if (principalName == null) {
@@ -706,18 +718,18 @@
 			conn = DBConnectionPool.getDBConnection("XMLAccessAccess.deleteXMLAccessForPrincipal");
     		serialNumber = conn.getCheckOutSerialNumber();
     		
-			String sql = "DELETE FROM xml_access WHERE docid = ? AND principal_name = ? " +
+			String sql = "DELETE FROM xml_access WHERE " + idAttribute + " = ? AND principal_name = ? " +
 				"AND perm_type = ? AND perm_order = ?";
 			pstmt = conn.prepareStatement(sql);
 
 			// Bind the values to the query
-			pstmt.setString(1, docId);
+			pstmt.setString(1, id);
 			pstmt.setString(2, principalName);
 			pstmt.setString(3, permType);
 			pstmt.setString(4, permOrder);
 			
 			String sqlReport = "XMLAccessAccess.deleteXMLAccessForPrincipal - SQL: " + sql;
-			sqlReport += " [" + docId + "," + principalName + "," + permType + "," + permOrder + "]";
+			sqlReport += " [" + id + "," + principalName + "," + permType + "," + permOrder + "]";
 			
 			logMetacat.info(sqlReport);
 
@@ -724,7 +736,7 @@
 			pstmt.execute();
 		} catch (SQLException sqle) {
 			throw new AccessException("XMLAccessAccess.deleteXMLAccessForPrincipal - SQL error when deleting"
-					+ "xml access permissions for doc id: " + docId + ", principal: " + 
+					+ "xml access permissions for id: " + id + ", principal: " + 
 					principalName + ":" + sqle.getMessage());
 		} finally {
 			closeDBObjects(pstmt, conn, serialNumber, logMetacat); 
@@ -745,7 +757,7 @@
 		int numDenyRecords = 0;
 		long allowPermissionMask = 0;
 		long denyPermissionMask = 0;
-		String docId = null;
+		String id = null;
 		String principalName = null;
 		String permType = null;
 		String permOrder = null;
@@ -757,13 +769,16 @@
 		// iterate through the list of access dao objects and bttwise or the permissions.  Most
 		// of this is just doing some error checking to make sure each record is valid.
 		for (XMLAccessDAO xmlAccessDAO : xmlAccessList) {
-			if (docId == null) {
-				docId = xmlAccessDAO.getDocId();
+			String daoId = xmlAccessDAO.getDocId();
+			if (idAttribute.equals(GUID)) {
+				daoId = xmlAccessDAO.getGuid();
+			}
+			if (id == null) {
+				id = daoId;
 			} else {
-				if (!docId.equals(xmlAccessDAO.getDocId())) {
+				if (!id.equals(daoId)) {
 					throw new AccessException("XMLAccessAccess.cleanupXMLAccessForPrincipal - " + 
-							" Conflicting doc ids " + xmlAccessDAO.getDocId() +
-							" and " + docId);
+							" Conflicting ids " + daoId + " and " + id);
 				}
 			}
 			if (principalName == null) {
@@ -780,7 +795,7 @@
 			} else {
 				if (!permType.equals(xmlAccessDAO.getPermType())) {
 					throw new AccessException("XMLAccessAccess.cleanupXMLAccessForPrincipal - " + 
-							" Conflicting permission orders for document " + xmlAccessDAO.getDocId() +
+							" Conflicting permission orders for document " + daoId +
 							"principalName " + principalName + ". Database intervention required ");
 				}
 			}
@@ -789,7 +804,7 @@
 			} else {
 				if (!permOrder.equals(xmlAccessDAO.getPermOrder())) {
 					throw new AccessException("XMLAccessAccess.cleanupXMLAccessForPrincipal - " + 
-							" Conflicting permission types for document " + xmlAccessDAO.getDocId() +
+							" Conflicting permission types for document " + daoId +
 							"principalName " + principalName + ". Database intervention required ");
 				}
 			}
@@ -798,7 +813,7 @@
 			} else {
 				if (!permType.equals(xmlAccessDAO.getPermType())) {
 					throw new AccessException("XMLAccessAccess.cleanupXMLAccessForPrincipal - " + 
-							" Conflicting permission orders for document " + xmlAccessDAO.getDocId() +
+							" Conflicting permission orders for document " + daoId +
 							"principalName " + principalName + ". Database intervention required ");
 				}
 			}
@@ -820,14 +835,14 @@
 		// if there was more than one allow record, remove all allow records for this user on this doc 
 		// with this perm type and perm order then insert a single record 
 		if (numAllowRecords > 1) {
-			deleteXMLAccessForPrincipal(docId, principalName, AccessControlInterface.ALLOW, permOrder);
-			insertXMLAccess(docId, principalName, allowPermissionMask, AccessControlInterface.ALLOW, permOrder, accessFileId, subTreeId);
+			deleteXMLAccessForPrincipal(id, principalName, AccessControlInterface.ALLOW, permOrder);
+			insertXMLAccess(id, principalName, allowPermissionMask, AccessControlInterface.ALLOW, permOrder, accessFileId, subTreeId);
 		}
 		// if there was more than one deny record, remove all deny records for this user on this doc 
 		// with this perm type and perm order then insert a single record 
 		if (numDenyRecords > 1) {
-			deleteXMLAccessForPrincipal(docId, principalName, AccessControlInterface.DENY, permOrder);
-			insertXMLAccess(docId, principalName, denyPermissionMask, AccessControlInterface.DENY, permOrder, accessFileId, subTreeId);
+			deleteXMLAccessForPrincipal(id, principalName, AccessControlInterface.DENY, permOrder);
+			insertXMLAccess(id, principalName, denyPermissionMask, AccessControlInterface.DENY, permOrder, accessFileId, subTreeId);
 		}
 	}
 	
@@ -841,12 +856,16 @@
 	private void validateDocXMLAccessList(Vector<XMLAccessDAO> xmlAccessList) throws PermOrderException {
 		String permOrder = null;
 		for(XMLAccessDAO xmlAccessDAO : xmlAccessList) {
+			String daoId = xmlAccessDAO.getDocId();
+			if (idAttribute.equals(GUID)) {
+				daoId = xmlAccessDAO.getGuid();
+			}
 			if (permOrder == null) {
 				permOrder = xmlAccessDAO.getPermOrder();
 			} else {
 				if(!permOrder.equals(xmlAccessDAO.getPermOrder())) {
 					throw new PermOrderException("XMLAccessAccess.validateXMLAccessList - " + 
-						" Conflicting permission orders for document " + xmlAccessDAO.getDocId() +
+						" Conflicting permission orders for document " + daoId +
 						". Database intervention required ");
 				}
 			}
@@ -865,7 +884,7 @@
 		
 		boolean allowFirst = false;
 		boolean denyFirst = false;
-		String docId = null;
+		String id = null;
 		
 		// These vectors will hold all combinations of access DAOs with different permission
 		// orders and permission types.  
@@ -876,9 +895,13 @@
 		
 		// sort the access dao records into the appropriate vector
 		for(XMLAccessDAO xmlAccessDAO : xmlAccessList) {
-			if (docId == null) {
-				docId = xmlAccessDAO.getDocId();
+			String daoId = xmlAccessDAO.getDocId();
+			if (idAttribute.equals(GUID)) {
+				daoId = xmlAccessDAO.getGuid();
 			}
+			if (id == null) {
+				id = daoId;
+			}
 			if (xmlAccessDAO.getPermOrder().equals(AccessControlInterface.ALLOWFIRST)) {
 				allowFirst = true;
 				if (xmlAccessDAO.getPermType().equals(AccessControlInterface.ALLOW)) {
@@ -888,7 +911,7 @@
 				} else {
 					throw new PermOrderException("XMLAccessAccess.validatePrincipalXMLAccessList - " + 
 							" Invalid permission type: " + xmlAccessDAO.getPermType() + " for document " + 
-							xmlAccessDAO.getDocId() + ". Database intervention required "); 
+							daoId + ". Database intervention required "); 
 				}
 			} else if (xmlAccessDAO.getPermOrder().equals(AccessControlInterface.DENYFIRST)) {
 				denyFirst = true;
@@ -899,12 +922,12 @@
 				} else {
 					throw new PermOrderException("XMLAccessAccess.validatePrincipalXMLAccessList - " + 
 							" Invalid permission type: " + xmlAccessDAO.getPermType() + " for document " + 
-							xmlAccessDAO.getDocId() + ". Database intervention required "); 
+							daoId + ". Database intervention required "); 
 				}
 			} else {
 				throw new PermOrderException("XMLAccessAccess.validatePrincipalXMLAccessList - " + 
 						" Invalid permission order: " + xmlAccessDAO.getPermOrder() + " for document " + 
-						xmlAccessDAO.getDocId() + ". Database intervention required "); 
+						daoId + ". Database intervention required "); 
 			}
 		}
 		
@@ -912,7 +935,7 @@
 		// document
 		if(allowFirst && denyFirst) {
 			throw new PermOrderException("XMLAccessAccess.validatePrincipalXMLAccessList - " + 
-					" Conflicting permission orders for document " + docId +
+					" Conflicting permission orders for document " + id +
 					". Database intervention required ");
 		}	
 	}
@@ -927,7 +950,7 @@
 	protected XMLAccessDAO populateDAO(ResultSet resultSet) throws SQLException {
 
 		XMLAccessDAO xmlAccessDAO = new XMLAccessDAO();
-		xmlAccessDAO.setDocId(resultSet.getString("docid"));
+		xmlAccessDAO.setDocId(resultSet.getString(idAttribute));
 		xmlAccessDAO.setAccessFileId(resultSet.getString("accessfileid"));
 		xmlAccessDAO.setPrincipalName(resultSet.getString("principal_name"));
 		xmlAccessDAO.setPermission(resultSet.getLong("permission"));
Index: src/edu/ucsb/nceas/metacat/accesscontrol/XMLAccessDAO.java
===================================================================
--- src/edu/ucsb/nceas/metacat/accesscontrol/XMLAccessDAO.java	(revision 6121)
+++ src/edu/ucsb/nceas/metacat/accesscontrol/XMLAccessDAO.java	(revision 6122)
@@ -40,6 +40,7 @@
 public class XMLAccessDAO extends BaseDAO {
 
 	private String _docId = null;
+	private String _guid = null;
 	private String _accessFileId = null;
 	private String _principalName = null;
 	private Long _permission = null;
@@ -63,6 +64,18 @@
 			_docId = docId;
 		}
 	}
+	
+	public String getGuid() {
+		return _guid;
+	}
+	
+	public void setGuid(String guid) {
+		if (guid != null && guid.equals("")) {
+			guid = null;
+		} else {
+			_guid = guid;
+		}
+	}
 
 	public String getAccessFileId() {
 		return _accessFileId;
Index: src/edu/ucsb/nceas/metacat/IdentifierManager.java
===================================================================
--- src/edu/ucsb/nceas/metacat/IdentifierManager.java	(revision 6121)
+++ src/edu/ucsb/nceas/metacat/IdentifierManager.java	(revision 6122)
@@ -1242,7 +1242,6 @@
      */
     private void insertAccessPolicy(String guid, AccessPolicy accessPolicy) throws McdbDocNotFoundException, AccessException {
     	
-    	String docid = getLocalId(guid);
     	List<XMLAccessDAO> accessDAOs = new ArrayList<XMLAccessDAO>();
         for (AccessRule accessRule: accessPolicy.getAllowList()) {
         	List<Subject> subjects = accessRule.getSubjectList();
@@ -1249,24 +1248,22 @@
         	List<Identifier> resources = accessRule.getResourceList();
         	List<Permission> permissions = accessRule.getPermissionList();
         	for (Subject subject: subjects) {
-        		for (Identifier resource: resources) {
-        			docid = getLocalId(resource.getValue());
-        			XMLAccessDAO accessDAO = new XMLAccessDAO();
-            		accessDAO.setPrincipalName(subject.getValue());
-        			accessDAO.setDocId(docid);
-        			accessDAO.setPermType(AccessControlInterface.ALLOW);
-        			accessDAO.setPermOrder(AccessControlInterface.DENYFIRST);
-        			for (Permission permission: permissions) {
-        				Long metacatPermission = new Long(convertPermission(permission));
-	        			accessDAO.addPermission(metacatPermission);
-        			}
-        			accessDAOs.add(accessDAO);
-        		}
+    			XMLAccessDAO accessDAO = new XMLAccessDAO();
+        		accessDAO.setPrincipalName(subject.getValue());
+    			accessDAO.setGuid(guid);
+    			accessDAO.setPermType(AccessControlInterface.ALLOW);
+    			accessDAO.setPermOrder(AccessControlInterface.DENYFIRST);
+    			for (Permission permission: permissions) {
+    				Long metacatPermission = new Long(convertPermission(permission));
+        			accessDAO.addPermission(metacatPermission);
+    			}
+    			accessDAOs.add(accessDAO);
         	}
         }
         
-        XMLAccessAccess accessController  = new XMLAccessAccess();
-        accessController.replaceAccess(docid, accessDAOs);
+        // use GUID to update
+        XMLAccessAccess accessController  = new XMLAccessAccess(true);
+        accessController.replaceAccess(guid, accessDAOs);
         
         
     }
@@ -1279,13 +1276,10 @@
      * @throws AccessException
      */
     private AccessPolicy getAccessPolicy(String guid) throws McdbDocNotFoundException, AccessException {
-    	String docid = getLocalId(guid);
-        XMLAccessAccess accessController  = new XMLAccessAccess();
-    	List<XMLAccessDAO> accessDAOs = accessController.getXMLAccessForDoc(docid);
-    	AccessRule accessRule = new AccessRule();
-    	Identifier resource = new Identifier();
-    	resource.setValue(guid);
-    	accessRule.addResource(resource);
+    	// use GUID to look up the access
+        XMLAccessAccess accessController  = new XMLAccessAccess(true);
+    	List<XMLAccessDAO> accessDAOs = accessController.getXMLAccessForDoc(guid);
+    	AccessRule accessRule = new AccessRule();    	
         for (XMLAccessDAO accessDAO: accessDAOs) {
         	Permission permission = convertPermission(accessDAO.getPermission().intValue());
         	accessRule.addPermission(permission);
