Index: src/edu/ucsb/nceas/metacat/MetaCatServlet.java
===================================================================
--- src/edu/ucsb/nceas/metacat/MetaCatServlet.java	(revision 90)
+++ src/edu/ucsb/nceas/metacat/MetaCatServlet.java	(revision 91)
@@ -3,7 +3,7 @@
  *     Purpose: A Class that implements a metadata catalog as a java Servlet
  *   Copyright: 2000 Regents of the University of California and the
  *              National Center for Ecological Analysis and Synthesis
- *     Authors: Matt Jones
+ *     Authors: Matt Jones, Dan Higgins
  * 
  *     Version: '$Id$'
  */
@@ -40,6 +40,8 @@
 import oracle.xml.parser.v2.XMLDocumentFragment;
 import oracle.xml.parser.v2.XSLProcessor;
 import oracle.xml.parser.v2.*;    //Oracle parser - DFH
+import java.io.File;  //DFH
+import java.io.FileInputStream; //DFH
 
 /**
  * A metadata catalog server implemented as a Java Servlet
@@ -57,6 +59,8 @@
    * query -- actual query text (to go with 'action=query')<br>
    * action=validate -- vallidate the xml contained in validatetext<br>
    * valtext -- XML text to be validated
+   * action=getdatadoc -- retreive a stored datadocument  //DFH
+   * datadoc -- data document name (id)                   //DFH
  */
 public class MetaCatServlet extends HttpServlet {
 
@@ -71,6 +75,8 @@
   String 	defaultDB = null;
   String 	resultStyleURL = null;
   String 	xmlcatalogfile = null;
+  String    defaultdatapath = null;  // path to directory where data files that can be downloaded will be stored
+  String    executescript  = null;  // script to get data file and put it in defaultdocpath dir
   PropertyResourceBundle options = null;
 
   /**
@@ -90,6 +96,8 @@
       defaultDB = (String)options.handleGetObject("defaultDB");
       resultStyleURL = (String)options.handleGetObject("resultStyleURL");
       xmlcatalogfile = (String)options.handleGetObject("xmlcatalogfile");
+      defaultdatapath = (String)options.handleGetObject("defaultdatapath");
+      executescript = (String)options.handleGetObject("executescript");
 
       try {
         // Open a connection to the database
@@ -160,6 +168,8 @@
       handlePutDocumentAction(out, params, response);
     } else if (action.equals("validate")) {
       handleValidateAction(out, params, response);  
+    } else if (action.equals("getdatadoc")) {
+      handleGetDataDocumentAction(out, params, response);  
     } else {
       out.println("Error: action not registered.  Please report this error.");
     }
@@ -356,4 +366,58 @@
 
     return doctype;
   }
+    
+    
+  /** 
+   * Handle the document request and return the results 
+   * to the requestor - DFH
+   */
+  private void handleGetDataDocumentAction(PrintWriter out, Hashtable params, HttpServletResponse response) {
+      boolean error_flag = false;
+      String error_message = "";
+      // Get the document indicated
+      String[] datadoc = (String[])params.get("datadoc");
+  //    defaultdatapath = "C:\\Temp\\";    // for testing only!!!
+   //   executescript = "test.bat";        // for testing only!!!
+      
+      // set content type and other response header fields first
+      response.setContentType("application/octet-stream");
+   if (defaultdatapath!=null) {
+        if(!defaultdatapath.endsWith(System.getProperty("file.separator"))) defaultdatapath=defaultdatapath+System.getProperty("file.separator");
+      System.out.println("Path= "+defaultdatapath+datadoc[0]);
+      if (executescript!=null) {
+        String command = null;
+        File scriptfile = new File(executescript);
+        if (scriptfile.exists()) {
+            command=executescript+" "+datadoc[0]; }  // execute script includes path
+        else {     // look in defaultdatapath
+                command = defaultdatapath+executescript+" "+datadoc[0];  // on Win98 one MUST include the .bat extender
+        }
+      System.out.println(command);
+      try {
+      Process proc = Runtime.getRuntime().exec(command);
+      proc.waitFor();
+      }
+      catch (Exception eee) {
+        System.out.println("Error running process!");
+        error_flag = true;
+        error_message = "Error running process!";}
+      } // end executescript not null if
+      File datafile = new File(defaultdatapath+datadoc[0]);
+      try {
+      FileInputStream fw = new FileInputStream(datafile);
+      int x;
+     while ((x = fw.read())!=-1) {
+        out.write(x); }
+      fw.close();
+      
+      }
+      catch (Exception e) {
+        System.out.println("Error in returning file\n"+e.getMessage());
+        error_flag=true;
+        error_message = error_message+"\nError in returning file\n"+e.getMessage();}
+   } // end defaultdatapath not null if
+  }
+    
+    
 }
Index: MetaCatServlet.java
===================================================================
--- MetaCatServlet.java	(revision 90)
+++ MetaCatServlet.java	(revision 91)
@@ -3,7 +3,7 @@
  *     Purpose: A Class that implements a metadata catalog as a java Servlet
  *   Copyright: 2000 Regents of the University of California and the
  *              National Center for Ecological Analysis and Synthesis
- *     Authors: Matt Jones
+ *     Authors: Matt Jones, Dan Higgins
  * 
  *     Version: '$Id$'
  */
@@ -40,6 +40,8 @@
 import oracle.xml.parser.v2.XMLDocumentFragment;
 import oracle.xml.parser.v2.XSLProcessor;
 import oracle.xml.parser.v2.*;    //Oracle parser - DFH
+import java.io.File;  //DFH
+import java.io.FileInputStream; //DFH
 
 /**
  * A metadata catalog server implemented as a Java Servlet
@@ -57,6 +59,8 @@
    * query -- actual query text (to go with 'action=query')<br>
    * action=validate -- vallidate the xml contained in validatetext<br>
    * valtext -- XML text to be validated
+   * action=getdatadoc -- retreive a stored datadocument  //DFH
+   * datadoc -- data document name (id)                   //DFH
  */
 public class MetaCatServlet extends HttpServlet {
 
@@ -71,6 +75,8 @@
   String 	defaultDB = null;
   String 	resultStyleURL = null;
   String 	xmlcatalogfile = null;
+  String    defaultdatapath = null;  // path to directory where data files that can be downloaded will be stored
+  String    executescript  = null;  // script to get data file and put it in defaultdocpath dir
   PropertyResourceBundle options = null;
 
   /**
@@ -90,6 +96,8 @@
       defaultDB = (String)options.handleGetObject("defaultDB");
       resultStyleURL = (String)options.handleGetObject("resultStyleURL");
       xmlcatalogfile = (String)options.handleGetObject("xmlcatalogfile");
+      defaultdatapath = (String)options.handleGetObject("defaultdatapath");
+      executescript = (String)options.handleGetObject("executescript");
 
       try {
         // Open a connection to the database
@@ -160,6 +168,8 @@
       handlePutDocumentAction(out, params, response);
     } else if (action.equals("validate")) {
       handleValidateAction(out, params, response);  
+    } else if (action.equals("getdatadoc")) {
+      handleGetDataDocumentAction(out, params, response);  
     } else {
       out.println("Error: action not registered.  Please report this error.");
     }
@@ -356,4 +366,58 @@
 
     return doctype;
   }
+    
+    
+  /** 
+   * Handle the document request and return the results 
+   * to the requestor - DFH
+   */
+  private void handleGetDataDocumentAction(PrintWriter out, Hashtable params, HttpServletResponse response) {
+      boolean error_flag = false;
+      String error_message = "";
+      // Get the document indicated
+      String[] datadoc = (String[])params.get("datadoc");
+  //    defaultdatapath = "C:\\Temp\\";    // for testing only!!!
+   //   executescript = "test.bat";        // for testing only!!!
+      
+      // set content type and other response header fields first
+      response.setContentType("application/octet-stream");
+   if (defaultdatapath!=null) {
+        if(!defaultdatapath.endsWith(System.getProperty("file.separator"))) defaultdatapath=defaultdatapath+System.getProperty("file.separator");
+      System.out.println("Path= "+defaultdatapath+datadoc[0]);
+      if (executescript!=null) {
+        String command = null;
+        File scriptfile = new File(executescript);
+        if (scriptfile.exists()) {
+            command=executescript+" "+datadoc[0]; }  // execute script includes path
+        else {     // look in defaultdatapath
+                command = defaultdatapath+executescript+" "+datadoc[0];  // on Win98 one MUST include the .bat extender
+        }
+      System.out.println(command);
+      try {
+      Process proc = Runtime.getRuntime().exec(command);
+      proc.waitFor();
+      }
+      catch (Exception eee) {
+        System.out.println("Error running process!");
+        error_flag = true;
+        error_message = "Error running process!";}
+      } // end executescript not null if
+      File datafile = new File(defaultdatapath+datadoc[0]);
+      try {
+      FileInputStream fw = new FileInputStream(datafile);
+      int x;
+     while ((x = fw.read())!=-1) {
+        out.write(x); }
+      fw.close();
+      
+      }
+      catch (Exception e) {
+        System.out.println("Error in returning file\n"+e.getMessage());
+        error_flag=true;
+        error_message = error_message+"\nError in returning file\n"+e.getMessage();}
+   } // end defaultdatapath not null if
+  }
+    
+    
 }
Index: lib/metacat.properties
===================================================================
--- lib/metacat.properties	(revision 90)
+++ lib/metacat.properties	(revision 91)
@@ -1,6 +1,6 @@
 #
 # Properties file defining options for the MetaCatServlet.java servlet
-# Matt Jones
+# Matt Jones, Dan Higgins
 # '$Id$'
 #
 user=jones
@@ -9,3 +9,5 @@
 dbDriver=oracle.jdbc.driver.OracleDriver
 resultStyleURL=file:///home/httpd/html/xmltodb/resultset.xsl
 xmlcatalogfile=/home/httpd/html/xmltodb/catalog.txt
+defaultdatapath=C:\Temp\
+executescript=test.bat
Index: metacat.properties
===================================================================
--- metacat.properties	(revision 90)
+++ metacat.properties	(revision 91)
@@ -1,6 +1,6 @@
 #
 # Properties file defining options for the MetaCatServlet.java servlet
-# Matt Jones
+# Matt Jones, Dan Higgins
 # '$Id$'
 #
 user=jones
@@ -9,3 +9,5 @@
 dbDriver=oracle.jdbc.driver.OracleDriver
 resultStyleURL=file:///home/httpd/html/xmltodb/resultset.xsl
 xmlcatalogfile=/home/httpd/html/xmltodb/catalog.txt
+defaultdatapath=C:\Temp\
+executescript=test.bat
