Index: lib/easystream-1.2.5.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: lib/easystream-1.2.5.jar
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: lib/slf4j-api-1.5.11.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: lib/slf4j-api-1.5.11.jar
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: lib/slf4j-simple-1.5.11.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: lib/slf4j-simple-1.5.11.jar
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/edu/ucsb/nceas/metacat/PermissionController.java
===================================================================
--- src/edu/ucsb/nceas/metacat/PermissionController.java	(revision 5297)
+++ src/edu/ucsb/nceas/metacat/PermissionController.java	(revision 5298)
@@ -231,22 +231,26 @@
    */
   private boolean hasPermissionForInlineData(String user, String[] groups,
                                       String myPermission, String inlineDataId)
-                                      throws Exception
+      throws McdbException
   {
      // this method can call the public method - hasPermission(...)
      // the only difference is about the ownership, you couldn't find the owner
      // from inlinedataId directly. You should get it from eml document itself
      String []userPackage = createUsersPackage(user, groups);
-     if (containDocumentOwner(userPackage, docId))
-     {
-       return true;
-     }
-     else
-     {
-         PermissionController controller =
-                               new PermissionController(inlineDataId, false);
-         return controller.hasPermission(user, groups, myPermission);
-     }
+     try {
+        if (containDocumentOwner(userPackage, docId))
+         {
+           return true;
+         }
+         else
+         {
+             PermissionController controller =
+                                   new PermissionController(inlineDataId, false);
+             return controller.hasPermission(user, groups, myPermission);
+         }
+    } catch (SQLException e) {
+        throw new McdbException(e.getMessage());
+    }
   }
 
   /**
@@ -964,7 +968,7 @@
    public static Hashtable<String, String> getUnReadableInlineDataIdList(String docidWithoutRev,
                                                    String user, String[] groups,
                                                    boolean withRevision)
-                                                throws Exception
+                                                throws McdbException
    {
      Hashtable<String, String> inlineDataList = getUnAccessableInlineDataIdList(docidWithoutRev,
                               user, groups, AccessControlInterface.READSTRING,
@@ -1007,15 +1011,20 @@
    private static Hashtable<String, String> getUnAccessableInlineDataIdList(String docid,
                                String user, String[] groups, String permission,
                                boolean withRevision)
-                             throws SQLException,McdbException, Exception
+                             throws McdbException
    {
-      Hashtable<String, String> unAccessibleIdList = new Hashtable();
-      if (user == null) {
-    	  return unAccessibleIdList;
-      }
-      
-      Hashtable allIdList = getAllInlineDataIdList(docid);
-      Enumeration<String> en = allIdList.keys();
+       Hashtable<String, String> unAccessibleIdList = new Hashtable();
+       if (user == null) {
+           return unAccessibleIdList;
+       }
+
+       Hashtable allIdList;
+       try {
+           allIdList = getAllInlineDataIdList(docid);
+       } catch (SQLException e) {
+           throw new McdbException(e.getMessage());
+       }
+       Enumeration<String> en = allIdList.keys();
       while (en.hasMoreElements())
       {
         String subTreeId = (String) en.nextElement();
Index: src/edu/ucsb/nceas/metacat/DocumentImpl.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DocumentImpl.java	(revision 5297)
+++ src/edu/ucsb/nceas/metacat/DocumentImpl.java	(revision 5298)
@@ -1357,8 +1357,9 @@
         
 		String xmlFileContents = "";
 		
-		try {			
-			xmlFileContents = FileUtil.readFileToString(documentPath);
+		try {
+            xmlFileContents = FileUtil.readFileToString(documentPath);
+       
             
 			// get a list of inline data sections that are not readable
 			// by this user
@@ -1395,12 +1396,11 @@
 			pw.write(xmlFileContents);
 			pw.close();	
 			
-            
-        } catch (Exception e) {
-            throw new McdbException("Error reading document " + documentPath 
-            		+ " from disk: " + e.getMessage());
+	     } catch (UtilException e) {
+             throw new McdbException(e.getMessage());
+         } catch (IOException e) {
+             throw new McdbException(e.getMessage());
         }
-        
     }
     
     /**
@@ -1465,7 +1465,7 @@
 	 *            the unique key for this inline element
 	 */
     private String stripInline20XData(String xmlFileContents, String inLineId)
-			throws Exception {
+			throws McdbException {
 		String changedString = xmlFileContents;
 		
     	Pattern distStartPattern = Pattern.compile("<distribution", Pattern.CASE_INSENSITIVE); 
@@ -1483,7 +1483,7 @@
     		// find the index of the corresponding end element
     		int distStart = distStartMatcher.end();
         	if (!distEndMatcher.find(distStart)) {
-        		throw new Exception("Could not find end tag for distribution");
+        		throw new McdbException("Could not find end tag for distribution");
         	}
         	int distEnd = distEndMatcher.start();
         	
@@ -1516,7 +1516,7 @@
 	 * @param inLineKey
 	 *            the unique key for this inline element
 	 */
-    private String stripInline21XData(String xmlFileContents, String inLineId) throws Exception {
+    private String stripInline21XData(String xmlFileContents, String inLineId) throws McdbException {
     	int distributionIndex = Integer.valueOf(inLineId);
     	String changedString = xmlFileContents;
     	Pattern distStartPattern = Pattern.compile("<distribution", Pattern.CASE_INSENSITIVE); 
@@ -1529,7 +1529,7 @@
     	// to set the start range we will search for the inline element.
     	for (int i = 0; i < distributionIndex; i++) {
     		if (!matcher.find()) {
-    			throw new Exception("Could not find distribution number " + (i + 1));
+    			throw new McdbException("Could not find distribution number " + (i + 1));
     		}
     	}	
     	int distStart = matcher.end();
@@ -1538,7 +1538,7 @@
     	// the end range we will search for the inline element
     	matcher.usePattern(distEndPattern);
     	if (!matcher.find(distStart)) {
-    		throw new Exception("Could not find end tag for distribution");
+    		throw new McdbException("Could not find end tag for distribution");
     	}
     	int distEnd = matcher.start();
     	
Index: src/edu/ucsb/nceas/metacat/MetacatHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/MetacatHandler.java	(revision 5297)
+++ src/edu/ucsb/nceas/metacat/MetacatHandler.java	(revision 5298)
@@ -29,6 +29,7 @@
 import java.io.FileInputStream;
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.StringReader;
@@ -71,6 +72,7 @@
 import edu.ucsb.nceas.metacat.accesscontrol.AccessControlForSingleFile;
 import edu.ucsb.nceas.metacat.accesscontrol.AccessControlInterface;
 import edu.ucsb.nceas.metacat.cart.CartManager;
+import edu.ucsb.nceas.metacat.client.InsufficientKarmaException;
 import edu.ucsb.nceas.metacat.database.DBConnection;
 import edu.ucsb.nceas.metacat.database.DBConnectionPool;
 import edu.ucsb.nceas.metacat.dataquery.DataQuery;
@@ -720,7 +722,6 @@
             String[] docs = new String[0];
             String docid = "";
             String qformat = "";
-            String abstrpath = null;
             
             // read the params
             if (params.containsKey("docid")) {
@@ -763,9 +764,8 @@
                         if (zip) {
                             addDocToZip(request, docid, providedFileName, zout, user, groups);
                         } else {
-                            readFromMetacat(request, response, docid, qformat,
-                                    abstrpath, user, groups, zip, zout,
-                                    withInlineData, params);
+                            readFromMetacat(request.getRemoteAddr(), response, response.getOutputStream(), docid, qformat,
+                                    user, groups, withInlineData, params);
                         }
                         
                         // case docid="http://.../filename"
@@ -783,9 +783,8 @@
                     if (zip) {
                         addDocToZip(request, docid, providedFileName, zout, user, groups);
                     } else {
-                        readFromMetacat(request, response, docid, qformat,
-                                abstrpath, user, groups, zip, zout,
-                                withInlineData, params);
+                        readFromMetacat(request.getRemoteAddr(), response, response.getOutputStream(), docid, qformat,
+                                user, groups, withInlineData, params);
                     }
                 }
             }
@@ -896,15 +895,18 @@
     }
     
     /** read metadata or data from Metacat
+     * @throws PropertyNotFoundException 
+     * @throws ParseLSIDException 
+     * @throws InsufficientKarmaException 
      */
-    private void readFromMetacat(HttpServletRequest request,
-            HttpServletResponse response, String docid, String qformat,
-            String abstrpath, String user, String[] groups, boolean zip,
-            ZipOutputStream zout, boolean withInlineData, Hashtable<String, String[]> params)
-            throws ClassNotFoundException, IOException, SQLException,
-            McdbException, Exception {
+    public void readFromMetacat(String ipAddress,
+            HttpServletResponse response, OutputStream out, String docid, String qformat,
+            String user, String[] groups, boolean withInlineData, 
+            Hashtable<String, String[]> params) throws ClassNotFoundException, 
+            IOException, SQLException, McdbException, PropertyNotFoundException, 
+            ParseLSIDException, InsufficientKarmaException {
         
-        Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
+        Logger logMetacat = Logger.getLogger(MetacatHandler.class);
         try {
             
             if (docid.startsWith("urn:")) {
@@ -923,15 +925,14 @@
             
             //check the permission for read
             if (!DocumentImpl.hasReadPermission(user, groups, docid)) {
-                Exception e = new Exception("User " + user
+                InsufficientKarmaException e = new InsufficientKarmaException("User " + user
                         + " does not have permission"
                         + " to read the document with the docid " + docid);
-                
                 throw e;
             }
             
             if (doc.getRootNodeID() == 0) {
-                // this is data file
+                // this is data file, so find the path on disk for the file
                 String filepath = PropertyService.getProperty("application.datafilepath");
                 if (!filepath.endsWith("/")) {
                     filepath += "/";
@@ -940,62 +941,26 @@
                 FileInputStream fin = null;
                 fin = new FileInputStream(filename);
                 
-                //MIME type
-                String contentType = servletContext.getMimeType(filename);
-                if (contentType == null) {
-                    ContentTypeProvider provider = new ContentTypeProvider(
-                            docid);
-                    contentType = provider.getContentType();
-                    logMetacat.info("MetaCatServlet.readFromMetacat - Final contenttype is: "
-                            + contentType);
-                }
-                
-                response.setContentType(contentType);
-                // if we decide to use "application/octet-stream" for all data
-                // returns
-                // response.setContentType("application/octet-stream");
+                if (response != null) {
+                    // MIME type
+                    String contentType = servletContext.getMimeType(filename);
+                    if (contentType == null) {
+                        ContentTypeProvider provider = new ContentTypeProvider(
+                                docid);
+                        contentType = provider.getContentType();
+                        logMetacat.info("MetaCatServlet.readFromMetacat - Final contenttype is: "
+                                + contentType);
+                    }
+                    response.setContentType(contentType);
 
-                // check for the existence of a metadatadocid parameter,
-                // if this is sent, then send a filename which contains both
-                // the metadata docid and the data docid, so the link with
-                // metadata is explicitly encoded in the filename.
-                String metadatadocid = null;
-                Vector<String> nameparts = new Vector<String>();
-
-                if(params.containsKey("metadatadocid")) {
-                    metadatadocid = params.get("metadatadocid")[0];
+                    // Set the output filename on the response
+                    String outputname = generateOutputName(docid, params, doc);                    
+                    response.setHeader("Content-Disposition",
+                            "attachment; filename=\"" + outputname + "\"");
                 }
-                if (metadatadocid != null && !metadatadocid.equals("")) {
-                    nameparts.add(metadatadocid);
-                }
-                // we'll always have the docid, include it in the name
-                String doctype = doc.getDoctype();
-                                // TODO: fix this to lookup the associated FGDC metadata document,
-                                // and grab the doctype tag for it.  These should be set to something 
-                                // consistent, not 'metadata' as it stands...
-                //if (!doctype.equals("metadata")) {
-                //    nameparts.add(docid);
-                //} 
-                                nameparts.add(docid);
-                // Set the name of the data file to the entity name plus docid,
-                // or if that is unavailable, use the docid alone
-                String docname = doc.getDocname();
-                if (docname != null && !docname.equals("")) {
-                    nameparts.add(docname); 
-                }
-                // combine the name elements with a dash, using a 'join' equivalent
-                String outputname = null;
-                String delimiter = "-";
-                Iterator<String> iter = nameparts.iterator();
-                StringBuffer buffer = new StringBuffer(iter.next());
-                while (iter.hasNext()) buffer.append(delimiter).append(iter.next());
-                outputname = buffer.toString();    
                 
-                response.setHeader("Content-Disposition",
-                        "attachment; filename=\"" + outputname + "\"");
-                
+                // Write the data to the output stream
                 try {
-                    ServletOutputStream out = response.getOutputStream();
                     byte[] buf = new byte[4 * 1024]; // 4K buffer
                     int b = fin.read(buf);
                     while (b != -1) {
@@ -1008,27 +973,29 @@
                 
             } else {
                 // this is metadata doc
-                ServletOutputStream streamOut = response.getOutputStream();
                 if (qformat.equals("xml") || qformat.equals("")) {
                     // if equals "", that means no qformat is specified. hence
                     // by default the document should be returned in xml format
                     // set content type first
-                    response.setContentType("text/xml"); //MIME type
-                    response.setHeader("Content-Disposition",
-                            "attachment; filename=" + docid + ".xml");
                     
+                    if (response != null) {
+                        response.setContentType("text/xml"); //MIME type
+                        response.setHeader("Content-Disposition",
+                                "attachment; filename=" + docid + ".xml");
+                    }
+                    
                     // Try to get the metadata file from disk. If it isn't
                     // found, create it from the db and write it to disk then.
                     try {
-                        PrintWriter out = new PrintWriter(streamOut);
-                        doc.toXml(out, user, groups, withInlineData);               
-                    } catch (Exception e) {
+                        PrintWriter pw = new PrintWriter(out);
+                        doc.toXml(pw, user, groups, withInlineData);               
+                    } catch (McdbException e) {
                         // any exceptions in reading the xml from disc, and we go back to the
                         // old way of creating the xml directly.
                         logMetacat.error("MetaCatServlet.readFromMetacat - could not read from document file " + docid 
                                 + ": " + e.getMessage());
-                        PrintWriter out = new PrintWriter(streamOut);
-                        doc.toXmlFromDb(out, user, groups, withInlineData);
+                        PrintWriter pw = new PrintWriter(out);
+                        doc.toXmlFromDb(pw, user, groups, withInlineData);
                     }
                 } else {
                     // TODO MCD, this should read from disk as well?
@@ -1041,9 +1008,12 @@
                             params.put("publicRead", new String[] {"false"});
                     }
                     
-                    response.setContentType("text/html"); //MIME type
-                    PrintWriter out = new PrintWriter(streamOut);
+                    if (response != null) {
+                        response.setContentType("text/html"); //MIME type
+                    }
                     
+                    PrintWriter pw = new PrintWriter(out);
+                    
                     // Look up the document type
                     String doctype = doc.getDoctype();
                     // Transform the document to the new doctype
@@ -1050,16 +1020,62 @@
                     DBTransform dbt = new DBTransform();
                     dbt.transformXMLDocument(doc.toString(user, groups,
                             withInlineData), doctype, "-//W3C//HTML//EN",
-                            qformat, out, params, null);
+                            qformat, pw, params, null);
                 }
                 
             }
-            EventLog.getInstance().log(request.getRemoteAddr(), user,
-                    docid, "read");
-        } catch (Exception except) {
+            EventLog.getInstance().log(ipAddress, user, docid, "read");
+        } catch (PropertyNotFoundException except) {
             throw except;
         }
     }
+
+    /**
+     * Create a filename to be used for naming a downloaded document
+     * @param docid the identifier of the document to be named
+     * @param params the parameters of the request
+     * @param doc the DocumentImpl of the document to be named
+     * @return String containing a name for the download
+     */
+    private String generateOutputName(String docid,
+            Hashtable<String, String[]> params, DocumentImpl doc) {
+        String outputname = null;
+        // check for the existence of a metadatadocid parameter,
+        // if this is sent, then send a filename which contains both
+        // the metadata docid and the data docid, so the link with
+        // metadata is explicitly encoded in the filename.
+        String metadatadocid = null;
+        Vector<String> nameparts = new Vector<String>();
+
+        if(params.containsKey("metadatadocid")) {
+            metadatadocid = params.get("metadatadocid")[0];
+        }
+        if (metadatadocid != null && !metadatadocid.equals("")) {
+            nameparts.add(metadatadocid);
+        }
+        // we'll always have the docid, include it in the name
+        String doctype = doc.getDoctype();
+        // TODO: fix this to lookup the associated FGDC metadata document,
+        // and grab the doctype tag for it.  These should be set to something 
+        // consistent, not 'metadata' as it stands...
+        //if (!doctype.equals("metadata")) {
+        //    nameparts.add(docid);
+        //} 
+        nameparts.add(docid);
+        // Set the name of the data file to the entity name plus docid,
+        // or if that is unavailable, use the docid alone
+        String docname = doc.getDocname();
+        if (docname != null && !docname.equals("")) {
+            nameparts.add(docname); 
+        }
+        // combine the name elements with a dash, using a 'join' equivalent
+        String delimiter = "-";
+        Iterator<String> iter = nameparts.iterator();
+        StringBuffer buffer = new StringBuffer(iter.next());
+        while (iter.hasNext()) buffer.append(delimiter).append(iter.next());
+        outputname = buffer.toString();
+        return outputname;
+    }
     
     /**
      * read data from URLConnection
@@ -2796,7 +2812,7 @@
      * If the given docid only have one seperter, we need
      * append rev for it. The rev come from xml_documents
      */
-    private static String appendRev(String docid) throws Exception {
+    private static String appendRev(String docid) throws PropertyNotFoundException, SQLException, McdbDocNotFoundException {
 //        Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
         String newAccNum = null;
         String separator = PropertyService.getProperty("document.accNumSeparator");
@@ -2807,7 +2823,7 @@
             //only one seperater
             int rev = DBUtil.getLatestRevisionInDocumentTable(docid);
             if (rev == -1) {
-                throw new Exception("the requested docid '"
+                throw new McdbDocNotFoundException("the requested docid '"
                         + docid+ "' does not exist");
             } else {
                 newAccNum = docid+ separator+ rev;
Index: src/edu/ucsb/nceas/metacat/dataone/CrudService.java
===================================================================
--- src/edu/ucsb/nceas/metacat/dataone/CrudService.java	(nonexistent)
+++ src/edu/ucsb/nceas/metacat/dataone/CrudService.java	(revision 5298)
@@ -0,0 +1,307 @@
+/**
+ *  '$RCSfile$'
+ *  Copyright: 2000 Regents of the University of California and the
+ *              National Center for Ecological Analysis and Synthesis
+ *
+ *   '$Author: Serhan AKIN $'
+ *     '$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.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Timer;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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.DescribeResponse;
+import org.dataone.service.types.IdentifierType;
+import org.dataone.service.types.LogRecordSet;
+import org.dataone.service.types.SystemMetadata;
+
+import com.gc.iotools.stream.is.InputStreamFromOutputStream;
+
+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.service.SessionService;
+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 ServletContext servletContext;
+    private HttpServletRequest request;
+    private HttpServletResponse response;
+
+//    private Logger logMetacat;
+    private MetacatHandler handler;
+//    private String username;
+//    private String password;
+//    private String sessionId;
+//    private String[] groupNames;
+    private Hashtable<String, String[]> params;
+
+    /**
+     * Initializes new instance by setting servlet context,request and response.
+     * TODO: remove dependency on Servlet infrastructure
+     * TODO: Make this a real service, and make it a Singleton
+     */
+    public CrudService(ServletContext servletContext,
+            HttpServletRequest request, HttpServletResponse response) {
+        this.servletContext = servletContext;
+        this.request = request;
+        this.response = response;
+
+        handler = new MetacatHandler(this.servletContext, new Timer());
+        initParams();
+//        loadSessionData();
+    }
+
+    /**
+     *  copies request parameters to a Hashtable which is given as argument to 
+     *  native MetacatHandler functions  
+     */
+    private void initParams() {
+
+        String name = null;
+        String[] value = null;
+        params = new Hashtable<String, String[]>();
+        Enumeration paramlist = request.getParameterNames();
+        while (paramlist.hasMoreElements()) {
+            name = (String) paramlist.nextElement();
+            value = request.getParameterValues(name);
+            params.put(name, value);
+        }
+    }
+    
+    /**
+     * 
+     * Load user details of metacat session from the request 
+     * 
+     */
+//    private void loadSessionData() {
+//        SessionData sessionData = RequestUtil.getSessionData(request);
+//
+//        // TODO: validate the session before allowing these values to be set
+//        username = sessionData.getUserName();
+//        password = sessionData.getPassword();
+//        groupNames = sessionData.getGroupNames();
+//        sessionId = sessionData.getId();
+//
+//        if (username == null) {
+//            username = "public";
+//        }
+//    }
+    
+    /*
+     * 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.
+     */
+    private static SessionData getSessionData(AuthToken token) {
+        SessionData sessionData = null;
+        String sessionId = token.getToken();
+        
+        // if the session id is registered in SessionService, get the
+        // SessionData for it. Otherwise, use the public session.
+        if (SessionService.isSessionRegistered(sessionId)) {
+            sessionData = SessionService.getRegisteredSession(sessionId);
+        } else {
+            sessionData = SessionService.getPublicSession();
+        }
+        
+        return sessionData;
+    }
+    
+    public IdentifierType create(AuthToken token, IdentifierType guid, 
+            InputStream object, SystemMetadata sysmeta) throws InvalidToken, 
+            ServiceFailure, NotAuthorized, IdentifierNotUnique, UnsupportedType, 
+            InsufficientResources, InvalidSystemMetadata, NotImplemented {
+        throw new NotImplemented(1000, "This method not yet implemented.");
+    }
+
+    public IdentifierType delete(AuthToken token, IdentifierType guid)
+            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
+            NotImplemented {
+        throw new NotImplemented(1000, "This method not yet implemented.");
+    }
+
+    public DescribeResponse describe(AuthToken token, IdentifierType guid)
+            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
+            NotImplemented {
+        throw new NotImplemented(1000, "This method not yet implemented.");
+    }
+    
+    public InputStream get(AuthToken token, IdentifierType guid)
+            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
+            NotImplemented {
+        
+        // Retrieve the session information from the AuthToken
+        // If the session is expired, then the user is '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.getIdentifier());
+
+            final InputStreamFromOutputStream<String> objectStream = 
+                new InputStreamFromOutputStream<String>() {
+                
+                @Override
+                public String produce(final OutputStream dataSink) throws Exception {
+
+                    try {
+                        handler.readFromMetacat(request.getRemoteAddr(), null, 
+                                dataSink, localId, "xml",
+                                sessionData.getUserName(), 
+                                sessionData.getGroupNames(), true, params);
+                    } catch (PropertyNotFoundException e) {
+                        throw new ServiceFailure(1030, e.getMessage());
+                    } catch (ClassNotFoundException e) {
+                        throw new ServiceFailure(1030, e.getMessage());
+                    } catch (IOException e) {
+                        throw new ServiceFailure(1030, e.getMessage());
+                    } catch (SQLException e) {
+                        throw new ServiceFailure(1030, e.getMessage());
+                    } catch (McdbException e) {
+                        throw new ServiceFailure(1030, e.getMessage());
+                    } catch (ParseLSIDException e) {
+                        throw new NotFound(1020, e.getMessage());
+                    } catch (InsufficientKarmaException e) {
+                        throw new NotAuthorized(1000, "Not authorized for get().");
+                    }
+
+                    return "Completed";
+                }
+            };
+            return objectStream;
+
+        } catch (McdbDocNotFoundException e) {
+            throw new NotFound(1020, e.getMessage());
+        }
+        
+/*    
+ *      Alternative approach that uses Piped streams, but requires thread handling
+ *      which makes exception handling difficult (because exceptions fall off the
+ *      calling thread, terminating the thread.
+ *      
+        // Look up the localId for this global identifier
+        IdentifierManager im = IdentifierManager.getInstance();
+        try {
+            final String localId = im.getLocalId(guid.getIdentifier());
+
+            // Now use that localId to read the object and return it
+            params.put("docid", new String[] { localId });        
+            final PipedInputStream in = new PipedInputStream();
+            new Thread(
+                    new Runnable() {
+                        public void run() {
+                            try {
+                                PipedOutputStream out = new PipedOutputStream(in);
+                                handler.readFromMetacat(request.getRemoteAddr(), null, 
+                                        out, localId, "xml",
+                                        username, groupNames, true, params);
+                            } catch (PropertyNotFoundException e) {
+                                throw new ServiceFailure(1030, e.getMessage());
+                            } catch (ClassNotFoundException e) {
+                                throw new ServiceFailure(1030, e.getMessage());
+                            } catch (IOException e) {
+                                throw new ServiceFailure(1030, e.getMessage());
+                            } catch (SQLException e) {
+                                throw new ServiceFailure(1030, e.getMessage());
+                            } catch (McdbException e) {
+                                throw new ServiceFailure(1030, e.getMessage());
+                            } catch (ParseLSIDException e) {
+                                throw new NotFound(1020, e.getMessage());
+                            } catch (InsufficientKarmaException e) {
+                                throw new NotAuthorized(1000, "Not authorized for get().");
+                            }
+                        }
+                    }
+            ).start();
+            return in;
+        } catch (McdbDocNotFoundException e) {
+            throw new NotFound(1020, e.getMessage());
+        }        
+*/
+    }
+
+    public Checksum getChecksum(AuthToken token, IdentifierType guid)
+            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
+            InvalidRequest, NotImplemented {
+        throw new NotImplemented(1000, "This method not yet implemented.");
+    }
+
+    public Checksum getChecksum(AuthToken token, IdentifierType guid, 
+            String checksumAlgorithm) throws InvalidToken, ServiceFailure, 
+            NotAuthorized, NotFound, InvalidRequest, NotImplemented {
+        throw new NotImplemented(1000, "This method not yet implemented.");
+    }
+
+    public LogRecordSet getLogRecords(AuthToken token, Date fromDate, Date toDate)
+            throws InvalidToken, ServiceFailure, NotAuthorized, InvalidRequest, 
+            NotImplemented {
+        throw new NotImplemented(1000, "This method not yet implemented.");
+    }
+
+    public SystemMetadata getSystemMetadata(AuthToken token, IdentifierType guid)
+            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
+            InvalidRequest, NotImplemented {
+        throw new NotImplemented(1000, "This method not yet implemented.");
+    }
+
+    public IdentifierType update(AuthToken token, IdentifierType guid, 
+            InputStream object, IdentifierType obsoletedGuid, SystemMetadata sysmeta) 
+            throws InvalidToken, ServiceFailure, NotAuthorized, IdentifierNotUnique, 
+            UnsupportedType, InsufficientResources, NotFound, InvalidSystemMetadata, 
+            NotImplemented {
+        throw new NotImplemented(1000, "This method not yet implemented.");
+    }
+
+}

Property changes on: src/edu/ucsb/nceas/metacat/dataone/CrudService.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
