Index: src/edu/ucsb/nceas/metacat/HttpMessage.java
===================================================================
--- src/edu/ucsb/nceas/metacat/HttpMessage.java	(revision 1821)
+++ src/edu/ucsb/nceas/metacat/HttpMessage.java	(nonexistent)
@@ -1,165 +0,0 @@
-/**
- *  '$RCSfile$'
- *    Purpose: Used for Java applet/application communication
- *             with servlet. Based on code given in the book
- *             "Java Servlet Programming" by Hunter & crawford
- *  Copyright: 2000 Regents of the University of California and the
- *             National Center for Ecological Analysis and Synthesis
- *    Authors: Dan Higgins modified for metacat by Chad Berkley
- *    Release: @release@
- *
- *   '$Author$'
- *     '$Date$'
- * '$Revision$'
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-package edu.ucsb.nceas.metacat;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-/**
- * Send a message to an HTTP server using either a GET or POST operation
- */
-public class HttpMessage {
-    public String contype;
-    URL servlet = null;
-    String argString = null;
-    static String cookie = null;
-    public HttpMessage(URL servlet) {
-        this.servlet = servlet;
-    }
-    
-    /**
-     * return the cookie that this message object contains
-     */
-    public static String getCookie()
-    {
-      return cookie;
-    }
-    
-    /**
-     * Performs a GET request to the previously given servlet
-     * with no query string
-    */
-    public InputStream sendGetMessage() throws IOException {
-        return sendGetMessage(null);
-    }
-    
-    /**
-     * Performs a GET request to the previously given servlet
-     *Builds a query string from the supplied Properties list.
-     */
-    public InputStream sendGetMessage(Properties args) throws IOException {
-        argString = ""; //default
-        
-        if (args != null) {
-            argString = "?" + toEncodedString(args);
-        }
-        URL url = new URL(servlet.toExternalForm() + argString);
-        
-        // turn off caching
-        URLConnection con = url.openConnection();
-        con.setUseCaches(false);
-        contype = con.getContentType();
-        
-        return con.getInputStream();
-    }
-    
-    /**
-     * Performs a POST request to the previously given servlet
-     * with no query string
-     */
-    public InputStream sendPostMessage() throws IOException {
-        return sendPostMessage(null);
-    }
-    
-    /**
-     * Builds post data from the supplied properties list
-     */
-    public InputStream sendPostMessage(Properties args) throws IOException {
-        argString = ""; //default
-        if (args != null) {
-            argString = toEncodedString(args); 
-        }
-        URLConnection con = servlet.openConnection();
-        if (cookie!=null) {
-            int k = cookie.indexOf(";");
-            if (k>0) {
-                cookie = cookie.substring(0, k);
-            }
-            //System.out.println("Cookie = " + cookie);
-            con.setRequestProperty("Cookie", cookie); 
-            con.setRequestProperty("User-Agent", "MORPHO");  // add 10/26/00 by DFH so Metacat can determine where request come from
-        }
-        //prepare for both input and output
-        con.setDoInput(true);
-        con.setDoOutput(true);
-        //turn off caching
-        con.setUseCaches(false);
-        
-        //work around a Netscape bug
-        //con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
-        //Write the arguments as post data
-        DataOutputStream out = new DataOutputStream(con.getOutputStream());
-        out.writeBytes(argString);
-        out.flush();
-        contype = con.getContentType();
-        String temp = con.getHeaderField("Set-Cookie");
-        if (temp!=null) {
-            cookie = temp;
-        }
-        //System.out.println(cookie);
-        out.close();
-        
-        return con.getInputStream();
-    }
-
-    /**
-     * Returns the urls argument strings
-     */
-    public String getArgString() {
-        String argString1 = argString;
-        if (!argString1.startsWith("?")) {
-            argString1 = "?"+argString1;}
-        return argString1;
-    }
-    
-    /**
-     * Converts a Properties list to a URL-encoded query string
-     */
-    private String toEncodedString(Properties args) {
-        StringBuffer buf = new StringBuffer();
-        Enumeration names = args.propertyNames();
-        while (names.hasMoreElements()) {
-            String name = (String)names.nextElement();
-            String value = args.getProperty(name);
-            buf.append(URLEncoder.encode(name) + "=" + URLEncoder.encode(value));
-            if (names.hasMoreElements()) buf.append("&");
-        }
-        return buf.toString();
-    }
-  
-  /**
-   * return the cookie that this message object contains
-   */
-  public static void setCookie(String newCookie)
-  {
-    cookie = newCookie;
-  }
-}

Property changes on: src/edu/ucsb/nceas/metacat/HttpMessage.java
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Deleted: svn:keywords
## -1 +0,0 ##
-Author Date Id Revision
\ No newline at end of property
Index: test/edu/ucsb/nceas/metacattest/MetaCatServletTest.java
===================================================================
--- test/edu/ucsb/nceas/metacattest/MetaCatServletTest.java	(revision 1821)
+++ test/edu/ucsb/nceas/metacattest/MetaCatServletTest.java	(revision 1822)
@@ -28,6 +28,7 @@
 package edu.ucsb.nceas.metacattest;
 
 import edu.ucsb.nceas.metacat.*;
+import edu.ucsb.nceas.utilities.HttpMessage;
 //import edu.ucsb.nceas.morpho.framework.*;
 import junit.framework.Test;
 import junit.framework.TestCase;
Index: test/edu/ucsb/nceas/metacattest/client/MetacatClientTest.java
===================================================================
--- test/edu/ucsb/nceas/metacattest/client/MetacatClientTest.java	(revision 1821)
+++ test/edu/ucsb/nceas/metacattest/client/MetacatClientTest.java	(revision 1822)
@@ -26,6 +26,7 @@
 package edu.ucsb.nceas.metacattest.client;
 
 import edu.ucsb.nceas.metacat.client.*;
+import edu.ucsb.nceas.utilities.HttpMessage;
 import edu.ucsb.nceas.utilities.IOUtil;
 
 import java.io.FileReader;
@@ -52,7 +53,7 @@
 public class MetacatClientTest extends TestCase
 {
     private String metacatUrl = 
-         "http://dev.nceas.ucsb.edu:8091/tao/servlet/metacat";
+         "http://dev.nceas.ucsb.edu/tao/servlet/metacat";
         //"http://knb.ecoinformatics.org/knb/servlet/metacat";
     private String wrongMetacatUrl=
                     "http://somepalce.somewhere.com/some/servlet/metacat";
@@ -95,6 +96,7 @@
         try {
             m = MetacatFactory.createMetacatConnection(metacatUrl);
         } catch (MetacatInaccessibleException mie) {
+            System.err.println("Metacat is: " + metacatUrl);
             fail("Metacat connection failed." + mie.getMessage());
         }
     }
@@ -122,7 +124,7 @@
         suite.addTest(new MetacatClientTest("query"));
         suite.addTest(new MetacatClientTest("invalidUpdate"));
         suite.addTest(new MetacatClientTest("update"));
-         suite.addTest(new MetacatClientTest("invalidDelete"));
+        suite.addTest(new MetacatClientTest("invalidDelete"));
         suite.addTest(new MetacatClientTest("delete"));
         suite.addTest(new MetacatClientTest("inaccessiblemetacat"));
         return suite;
@@ -144,7 +146,14 @@
     {
         // Try a valid login
         try {
-            m.login(username, password);
+            String response = m.login(username, password);
+            System.err.println("Login response: " + response);
+            assertTrue(response != null);
+            assertTrue(response.indexOf("<login>") != -1);
+            String sessionId = m.getSessionId();
+            System.err.println("Session ID: " + m.getSessionId());
+            //assertTrue(sessionId != null);
+            //assertTrue(response.indexOf(m.getSessionId()) != -1);
         } catch (MetacatAuthException mae) {
             fail("Authorization failed:\n" + mae.getMessage());
         } catch (MetacatInaccessibleException mie) {
@@ -180,7 +189,7 @@
             m.logout();
             String response = m.insert(identifier, 
                     new StringReader(testdocument), null);
-            System.out.println("response in logout: "+response);
+            System.err.println("Response in logout: "+response);
             assertTrue(response.indexOf("<success>") == -1);
         } catch (MetacatAuthException mae) {
             fail("Authorization failed:\n" + mae.getMessage());
Index: src/edu/ucsb/nceas/metacat/AuthSession.java
===================================================================
--- src/edu/ucsb/nceas/metacat/AuthSession.java	(revision 1821)
+++ src/edu/ucsb/nceas/metacat/AuthSession.java	(revision 1822)
@@ -73,8 +73,9 @@
           groups = new String[0];
         }
         this.session = getSession(request, username, password, groups);
+        String sessionId = session.getId();
         message = "Authentication successful for user: " + username;
-        this.statusMessage = formatOutput("login", message);
+        this.statusMessage = formatOutput("login", message, sessionId);
         return true;
       } else {  
         message = "Authentication failed for user: " + username;
@@ -145,13 +146,28 @@
    * @param tag the root element tag for the message (error or success)
    * @param message the message content of the root element
    */
-  private String formatOutput(String tag, String message) {
-    
+  private String formatOutput(String tag, String message) 
+  {
+      return formatOutput(tag, message, null);
+  }
+
+  /* 
+   * format the output in xml for processing from client applications
+   *
+   * @param tag the root element tag for the message (error or success)
+   * @param message the message content of the root element
+   * @param sessionId the session identifier for a successful login
+   */
+  private String formatOutput(String tag, String message, String sessionId) 
+  {
     StringBuffer out = new StringBuffer();
       
     out.append("<?xml version=\"1.0\"?>\n");
     out.append("<" + tag + ">");
     out.append("\n  <message>" + message + "</message>\n");
+    if (sessionId != null) {
+        out.append("\n  <sessionId>" + message + "</sessionId>\n");
+    }
     out.append("</" + tag + ">");
     
     return out.toString();
Index: src/edu/ucsb/nceas/metacat/RemoteDocument.java
===================================================================
--- src/edu/ucsb/nceas/metacat/RemoteDocument.java	(revision 1821)
+++ src/edu/ucsb/nceas/metacat/RemoteDocument.java	(revision 1822)
@@ -27,6 +27,7 @@
 
 package edu.ucsb.nceas.metacat;
 
+import edu.ucsb.nceas.utilities.HttpMessage;
 import javax.servlet.ServletOutputStream;
 import java.io.*;
 import java.net.*;
Index: src/edu/ucsb/nceas/metacat/client/MetacatClient.java
===================================================================
--- src/edu/ucsb/nceas/metacat/client/MetacatClient.java	(revision 1821)
+++ src/edu/ucsb/nceas/metacat/client/MetacatClient.java	(revision 1822)
@@ -48,6 +48,9 @@
     /** The URL string for the metacat server */
     private String metacatUrl;
 
+    /** The session identifier for the session */
+    private String sessionId;
+
     /**
      * Constructor to create a new instance. Protected because instances
      * should only be created by the factory MetacatFactory.
@@ -54,6 +57,8 @@
      */
     protected MetacatClient()
     {
+        this.metacatUrl = null;
+        this.sessionId = null;
     }
 
     /**
@@ -64,10 +69,11 @@
      *
      *  @param username   the username of the user, like an LDAP DN
      *  @param password   the password for that user for authentication
+     *  @return the response string from metacat in XML format
      *  @throws MetacatAuthException when the username/password could
      *                    not be authenticated
      */
-    public void login(String username, String password) 
+    public String login(String username, String password) 
            throws MetacatAuthException, MetacatInaccessibleException
     {
         Properties prop = new Properties();
@@ -86,17 +92,25 @@
         if (response.indexOf("<login>") == -1) {
             HttpMessage.setCookie(null);
             throw new MetacatAuthException(response);
+        } else {
+            int start = response.indexOf("<sessionId>");
+            int end = response.indexOf("</sessionId>");
+            if ((start != -1) && (end != -1)) {
+                sessionId = response.substring(start,end);
+            }
         }
+        return response;
     }
 
     /**
-     *  Method used to log out a metacat server. When Metacat server will end
-     *  the session when this call is invoken.
+     *  Method used to log out a metacat server. The Metacat server will end
+     *  the session when this call is invoked.
      *
+     *  @return the response string from metacat in XML format
      *  @throws MetacatInaccessibleException when the metacat server can not be
      *                                    reached or does not respond
      */
-    public void logout() throws MetacatInaccessibleException, MetacatException
+    public String logout() throws MetacatInaccessibleException, MetacatException
     {
         Properties prop = new Properties();
         prop.put("action", "logout");
@@ -112,9 +126,10 @@
         if (response.indexOf("<logout>") == -1) {
             throw new MetacatException(response);
         }
+        this.sessionId = null;
+        return response;
     }
     
-    
     /**
      * Read an XML document from the metacat server session, accessed by docid,
      * and returned as a Reader.
@@ -372,6 +387,18 @@
         this.metacatUrl = metacatUrl;
     }
 
+    /**
+     * Get the session identifier for this session.  This is only valid if
+     * the login methods has been called successfully for this Metacat object
+     * beforehand.
+     *
+     * @returns the sessionId as a String, or null if the session is invalid
+     */
+    public String getSessionId()
+    {
+        return this.sessionId;
+    }
+
     /************************************************************************
      * PRIVATE METHODS
      ************************************************************************/
Index: src/edu/ucsb/nceas/metacat/client/Metacat.java
===================================================================
--- src/edu/ucsb/nceas/metacat/client/Metacat.java	(revision 1821)
+++ src/edu/ucsb/nceas/metacat/client/Metacat.java	(revision 1822)
@@ -42,20 +42,23 @@
      *
      *  @param username   the username of the user, like an LDAP DN
      *  @param password   the password for that user for authentication
+     *  @return the response string from metacat in XML format
      *  @throws MetacatAuthException when the username/password could
      *                    not be authenticated
      */
-    public void login(String username, String password) 
+    public String login(String username, String password) 
            throws MetacatAuthException, MetacatInaccessibleException;
     
     /**
-     *  Method used to log out a metacat server. When Metacat server will end
-     *  the session when this call is invoken.
+     *  Method used to log out a metacat server. The Metacat server will end
+     *  the session when this call is invoked.
      *
+     *  @return the response string from metacat in XML format
      *  @throws MetacatInaccessibleException when the metacat server can not be
      *                                    reached or does not respond
      */
-    public void logout() throws MetacatInaccessibleException, MetacatException;
+    public String logout() throws MetacatInaccessibleException, 
+        MetacatException;
 
     /**
      * Read an XML document from the metacat server session, accessed by docid,
@@ -142,4 +145,11 @@
      * @param metacatUrl the URL for the metacat server
      */
     public void setMetacatUrl(String metacatUrl);
+
+    /**
+     * Get the session identifier for this session.
+     *
+     * @returns the sessionId as a String, or null if the session is invalid
+     */
+    public String getSessionId();
 }
Index: build.xml
===================================================================
--- build.xml	(revision 1821)
+++ build.xml	(revision 1822)
@@ -87,10 +87,10 @@
       <property name="mcanotherpassword" value=""/>
 
       <!-- Tomcat version, if you use tomcat 3, please fill it "tomcat3". If you using tomcat4, please fill it "tomcat4"-->
-      <property name="tomcatversion" value="tomcat4"/>
+      <property name="tomcatversion" value="tomcat3"/>
 
-      <property name="server" value="pine.nceas.ucsb.edu:8443"/>
-      <property name="systemidserver" value="http://pine.nceas.ucsb.edu:8080" />
+      <property name="server" value="dev.nceas.ucsb.edu"/>
+      <property name="systemidserver" value="http://dev.nceas.ucsb.edu" />
       <property name="datafilepath" value="/usr/local/devtools/jakarta-tomcat/data/tao/data" />
       <property name="inlinedatafilepath" value="/usr/local/devtools/jakarta-tomcat/data/tao/inlinedata" />
       <property name="debuglevel" value="55" />
@@ -108,7 +108,7 @@
       <!-- Make sure these paths match the location of the jar files
            on your system, the defaults should usually work -->
       <property name="jsdk"
-                value="${tomcat}/common/lib/servlet.jar" />
+                value="${tomcat}/lib/common/servlet.jar" />
       <property name="xmlp"
                 value="lib/xercesImpl.jar" />
       <property name="srb"
@@ -241,7 +241,7 @@
       </copy>
    </target>
 
-   <target name="compile" depends="prepare">
+   <target name="compile" depends="prepare,utilities">
        <javac srcdir="${build.src}"
               destdir="${build.dest}"
               classpath="${cpath}"
@@ -445,7 +445,7 @@
      
    </target>
    
-   <target name="testprep" depends="install">
+   <target name="testprep" depends="jar,clientjar">
       <mkdir dir="${build.tests}"/>
       <copy todir="${build.tests}" filtering="yes">
         <fileset dir="${testdir}">
@@ -452,13 +452,10 @@
           <include name="edu/**"/>
         </fileset>
       </copy>
-   </target>
-
-   <target name="test" depends="testprep">
       <!-- copy and compile the tests into a jar file -->
       <javac srcdir="${build.tests}"
              destdir="${build.tests}"
-             classpath="${cpath}:${build.dir}/${name}.jar"
+             classpath="${cpath}:${build.dir}/${name}.jar:${build.dir}/${name}-client.jar"
              debug="on"
        includes="**/*.java" />
 
@@ -465,7 +462,10 @@
       <jar jarfile="${build.dir}/${name}-junittests.jar"
         basedir="${build.tests}"
                 includes="**/*.class" />
+   </target>
 
+   <target name="test" depends="testprep">
+
       <!-- use the ant "junit" task to run JUnit tests. -->
       <junit printsummary="yes" haltonfailure="no" fork="yes"
              haltonerror="no">
@@ -485,19 +485,8 @@
    </target>
 
     <target name="runonetest" depends="testprep">
-      <!-- copy and compile the tests into a jar file -->
-      <!--<property name="testtorun" value="SubTreeTest"/> -->
       <echo>testtorun: ${testtorun}</echo>
-      <javac srcdir="${build.tests}"
-             destdir="${build.tests}"
-             classpath="${cpath}:${build.dir}/${name}.jar"
-             debug="on"
-       includes="**/*.java" />
 
-      <jar jarfile="${build.dir}/${name}-junittests.jar"
-        basedir="${build.tests}"
-                includes="**/*.class" />
-
       <!-- use the ant "junit" task to run JUnit tests. -->
       <junit printsummary="yes" haltonfailure="no" fork="yes"
              haltonerror="no">
@@ -566,6 +555,8 @@
 
    <target name="clean" depends="init">
        <delete dir="${build.dir}" />
+       <delete file="lib/httpclient.jar" />
+       <delete file="lib/utilities.jar" />
    </target>
 
    <target name="jdoc" depends="prepare">
