Index: src/edu/ucsb/nceas/metacat/dataone/CrudService.java
===================================================================
--- src/edu/ucsb/nceas/metacat/dataone/CrudService.java	(revision 5465)
+++ src/edu/ucsb/nceas/metacat/dataone/CrudService.java	(revision 5466)
@@ -188,6 +188,11 @@
     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());   
@@ -283,6 +288,8 @@
 
         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("1000", "User " + username + " is not authorized to create content." +
                     "  If you are not logged in, please do so and retry the request.");
         }
@@ -305,10 +312,17 @@
         // Check if we are handling metadata or data
         boolean isScienceMetadata = isScienceMetadata(sysmeta);
         
+        /* TODO:
+         * For EML documents, the data url field needs to be checked here
+         * and the describes and describedBy fields of the system metadata
+         * need to be set with the appropriate uri.  Older EML documents
+         * maybe have ecogrid:// uri's embedded in them.  See bug 618 
+         * (https://trac.dataone.org/ticket/618) for more info on this.
+         */
         if (isScienceMetadata) {
             // CASE METADATA:
             try {
-                System.out.println("CrudService: inserting document with guid " + guid.getValue());
+                //System.out.println("CrudService: inserting document with guid " + guid.getValue());
                 this.insertDocument(object, guid, sessionData);
                 localId = im.getLocalId(guid.getValue());
             } catch (IOException e) {
@@ -332,8 +346,8 @@
         // For Metadata and Data, insert the system metadata into the object store too
         String sysMetaLocalId = insertSystemMetadata(sysmeta, sessionData);
         //get the document info.  add any access params for the sysmeta too
-        System.out.println("looking for access records to add for system " +
-            "metadata who's parent doc's  local id is " + localId);
+        //System.out.println("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(".")));
@@ -346,9 +360,9 @@
                 String permissionType = (String)ah.get("permission_type");
                 String permissionOrder = (String)ah.get("permission_order");
                 int perm = new Integer(permission).intValue();
-                System.out.println("found access record for principal " + principal);
-                System.out.println("permission: " + perm + " perm_type: " + permissionType + 
-                    " perm_order: " + permissionOrder);
+                //System.out.println("found access record for principal " + principal);
+                //System.out.println("permission: " + perm + " perm_type: " + permissionType + 
+                //    " perm_order: " + permissionOrder);
                 this.setAccess(token, guid, principal, perm, permissionType, permissionOrder, true);
             }
         }
@@ -356,6 +370,8 @@
         {
             logMetacat.error("Error setting permissions on System Metadata object " + 
                     " with id " + sysMetaLocalId + ": " + e.getMessage());
+            //TODO: decide if this error should cancel the entire create or
+            //if it should continue with just a logged error.
         }
         
         
@@ -445,8 +461,8 @@
         {
             perm = "write";
         }
-        System.out.println("perm in setAccess: " + perm);
-        System.out.println("permission in setAccess: " + permission);
+        //System.out.println("perm in setAccess: " + perm);
+        //System.out.println("permission in setAccess: " + permission);
         setAccess(token, id, principal, perm, permissionType, permissionOrder,
                 setSystemMetadata);
        
@@ -465,6 +481,12 @@
             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);
@@ -551,6 +573,7 @@
       int totalAfterQuery = 0;
       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)
@@ -562,6 +585,10 @@
               System.out.println("query end time is " + endTime);
           }
           params.clear();
+          /* TODO:
+           * These metacat queries should not be hard coded here.  They
+           * should be accessed from within a .properties file
+           */
           params.put("returndoctype", new String[] {"http://dataone.org/service/types/SystemMetadata/0.1"});
           params.put("qformat", new String[] {"xml"});
           params.put("returnfield", new String[] {"size", "originMemberNode", 
@@ -592,6 +619,11 @@
           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);
@@ -617,6 +649,7 @@
                   //dateSysMetadataModified = parseDate(dateSMM);
                   if(dateSMM.indexOf(".") != -1)
                   {  //strip the milliseconds
+                      //TODO: don't do this. we need milliseconds now.
                       dateSMM = dateSMM.substring(0, dateSMM.indexOf(".")) + 'Z';
                   }
                   //System.out.println("dateSMM: " + dateSMM);
@@ -852,6 +885,16 @@
                             " dataSink: " + dataSink + " localId: " + localId + 
                             " username: " + username + " params: " + params.toString());
                         */    
+                        /* TODO:
+                         * This multithreaded approach to getting data without
+                         * being memory bound causes problems with exception 
+                         * handling.  The only exception the produce method
+                         * will return is an IOException, rendering all of the 
+                         * catch blocks below mute.  This should probably be changed
+                         * to use a memory mapped solution instead so that we
+                         * can properly pass exceptions to the client.
+                         * see https://trac.dataone.org/ticket/706
+                         */
                         handler.readFromMetacat(metacatUrl, null, 
                                 dataSink, localId, "xml",
                                 username, 
@@ -906,6 +949,7 @@
             throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
             InvalidRequest, NotImplemented {
         logCrud.info("getChecksum");
+        //TODO: this could now easily be implemented
         throw new NotImplemented("1000", "This method not yet implemented.");
     }
 
@@ -916,6 +960,7 @@
             String checksumAlgorithm) throws InvalidToken, ServiceFailure, 
             NotAuthorized, NotFound, InvalidRequest, NotImplemented {
         logCrud.info("getChecksum");
+        //TODO: this could now easily be implemented
         throw new NotImplemented("1000", "This method not yet implemented.");
     }
 
@@ -1153,6 +1198,9 @@
     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");
@@ -1242,6 +1290,7 @@
      */
     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;
@@ -1378,25 +1427,7 @@
 
         return newFile;
     }
-    
-    private static Date getDateInTimeZone(Date currentDate, String timeZoneId)
-    {
-        TimeZone tz = TimeZone.getTimeZone(timeZoneId);
-        Calendar mbCal = new GregorianCalendar(TimeZone.getTimeZone(timeZoneId));
-        mbCal.setTimeInMillis(currentDate.getTime());
 
-        Calendar cal = Calendar.getInstance();
-        cal.set(Calendar.YEAR, mbCal.get(Calendar.YEAR));
-        cal.set(Calendar.MONTH, mbCal.get(Calendar.MONTH));
-        cal.set(Calendar.DAY_OF_MONTH, mbCal.get(Calendar.DAY_OF_MONTH));
-        cal.set(Calendar.HOUR_OF_DAY, mbCal.get(Calendar.HOUR_OF_DAY));
-        cal.set(Calendar.MINUTE, mbCal.get(Calendar.MINUTE));
-        cal.set(Calendar.SECOND, mbCal.get(Calendar.SECOND));
-        cal.set(Calendar.MILLISECOND, mbCal.get(Calendar.MILLISECOND));
-
-        return cal.getTime();
-    }
-
     /**
      * insert a systemMetadata doc, return the localId of the sysmeta
      */
@@ -1776,6 +1807,7 @@
             sm.setDateSysMetadataModified(dateUpdated);
         }
         NodeReference nr = new NodeReference();
+        //TODO: this should be set to be something more meaningful once the registry is up
         nr.setValue("metacat");
         sm.setOriginMemberNode(nr);
         sm.setAuthoritativeMemberNode(nr);
