Index: test/edu/ucsb/nceas/metacat/dataone/CrudServiceTest.java
===================================================================
--- test/edu/ucsb/nceas/metacat/dataone/CrudServiceTest.java	(revision 6361)
+++ test/edu/ucsb/nceas/metacat/dataone/CrudServiceTest.java	(nonexistent)
@@ -1,952 +0,0 @@
-/**
- *  '$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: berkley $'
- *     '$Date: 2010-05-03 14:26:08 -0700 (Fri, 14 Aug 2009) $'
- * '$Revision: 5027 $'
- *
- * 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.io.InputStream;
-import java.io.StringBufferInputStream;
-import java.security.MessageDigest;
-import java.util.Date;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.apache.commons.io.IOUtils;
-import org.dataone.client.ObjectFormatCache;
-import org.dataone.service.exceptions.BaseException;
-import org.dataone.service.types.AuthToken;
-import org.dataone.service.types.Checksum;
-import org.dataone.service.types.ChecksumAlgorithm;
-import org.dataone.service.types.DescribeResponse;
-import org.dataone.service.types.Identifier;
-import org.dataone.service.types.Log;
-import org.dataone.service.types.LogEntry;
-import org.dataone.service.types.NodeReference;
-import org.dataone.service.types.ObjectFormat;
-import org.dataone.service.types.ObjectInfo;
-import org.dataone.service.types.ObjectList;
-import org.dataone.service.types.Subject;
-import org.dataone.service.types.SystemMetadata;
-
-import edu.ucsb.nceas.MCTestCase;
-import edu.ucsb.nceas.metacat.MetaCatServlet;
-import edu.ucsb.nceas.metacat.client.rest.MetacatRestClient;
-import edu.ucsb.nceas.metacat.properties.PropertyService;
-import edu.ucsb.nceas.metacat.service.SessionService;
-import edu.ucsb.nceas.metacat.util.SessionData;
-
-/**
- * A JUnit test for testing the dataone CrudService class
- */
-public class CrudServiceTest extends MCTestCase 
-{   
-    private int createCount = 0;
-    
-    /**
-    * consstructor for the test
-    */
-    public CrudServiceTest(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() 
-	{
-	    System.out.println(createCount + " docs created in this test session.");
-	}
-
-	/**
-	 * Create a suite of tests to be run together
-	 */
-	public static Test suite() 
-	{
-		TestSuite suite = new TestSuite();
-		suite.addTest(new CrudServiceTest("initialize"));
-		
-		suite.addTest(new CrudServiceTest("testSingletonAccessor"));
-		suite.addTest(new CrudServiceTest("testCreateAndGet"));
-		suite.addTest(new CrudServiceTest("testGetSystemMetadata"));
-		suite.addTest(new CrudServiceTest("testUpdate"));
-		suite.addTest(new CrudServiceTest("testListObjects"));
-		suite.addTest(new CrudServiceTest("testAccessControl"));
-		suite.addTest(new CrudServiceTest("testGetLogRecords"));
-		suite.addTest(new CrudServiceTest("testChecksumError"));
-		suite.addTest(new CrudServiceTest("testPublicAccess"));
-		suite.addTest(new CrudServiceTest("testFailedCreate"));
-		suite.addTest(new CrudServiceTest("testChecksum"));
-		suite.addTest(new CrudServiceTest("testDescribe"));
-		suite.addTest(new CrudServiceTest("testDelete"));
-		suite.addTest(new CrudServiceTest("testSemiColonsInIdentifiers"));
-		return suite;
-	}
-	
-	/**
-	 * test for the use of semi colons in identifiers
-	 * in response to https://redmine.dataone.org/issues/1143
-	 */
-	public void testSemiColonsInIdentifiers()
-	{
-	    try
-        {
-            CrudService cs = CrudService.getInstance();
-            AuthToken token = getToken();
-            String testDoc = getTestDoc();
-            
-            Identifier id = new Identifier();
-            id.setValue("someid;id;with;semi;colons;in;it." + new Date().getTime());
-            String docid = generateDocumentId();
-            
-            //create the system metadata then run the create method
-            StringBufferInputStream sbis = new StringBufferInputStream(testDoc);
-            SystemMetadata sm = createSystemMetadata(id, testDoc, 
-                    ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.1.0"));
-            //create the doc
-            Identifier rGuid = cs.create(token, id, sbis, sm);
-            
-            System.out.println("ID: " + rGuid.getValue());
-            assertTrue(rGuid.toString().equals(id.toString())); 
-            System.out.println("created doc with id " + id.getValue());
-        }
-        catch(Exception e)
-        {
-            fail("Unexpected error in testDescribe: " + e.getMessage());
-        }
-	}
-	
-	/**
-	 * test the delete function
-	 */
-	public void testDelete()
-	{
-	    try
-        {
-            CrudService cs = CrudService.getInstance();
-            AuthToken token = getToken();
-            String doc = getTestDoc();
-            Identifier id = createDoc(token, doc);
-            System.out.println("ID: " + id.getValue());
-            makeDocPublic(token, id, true);
-            cs.get(token, id);
-            cs.delete(token, id);
-            //there should be a try/catch around the next statement
-            //to make sure that the document is no longer readable,
-            //but because the data is output in a 2nd thread, the
-            //exception does not get caught here.  See 
-            //https://redmine.dataone.org/issues/1079
-            //cs.get(token, id);
-        }
-        catch(Exception e)
-        {
-            fail("Unexpected error in testDescribe: " + e.getMessage());
-        }
-	}
-	
-	/**
-	 * test the describe crud function
-	 */
-	public void testDescribe()
-	{
-	    try
-	    {
-	        CrudService cs = CrudService.getInstance();
-	        AuthToken token = getToken();
-	        
-	        String doc = getTestDoc();
-	        Identifier id = createDoc(token, doc);
-	        System.out.println("ID: " + id.getValue());
-	        makeDocPublic(token, id, true);
-	        
-	        SystemMetadata sm = cs.getSystemMetadata(token, id);
-	        
-	        DescribeResponse dr = cs.describe(token, id);
-	        
-	        assertTrue(dr.getDataONE_Checksum().getValue().equals(sm.getChecksum().getValue()));
-	        assertTrue(dr.getDataONE_ObjectFormat().toString().equals(sm.getObjectFormat().getFmtid().getValue()));
-	        assertTrue(dr.getLast_Modified().getTime() == sm.getDateSysMetadataModified().getTime());
-	        assertTrue(dr.getContent_Length() == sm.getSize());
-	    }
-	    catch(Exception e)
-	    {
-	        fail("Unexpected error in testDescribe: " + e.getMessage());
-	    }
-	}
-	
-	/**
-	 * test the checksum creation
-	 */
-	public void testChecksum()
-	{
-	    try
-	    {
-	        CrudService cs = CrudService.getInstance();
-	        AuthToken token = getToken();
-	        System.out.println("token: " + token.getToken());
-	        String doc = getTestDoc();
-	        Identifier id = createDoc(token, doc);
-	        System.out.println("ID: " + id.getValue());
-            makeDocPublic(token, id, true);
-	        String doc2 = getDoc(token, id);
-            
-	        String checksum = checksum(doc);
-            Checksum checksum2 = cs.getChecksum(token, id, "MD5");
-            System.out.println("doc: \"" + doc + "\"");
-            System.out.println("doc2: \"" + doc2 + "\"");
-            System.out.println("checksum1: " + checksum);
-            System.out.println("checksum2: " + checksum2.getValue());
-            assertTrue(checksum.equals(checksum2.getValue()));
-            
-	    }
-	    catch(Exception e)
-	    {
-	        fail("Unexpected error in testChecksum: " + e.getMessage());
-	    }
-	    
-	}
-	
-	/**
-	 * insert an invalid document and make sure create fails and does not
-	 * leave any artifacts behind
-	 */
-	public void testFailedCreate()
-	{
-	    try
-	    {
-	        String invalidDoc = "<xxx></yyy>";
-	        System.out.println("trying to insert doc " + invalidDoc);
-	        CrudService cs = CrudService.getInstance();
-            AuthToken token = getToken();
-            //run create
-            try
-            {
-                Identifier id = createDoc(token, invalidDoc);
-                fail("Should have thrown an exception.");
-            }
-            catch(Exception e)
-            {
-                //e.printStackTrace();
-            }
-            
-	    }
-	    catch(Exception e)
-	    {
-	        fail("unexpected exception in testFailedCreate: " + e.getMessage());
-	    }
-	}
-	
-	/**
-	 * test to make sure that get and listObjects methods are publicly accessible
-	 */
-	public void testPublicAccess()
-	{
-	    try
-	    {
-	        System.out.println("********************* testPublicAccess *********************");
-	        AuthToken token = new AuthToken("public");
-	        //AuthToken token = getToken();
-	        CrudService cs = CrudService.getInstance();
-	        ObjectList ol = cs.listObjects(token, null, null, null);
-	        System.out.println("ol: " + ol.sizeObjectInfoList());
-	        assertTrue(ol.sizeObjectInfoList() > 0);
-	        
-	        ObjectInfo oi = ol.getObjectInfo(0);
-	        String s = getDoc(token, oi.getIdentifier());
-	        assertNotNull(s);
-	        
-	        try
-	        { //try a create with the public auth.  should fail
-	            Identifier id = new Identifier();
-	            String docid = generateDocumentId();
-	            id.setValue(docid);
-	            String testDoc = getTestDoc();
-	            StringBufferInputStream sbis = new StringBufferInputStream(testDoc);
-	            ObjectFormat of1 = ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.1.0");
-	            SystemMetadata sm = createSystemMetadata(id, testDoc, of1);
-	            assertFalse(sm.getChecksum().getValue().startsWith("MD5"));
-	            //create the doc
-	            Identifier idC = cs.create(token, id, sbis, sm);
-	            fail("Should have thrown an auth exception");
-	        }
-	        catch(Exception e)
-	        {
-	            
-	        }
-	        
-	        //create a legit doc
-	        token = getToken();
-	        Identifier id = new Identifier();
-            String docid = generateDocumentId();
-            id.setValue(docid);
-            String testDoc = getTestDoc();
-            StringBufferInputStream sbis = new StringBufferInputStream(testDoc);
-            ObjectFormat of1 = ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.1.0");
-            SystemMetadata sm = createSystemMetadata(id, testDoc, of1);
-            assertFalse(sm.getChecksum().getValue().startsWith("MD5"));
-            //create the doc
-            Identifier idC = cs.create(token, id, sbis, sm);
-            //make it public, then use a public token to try to get it
-            InputStream data = null;
-            try
-            {
-                AuthToken publicToken = new AuthToken("public");
-                data = cs.get(publicToken, id);
-                data.read();
-                
-                fail("should have thrown an exception");
-            }
-            catch(Exception e)
-            {
-                /*System.out.println("%%%%%%%%%%%%%%%%%%%%%%%getting result");
-                Object o = ((InputStreamFromOutputStream)data).getResult();
-                System.out.println("result: " + o);
-                System.out.println("exception thrown!");
-                System.out.println("exception thrown: " + e.getClass().getName());*/
-            }
-            
-            
-            
-            makeDocPublic(token, id, true);
-            token = new AuthToken("public");
-	        data = cs.get(token, id);
-	    }
-	    catch(Exception e)
-	    {
-	        fail("Error in testPublicAccess: " + e.getMessage());
-	    }
-	    
-	}
-	
-	/**
-	 * test for an error where the checksum algorithm gets appended onto the checksum.
-	 */
-	public void testChecksumError()
-	{
-	    printTestHeader("testChecksumError");
-	    try
-	    {
-	        Date d1 = new Date(new Date().getTime() - 5000);
-	        CrudService cs = CrudService.getInstance();
-	        AuthToken token = getToken();
-	        ObjectFormat of1 = ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.1.0");
-	        //create docs at different times
-
-	        Identifier id = new Identifier();
-	        String docid = "test." + new Date().getTime();
-	        id.setValue(docid);
-
-	        //create the system metadata then run the create method
-	        String testDoc = getTestDoc();
-	        StringBufferInputStream sbis = new StringBufferInputStream(testDoc);
-	        SystemMetadata sm = createSystemMetadata(id, testDoc, of1);
-	        assertFalse(sm.getChecksum().getValue().startsWith("MD5"));
-	        //create the doc
-	        Identifier idC = cs.create(token, id, sbis, sm);
-	        makeDocPublic(token, id, true);
-	        assertTrue(idC.getValue().equals(id.getValue()));
-	        SystemMetadata smC = getSystemMetadata(token, idC);
-	        assertFalse(smC.getChecksum().getValue().startsWith("MD5"));
-	        
-	        Date d2 = new Date(new Date().getTime() + 5000);
-	        
-	        ObjectList ol = cs.listObjects(token, d1, d2, of1);
-	        assertTrue(ol.sizeObjectInfoList() > 0);
-	        ObjectInfo oi = ol.getObjectInfo(0);
-	        //this will fail if the error state exists.
-	        assertFalse(oi.getChecksum().getValue().startsWith("MD5"));
-	    }
-	    catch(Exception e)
-	    {
-	        fail("Unexpected exception: " + e.getMessage());
-	    }
-        
-	}
-	
-	/**
-	 * test CrudService.getLogRecords
-	 */
-	public void testGetLogRecords()
-	{
-	    printTestHeader("testGetLogRecords");
-	    try
-	    {
-	        CrudService cs = CrudService.getInstance();
-	        AuthToken token = getToken();
-	        Date fromDate = new Date();
-	        Identifier id = createDoc(token, getTestDoc());
-	        Date toDate = new Date();
-	        Log lrs = cs.getLogRecords(token, fromDate, toDate, null);
-	        assertNotNull(lrs);
-	        System.out.println("log entry size: " + lrs.sizeLogEntryList());
-	        assertTrue(lrs.sizeLogEntryList() == 1);
-	        LogEntry lrLogEvent = lrs.getLogEntry(0);
-	        assertTrue(lrLogEvent.getEvent().name().equals("CREATE"));
-	        assertTrue(lrLogEvent.getIdentifier().getValue().equals(id.getValue()));
-	    }
-	    catch(Exception e)
-	    {
-	        e.printStackTrace();
-	        fail("testGetLogRecords threw an unexpected exception: " + e.getMessage());
-	    }
-	}
-	
-	/**
-	 * make sure that only valid sessions can update/delete
-	 */
-	public void testAccessControl()
-	{
-	    printTestHeader("testAccessControl");
-        try
-        {
-            CrudService cs = CrudService.getInstance();
-            AuthToken token = getToken();
-            //create a doc
-            Identifier id = createDoc(token, getTestDoc());
-            
-            //get the doc and sysmetadata
-            String gotDoc = getDoc(token, id);
-            SystemMetadata sm = getSystemMetadata(token, id);
-            
-            //break the session id
-            String sessionid = "somefakesessionid";
-            token = new AuthToken(sessionid);
-            
-            //update the doc
-            gotDoc = gotDoc.replaceAll("XXX", "YYY");
-            Identifier newid = new Identifier();
-            newid.setValue(generateDocumentId());
-            StringBufferInputStream sbis = new StringBufferInputStream(gotDoc);
-            SystemMetadata newsm = createSystemMetadata(newid, gotDoc);
-            Identifier updatedid = cs.update(token, newid, sbis, id, newsm);
-            fail("exception should have been thrown.");
-        }
-        catch(Exception e)
-        {
-        }
-        
-        try
-        {
-            CrudService cs = CrudService.getInstance();
-            AuthToken token = new AuthToken("somefakesessionid");
-            //create a doc
-            Identifier id = createDoc(token, getTestDoc());
-            fail("exception should have been thrown.");
-        }
-        catch(Exception e)
-        {
-        }
-	}
-	
-	/**
-	 * public ObjectList listObjects(AuthToken token, Date startTime, Date endTime, 
-     *     ObjectFormat objectFormat, boolean replicaStatus, int start, int count)
-     *       throws NotAuthorized, InvalidRequest, NotImplemented, ServiceFailure, InvalidToken
-	 */
-	public void testListObjects()
-	{
-	    printTestHeader("testListObjects");
-	    try
-	    {
-	        CrudService cs = CrudService.getInstance();
-	        AuthToken token = getToken();
-	        ObjectFormat of1 = ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.1.0");
-	        ObjectFormat of2 = ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.0.0");
-	        //create docs at different times
-	        Date d1 = new Date();
-	        Identifier id1 = createDoc(token, getTestDoc(EML2_1_0), of1);
-            SystemMetadata sm1 = getSystemMetadata(token, id1);
-            
-            Date d2 = new Date();
-            Identifier id2 = createDoc(token, getTestDoc(EML2_0_0), of2);
-            makeDocPublic(token, id2, true);
-            SystemMetadata sm2 = getSystemMetadata(token, id2);
-            
-            Date d3 = new Date();
-            Identifier id3 = createDoc(token, getTestDoc(EML2_1_0), of1);
-            makeDocPublic(token, id3, true);
-            SystemMetadata sm3 = getSystemMetadata(token, id3);
-              
-            Date d4 = new Date();
-            Identifier id4 = createDoc(token, getTestDoc(EML2_0_0), of2);
-            makeDocPublic(token, id4, true);
-            SystemMetadata sm4 = getSystemMetadata(token, id4);
-            
-            Date d5 = new Date();
-            Identifier id5 = createDoc(token, getTestDoc(EML2_1_0), of1);
-            makeDocPublic(token, id5, true);
-            SystemMetadata sm5 = getSystemMetadata(token, id5);  
-             
-            Date d6 = new Date();
-            
-            //now get the objects for specific time ranges and test that it returns
-            //the correct objects
-            
-            //ObjectList list = cs.listObjects(token, null, null, null);
-            //System.out.println("list size: " + list.sizeObjectInfoList());
-           
-            //should return sm1 and sm2
-            ObjectList list1 = cs.listObjects(token, d1, d3, null);
-            assertTrue(list1.sizeObjectInfoList() == 2);
-            assertTrue(idInObjectList(id1, list1));
-            assertTrue(idInObjectList(id2, list1));
-            
-            ObjectInfo info = list1.getObjectInfo(0);
-            
-            
-            //should only return sm1
-            ObjectList list2 = cs.listObjects(token, d1, d3, of1);
-            assertTrue(list2.sizeObjectInfoList() == 1);
-            assertTrue(idInObjectList(id1, list2));
-            
-            //should return sm1-sm4
-            ObjectList list3 = cs.listObjects(token, d1, d5, null);
-            assertTrue(list3.sizeObjectInfoList() == 4);
-            ObjectInfo oi4 = list3.getObjectInfo(0);
-            assertTrue(idInObjectList(id1, list3));
-            assertTrue(idInObjectList(id2, list3));
-            assertTrue(idInObjectList(id3, list3));
-            assertTrue(idInObjectList(id4, list3));
-            
-            //should only return sm2 and sm4
-            ObjectList list4 = cs.listObjects(token, d1, d5, of2);
-            assertTrue(list4.sizeObjectInfoList() == 2);
-            assertTrue(idInObjectList(id2, list4));
-            assertTrue(idInObjectList(id4, list4));
-            
-            //should return all
-            ObjectList list5 = cs.listObjects(token, d1, d6, null);
-            assertTrue(list5.sizeObjectInfoList() == 5);
-            assertTrue(idInObjectList(id1, list5));
-            assertTrue(idInObjectList(id2, list5));
-            assertTrue(idInObjectList(id3, list5));
-            assertTrue(idInObjectList(id4, list5));
-            assertTrue(idInObjectList(id5, list5));
-            
-            //should return 1, 3, 5
-            ObjectList list6 = cs.listObjects(token, d1, d6, of1);
-            assertTrue(list6.sizeObjectInfoList() == 3);
-            assertTrue(idInObjectList(id1, list6));
-            assertTrue(idInObjectList(id3, list6));
-            assertTrue(idInObjectList(id5, list6));
-            
-            //should return 4 (id1 is not public)
-            token = new AuthToken("public");
-            ObjectList list7 = cs.listObjects(token, d1, d6, null);
-            //System.out.println("list7 size: " + list7.sizeObjectInfoList());
-            assertTrue(list7.sizeObjectInfoList() == 5);
-            
-            //test paging
-            ObjectList list8 = cs.listObjects(token, d1, d6, null, false, 2, 2);
-            assertTrue(list8.getCount() == 2);
-            assertTrue(list8.getStart() == 2);
-            assertTrue(list8.getTotal() == 5);
-            
-            
-	    }
-	    catch(Exception e)
-	    {
-	        //e.printStackTrace();
-	        fail("Error in listObjects: " + e.getMessage());
-	    }
-	}
-	
-	private boolean idInObjectList(Identifier id, ObjectList list)
-	{
-	    for(int i=0; i<list.sizeObjectInfoList(); i++)
-	    {
-	        ObjectInfo oi = list.getObjectInfo(i);
-	        if(id.getValue().equals(oi.getIdentifier().getValue()))
-	            return true;
-	    }
-	    return false;
-	}
-	
-	/**
-	 * public Identifier update(AuthToken token, Identifier guid, 
-     *       InputStream object, Identifier obsoletedGuid, SystemMetadata sysmeta) 
-     *         throws InvalidToken, ServiceFailure, NotAuthorized, IdentifierNotUnique, 
-     *           UnsupportedType, InsufficientResources, NotFound, InvalidSystemMetadata, 
-     *           NotImplemented
-	 */
-	public void testUpdate()
-	{
-	    printTestHeader("testUpdate");
-	    try
-	    {
-	        CrudService cs = CrudService.getInstance();
-	        AuthToken token = getToken();
-            //create a doc
-            Identifier id = createDoc(token, getTestDoc());
-            
-            //get the doc and sysmetadata
-            String gotDoc = getDoc(token, id);
-            SystemMetadata sm = getSystemMetadata(token, id);
-            
-            //update the doc
-            gotDoc = gotDoc.replaceAll("XXX", "YYY");
-            Identifier newid = new Identifier();
-            newid.setValue(generateDocumentId());
-            StringBufferInputStream sbis = new StringBufferInputStream(gotDoc);
-            SystemMetadata newsm = createSystemMetadata(newid, gotDoc);
-            Identifier updatedid = cs.update(token, newid, sbis, id, newsm);
-            
-            //get doc - check that it matches update
-            String newdoc = getDoc(token, newid);
-            assertTrue(gotDoc.equals(newdoc));
-            
-            //get sysmeta - check that ids and other fields are updated
-            SystemMetadata newnewsm = getSystemMetadata(token, id);
-            assertTrue(newnewsm.getObsoletedBy(0).getValue().equals(newid.getValue()));
-            
-            //get the new sysmeta and make sure the obsoletes field is set
-            SystemMetadata newnewnewsm = getSystemMetadata(token, newid);
-            assertTrue(newnewnewsm.getObsolete(0).getValue().equals(id.getValue()));
-        }
-        catch(Exception e)
-        {
-            e.printStackTrace();
-            fail("Error in testUpdate: " + e.getMessage());
-        }
-	}
-	
-	/**
-	 * public SystemMetadata getSystemMetadata(AuthToken token, Identifier guid)
-     *       throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
-     *       InvalidRequest, NotImplemented
-	 */
-	public void testGetSystemMetadata()
-	{
-	    printTestHeader("testGetSystemMetadata");
-	    try
-	    {
-            CrudService cs = CrudService.getInstance();
-            AuthToken token = getToken();
-            //run create
-            Identifier id = createDoc(token, getTestDoc());
-            //get the systemMetadata and make sure it is the correct object for this testDoc
-            SystemMetadata sm = getSystemMetadata(token, id);
-            assertTrue(sm.getIdentifier().getValue().equals(id.getValue()));
-            assertTrue(sm.getChecksum().getValue().equals(checksum(getTestDoc())));
-            
-            try
-            {
-                Identifier fakeid = new Identifier();
-                fakeid.setValue("somethingfake.234234");
-                getSystemMetadata(token, fakeid);
-                fail("getSystemMetadata should have thrown an exception.");
-            }
-            catch(Exception e)
-            {
-                assertTrue(true);
-            }
-        }
-        catch(Exception e)
-        {
-            e.printStackTrace();
-            fail("Error testing system metadata: " + e.getMessage());
-        }
-	}
-	
-	/**
-	 * create(AuthToken token, Identifier guid, InputStream object, SystemMetadata sysmeta) 
-   *   throws InvalidToken, ServiceFailure, NotAuthorized, IdentifierNotUnique, UnsupportedType, 
-   *       InsufficientResources, InvalidSystemMetadata, NotImplemented
-   *
-   * public InputStream get(AuthToken token, Identifier guid)
-   *       throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
-   *       NotImplemented
-	 */
-	public void testCreateAndGet()
-	{
-	    printTestHeader("testCreateAndGet");
-	    try
-	    {
-	        CrudService cs = CrudService.getInstance();
-	        AuthToken token = getToken();
-	        //run create
-	        Identifier id = createDoc(token, getTestDoc());
-	        //make these docs public for debugging purposes.
-	        makeDocPublic(token, id, true);
-            //compare the docs
-            String gotDoc = getDoc(token, id);
-            assertTrue(gotDoc.trim().equals(getTestDoc().trim()));
-            
-            try
-            {
-                Identifier fakeid = new Identifier();
-                fakeid.setValue("somethingfake.234234");
-                getDoc(token, fakeid);
-                fail("testCreateAndGet should have thrown an exception.");
-            }
-            catch(Exception e)
-            {
-                assertTrue(true);
-            }
-        }
-        catch(Exception e)
-        {
-            e.printStackTrace();
-            fail("Error in testCreate: " + e.getMessage());
-        }
-	}
-	
-	/**
-	 * getInstance()
-	 */
-	public void testSingletonAccessor()
-	{
-	    printTestHeader("testSingletonAccessor");
-	    CrudService cs = CrudService.getInstance();
-	    assertNotNull(cs);
-	}
-	
-	/**
-	 * Run an initial test that always passes to check that the test harness is
-	 * working.
-	 */
-	public void initialize() 
-	{
-	    printTestHeader("initialize");
-		assertTrue(1 == 1);
-	}
-	
-	/**
-	 * return the systemMetadata object for id
-	 */
-	private SystemMetadata getSystemMetadata(AuthToken token, Identifier id)
-	  throws BaseException
-	{
-	    CrudService cs = CrudService.getInstance();
-	    return cs.getSystemMetadata(token, id);
-	}
-	
-	/**
-	 * get a doc from metacat using CrudService.get()
-	 */
-	private String getDoc(AuthToken token, Identifier id)
-	  throws Exception
-	{
-	    CrudService cs = CrudService.getInstance();
-        InputStream gotDocStream = cs.get(token, id);
-        return IOUtils.toString(gotDocStream);
-	}
-	
-	public String getTestDoc()
-	{
-	    return getTestDoc("eml://ecoinformatics.org/eml-2.1.0");
-	}
-	
-	/**
-	 * return a test document.  objectFormat should come from MCTestCase
-	 */
-	public String getTestDoc(String objectFormat)
-	{
-	    if(objectFormat == null)
-	    {
-	        return "<?xml version=\"1.0\"?><test><somecontent>This is some content XXX</somecontent></test>\n";
-	    }
-	    
-	    String accessBlock = getAccessBlock("public", true, true,
-                false, false, false);
-	    
-	    
-	    return getTestEmlDoc("Test identifier manager", objectFormat, null,
-	                null, "http://fake.example.com/somedata", null,
-	                accessBlock, null, null,
-	                null, null);
-	}
-	
-	/**
-	 * authenticate and return a token
-	 * use the test.mcUser and test.mcPassword username/password combo
-	 */
-	public AuthToken getToken()
-	  throws Exception
-	{
-        String username = PropertyService.getProperty("test.mcUser");
-        String password = PropertyService.getProperty("test.mcPassword");
-        return getToken(username, password);
-	}
-	
-	/**
-	 * authenticate and return a token using the given credentials
-	 */
-	public AuthToken getToken(String username, String password)
-	  throws Exception
-	{
-	    CrudService cs = CrudService.getInstance();
-        //login and get a sessionid
-        MetacatRestClient restClient = new MetacatRestClient(cs.getContextUrl());
-        String response = restClient.login(username, password);
-        String sessionid = restClient.getSessionId();
-        SessionService sessionService = SessionService.getInstance();
-        sessionService.registerSession(new SessionData(sessionid, username, new String[0], password, "CrudServiceLogin"));
-        AuthToken token = new AuthToken(sessionid);
-        return token;
-	}
-	
-	/**
-	 * create a doc using CrudService.create() and return its id
-	 */
-	public Identifier createDoc(AuthToken token, String testDoc) throws Exception
-	{
-	    return createDoc(token, testDoc, ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.1.0"));
-	}
-	
-	/**
-	 * create a doc using CrudService.create() and return its id
-	 */
-	public Identifier createDoc(AuthToken token, String testDoc, ObjectFormat format) throws Exception
-	{
-	    Identifier id;
-        CrudService cs = CrudService.getInstance();
-        
-        id = new Identifier();
-        String docid = generateDocumentId();
-        id.setValue(docid);
-        
-        //create the system metadata then run the create method
-        StringBufferInputStream sbis = new StringBufferInputStream(testDoc);
-        SystemMetadata sm = createSystemMetadata(id, testDoc, format);
-        //create the doc
-        cs.create(token, id, sbis, sm);
-        createCount++;
-        return id;
-	}
-	
-	/**
-	 * create a generic SystemMetadata object for testing
-	 */
-	private SystemMetadata createSystemMetadata(Identifier id, String testDoc)
-	  throws Exception
-	{
-	    return createSystemMetadata(id, testDoc, 
-	            ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.1.0"));
-	}
-	
-	/**
-	 * create system metadata with a specified id, doc and format
-	 */
-	private SystemMetadata createSystemMetadata(Identifier id, String testDoc, ObjectFormat format)
-	  throws Exception
-	{
-	    SystemMetadata sm = new SystemMetadata();
-        //set the id
-        sm.setIdentifier(id);
-        sm.setObjectFormat(format);
-        //create the checksum
-        String checksumS = checksum(testDoc);
-        ChecksumAlgorithm ca = ChecksumAlgorithm.convert("MD5");
-        Checksum checksum = new Checksum();
-        checksum.setValue(checksumS);
-        checksum.setAlgorithm(ca);
-        sm.setChecksum(checksum);
-        //set the size
-        sm.setSize(testDoc.getBytes(MetaCatServlet.DEFAULT_ENCODING).length);
-        //submitter
-        Subject p = new Subject();
-        p.setValue("joe");
-        sm.setSubmitter(p);
-        sm.setRightsHolder(p);
-        sm.setDateUploaded(new Date());
-        sm.setDateSysMetadataModified(new Date());
-        NodeReference nr = new NodeReference();
-        nr.setValue("metacat");
-        sm.setOriginMemberNode(nr);
-        sm.setAuthoritativeMemberNode(nr);
-        return sm;
-	}
-	
-	/**
-	 *  make a document public in metacat by inserting an access document
-	 * @param id
-	 */
-	private void makeDocPublic(AuthToken token, Identifier id, boolean systemMetadataToo)
-	  throws Exception
-	{
-	    CrudService cs = CrudService.getInstance();
-	    cs.setAccess(token, id, "public", "read", "allow", "allowFirst", systemMetadataToo);
-	}
-	
-	/**
-	 * print a header to start each test
-	 */
-	private void printTestHeader(String testName)
-	{
-	    System.out.println();
-	    System.out.println("*************** " + testName + " ***************");
-	}
-  
-	/**
-	 * produce an md5 checksum for item
-	 */
-	private String checksum(String item)
-	  throws Exception
-	{
-        StringBufferInputStream fis =  new StringBufferInputStream(item);
-        
-        byte[] buffer = new byte[1024];
-        MessageDigest complete = MessageDigest.getInstance("MD5");
-        int numRead;
-        
-        do 
-        {
-          numRead = fis.read(buffer);
-          if (numRead > 0) 
-          {
-            complete.update(buffer, 0, numRead);
-          }
-        } while (numRead != -1);
-        
-        
-        return getHex(complete.digest());
-	}
-	
-	/**
-	 * convert a byte array to a hex string
-	 */
-	private static String getHex( byte [] raw ) 
-	{
-	    final String HEXES = "0123456789ABCDEF";
-        if ( raw == null ) {
-          return null;
-        }
-        final StringBuilder hex = new StringBuilder( 2 * raw.length );
-        for ( final byte b : raw ) {
-          hex.append(HEXES.charAt((b & 0xF0) >> 4))
-             .append(HEXES.charAt((b & 0x0F)));
-        }
-        return hex.toString();
-  }
-}
Index: src/edu/ucsb/nceas/metacat/dataone/CrudService.java
===================================================================
--- src/edu/ucsb/nceas/metacat/dataone/CrudService.java	(revision 6361)
+++ src/edu/ucsb/nceas/metacat/dataone/CrudService.java	(nonexistent)
@@ -1,1831 +0,0 @@
-/**
- *  '$RCSfile$'
- *  Copyright: 2000 Regents of the University of California and the
- *              National Center for Ecological Analysis and Synthesis
- *
- *   '$Author: $'
- *     '$Date: 2009-06-13 15:28:13 +0300  $'
- *
- * 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.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.NoSuchAlgorithmException;
-import java.sql.SQLException;
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.TimeZone;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.Vector;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.log4j.Logger;
-import org.dataone.service.exceptions.IdentifierNotUnique;
-import org.dataone.service.exceptions.InsufficientResources;
-import org.dataone.service.exceptions.InvalidRequest;
-import org.dataone.service.exceptions.InvalidSystemMetadata;
-import org.dataone.service.exceptions.InvalidToken;
-import org.dataone.service.exceptions.NotAuthorized;
-import org.dataone.service.exceptions.NotFound;
-import org.dataone.service.exceptions.NotImplemented;
-import org.dataone.service.exceptions.ServiceFailure;
-import org.dataone.service.exceptions.UnsupportedType;
-import org.dataone.service.mn.MemberNodeCrud;
-import org.dataone.service.types.AuthToken;
-import org.dataone.service.types.Checksum;
-import org.dataone.service.types.ChecksumAlgorithm;
-import org.dataone.service.types.DescribeResponse;
-import org.dataone.service.types.Event;
-import org.dataone.service.types.Identifier;
-import org.dataone.service.types.Log;
-import org.dataone.service.types.LogEntry;
-import org.dataone.service.types.NodeReference;
-import org.dataone.service.types.ObjectFormat;
-import org.dataone.service.types.ObjectList;
-import org.dataone.service.types.Subject;
-import org.dataone.service.types.SystemMetadata;
-import org.dataone.service.types.util.ServiceTypeUtil;
-
-import edu.ucsb.nceas.metacat.AccessionNumberException;
-import edu.ucsb.nceas.metacat.DocumentImpl;
-import edu.ucsb.nceas.metacat.EventLog;
-import edu.ucsb.nceas.metacat.IdentifierManager;
-import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
-import edu.ucsb.nceas.metacat.McdbException;
-import edu.ucsb.nceas.metacat.MetacatHandler;
-import edu.ucsb.nceas.metacat.client.InsufficientKarmaException;
-import edu.ucsb.nceas.metacat.client.rest.MetacatRestClient;
-import edu.ucsb.nceas.metacat.properties.PropertyService;
-import edu.ucsb.nceas.metacat.replication.ForceReplicationHandler;
-import edu.ucsb.nceas.metacat.service.SessionService;
-import edu.ucsb.nceas.metacat.util.DocumentUtil;
-import edu.ucsb.nceas.metacat.util.SessionData;
-import edu.ucsb.nceas.utilities.ParseLSIDException;
-import edu.ucsb.nceas.utilities.PropertyNotFoundException;
-
-/**
- * 
- * Implements DataONE MemberNode CRUD API for Metacat. 
- * 
- * @author Matthew Jones
- */
-public class CrudService implements MemberNodeCrud
-{
-    private static CrudService crudService = null;
-
-    private MetacatHandler handler;
-    private Hashtable<String, String[]> params;
-    private Logger logMetacat = null;
-    private Logger logCrud = null;
-    
-    private String metacatUrl;
-    
-    /**
-     * singleton accessor
-     */
-    public static CrudService getInstance() 
-    {
-      if(crudService == null)
-      {
-        crudService = new CrudService();
-      }
-      
-      return crudService;
-    }
-    
-    /**
-     * Constructor, private for singleton access
-     */
-    private CrudService() {
-        logMetacat = Logger.getLogger(CrudService.class);
-        logCrud = Logger.getLogger("DataOneLogger");
-        try
-        {
-            String server = PropertyService.getProperty("server.name");
-            String port = PropertyService.getProperty("server.httpPort");
-            String context = PropertyService.getProperty("application.context");
-            metacatUrl = "http://" + server + ":" + port + "/" + context + "/d1";
-            logMetacat.debug("Initializing CrudService with url " + metacatUrl);
-        }
-        catch(Exception e)
-        {
-            logMetacat.error("Could not find servlet url in CrudService: " + e.getMessage());
-            e.printStackTrace();
-            throw new RuntimeException("Error getting servlet url in CrudService: " + e.getMessage());
-        }
-        
-        params = new Hashtable<String, String[]>();
-        handler = new MetacatHandler(new Timer());
-    }
-    
-    /**
-     * return the context url CrudService is using.
-     */
-    public String getContextUrl()
-    {
-        return metacatUrl;
-    }
-    
-    /**
-     * Set the context url that this service uses.  It is normally not necessary
-     * to call this method unless you are trying to connect to a server other
-     * than the one in which this service is installed.  Otherwise, this value is
-     * taken from the metacat.properties file (server.name, server.port, application.context).
-     */
-    public void setContextUrl(String url)
-    {
-        metacatUrl = url;
-    }
-    
-    /**
-     * set the params for this service from an HttpServletRequest param list
-     */
-    public void setParamsFromRequest(HttpServletRequest request)
-    {
-        @SuppressWarnings("unchecked")
-        Enumeration<String> paramlist = request.getParameterNames();
-        while (paramlist.hasMoreElements()) {
-            String name = (String) paramlist.nextElement();
-            String[] value = (String[])request.getParameterValues(name);
-            params.put(name, value);
-        }
-    }
-    
-    /**
-     * Authenticate against metacat and get a token.
-     * @param username
-     * @param password
-     * @return
-     * @throws ServiceFailure
-     */
-    public AuthToken authenticate(String username, String password)
-      throws ServiceFailure
-    {
-        /* TODO:
-         * This method is not in the original D1 crud spec.  It is highly
-         * metacat centric.  Higher level decisions need to be made on authentication
-         * interfaces for D1 nodes.
-         */
-        try
-        {
-            MetacatRestClient restClient = new MetacatRestClient(getContextUrl());   
-            String response = restClient.login(username, password);
-            String sessionid = restClient.getSessionId();
-            SessionService sessionService = SessionService.getInstance();
-            sessionService.registerSession(new SessionData(sessionid, username, new String[0], password, "CrudServiceLogin"));
-            AuthToken token = new AuthToken(sessionid);
-            EventLog.getInstance().log(metacatUrl,
-                    username, null, "authenticate");
-            logCrud.info("authenticate");
-            return token;
-        }
-        catch(Exception e)
-        {
-            throw new ServiceFailure("1620", "Error authenticating with metacat: " + e.getMessage());
-        }
-    }
-    
-    /**
-     * set the parameter values needed for this request
-     */
-    public void setParameter(String name, String[] value)
-    {
-        params.put(name, value);
-    }
-    
-
-    
-    
-    
-    /**
-     * create an object via the crud interface
-     */
-    public Identifier create(AuthToken token, Identifier guid, 
-            InputStream object, SystemMetadata sysmeta) throws InvalidToken, 
-            ServiceFailure, NotAuthorized, IdentifierNotUnique, UnsupportedType, 
-            InsufficientResources, InvalidSystemMetadata, NotImplemented {
-        logMetacat.debug("Starting CrudService.create()...");
-        
-        // authenticate & get user info
-        SessionData sessionData = getSessionData(token);
-        String username = "public";
-        String[] groups = null;
-        if(sessionData != null)
-        {
-            username = sessionData.getUserName();
-            groups = sessionData.getGroupNames();
-        }
-        String localId = null;
-
-        if (username == null || username.equals("public"))
-        {
-            //TODO: many of the thrown exceptions do not use the correct error codes
-            //check these against the docs and correct them
-            throw new NotAuthorized("1100", "User " + username + " is not authorized to create content." +
-                    "  If you are not logged in, please do so and retry the request.");
-        }
-        
-        // verify that guid == SystemMetadata.getIdentifier()
-        logMetacat.debug("Comparing guid|sysmeta_guid: " + guid.getValue() + "|" + sysmeta.getIdentifier().getValue());
-        if (!guid.getValue().equals(sysmeta.getIdentifier().getValue())) {
-            throw new InvalidSystemMetadata("1180", 
-                "GUID in method call (" + guid.getValue() + ") does not match GUID in system metadata (" +
-                sysmeta.getIdentifier().getValue() + ").");
-        }
-
-        logMetacat.debug("Checking if identifier exists...");
-        // Check that the identifier does not already exist
-        IdentifierManager im = IdentifierManager.getInstance();
-        if (im.identifierExists(guid.getValue())) {
-            throw new IdentifierNotUnique("1120", 
-                "GUID is already in use by an existing object.");
-        }
-
-        // Check if we are handling metadata or data
-        boolean isScienceMetadata = isScienceMetadata(sysmeta);
-        
-        if (isScienceMetadata) {
-            // CASE METADATA:
-            try {
-                //logCrud.debug("CrudService: inserting document with guid " + guid.getValue());
-                this.insertDocument(object, guid, sessionData);
-                localId = im.getLocalId(guid.getValue());
-            } catch (IOException e) {
-                String msg = "Could not create string from XML stream: " +
-                    " " + e.getMessage();
-                logMetacat.debug(msg);
-                throw new ServiceFailure("1190", msg);
-            } catch(Exception e) {
-                String msg = "Unexpected error in CrudService.create: " + e.getMessage();
-                logMetacat.debug(msg);
-                throw new ServiceFailure("1190", msg);
-            }
-            
-
-        } else {
-            // DEFAULT CASE: DATA (needs to be checked and completed)
-            localId = insertDataObject(object, guid, sessionData);
-            
-        }
-
-        // For Metadata and Data, insert the system metadata into the object store too
-        insertSystemMetadata(sysmeta, sessionData);
-        //get the document info.  add any access params for the sysmeta too
-        //logCrud.debug("looking for access records to add for system " +
-        //    "metadata who's parent doc's  local id is " + localId);
-        try
-        {
-            Hashtable<String, Object> h = im.getDocumentInfo(localId.substring(0, localId.lastIndexOf(".")));
-            Vector v = (Vector)h.get("access");
-            for(int i=0; i<v.size(); i++)
-            {
-                @SuppressWarnings("unchecked")
-                Hashtable<String, String> ah = (Hashtable<String, String>)v.elementAt(i);
-                String principal = (String)ah.get("principal_name");
-                String permission = (String)ah.get("permission");
-                String permissionType = (String)ah.get("permission_type");
-                String permissionOrder = (String)ah.get("permission_order");
-                int perm = new Integer(permission).intValue();
-                //logCrud.debug("found access record for principal " + principal);
-                //logCrud.debug("permission: " + perm + " perm_type: " + permissionType + 
-                //    " perm_order: " + permissionOrder);
-                this.setAccess(token, guid, principal, perm, permissionType, permissionOrder, true);
-            }
-        }
-        catch(Exception e)
-        {
-            logMetacat.error("Error setting permissions on System Metadata object: " +
-            		e.getMessage());
-            //TODO: decide if this error should cancel the entire create or
-            //if it should continue with just a logged error.
-        }
-        
-        
-        logMetacat.debug("Returning from CrudService.create()");
-        EventLog.getInstance().log(metacatUrl,
-                username, localId, "create");
-        logCrud.info("create D1GUID:" + guid.getValue() + ":D1SCIMETADATA:" + localId);
-        return guid;
-    }
-    
-    /**
-     * update an existing object with a new object.  Change the system metadata
-     * to reflect the changes and update it as well.
-     */
-    public Identifier update(AuthToken token, Identifier guid, 
-            InputStream object, Identifier obsoletedGuid, SystemMetadata sysmeta) 
-            throws InvalidToken, ServiceFailure, NotAuthorized, IdentifierNotUnique, 
-            UnsupportedType, InsufficientResources, NotFound, InvalidSystemMetadata, 
-            NotImplemented {
-    	try
-    	{
-    		SessionData sessionData = getSessionData(token);
-            
-            //find the old systemmetadata (sm.old) document id (the one linked to obsoletedGuid)
-            SystemMetadata sm = getSystemMetadata(token, obsoletedGuid);
-            //change sm.old's obsoletedBy field 
-            List<Identifier> l = sm.getObsoletedByList();
-            l.add(guid);
-            sm.setObsoletedByList(l);
-            //update sm.old
-            updateSystemMetadata(sm, sessionData);
-            
-            //change the obsoletes field of the new systemMetadata (sm.new) to point to the id of the old one
-            sysmeta.addObsolete(obsoletedGuid);
-            //insert sm.new
-            insertSystemMetadata(sysmeta, sessionData);
-            String localId;
-            
-            boolean isScienceMetadata = isScienceMetadata(sysmeta);
-            if(isScienceMetadata)
-            {
-                //update the doc
-                localId = updateDocument(object, obsoletedGuid, guid, sessionData, false);
-            }
-            else
-            {
-                //update a data file, not xml
-                localId = insertDataObject(object, guid, sessionData);
-            }
-            
-            IdentifierManager im = IdentifierManager.getInstance();
-            String username = "public";
-            if(sessionData != null)
-            {
-                username = sessionData.getUserName();
-            }
-            EventLog.getInstance().log(metacatUrl,
-                    username, im.getLocalId(guid.getValue()), "update");
-            logCrud.info("update D1GUID:" + guid.getValue() + ":D1SCIMETADATA:" + localId);
-            return guid;
-        }
-
-    	catch(IOException e) {
-            throw new ServiceFailure("1310", "Error updating document in CrudService: " + e.getMessage());
-        }
-    	catch( McdbDocNotFoundException e) {
-    		throw new ServiceFailure("1310", "Error updating document in CrudService: " + e.getMessage());
-    	}
-    	catch( InvalidRequest e) {
-    		throw new ServiceFailure("1310", "Error updating document in CrudService: " + e.getMessage());
-    	}
-    }
-    
-    /**
-     * set access permissions on both the science metadata and system metadata
-     */
-    public void setAccess(AuthToken token, Identifier id, String principal, String permission,
-            String permissionType, String permissionOrder)
-      throws ServiceFailure
-    {
-        setAccess(token, id, principal, permission, permissionType, permissionOrder, true);
-    }
-    
-    /**
-     * set access control on the doc
-     * @param token
-     * @param id
-     * @param principal
-     * @param permission
-     */
-    public void setAccess(AuthToken token, Identifier id, String principal, int permission,
-      String permissionType, String permissionOrder, boolean setSystemMetadata)
-      throws ServiceFailure
-    {
-        String perm = "";
-        if(permission >= 4)
-        {
-            perm = "read";
-        }
-        if(permission >= 6)
-        {
-            perm = "write";
-        }
-        //logCrud.debug("perm in setAccess: " + perm);
-        //logCrud.debug("permission in setAccess: " + permission);
-        setAccess(token, id, principal, perm, permissionType, permissionOrder,
-                setSystemMetadata);
-       
-    }
-    
-    /**
-     * set the permission on the document
-     * @param token
-     * @param principal
-     * @param permission
-     * @param permissionType
-     * @param permissionOrder
-     * @return
-     */
-    public void setAccess(AuthToken token, Identifier id, String principal, String permission,
-            String permissionType, String permissionOrder, boolean setSystemMetadata)
-      throws ServiceFailure
-    {
-        /* TODO:
-         * This is also not part of the D1 Crud spec.  This method is needed for
-         * systems such as metacat where access to objects is controlled by
-         * and ACL.  Higher level decisions need to be made about how this
-         * should work within D1.
-         */
-        try
-        {
-            final SessionData sessionData = getSessionData(token);
-            if(sessionData == null)
-            {
-                throw new ServiceFailure("1000", "User must be logged in to set access.");
-            }
-            IdentifierManager im = IdentifierManager.getInstance();
-            String docid = im.getLocalId(id.getValue());
-        
-            String permNum = "0";
-            if(permission.equals("read"))
-            {
-                permNum = "4";
-            }
-            else if(permission.equals("write"))
-            {
-                permNum = "6";
-            }
-            logCrud.debug("user " + sessionData.getUserName() + 
-                    " is setting access level " + permNum + " for permission " + 
-                    permissionType + " on doc with localid " + docid);
-            handler.setAccess(metacatUrl, sessionData.getUserName(), docid, 
-                    principal, permNum, permissionType, permissionOrder);
-            
-            String username = "public";
-            if(sessionData != null)
-            {
-                username = sessionData.getUserName();
-            }
-            EventLog.getInstance().log(metacatUrl,
-                    username, im.getLocalId(id.getValue()), "setAccess");
-            logCrud.info("setAccess");
-        }
-        catch(Exception e)
-        {
-            e.printStackTrace();
-            throw new ServiceFailure("1000", "Could not set access on the document with id " + id.getValue());
-        }
-    }
-    
-    /**
-     *  Retrieve the list of objects present on the MN that match the calling 
-     *  parameters. This method is required to support the process of Member 
-     *  Node synchronization. At a minimum, this method should be able to 
-     *  return a list of objects that match:
-     *  startTime <= SystemMetadata.dateSysMetadataModified
-     *  but is expected to also support date range (by also specifying endTime), 
-     *  and should also support slicing of the matching set of records by 
-     *  indicating the starting index of the response (where 0 is the index 
-     *  of the first item) and the count of elements to be returned.
-     *  
-     *  If startTime or endTime is null, the query is not restricted by that parameter.
-     *  
-     * @see http://mule1.dataone.org/ArchitectureDocs/mn_api_replication.html#MN_replication.listObjects
-     * @param token
-     * @param startTime
-     * @param endTime
-     * @param objectFormat
-     * @param replicaStatus
-     * @param start
-     * @param count
-     * @return ObjectList
-     * @throws NotAuthorized
-     * @throws InvalidRequest
-     * @throws NotImplemented
-     * @throws ServiceFailure
-     * @throws InvalidToken
-     */
-    public ObjectList listObjects(AuthToken token, Date startTime, Date endTime, 
-        ObjectFormat objectFormat, boolean replicaStatus, int start, int count)
-      throws NotAuthorized, InvalidRequest, NotImplemented, ServiceFailure, InvalidToken
-    {
-      //ObjectList ol = new ObjectList();
-      //final SessionData sessionData = getSessionData(token);
-      //int totalAfterQuery = 0;
-      
-      
-    	ObjectList objectList = null;
-        try {
-    	    objectList = IdentifierManager.getInstance().querySystemMetadata(startTime, endTime,
-    	              objectFormat.getFmtid(), replicaStatus, start, count);
-        } catch (Exception e) {
-    		throw new ServiceFailure("1580", "Error querying system metadata: " + e.getMessage());
-    	}
-        
-        return objectList;
-      
-      
-      /////////////////////////////////////////////////////////////////////////
-      ///////////////// OLD CODE //////////////////////////////////////////////
-      /////////////////////////////////////////////////////////////////////////
-      
-//      try
-//      {
-//          if (PropertyService.getProperty("database.queryCacheOn").equals("true"))
-//          {
-//              //System.out.println("the string stored into cache is "+ resultsetBuffer.toString());
-//              DBQuery.clearQueryResultCache();
-//          }
-//      }
-//      catch (PropertyNotFoundException e1)
-//      {
-//          //just don't do anything
-//      }
-//      
-//      try
-//      {
-//          //TODO: Milliseconds need to be added to the dateFormat
-//          System.out.println("=========== Listing Objects =============");
-//          System.out.println("Current server time is: " + new Date());
-//          if(startTime != null)
-//          {
-//              System.out.println("query start time is " + startTime);
-//          }
-//          if(endTime != null)
-//          {
-//              System.out.println("query end time is " + endTime);
-//          }
-//          params.clear();
-//          params.put("qformat", new String[] {PropertyService.getProperty("crudService.listObjects.QFormat")});
-//          params.put("action", new String[] {"squery"});
-//          params.put("query", new String[] {createListObjectsPathQueryDocument()});
-//          
-//          /*System.out.println("query is: metacatUrl: " + metacatUrl + " user: " + sessionData.getUserName() +
-//                  " sessionid: " + sessionData.getId() + " params: ");
-//          String url = metacatUrl + "/metacat?action=query&sessionid=" + sessionData.getId();
-//          Enumeration keys = params.keys();
-//          while(keys.hasMoreElements())
-//          {
-//              String key = (String)keys.nextElement();
-//              String[] parr = params.get(key);
-//              for(int i=0; i<parr.length; i++)
-//              {
-//                  System.out.println("param " + key + ": " + parr[i]);
-//                  url += "&" + key + "=" + parr[i] ;
-//              }
-//          }
-//          System.out.println("query url: " + url);
-//          */
-//          String username = "public";
-//          String[] groups = null;
-//          String sessionid = "";
-//          if(sessionData != null)
-//          {
-//              username = sessionData.getUserName();
-//              groups = sessionData.getGroupNames();
-//              sessionid = sessionData.getId();
-//          }
-//          
-//          MetacatResultSet rs = handler.query(metacatUrl, params, username, 
-//                  groups, sessionid);
-//          List docs = rs.getDocuments();
-//          
-//          System.out.println("query returned " + docs.size() + " documents.");
-//          Vector<Document> docCopy = new Vector<Document>();
-//          
-//          //preparse the list to remove any that don't match the query params
-//          /* TODO: this type of query/subquery processing is probably not scalable
-//           * to larger object stores.  This code should be revisited.  The metacat
-//           * query handler should probably be altered to handle the type of query 
-//           * done here.
-//           */ 
-//          for(int i=0; i<docs.size(); i++)
-//          {
-//              Document d = (Document)docs.get(i);
-//              
-//              ObjectFormat returnedObjectFormat = ObjectFormat.convert(d.getField("objectFormat"));
-//              
-//              if(returnedObjectFormat != null && 
-//                 objectFormat != null && 
-//                 !objectFormat.toString().trim().equals(returnedObjectFormat.toString().trim()))
-//              { //make sure the objectFormat is the one specified
-//                  continue;
-//              }
-//              
-//              String dateSMM = d.getField("dateSysMetadataModified");
-//              if((startTime != null || endTime != null) && dateSMM == null)
-//              {  //if startTime or endTime are not null, we need a date to compare to
-//                  continue;
-//              }
-//              
-//              //date parse
-//              Date dateSysMetadataModified = null;
-//              if(dateSMM != null)
-//              {
-//
-//                  /*                  
-//                  if(dateSMM.indexOf(".") != -1)
-//                  {  //strip the milliseconds
-//                      //TODO: don't do this. we need milliseconds now.
-//                      //TODO: explore ISO 8601 to figure out milliseconds
-//                      dateSMM = dateSMM.substring(0, dateSMM.indexOf(".")) + 'Z';
-//                  }
-//                  */
-//                  //System.out.println("dateSMM: " + dateSMM);
-//                  //dateFormat.setTimeZone(TimeZone.getTimeZone("GMT-0"));
-//                  try
-//                  {   //the format we want
-//                      dateSysMetadataModified = dateFormat.parse(dateSMM);
-//                  }
-//                  catch(java.text.ParseException pe)
-//                  {   //try another legacy format
-//                      try
-//                      {
-//                          DateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.S'Z'");
-//                          dateFormat2.setTimeZone(TimeZone.getTimeZone("GMT-0"));
-//                          dateSysMetadataModified = dateFormat2.parse(dateSMM);
-//                      }
-//                      catch(java.text.ParseException pe2)
-//                      {
-//                          //try another legacy format
-//                          DateFormat dateFormat3 = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'");
-//                          dateFormat3.setTimeZone(TimeZone.getTimeZone("GMT-0"));
-//                          dateSysMetadataModified = dateFormat3.parse(dateSMM);
-//                      }
-//                      
-//                  }                  
-//              }
-//              
-//              /*System.out.println("====================================");
-//              System.out.println("doc number " + i);
-//              System.out.println("docid: " + d.docid);
-//              System.out.println("guid: " + d.getField("identifier").trim());
-//              System.out.println("dateSMM: " + dateSMM);
-//              System.out.println("dateSysMetadataModified: " + dateSysMetadataModified);
-//              System.out.println("startTime: " + startTime);
-//              System.out.println("endtime: " + endTime);*/
-//              
-//              int startDateComparison = 0;
-//              int endDateComparison = 0;
-//              if(startTime != null)
-//              {
-//                  Calendar zTime = Calendar.getInstance(TimeZone.getTimeZone("GMT-0"));
-//                  zTime.setTime(startTime);
-//                  startTime = zTime.getTime();
-//                  
-//                  if(dateSysMetadataModified == null)
-//                  {
-//                      startDateComparison = -1;
-//                  }
-//                  else
-//                  {
-//                      startDateComparison = dateSysMetadataModified.compareTo(startTime);
-//                  }
-//                  //System.out.println("startDateCom: " + startDateComparison);
-//              }
-//              else
-//              {
-//                  startDateComparison = 1;
-//              }
-//              
-//              if(endTime != null)
-//              {
-//                  Calendar zTime = Calendar.getInstance(TimeZone.getTimeZone("GMT-0"));
-//                  zTime.setTime(endTime);
-//                  endTime = zTime.getTime();
-//                  
-//                  if(dateSysMetadataModified == null)
-//                  {
-//                      endDateComparison = 1;
-//                  }
-//                  else
-//                  {
-//                      endDateComparison = dateSysMetadataModified.compareTo(endTime);
-//                  }
-//                  //System.out.println("endDateCom: " + endDateComparison);
-//              }
-//              else
-//              {
-//                  endDateComparison = -1;
-//              }
-//              
-//              
-//              if(startDateComparison < 0 || endDateComparison > 0)
-//              { 
-//                  continue;                  
-//              }
-//              
-//              docCopy.add((Document)docs.get(i));
-//          } //end pre-parse
-//          
-//          docs = docCopy;
-//          totalAfterQuery = docs.size();
-//          //System.out.println("total after subquery: " + totalAfterQuery);
-//          
-//          //make sure we don't run over the end
-//          int end = start + count;
-//          if(end > docs.size())
-//          {
-//              end = docs.size();
-//          }
-//          
-//          for(int i=start; i<end; i++)
-//          {
-//              //get the document from the result
-//              Document d = (Document)docs.get(i);
-//              //System.out.println("processing doc " + d.docid);
-//              
-//              String dateSMM = d.getField("dateSysMetadataModified");
-//              //System.out.println("dateSMM: " + dateSMM);
-//              //System.out.println("parsed date: " + parseDate(dateSMM));
-//              Date dateSysMetadataModified = null;
-//              if(dateSMM != null)
-//              {
-//                  try
-//                  {
-//                      dateSysMetadataModified = parseDate(dateSMM);
-//                  }
-//                  catch(Exception e)
-//                  { //if we fail to parse the date, just ignore the value
-//                      dateSysMetadataModified = null;
-//                  }
-//              }
-//              ObjectFormat returnedObjectFormat = ObjectFormat.convert(d.getField("objectFormat"));
-//                
-//              
-//              ObjectInfo info = new ObjectInfo();
-//              //add the fields to the info object
-//              Checksum cs = new Checksum();
-//              cs.setValue(d.getField("checksum"));
-//              String csalg = d.getField("algorithm");
-//              if(csalg == null)
-//              {
-//                  csalg = "MD5";
-//              }
-//              ChecksumAlgorithm ca = ChecksumAlgorithm.convert(csalg);
-//              cs.setAlgorithm(ca);
-//              info.setChecksum(cs);
-//              info.setDateSysMetadataModified(dateSysMetadataModified);
-//              Identifier id = new Identifier();
-//              id.setValue(d.getField("identifier").trim());
-//              info.setIdentifier(id);
-//              info.setObjectFormat(returnedObjectFormat);
-//              String size = d.getField("size");
-//              if(size != null)
-//              {
-//                  info.setSize(new Long(size.trim()).longValue());
-//              }
-//              //add the ObjectInfo to the ObjectList
-//              //logCrud.info("objectFormat: " + info.getObjectFormat().toString());
-//              //logCrud.info("id: " + info.getIdentifier().getValue());
-//              
-//              if(info.getIdentifier().getValue() != null)
-//              { //id can be null from tests.  should not happen in production.
-//                  if((info.getObjectFormat() != null && !info.getObjectFormat().toString().trim().equals("")))
-//                  { //objectFormat needs to not be null and not be an empty string
-//                    ol.addObjectInfo(info);
-//                  }
-//                  else
-//                  {
-//                      logCrud.info("Not adding object with null objectFormat" + info.getIdentifier().getValue().toString());
-//                  }
-//              }
-//             
-//          }
-//      }
-//      catch(Exception e)
-//      {
-//          e.printStackTrace();
-//          logCrud.error("Error creating ObjectList: " + e.getMessage() + " cause: " + e.getCause());
-//          throw new ServiceFailure("1580", "Error retrieving ObjectList: " + e.getMessage());
-//      }
-//      String username = "public";
-//      if(sessionData != null)
-//      {
-//          username = sessionData.getUserName();
-//      }
-//      EventLog.getInstance().log(metacatUrl,
-//              username, null, "read");
-//      logCrud.info("listObjects");
-//      if(totalAfterQuery < count)
-//      {
-//          count = totalAfterQuery;
-//      }
-//      ol.setCount(count);
-//      ol.setStart(start);
-//      ol.setTotal(totalAfterQuery);
-//      return ol;
-    }
-    
-    /**
-     * Call listObjects with the default values for replicaStatus (true), start (0),
-     * and count (1000).
-     * @param token
-     * @param startTime
-     * @param endTime
-     * @param objectFormat
-     * @return
-     * @throws NotAuthorized
-     * @throws InvalidRequest
-     * @throws NotImplemented
-     * @throws ServiceFailure
-     * @throws InvalidToken
-     */
-    public ObjectList listObjects(AuthToken token, Date startTime, Date endTime, 
-        ObjectFormat objectFormat)
-      throws NotAuthorized, InvalidRequest, NotImplemented, ServiceFailure, InvalidToken
-    {
-       return listObjects(token, startTime, endTime, objectFormat, true, 0, 1000);
-    }
-
-    /**
-     * Delete a document. 
-     */
-    public Identifier delete(AuthToken token, Identifier guid)
-            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
-            NotImplemented, InvalidRequest {
-        logCrud.info("delete");
-        
-        if(token == null || token.getToken().equals("publid"))
-        {
-            throw new NotAuthorized("1320", "You must be logged in to delete records.");
-        }
-        
-        if(guid == null || guid.getValue().trim().equals(""))
-        {
-            throw new InvalidRequest("1322", "No GUID specified in CrudService.delete()");
-        }
-        final SessionData sessionData = getSessionData(token);
-        IdentifierManager manager = IdentifierManager.getInstance();
-        
-        String docid;
-        try
-        {
-            docid = manager.getLocalId(guid.getValue());
-        }
-        catch(McdbDocNotFoundException mnfe)
-        {
-            throw new InvalidRequest("1322", "GUID " + guid + " not found.");
-        }
-        
-        try
-        {
-            DocumentImpl.delete(docid, sessionData.getUserName(), sessionData.getGroupNames(), null);
-        }
-        catch(SQLException e)
-        {
-            throw new ServiceFailure("1350", "Could not delete document: " + e.getMessage());
-        }
-        catch(McdbDocNotFoundException e)
-        {
-          throw new ServiceFailure("1350", "Could not delete document: " + e.getMessage());
-        }
-        catch(InsufficientKarmaException e)
-        {
-          throw new ServiceFailure("1350", "Could not delete document: " + e.getMessage());
-        }
-        catch(Exception e)
-        {
-          throw new ServiceFailure("1350", "Could not delete document: " + e.getMessage());
-        }
-        return guid;
-    }
-
-    /**
-     * describe a document.  
-     */
-    public DescribeResponse describe(AuthToken token, Identifier guid)
-            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
-            NotImplemented, InvalidRequest {
-        logCrud.info("describe");
-        
-        if(token == null)
-        {
-            throw new InvalidToken("1370", "Authentication token is null");
-        }
-        
-        if(guid == null || guid.getValue().trim().equals(""))
-        {
-            throw new InvalidRequest("1362", "Guid is null.  A valid guid is required.");
-        }
-        
-        SystemMetadata sm = getSystemMetadata(token, guid);
-        DescribeResponse dr = new DescribeResponse(sm.getObjectFormat(), 
-                sm.getSize(), sm.getDateSysMetadataModified(), sm.getChecksum());
-        return dr;
-    }
-    
-    /**
-     * get a document with a specified guid.
-     */
-    public InputStream get(AuthToken token, Identifier guid)
-            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
-            NotImplemented {
-        
-        // Retrieve the session information from the AuthToken
-        // If the session is expired, then the user is 'public'
-        if(token == null)
-        {
-            token = new AuthToken("Public");
-        }
-        final SessionData sessionData = getSessionData(token);
-        
-        // Look up the localId for this global identifier
-        IdentifierManager im = IdentifierManager.getInstance();
-        
-        try 
-        {
-            final String localId = im.getLocalId(guid.getValue());
-            InputStream objectStream;
-            try 
-            {
-                String username = "public";
-                String[] groups = new String[0];
-                if(sessionData != null)
-                {
-                    username = sessionData.getUserName();
-                    groups = sessionData.getGroupNames();
-                }
-                
-                objectStream = readFromMetacat(localId, username, groups);
-                
-            } catch (PropertyNotFoundException e) {
-                e.printStackTrace();
-                throw new ServiceFailure("1030", "Error getting property from metacat: " + e.getMessage());
-            } catch (ClassNotFoundException e) {
-                e.printStackTrace();
-                throw new ServiceFailure("1030", "Class not found error when reading from metacat: " + e.getMessage());
-            } catch (IOException e) {
-                e.printStackTrace();
-                throw new ServiceFailure("1030", "IOException while reading from metacat: " + e.getMessage());
-            } catch (SQLException e) {
-                e.printStackTrace();
-                throw new ServiceFailure("1030", "SQLException while reading from metacat: " + e.getMessage());
-            } catch (McdbException e) {
-                e.printStackTrace();
-                throw new ServiceFailure("1030", "Metacat DB exception while reading from metacat: " + e.getMessage());
-            } catch (ParseLSIDException e) {
-                e.printStackTrace();
-                throw new NotFound("1020", "LSID parsing exception while reading from metacat: " + e.getMessage());
-            } catch (InsufficientKarmaException e) {
-                e.printStackTrace();
-                throw new NotAuthorized("1000", "User not authorized for get(): " + e.getMessage());
-            }
-        
-        
-            String username = "public";
-            if(sessionData != null)
-            {
-                username = sessionData.getUserName();
-            }
-            
-            EventLog.getInstance().log(metacatUrl,
-                    username, im.getLocalId(guid.getValue()), "read");
-            logCrud.info("get D1GUID:" + guid.getValue() + ":D1SCIMETADATA:" + localId + 
-                    ":");
-            
-            return objectStream;
-        } 
-        catch (McdbDocNotFoundException e) 
-        {
-            throw new NotFound("1020", e.getMessage());
-        } 
-    }
-
-    /**
-     * get the checksum for a document.  defaults to MD5.
-     */
-    public Checksum getChecksum(AuthToken token, Identifier guid)
-            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
-            InvalidRequest, NotImplemented 
-    {
-        logCrud.info("getChecksum");
-        return getChecksum(token, guid, "MD5");
-    }
-
-    /**
-     * get the checksum for a document with the given algorithm
-     */
-    public Checksum getChecksum(AuthToken token, Identifier guid, 
-            String checksumAlgorithm) throws InvalidToken, ServiceFailure, 
-            NotAuthorized, NotFound, InvalidRequest, NotImplemented 
-    {
-        logCrud.info("getChecksum");
-        SystemMetadata sm = getSystemMetadata(token, guid);
-        Checksum cs = sm.getChecksum();
-        if(cs.getAlgorithm().toString().equals(checksumAlgorithm))
-        {
-            return cs;
-        }
-        else
-        {
-            if(checksumAlgorithm == null)
-            {
-                checksumAlgorithm = "MD5";
-            }
-            
-            String checksum;
-            try
-            {
-            	//InputStream docStream = get(token, guid);
-                String localId = IdentifierManager.getInstance().getLocalId(guid.getValue());
-                DocumentImpl doc = new DocumentImpl(localId);
-                InputStream docStream = new ByteArrayInputStream(doc.getBytes());
-                
-                checksum = checksum(docStream, checksumAlgorithm);
-            }
-            catch(Exception e)
-            {
-                throw new ServiceFailure("1410", "Error getting checksum: " + e.getMessage());
-            }
-            Checksum c = new Checksum();
-            c.setAlgorithm(ChecksumAlgorithm.convert(checksumAlgorithm));
-            c.setValue(checksum);
-            return c;
-        }
-    }
-
-    /**
-     * get log records.  
-     */
-    public Log getLogRecords(AuthToken token, Date fromDate, Date toDate, Event event)
-            throws InvalidToken, ServiceFailure, NotAuthorized, InvalidRequest, 
-            NotImplemented 
-    {
-        /*System.out.println("=================== Getting log records ===================");
-        System.out.println("Current server time is: " + new Date());
-        if(fromDate != null)
-        {
-          System.out.println("query start time is " + fromDate);
-        }
-        if(toDate != null)
-        {
-          System.out.println("query end time is " + toDate);
-        }*/
-        Log log = new Log();
-        Vector<LogEntry> logs = new Vector<LogEntry>();
-        IdentifierManager im = IdentifierManager.getInstance();
-        EventLog el = EventLog.getInstance();
-        if(fromDate == null)
-        {
-            //System.out.println("setting fromdate from null");
-            fromDate = new Date(1);
-        }
-        if(toDate == null)
-        {
-            //System.out.println("setting todate from null");
-            toDate = new Date();
-        }
-        
-        //System.out.println("fromDate: " + fromDate);
-        //System.out.println("toDate: " + toDate);
-        
-        String report = el.getReport(null, null, null, null, 
-                new java.sql.Timestamp(fromDate.getTime()), 
-                new java.sql.Timestamp(toDate.getTime()), false);
-        
-        //System.out.println("report: " + report);
-        
-        String logEntry = "<logEntry>";
-        String endLogEntry = "</logEntry>";
-        int startIndex = 0;
-        int foundIndex = report.indexOf(logEntry, startIndex);
-        while(foundIndex != -1)
-        {
-            //parse out each entry
-            int endEntryIndex = report.indexOf(endLogEntry, foundIndex);
-            String entry = report.substring(foundIndex, endEntryIndex);
-            //System.out.println("entry: " + entry);
-            startIndex = endEntryIndex + endLogEntry.length();
-            foundIndex = report.indexOf(logEntry, startIndex);
-            
-            String entryId = getLogEntryField("entryid", entry);
-            String ipAddress = getLogEntryField("ipAddress", entry);
-            String principal = getLogEntryField("principal", entry);
-            String docid = getLogEntryField("docid", entry);
-            String eventS = getLogEntryField("event", entry);
-            String dateLogged = getLogEntryField("dateLogged", entry);
-            
-            LogEntry le = new LogEntry();
-            
-            Event e = Event.convert(eventS);
-            if(e == null)
-            { //skip any events that are not Dataone Crud events
-                continue;
-            }
-            le.setEvent(e);
-            Identifier entryid = new Identifier();
-            entryid.setValue(entryId);
-            le.setEntryId(entryid);
-            Identifier identifier = new Identifier();
-            try
-            {
-                //System.out.println("converting docid '" + docid + "' to a guid.");
-                if(docid == null || docid.trim().equals("") || docid.trim().equals("null"))
-                {
-                    continue;
-                }
-                docid = docid.substring(0, docid.lastIndexOf("."));
-                identifier.setValue(im.getGUID(docid, im.getLatestRevForLocalId(docid)));
-            }
-            catch(Exception ex)
-            { //try to get the guid, if that doesn't work, just use the local id
-                //throw new ServiceFailure("1030", "Error getting guid for localId " + 
-                //        docid + ": " + ex.getMessage());\
-                
-                //skip it if the guid can't be found
-                continue;
-            }
-            
-            le.setIdentifier(identifier);
-            le.setIpAddress(ipAddress);
-            Calendar c = Calendar.getInstance();
-            String year = dateLogged.substring(0, 4);
-            String month = dateLogged.substring(5, 7);
-            String date = dateLogged.substring(8, 10);
-            //System.out.println("year: " + year + " month: " + month + " day: " + date);
-            c.set(new Integer(year).intValue(), new Integer(month).intValue(), new Integer(date).intValue());
-            Date logDate = c.getTime();
-            le.setDateLogged(logDate);
-            NodeReference memberNode = new NodeReference();
-            memberNode.setValue(ipAddress);
-            le.setMemberNode(memberNode);
-            Subject princ = new Subject();
-            princ.setValue(principal);
-            le.setSubject(princ);
-            le.setUserAgent("metacat/RESTService");
-            
-            if(event == null)
-            {
-                logs.add(le);
-            }
-            
-            if(event != null &&
-               e.toString().toLowerCase().trim().equals(event.toString().toLowerCase().trim()))
-            {
-              logs.add(le);
-            }
-        }
-        
-        log.setLogEntryList(logs);
-        logCrud.info("getLogRecords");
-        return log;
-    }
-    
-    /**
-     * parse a logEntry and get the relavent field from it
-     * @param fieldname
-     * @param entry
-     * @return
-     */
-    private String getLogEntryField(String fieldname, String entry)
-    {
-        String begin = "<" + fieldname + ">";
-        String end = "</" + fieldname + ">";
-        //System.out.println("looking for " + begin + " and " + end + " in entry " + entry);
-        String s = entry.substring(entry.indexOf(begin) + begin.length(), entry.indexOf(end));
-        //System.out.println("entry " + fieldname + " : " + s);
-        return s;
-    }
-
-    /**
-     * get the system metadata for a document with a specified guid.
-     */
-    public SystemMetadata getSystemMetadata(AuthToken token, Identifier guid)
-            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
-            InvalidRequest, NotImplemented {
-        
-    	logMetacat.debug("CrudService.getSystemMetadata - for guid: " + guid.getValue());
-        
-        SystemMetadata sysmeta = null;
-		try {
-	        // look up the SysMeta
-	        sysmeta = IdentifierManager.getInstance().getSystemMetadata(guid.getValue());
-		} catch (McdbDocNotFoundException e) {
-			e.printStackTrace();
-			throw new NotFound(null, "Could not locate SystemMetadata for: " + guid.getValue());
-		}        
-
-		logCrud.info("getsystemmetadata D1GUID:" + guid.getValue());;
-        
-        return sysmeta;
-                   
-    }
-    
-    /**
-     * parse the date in the systemMetadata
-     * @param s
-     * @return
-     * @throws Exception
-     */
-    public Date parseDate(String s)
-      throws Exception
-    {
-        /* TODO:
-         * This method should be replaced by a DateFormatter
-         */
-        Date d = null;
-        int tIndex = s.indexOf("T");
-        int zIndex = s.indexOf("Z");
-        if(tIndex != -1 && zIndex != -1)
-        { //parse a date that looks like 2010-05-18T21:12:54.362Z
-            //System.out.println("original date: " + s);
-            
-            String date = s.substring(0, tIndex);
-            String year = date.substring(0, date.indexOf("-"));
-            String month = date.substring(date.indexOf("-") + 1, date.lastIndexOf("-"));
-            String day = date.substring(date.lastIndexOf("-") + 1, date.length());
-            /*System.out.println("date: " + "year: " + new Integer(year).intValue() + 
-                    " month: " + new Integer(month).intValue() + " day: " + 
-                    new Integer(day).intValue());
-            */
-            String time = s.substring(tIndex + 1, zIndex);
-            String hour = time.substring(0, time.indexOf(":"));
-            String minute = time.substring(time.indexOf(":") + 1, time.lastIndexOf(":"));
-            String seconds = "00";
-            String milliseconds = "00";
-            if(time.indexOf(".") != -1)
-            {
-                seconds = time.substring(time.lastIndexOf(":") + 1, time.indexOf("."));
-                milliseconds = time.substring(time.indexOf(".") + 1, time.length());
-            }
-            else
-            {
-                seconds = time.substring(time.lastIndexOf(":") + 1, time.length());
-            }
-            /*System.out.println("time: " + "hour: " + new Integer(hour).intValue() + 
-                    " minute: " + new Integer(minute).intValue() + " seconds: " + 
-                    new Integer(seconds).intValue() + " milli: " + 
-                    new Integer(milliseconds).intValue());*/
-            
-            //d = DateFormat.getDateTimeInstance().parse(date + " " + time);
-            Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT-0")/*TimeZone.getDefault()*/);
-            c.set(new Integer(year).intValue(), new Integer(month).intValue() - 1, 
-                  new Integer(day).intValue(), new Integer(hour).intValue(), 
-                  new Integer(minute).intValue(), new Integer(seconds).intValue());
-            c.set(Calendar.MILLISECOND, new Integer(milliseconds).intValue());
-            d = new Date(c.getTimeInMillis());
-            //System.out.println("d: " + d);
-            return d;
-        }
-        else
-        {  //if it's not in the expected format, try the formatter
-            return DateFormat.getDateTimeInstance().parse(s);
-        }
-    }
-
-    /*
-     * Look up the information on the session using the token provided in
-     * the AuthToken.  The Session should have all relevant user information.
-     * If the session has expired or is invalid, the 'public' session will
-     * be returned, giving the user anonymous access.
-     */
-    public static SessionData getSessionData(AuthToken token) {
-        SessionData sessionData = null;
-        String sessionId = "PUBLIC";
-        if (token != null) {
-            sessionId = token.getToken();
-        }
-        
-        // if the session id is registered in SessionService, get the
-        // SessionData for it. Otherwise, use the public session.
-        //System.out.println("sessionid: " + sessionId);
-        if (sessionId != null &&
-            !sessionId.toLowerCase().equals("public") &&
-            SessionService.getInstance().isSessionRegistered(sessionId)) 
-        {
-            sessionData = SessionService.getInstance().getRegisteredSession(sessionId);
-        } else {
-            sessionData = SessionService.getInstance().getPublicSession();
-        }
-        
-        return sessionData;
-    }
-
-    /** 
-     * Determine if a given object should be treated as an XML science metadata
-     * object. 
-     * 
-     * TODO: This test should be externalized in a configuration dictionary rather than being hardcoded.
-     * 
-     * @param sysmeta the SystemMetadata describig the object
-     * @return true if the object should be treated as science metadata
-     */
-    private boolean isScienceMetadata(SystemMetadata sysmeta) {
-        /*boolean scimeta = false;
-        //TODO: this should be read from a .properties file instead of being hard coded
-        switch (sysmeta.getObjectFormat()) {
-            case EML_2_1_0: scimeta = true; break;
-            case EML_2_0_1: scimeta = true; break;
-            case EML_2_0_0: scimeta = true; break;
-            case FGDC_STD_001_1_1999: scimeta = true; break;
-            case FGDC_STD_001_1998: scimeta = true; break;
-            case NCML_2_2: scimeta = true; break;
-            case DSPACE_METS_SIP_1_0: scimeta = true; break;
-        }
-        
-        return scimeta;*/
-        
-        return MetadataTypeRegister.isMetadataType(sysmeta.getObjectFormat());
-    }
-
-    /**
-     * insert a data doc
-     * @param object
-     * @param guid
-     * @param sessionData
-     * @throws ServiceFailure
-     * @returns localId of the data object inserted
-     */
-    private String insertDataObject(InputStream object, Identifier guid, 
-            SessionData sessionData) throws ServiceFailure {
-        
-        String username = "public";
-        String[] groups = null;
-        if(sessionData != null)
-        {
-          username = sessionData.getUserName();
-          groups = sessionData.getGroupNames();
-        }
-
-        // generate guid/localId pair for object
-        logMetacat.debug("Generating a guid/localId mapping");
-        IdentifierManager im = IdentifierManager.getInstance();
-        String localId = im.generateLocalId(guid.getValue(), 1);
-
-        try {
-            logMetacat.debug("Case DATA: starting to write to disk.");
-            if (DocumentImpl.getDataFileLockGrant(localId)) {
-    
-                // Save the data file to disk using "localId" as the name
-                try {
-                    String datafilepath = PropertyService.getProperty("application.datafilepath");
-    
-                    File dataDirectory = new File(datafilepath);
-                    dataDirectory.mkdirs();
-    
-                    File newFile = writeStreamToFile(dataDirectory, localId, object);
-    
-                    // TODO: Check that the file size matches SystemMetadata
-                    //                        long size = newFile.length();
-                    //                        if (size == 0) {
-                    //                            throw new IOException("Uploaded file is 0 bytes!");
-                    //                        }
-    
-                    // Register the file in the database (which generates an exception
-                    // if the localId is not acceptable or other untoward things happen
-                    try {
-                        logMetacat.debug("Registering document...");
-                        DocumentImpl.registerDocument(localId, "BIN", localId,
-                                username, groups);
-                        logMetacat.debug("Registration step completed.");
-                    } catch (SQLException e) {
-                        //newFile.delete();
-                        logMetacat.debug("SQLE: " + e.getMessage());
-                        e.printStackTrace(System.out);
-                        throw new ServiceFailure("1190", "Registration failed: " + e.getMessage());
-                    } catch (AccessionNumberException e) {
-                        //newFile.delete();
-                        logMetacat.debug("ANE: " + e.getMessage());
-                        e.printStackTrace(System.out);
-                        throw new ServiceFailure("1190", "Registration failed: " + e.getMessage());
-                    } catch (Exception e) {
-                        //newFile.delete();
-                        logMetacat.debug("Exception: " + e.getMessage());
-                        e.printStackTrace(System.out);
-                        throw new ServiceFailure("1190", "Registration failed: " + e.getMessage());
-                    }
-    
-                    logMetacat.debug("Logging the creation event.");
-                    EventLog.getInstance().log(metacatUrl,
-                            username, localId, "create");
-    
-                    // Schedule replication for this data file
-                    logMetacat.debug("Scheduling replication.");
-                    ForceReplicationHandler frh = new ForceReplicationHandler(
-                            localId, "create", false, null);
-    
-                } catch (PropertyNotFoundException e) {
-                    throw new ServiceFailure("1190", "Could not lock file for writing:" + e.getMessage());
-                }
-            }
-            return localId;
-        } catch (Exception e) {
-            // Could not get a lock on the document, so we can not update the file now
-            throw new ServiceFailure("1190", "Failed to lock file: " + e.getMessage());
-        }
-    }
-
-    /**
-     * write a file to a stream
-     * @param dir
-     * @param fileName
-     * @param data
-     * @return
-     * @throws ServiceFailure
-     */
-    private File writeStreamToFile(File dir, String fileName, InputStream data) 
-        throws ServiceFailure {
-        
-        File newFile = new File(dir, fileName);
-        logMetacat.debug("Filename for write is: " + newFile.getAbsolutePath());
-
-        try {
-            if (newFile.createNewFile()) {
-                // write data stream to desired file
-                OutputStream os = new FileOutputStream(newFile);
-                long length = IOUtils.copyLarge(data, os);
-                os.flush();
-                os.close();
-            } else {
-                logMetacat.debug("File creation failed, or file already exists.");
-                throw new ServiceFailure("1190", "File already exists: " + fileName);
-            }
-        } catch (FileNotFoundException e) {
-            logMetacat.debug("FNF: " + e.getMessage());
-            throw new ServiceFailure("1190", "File not found: " + fileName + " " 
-                    + e.getMessage());
-        } catch (IOException e) {
-            logMetacat.debug("IOE: " + e.getMessage());
-            throw new ServiceFailure("1190", "File was not written: " + fileName 
-                    + " " + e.getMessage());
-        }
-
-        return newFile;
-    }
-
-    /**
-     * insert a systemMetadata doc, return the localId of the sysmeta
-     */
-    private void insertSystemMetadata(SystemMetadata sysmeta, SessionData sessionData) 
-        throws ServiceFailure 
-    {
-        logMetacat.debug("Starting to insert SystemMetadata...");
-        sysmeta.setDateSysMetadataModified(new Date());
-        logCrud.debug("****inserting new system metadata with modified date " + 
-                sysmeta.getDateSysMetadataModified());
-
-        //insert the system metadata
-        try {
-			IdentifierManager.getInstance().createSystemMetadata(sysmeta);
-		} catch (Exception e) {
-            throw new ServiceFailure("1030", "Error inserting system metadata: " + e.getClass() + ": " + e.getMessage());
-		}
-        
-        
-    }
-    
-    /**
-     * update a systemMetadata doc
-     */
-    private void updateSystemMetadata(SystemMetadata sm, SessionData sessionData)
-      throws ServiceFailure
-    {
-        
-        logCrud.debug("CrudService.updateSystemMetadata() called.");
-        try
-        {
-            logCrud.debug("Setting date modified to " + new Date());
-            sm.setDateSysMetadataModified(new Date());
-            IdentifierManager.getInstance().updateSystemMetadata(sm);
-        }
-        catch(Exception e)
-        {
-            throw new ServiceFailure("1030", "Error updating system metadata: " + e.getClass() + ": " + e.getMessage());
-        }
-    }
-    
-    private String insertDocument(String xml, Identifier guid, SessionData sessionData)
-        throws ServiceFailure
-    {
-        return insertDocument(xml, guid, sessionData, false);
-    }
-    
-    /**
-     * insert a document
-     * NOTE: this method shouldn't be used from the update or create() methods.  
-     * we shouldn't be putting the science metadata or data objects into memory.
-     */
-    private String insertDocument(String xml, Identifier guid, SessionData sessionData,
-            boolean isSystemMetadata)
-        throws ServiceFailure
-    {
-        return insertOrUpdateDocument(xml, guid, sessionData, "insert", isSystemMetadata);
-    }
-    
-    /**
-     * insert a document from a stream
-     */
-    private String insertDocument(InputStream is, Identifier guid, SessionData sessionData)
-      throws IOException, ServiceFailure
-    {
-        //HACK: change this eventually.  we should not be converting the stream to a string
-        String xml = IOUtils.toString(is);
-        return insertDocument(xml, guid, sessionData);
-    }
-    
-    /**
-     * update a document
-     * NOTE: this method shouldn't be used from the update or create() methods.  
-     * we shouldn't be putting the science metadata or data objects into memory.
-     */
-    private String updateDocument(String xml, Identifier obsoleteGuid, 
-            Identifier guid, SessionData sessionData, boolean isSystemMetadata)
-        throws ServiceFailure
-    {
-        return insertOrUpdateDocument(xml, obsoleteGuid, sessionData, "update", isSystemMetadata);
-    }
-    
-    /**
-     * update a document from a stream
-     */
-    private String updateDocument(InputStream is, Identifier obsoleteGuid, 
-            Identifier guid, SessionData sessionData, boolean isSystemMetadata)
-      throws IOException, ServiceFailure
-    {
-        //HACK: change this eventually.  we should not be converting the stream to a string
-        String xml = IOUtils.toString(is);
-        String localId = updateDocument(xml, obsoleteGuid, guid, sessionData, isSystemMetadata);
-        IdentifierManager im = IdentifierManager.getInstance();
-        if(guid != null)
-        {
-          im.createMapping(guid.getValue(), localId);
-        }
-        return localId;
-    }
-    
-    /**
-     * insert a document, return the id of the document that was inserted
-     */
-    protected String insertOrUpdateDocument(String xml, Identifier guid, 
-            SessionData sessionData, String insertOrUpdate, boolean isSystemMetadata) 
-        throws ServiceFailure {
-        logMetacat.debug("Starting to insert xml document...");
-        IdentifierManager im = IdentifierManager.getInstance();
-
-        // generate guid/localId pair for sysmeta
-        String localId = null;
-        if(insertOrUpdate.equals("insert"))
-        {
-            localId = im.generateLocalId(guid.getValue(), 1, isSystemMetadata);
-        }
-        else
-        {
-            //localid should already exist in the identifier table, so just find it
-            try
-            {
-                logCrud.debug("updating guid " + guid.getValue());
-                logCrud.debug("looking in identifier table for guid " + guid.getValue());
-                
-                localId = im.getLocalId(guid.getValue());
-                
-                logCrud.debug("localId: " + localId);
-                //increment the revision
-                String docid = localId.substring(0, localId.lastIndexOf("."));
-                String revS = localId.substring(localId.lastIndexOf(".") + 1, localId.length());
-                int rev = new Integer(revS).intValue();
-                rev++;
-                docid = docid + "." + rev;
-                localId = docid;
-                logCrud.debug("incremented localId: " + localId);
-            }
-            catch(McdbDocNotFoundException e)
-            {
-                throw new ServiceFailure("1030", "CrudService.insertOrUpdateDocument(): " +
-                    "guid " + guid.getValue() + " should have been in the identifier table, but it wasn't: " + e.getMessage());
-            }
-        }
-        logMetacat.debug("Metadata guid|localId: " + guid.getValue() + "|" +
-                localId);
-
-        String[] action = new String[1];
-        action[0] = insertOrUpdate;
-        params.put("action", action);
-        String[] docid = new String[1];
-        docid[0] = localId;
-        params.put("docid", docid);
-        String[] doctext = new String[1];
-        doctext[0] = xml;
-        logMetacat.debug(doctext[0]);
-        params.put("doctext", doctext);
-        
-        // TODO: refactor handleInsertOrUpdateAction() to not output XML directly
-        // onto output stream, or alternatively, capture that and parse it to 
-        // generate the right exceptions
-        //ByteArrayOutputStream output = new ByteArrayOutputStream();
-        //PrintWriter pw = new PrintWriter(output);
-        String username = "public";
-        String[] groupnames = null;
-        if(sessionData != null)
-        {
-            username = sessionData.getUserName();
-            groupnames = sessionData.getGroupNames();
-        }
-        String result = handler.handleInsertOrUpdateAction(metacatUrl, null, 
-                            null, params, username, groupnames);
-        if(result.indexOf("<error>") != -1)
-        {
-            throw new ServiceFailure("1000", "Error inserting or updating document: " + result);
-        }
-        //String outputS = new String(output.toByteArray());
-        logMetacat.debug("CrudService.insertDocument - Metacat returned: " + result);
-        logMetacat.debug("Finsished inserting xml document with id " + localId);
-        return localId;
-    }
-    
-    /**
-     * serialize a dataone type
-     */
-//    private void serializeServiceType(Class type, Object object, OutputStream out)
-//        throws JiBXException
-//    {
-//        IBindingFactory bfact = BindingDirectory.getFactory(type);
-//        IMarshallingContext mctx = bfact.createMarshallingContext();
-//        mctx.marshalDocument(object, "UTF-8", null, out);
-//    }
-    
-    /**
-     * serialize a system metadata doc
-     * @param sysmeta
-     * @return
-     * @throws ServiceFailure
-     */
-//    public static ByteArrayOutputStream serializeSystemMetadata(SystemMetadata sysmeta) 
-//        throws ServiceFailure {
-//        IBindingFactory bfact;
-//        ByteArrayOutputStream sysmetaOut = null;
-//        try {
-//            bfact = BindingDirectory.getFactory(SystemMetadata.class);
-//            IMarshallingContext mctx = bfact.createMarshallingContext();
-//            sysmetaOut = new ByteArrayOutputStream();
-//            mctx.marshalDocument(sysmeta, "UTF-8", null, sysmetaOut);
-//        } catch (JiBXException e) {
-//            e.printStackTrace();
-//            throw new ServiceFailure("1190", "Failed to serialize and insert SystemMetadata: " + e.getMessage());
-//        }
-//        
-//        return sysmetaOut;
-//    }
-//    
-    /**
-     * deserialize a system metadata doc
-     * @param xml
-     * @return
-     * @throws ServiceFailure
-     */
-//    public static SystemMetadata deserializeSystemMetadata(InputStream xml) 
-//        throws ServiceFailure {
-//        try {
-//            IBindingFactory bfact = BindingDirectory.getFactory(SystemMetadata.class);
-//            IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
-//            SystemMetadata sysmeta = (SystemMetadata) uctx.unmarshalDocument(xml, null);
-//            return sysmeta;
-//        } catch (JiBXException e) {
-//            e.printStackTrace();
-//            throw new ServiceFailure("1190", "Failed to deserialize and insert SystemMetadata: " + e.getMessage());
-//        }    
-//    }
-    
-    /**
-     * read a document from metacat and return the InputStream
-     * 
-     * @param localId
-     * @param username
-     * @param groups
-     * @return
-     * @throws InsufficientKarmaException
-     * @throws ParseLSIDException
-     * @throws PropertyNotFoundException
-     * @throws McdbException
-     * @throws SQLException
-     * @throws ClassNotFoundException
-     * @throws IOException
-     */
-    private InputStream readFromMetacat(String localId, String username, String[] groups)
-        throws InsufficientKarmaException, ParseLSIDException,
-        PropertyNotFoundException, McdbException, SQLException, 
-        ClassNotFoundException, IOException
-    {
-        File tmpDir;
-        try
-        {
-            tmpDir = new File(PropertyService.getProperty("application.tempDir"));
-        }
-        catch(PropertyNotFoundException pnfe)
-        {
-            logMetacat.error("ResourceHandler.writeMMPPartstoFiles: " +
-                    "application.tmpDir not found.  Using /tmp instead.");
-            tmpDir = new File("/tmp");
-        }
-        Date d = new Date();
-        final File outputFile = new File(tmpDir, "metacat.output." + d.getTime());
-        FileOutputStream dataSink = new FileOutputStream(outputFile);
-        
-        handler.readFromMetacat(metacatUrl, null, 
-                dataSink, localId, "xml",
-                username, 
-                groups, true, params);
-        
-        //set a timer to clean up the temp files
-        Timer t = new Timer();
-        TimerTask tt = new TimerTask() {
-            @Override
-            public void run()
-            {
-                outputFile.delete();
-            }
-        };
-        t.schedule(tt, 20000); //schedule after 20 secs
-        
-        InputStream objectStream = new FileInputStream(outputFile);
-        return objectStream;
-    }
-    
-    /**
-     * return an MD5 checksum for the stream
-     * @param is
-     * @return
-     * @throws IOException 
-     * @throws NoSuchAlgorithmException 
-     */
-    public static String checksum(InputStream is) throws NoSuchAlgorithmException, IOException
-    {
-        return checksum(is, "MD5");
-    }
-    
-    /**
-     * produce a checksum for item using the given algorithm
-     * @throws IOException 
-     * @throws NoSuchAlgorithmException 
-     */
-    public static String checksum(InputStream is, String algorithm) throws NoSuchAlgorithmException, IOException
-    {        
-        return ServiceTypeUtil.checksum(is, ChecksumAlgorithm.convert(algorithm)).getValue();
-    }
-    
-    
-    
-    /**
-     * find the size (in bytes) of a stream
-     * @param is
-     * @return
-     * @throws IOException
-     */
-    private long sizeOfStream(InputStream is)
-        throws IOException
-    {
-        long size = 0;
-        byte[] b = new byte[1024];
-        int numread = is.read(b, 0, 1024);
-        while(numread != -1)
-        {
-            size += numread;
-            numread = is.read(b, 0, 1024);
-        }
-        return size;
-    }
-    
-    
-    
-    /**
-     * create the listObjects pathQuery document
-     */
-//    private String createListObjectsPathQueryDocument()
-//        throws PropertyNotFoundException
-//    {
-//        String s = "<pathquery>";
-//        s += "<returndoctype>" + PropertyService.getProperty("crudService.listObjects.ReturnDoctype") + "</returndoctype>";
-//        s += "<returnfield>" + PropertyService.getProperty("crudService.listObjects.ReturnField.1") + "</returnfield>";
-//        s += "<returnfield>" + PropertyService.getProperty("crudService.listObjects.ReturnField.2") + "</returnfield>";
-//        s += "<returnfield>" + PropertyService.getProperty("crudService.listObjects.ReturnField.3") + "</returnfield>";
-//        s += "<returnfield>" + PropertyService.getProperty("crudService.listObjects.ReturnField.4") + "</returnfield>";
-//        s += "<returnfield>" + PropertyService.getProperty("crudService.listObjects.ReturnField.5") + "</returnfield>";
-//        s += "<returnfield>" + PropertyService.getProperty("crudService.listObjects.ReturnField.6") + "</returnfield>";
-//        s += "<returnfield>" + PropertyService.getProperty("crudService.listObjects.ReturnField.7") + "</returnfield>";
-//        s += "<querygroup operator=\"UNION\"><queryterm casesensitive=\"false\" searchmode=\"contains\">";
-//        s += "<value>%</value>"; 
-//        s += "<pathexpr>" + PropertyService.getProperty("crudService.listObjects.ReturnField.3") + "</pathexpr>";
-//        s += "</queryterm></querygroup></pathquery>";
-//  
-//        return s;
-//    }
-}
-

Property changes on: src/edu/ucsb/nceas/metacat/dataone/CrudService.java
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Index: test/edu/ucsb/nceas/metacat/dataone/SystemMetadataManagerTest.java
===================================================================
--- test/edu/ucsb/nceas/metacat/dataone/SystemMetadataManagerTest.java	(revision 6361)
+++ test/edu/ucsb/nceas/metacat/dataone/SystemMetadataManagerTest.java	(revision 6362)
@@ -25,33 +25,13 @@
 
 package edu.ucsb.nceas.metacat.dataone;
 
-import java.util.*;
-import java.io.*;
-
+import java.io.StringBufferInputStream;
 import java.security.MessageDigest;
 
-import edu.ucsb.nceas.MCTestCase;
-import edu.ucsb.nceas.metacat.IdentifierManager;
-import edu.ucsb.nceas.metacat.client.MetacatAuthException;
-import edu.ucsb.nceas.metacat.client.MetacatException;
-import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException;
-import edu.ucsb.nceas.metacat.dataone.CrudService;
 import junit.framework.Test;
 import junit.framework.TestSuite;
+import edu.ucsb.nceas.MCTestCase;
 
-import org.dataone.service.exceptions.InvalidRequest;
-import org.dataone.service.exceptions.InvalidToken;
-import org.dataone.service.exceptions.NotAuthorized;
-import org.dataone.service.exceptions.NotImplemented;
-import org.dataone.service.exceptions.ServiceFailure;
-import org.dataone.service.types.*;
-
-import edu.ucsb.nceas.metacat.properties.PropertyService;
-import edu.ucsb.nceas.metacat.client.rest.MetacatRestClient;
-
-import edu.ucsb.nceas.metacat.service.SessionService;
-import edu.ucsb.nceas.metacat.util.SessionData;
-
 /**
  * A JUnit test for testing the dataone SystemMetadataManager class
  */
Index: test/edu/ucsb/nceas/metacat/util/MetacatPopulatorTest.java
===================================================================
--- test/edu/ucsb/nceas/metacat/util/MetacatPopulatorTest.java	(revision 6361)
+++ test/edu/ucsb/nceas/metacat/util/MetacatPopulatorTest.java	(revision 6362)
@@ -24,34 +24,10 @@
 
 package edu.ucsb.nceas.metacat.util;
 
-import java.util.*;
-import java.io.*;
-
-import java.security.MessageDigest;
-
-import edu.ucsb.nceas.MCTestCase;
-import edu.ucsb.nceas.metacat.IdentifierManager;
-import edu.ucsb.nceas.metacat.client.MetacatAuthException;
-import edu.ucsb.nceas.metacat.client.MetacatException;
-import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException;
-import edu.ucsb.nceas.metacat.util.MetacatPopulator;
-import edu.ucsb.nceas.metacat.dataone.CrudService;
 import junit.framework.Test;
 import junit.framework.TestSuite;
+import edu.ucsb.nceas.MCTestCase;
 
-import org.dataone.service.exceptions.InvalidRequest;
-import org.dataone.service.exceptions.InvalidToken;
-import org.dataone.service.exceptions.NotAuthorized;
-import org.dataone.service.exceptions.NotImplemented;
-import org.dataone.service.exceptions.ServiceFailure;
-import org.dataone.service.types.*;
-
-import edu.ucsb.nceas.metacat.properties.PropertyService;
-import edu.ucsb.nceas.metacat.client.rest.MetacatRestClient;
-
-import edu.ucsb.nceas.metacat.service.SessionService;
-import edu.ucsb.nceas.metacat.util.SessionData;
-
 /**
  * A JUnit test for testing the dataone MetacatPopulator class
  */
Index: test/edu/ucsb/nceas/metacat/restservice/ResourceHandlerTest.java
===================================================================
--- test/edu/ucsb/nceas/metacat/restservice/ResourceHandlerTest.java	(revision 6361)
+++ test/edu/ucsb/nceas/metacat/restservice/ResourceHandlerTest.java	(revision 6362)
@@ -25,13 +25,15 @@
 
 package edu.ucsb.nceas.metacat.restservice;
 
-import java.util.*;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Date;
 
-import edu.ucsb.nceas.MCTestCase;
-import edu.ucsb.nceas.metacat.dataone.CrudServiceTest;
-import edu.ucsb.nceas.metacat.properties.PropertyService;
-
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
@@ -40,13 +42,12 @@
 import org.dataone.service.exceptions.InvalidSystemMetadata;
 import org.dataone.service.exceptions.ServiceFailure;
 import org.dataone.service.types.SystemMetadata;
-
 import org.jibx.runtime.BindingDirectory;
 import org.jibx.runtime.IBindingFactory;
 import org.jibx.runtime.IMarshallingContext;
-import org.jibx.runtime.IUnmarshallingContext;
-import org.jibx.runtime.JiBXException;
 
+import edu.ucsb.nceas.MCTestCase;
+
 /**
  * @author berkley
  * class to test ResourceHandler
Index: src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java	(revision 6361)
+++ src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java	(revision 6362)
@@ -795,12 +795,6 @@
                 System.out.println("ERROR: Checksums do not match!");
             }
             
-            //insert the document in local db
-            //System.out.println("creating new doc");
-            //CrudService.getInstance().create(token, 
-            //        sm.getIdentifier(), new FileInputStream(outputTmpFile), sm);
-            //call cn.setReplicationStatus(guid, COMPLETE)
-            
         }
     }
     
Index: src/edu/ucsb/nceas/metacat/restservice/CNResourceHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/restservice/CNResourceHandler.java	(revision 6361)
+++ src/edu/ucsb/nceas/metacat/restservice/CNResourceHandler.java	(revision 6362)
@@ -322,7 +322,7 @@
     }
     
 	/**
-     * get the logs from the CrudService based on passed params.  Available 
+     * get the logs based on passed params.  Available 
      * params are token, fromDate, toDate, event.  See 
      * http://mule1.dataone.org/ArchitectureDocs/mn_api_crud.html#MN_crud.getLogRecords
      * for more info
Index: src/edu/ucsb/nceas/metacat/admin/upgrade/GenerateSystemMetadata.java
===================================================================
--- src/edu/ucsb/nceas/metacat/admin/upgrade/GenerateSystemMetadata.java	(revision 6361)
+++ src/edu/ucsb/nceas/metacat/admin/upgrade/GenerateSystemMetadata.java	(revision 6362)
@@ -136,7 +136,7 @@
     throws ServiceFailure, McdbDocNotFoundException, PropertyNotFoundException, InvalidToken, NotAuthorized,
     NotFound, NotImplemented, InvalidRequest, NoSuchAlgorithmException, AccessionNumberException, SQLException 
     {
-    	log.debug("CrudService.generateMissingSystemMetadata() called.");
+    	log.debug("generateMissingSystemMetadata() called.");
     	log.debug("Creating SystemMetadata for localId " + localId);
         SystemMetadata sm = null;
 
