Index: trunk/java-client/org/nzdl/gsdl/SearchAllCollections.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/SearchAllCollections.java	(revision 2116)
+++ trunk/java-client/org/nzdl/gsdl/SearchAllCollections.java	(revision 2119)
@@ -71,6 +71,6 @@
  * @see org.nzdl.gsdl.service.NzdlService
  * @see org.nzdl.gsdl.service.NzdlServiceClient
- * @see gnu.getopt.Getopt;
- * @see gnu.getopt.LongOpt;
+ * @see gnu.getopt.Getopt
+ * @see gnu.getopt.LongOpt
  */
 
Index: trunk/java-client/org/nzdl/gsdl/SimpleClient.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/SimpleClient.java	(revision 2116)
+++ trunk/java-client/org/nzdl/gsdl/SimpleClient.java	(revision 2119)
@@ -64,4 +64,5 @@
  * @author Gordon Paynter (paynter@cs.waikato.ac.nz)
  * @version $Revision$
+ * @see org.nzdl.gsdl.SimpleServer
  * @see org.nzdl.gsdl.service.NzdlCollectionInfo
  * @see org.nzdl.gsdl.service.NzdlQuery
@@ -70,7 +71,9 @@
  * @see org.nzdl.gsdl.service.NzdlResultSet
  * @see org.nzdl.gsdl.service.NzdlService
- * @see org.nzdl.gsdl.service.NzdlServiceImpl
- * @see gnu.getopt.Getopt;
- * @see gnu.getopt.LongOpt;
+ * @see org.nzdl.gsdl.service.NzdlServiceClient
+ * @see gnu.getopt.Getopt
+ * @see gnu.getopt.LongOpt
+ * @see <a href="http://www.nzdl.org/">The New Zealand Digital Library Project</a>
+ * @see <a href="http://www.nzdl.org/fast-cgi-bin/library?&a=p&p=gsdl">Greenstone Digital Library Software</a>
  */
 
@@ -102,8 +105,16 @@
   int verbosity = 2;
 
-  SimpleClient() {
+  /** 
+   * Basic no-args constructor. Not recommended for normal use, 
+   * but necessary if we want to create beans ... 
+   */ 
+  protected SimpleClient() {
     init(null);
   }
-
+  
+  /** 
+   * Normal constructor. the args are passed into the orb 
+   * initialisation code so they can extract obscure args ...
+   */ 
   SimpleClient(String [] args) {
     parseArgs(args);
@@ -111,5 +122,8 @@
   }
 
-  void init(String [] args)  {
+  /**
+   *
+   */
+  protected void init(String [] args)  {
 
     // read our prevously seed IORs ...
Index: trunk/java-client/org/nzdl/gsdl/SimpleServer.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/SimpleServer.java	(revision 2116)
+++ trunk/java-client/org/nzdl/gsdl/SimpleServer.java	(revision 2119)
@@ -22,14 +22,8 @@
 
 // java standard library classes used
-import java.io.IOException;
 import java.io.Serializable;
-import java.lang.Cloneable;
-import java.util.*;
+//import java.util.*;
 
-// HelloServer will use the naming service.
 import org.omg.CosNaming.*;
-// The package containing special exceptions thrown by the name service.
-//import org.omg.CosNaming.NamingContextPackage.*;
-// All CORBA applications need these classes.
 import org.omg.CORBA.ORB;
 
@@ -48,25 +42,22 @@
 
 /**
- * SimpleServer
- *
- * Based on algorithms in ...
+ * SimpleServer A very basic Greenstoen server (not yet complete). 
  *
  * @author stuart yeates (say1@cs.waikato.ac.nz)
  * @version $Revision$
- * @see
- * @see
- * @see
- * 
+ * @see org.nzdl.gsdl.SimpleClient
+ * @see org.nzdl.gsdl.service.NzdlServiceServer
+ * @see org.omg.CORBA.ORB
+ * @see <a href="http://www.nzdl.org/">The New Zealand Digital Library Project</a>
+ * @see <a href="http://www.nzdl.org/fast-cgi-bin/library?&a=p&p=gsdl">Greenstone Digital Library Software</a>
  */
 
 
-public class SimpleServer
+public class SimpleServer implements Serializable, Cloneable
 {
   /**
-   * Tests...
+   * Starts up a trivial server.
    *
-   *
-   * @exception java.io.IOException when ...
-   * @param args the arguments ...
+   * @param args the arguments passed through to the orb initialisation code...
    */
   public static void main(String args[])
@@ -101,10 +92,2 @@
   }
 }
-
-  /**
-   * Tests...
-   *
-   *
-   * @exception java.io.IOException when ...
-   * @param args the arguments ...
-   */
Index: trunk/java-client/org/nzdl/gsdl/ptp/Makefile
===================================================================
--- trunk/java-client/org/nzdl/gsdl/ptp/Makefile	(revision 2116)
+++ trunk/java-client/org/nzdl/gsdl/ptp/Makefile	(revision 2119)
@@ -18,4 +18,5 @@
   Poller.class \
   Connection.class \
+  Listener.class \
   Node.class 
 
Index: trunk/java-client/org/nzdl/gsdl/ptp/Node.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/ptp/Node.java	(revision 2116)
+++ trunk/java-client/org/nzdl/gsdl/ptp/Node.java	(revision 2119)
@@ -36,13 +36,18 @@
 
 /**
- * Class ...
+ * Class representing a Node in a Peer-To-Peer (PTP) network. 
  *
- * Based on algorithms in ...
+ * Does very little actual work, but maintains a number of important 
+ * statics and contains the command-line parsing and initialisation 
+ * code (or it will).
+ *
+ * Unlike PTP networks as Napster and Gnutella queries are not 
+ * propogated, only knowledge about servers. 
  *
  * @author stuart yeates (say1@cs.waikato.ac.nz)
  * @version $Revision$
- * @see
- * @see
- * @see
+ * @see Poller
+ * @see <a href="http://www.napster.com/">Napster</a> 
+ * @see <a href="http://gnutella.wego.com/">Gnutella</a> 
  * 
  */
@@ -50,19 +55,26 @@
 public class Node {
 
+  /** A list of Locators which we know. */
   static Properties knownList = new Properties();
   
+  /** Our IOR string*/
   static String identityIOR = "IOR:123456789012345678901234567890123456789012345678901234567890";
   
+  /** Our HTTP string */
   static String identityHTTP = "http://www.nzdl.org";
 
+  /** The port we listen on */
   static int identityPort = 4567;
+  /** Our host name */
   static String identityHost = null; //= InetAddress.getLocalHost().getHostName();
-  static String identityP2P = identityHost + ":" + identityPort;
+  /** Our PTP object ...*/
+  static String identityPTP = identityHost + ":" + identityPort;
 
+  /** Initialise the static variables  */
   void init(){
     if (identityHost == null) {
       try {
 	identityHost = InetAddress.getLocalHost().getHostName();
-	identityP2P = identityHost + ":" + identityPort;
+	identityPTP = identityHost + ":" + identityPort;
       } catch (Exception exception) {
 	System.err.println("caught exception: "+exception);
@@ -72,22 +84,20 @@
   }
   
-  
-  Node() {
+  /**
+   * Construct and rung a Node ...
+   */
+  public Node() {
     
     init();
 
-
     // start the server ...
-    
+    Listener listener = new Listener();
+    listener.run();
     
     // start the poller ...
     Poller poller = new Poller();
-    poller.run();
+    poller.run();    
   
   }
-
-  
-
-
 
 
@@ -102,6 +112,7 @@
   public static void main(String args[]) throws IOException
   {
-
+    Node node = new Node();
   }
 }
 
+
Index: trunk/java-client/org/nzdl/gsdl/ptp/PTP.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/ptp/PTP.java	(revision 2116)
+++ trunk/java-client/org/nzdl/gsdl/ptp/PTP.java	(revision 2119)
@@ -35,40 +35,38 @@
 
 /**
- * Class ...
+ * Class PTP represents a URL-like connection information to a remote Peer
  *
- * Based on algorithms in ...
+ * PTP's and connections initiated based on them form the backbone 
+ * of the Peer-To-Peer network.
  *
  * @author stuart yeates (say1@cs.waikato.ac.nz)
  * @version $Revision$
- * @see
- * @see
- * @see
+ * @see org.nzdl.gsdl.ptp.Connection
+ * @see Locator
+ * @see HTTP
+ * @see IOR
  * 
  */
 
-public class PTP extends Locator{
+public class PTP extends Locator {
+  /** The remote port at which the peer is listening */
   int port;
+  /** The host on which the peer is resident */
   String host;
   
+  /** The basic constructor */
   PTP(String host, int port) {
     this.host = host;
     this.port = port;
   }
+  /** the no-arguments constructor */
+  protected PTP() {
+    this.host = "";
+    this.port = 0;
+  }
+
+  /** convert the PTP to a string suitable for parsing later on ...*/
   public String toString() {
     return "PTP:" + host + ":" + port;
-  }
-
-
-  /**
-   * Tests...
-   *
-   *
-   * @exception java.io.IOException when ...
-   * @param args the arguments ...
-   */
-
-  public static void main(String args[]) throws IOException
-  {
-
   }
 
Index: trunk/java-client/org/nzdl/gsdl/ptp/Poller.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/ptp/Poller.java	(revision 2116)
+++ trunk/java-client/org/nzdl/gsdl/ptp/Poller.java	(revision 2119)
@@ -35,23 +35,36 @@
 
 /**
- * Class ...
+ * Class Poller polls a group of peers periodically. 
  *
- * Based on algorithms in ...
+ * Poller exists in it's  own Thread so it is asynchronous with 
+ * the rest of the program. The Connections to peers are also in
+ * seperate Threads, but only one run at once.
+ *
+ * The static Node.knownList is consulted about which peers to 
+ * poll.
  *
  * @author stuart yeates (say1@cs.waikato.ac.nz)
  * @version $Revision$
- * @see
- * @see
- * @see
- * 
+ * @see org.nzdl.gsdl.ptp.PTP
+ * @see org.nzdl.gsdl.ptp.Connection
+ * @see org.nzdl.gsdl.ptp.Node
+ * @see org.nzdl.gsdl.ptp.Node#knownList
+ * @see java.lang.Thread
  */
 
 public class Poller extends Thread {
+  /** How often should we poll our peers? */
   int secondsBetweenPollCycles = 60; 
   
+  /** The no-args constructor */
   public Poller() {
 
   }
 
+  /** 
+   * Start the poller. 
+   * 
+   * Only returns if interrupted or an Error is thrown.
+   */
   public void run() {
     while (true) {
@@ -66,5 +79,11 @@
   }
 
-  void poll() {
+  /** 
+   * Poll each peer once, waiting for the Connections to terminate
+   * between each. 
+   * 
+   * Returns when all peer has been polled.
+   */
+ void poll() {
     Enumeration e = Node.knownList.propertyNames();
     while (e.hasMoreElements()) {
@@ -88,16 +107,4 @@
   }
   
-  /**
-   * Tests...
-   *
-   * 
-   * @exception java.io.IOException when ...
-   * @param args the arguments ...
-   */
-
-  public static void main(String args[]) throws IOException
-  {
-
-  }
 
 }
Index: trunk/java-client/org/nzdl/gsdl/service/NzdlServiceClient.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/service/NzdlServiceClient.java	(revision 2116)
+++ trunk/java-client/org/nzdl/gsdl/service/NzdlServiceClient.java	(revision 2119)
@@ -17,4 +17,5 @@
 
   public NzdlServiceClient( String [] _args, Properties _props, String _IOR) {
+    corbaComErrorHolder error = new corbaComErrorHolder();
     try {
       System.err.println("before ORB.init");
@@ -29,6 +30,7 @@
       m_nzdlServer = corbaifaceHelper.narrow(obj);
       System.err.println("after .narrow");
+      
       // basic setup
-      if (m_nzdlServer.initialise()) {
+      if (m_nzdlServer.initialise(error)) {
 	System.err.println("Nzdl init ... YES");
       }
@@ -44,4 +46,7 @@
       System.exit(1);
     }
+    if (error.value.value() != corbaComError._corbaNoError) {
+      System.err.println("CORBA error:" + error.value.value());
+    }
     
     System.err.println("Service init ... YES");
@@ -49,14 +54,23 @@
   
   public void configure( String _key, Set _values ) {
+    corbaComErrorHolder error = new corbaComErrorHolder();
     m_nzdlServer.configure( NzdlCorbaFactory.toCorbaText( _key ),
-			    NzdlCorbaFactory.toCorbaTextArray( _values ));
+			    NzdlCorbaFactory.toCorbaTextArray( _values ),
+			    error);
+    if (error.value.value() != corbaComError._corbaNoError) {
+      System.err.println("CORBA error:" + error.value.value());
+    }
   }
   
   public Set getCollectionSet( ) {
+    corbaComErrorHolder error = new corbaComErrorHolder();
     corbatext_tarrayHolder c_collSet = NzdlCorbaFactory.createCorbaTextArrayHolder();
-    m_nzdlServer.collectionList(c_collSet);
+    m_nzdlServer.collectionList(c_collSet, error);
     Set collSet = new HashSet();
     for (int i=0; i<c_collSet.value.length; i++) {
       collSet.add( NzdlCorbaFactory.toString( c_collSet.value[i] ) );
+    }
+    if (error.value.value() != corbaComError._corbaNoError) {
+      System.err.println("CORBA error:" + error.value.value());
     }
     return collSet ;
Index: trunk/java-client/org/nzdl/gsdl/service/NzdlServiceServer.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/service/NzdlServiceServer.java	(revision 2116)
+++ trunk/java-client/org/nzdl/gsdl/service/NzdlServiceServer.java	(revision 2119)
@@ -69,20 +69,24 @@
   }
 
-  public boolean initialise () {
+  public boolean initialise (corbaComErrorHolder error) {
     // TODO should map the anything in NzdlService?
     if (nzdl == null)
       throw new Error ("NzdlServer needs a NzdlService to foward calls to ...");
+    error.value = corbaComError.from_int(corbaComError._corbaNoError);
     return true;
   }
   public void configure (corbatext_t key, 
-		  corbatext_t[] cfgline) {
-//      m_nzdlServer.configure( NzdlCorbaFactory.toCorbaText( _key ),
-//  			    NzdlCorbaFactory.toCorbaTextArray( _values ));
+			 corbatext_t[] cfgline,
+			 corbaComErrorHolder error) {
+    //      m_nzdlServer.configure( NzdlCorbaFactory.toCorbaText( _key ),
+    //  			    NzdlCorbaFactory.toCorbaTextArray( _values ));
 
     nzdl.configure( NzdlCorbaFactory.toString(key),
 		    NzdlCorbaFactory.toSet(cfgline));
-  }
-
-  public void collectionList (corbatext_tarrayHolder collist) {
+    error.value = corbaComError.from_int(corbaComError._corbaNoError);
+  }
+
+  public void collectionList (corbatext_tarrayHolder collist,
+			      corbaComErrorHolder error) {
     //corbatext_tarrayHolder c_collSet = NzdlCorbaFactory.createCorbaTextArrayHolder();
     //m_nzdlServer.collectionList(c_collSet);
@@ -98,62 +102,66 @@
     while (itr.hasNext()) {
       String s = (String) itr.next();
-       collist.value[i++] = NzdlCorbaFactory.toCorbaText(s);
+      collist.value[i++] = NzdlCorbaFactory.toCorbaText(s);
     }
+    error.value = corbaComError.from_int(corbaComError._corbaNoError);
 
     return;
   }
   public void hasCollection (corbatext_t corbaCollection,
-		      org.omg.CORBA.BooleanHolder has, 
-		      corbaComErrorHolder error) {
-//      corbaComErrorHolder c_err = NzdlCorbaFactory.createComErrorHolder();
-//      org.omg.CORBA.BooleanHolder c_has = new org.omg.CORBA.BooleanHolder();
-//      m_nzdlServer.hasCollection( NzdlCorbaFactory.toCorbaText(_name), c_has, c_err );
-//      if (c_err.value.value() != 0)
-//        System.err.println("hasCollection error " + c_err.value.value());
-//      return c_has.value;
+			     org.omg.CORBA.BooleanHolder has, 
+			     corbaComErrorHolder error) {
+    //      corbaComErrorHolder c_err = NzdlCorbaFactory.createComErrorHolder();
+    //      org.omg.CORBA.BooleanHolder c_has = new org.omg.CORBA.BooleanHolder();
+    //      m_nzdlServer.hasCollection( NzdlCorbaFactory.toCorbaText(_name), c_has, c_err );
+    //      if (c_err.value.value() != 0)
+    //        System.err.println("hasCollection error " + c_err.value.value());
+    //      return c_has.value;
     String name = NzdlCorbaFactory.toString(corbaCollection);
     has.value  = nzdl.hasCollection(name);
+    error.value = corbaComError.from_int(corbaComError._corbaNoError);
     return;
   }
   public boolean ping (corbatext_t collection, 
-		corbaComErrorHolder error) {
+		       corbaComErrorHolder error) {
     String name = NzdlCorbaFactory.toString(collection);
     return  nzdl.hasCollection(name);
   }
   public void getDocument (corbatext_t collection, 
-		    corbaDocRequestHolder request, 
-		    corbaDocResponseHolder response, 
-		    corbaComErrorHolder error) {
-//      corbatext_t c_name = NzdlCorbaFactory.toCorbaText( _name );
-//      corbaDocRequestHolder c_request = NzdlCorbaFactory.createDocRequestHolder( _docID );
-//      corbaDocResponseHolder c_response = NzdlCorbaFactory.createDocResponseHolder( );
-//      corbaComErrorHolder c_err = NzdlCorbaFactory.createComErrorHolder();
-//      m_nzdlServer.getDocument( c_name, c_request, c_response, c_err );
-//      if (c_err.value.value() != 0)
-//        System.err.println("getDocument() error " + c_err.value.value());
-//      return NzdlCorbaFactory.toString( c_response.value.doc );
+			   corbaDocRequestHolder request, 
+			   corbaDocResponseHolder response, 
+			   corbaComErrorHolder error) {
+    //      corbatext_t c_name = NzdlCorbaFactory.toCorbaText( _name );
+    //      corbaDocRequestHolder c_request = NzdlCorbaFactory.createDocRequestHolder( _docID );
+    //      corbaDocResponseHolder c_response = NzdlCorbaFactory.createDocResponseHolder( );
+    //      corbaComErrorHolder c_err = NzdlCorbaFactory.createComErrorHolder();
+    //      m_nzdlServer.getDocument( c_name, c_request, c_response, c_err );
+    //      if (c_err.value.value() != 0)
+    //        System.err.println("getDocument() error " + c_err.value.value());
+    //      return NzdlCorbaFactory.toString( c_response.value.doc );
     String collectionName = NzdlCorbaFactory.toString(collection);
     String documentID = NzdlCorbaFactory.toString(request.value.OID);
     String doc = nzdl.getDocument( collectionName, documentID );
     response.value.doc = NzdlCorbaFactory.toCorbaText(doc);
+    error.value = corbaComError.from_int(corbaComError._corbaNoError);
     return;
   }
   public void getCollectInfo (corbatext_t collection, 
-		       corbaColInfoResponseHolder response, 
-		       corbaComErrorHolder error) {
-//      corbaComErrorHolder c_err = NzdlCorbaFactory.createComErrorHolder();
-//      corbaColInfoResponseHolder c_info = NzdlCorbaFactory.createColInfoResponseHolder();
-//      m_nzdlServer.getCollectInfo( NzdlCorbaFactory.toCorbaText(_name), c_info, c_err );
-//      if (c_err.value.value() != 0)
-//        System.err.println("getCollectionInfo() error " + c_err.value.value());
-//      return new NzdlCollectionInfo( c_info.value );
+			      corbaColInfoResponseHolder response, 
+			      corbaComErrorHolder error) {
+    //      corbaComErrorHolder c_err = NzdlCorbaFactory.createComErrorHolder();
+    //      corbaColInfoResponseHolder c_info = NzdlCorbaFactory.createColInfoResponseHolder();
+    //      m_nzdlServer.getCollectInfo( NzdlCorbaFactory.toCorbaText(_name), c_info, c_err );
+    //      if (c_err.value.value() != 0)
+    //        System.err.println("getCollectionInfo() error " + c_err.value.value());
+    //      return new NzdlCollectionInfo( c_info.value );
     String collectionName = NzdlCorbaFactory.toString(collection);
     NzdlCollectionInfo info = nzdl.getCollectionInfo( collectionName );
     response.value = info.getInfo();
+    error.value = corbaComError.from_int(corbaComError._corbaNoError);
     return;
   }
   public void getFilterInfo (corbatext_t collection, 
-		      corbatext_tarrayHolder filterNames, 
-		      corbaComErrorHolder error) {
+			     corbatext_tarrayHolder filterNames, 
+			     corbaComErrorHolder error) {
     String collectionName = NzdlCorbaFactory.toString(collection);
  
@@ -164,24 +172,27 @@
     while (itr.hasNext()) {
       String s = (String) itr.next();
-       filterNames.value[i++] = NzdlCorbaFactory.toCorbaText(s);
+      filterNames.value[i++] = NzdlCorbaFactory.toCorbaText(s);
     }
 
+    error.value = corbaComError.from_int(corbaComError._corbaNoError);
     return;
   }
   public void getFilterOptions (corbatext_t collection, 
-			 corbatext_t option, 
-			 corbaFilterOptionsResponseHolder response, 
-			 corbaComErrorHolder error) {
-    String collectionName = NzdlCorbaFactory.toString(collection);
-        System.err.println("TO BE IMPLEMENTED: DON'T KNOW HOW YET !!!");
-
-    return;
-      }
+				corbatext_t option, 
+				corbaFilterOptionsResponseHolder response, 
+				corbaComErrorHolder error) {
+    String collectionName = NzdlCorbaFactory.toString(collection);
+    System.err.println("TO BE IMPLEMENTED: DON'T KNOW HOW YET !!!");
+
+    error.value = corbaComError.from_int(corbaComError._corbaProtocolError);
+    return;
+  }
   public  void filter (corbatext_t collection, 
-	       corbaFilterRequest request, 
-	       corbaFilterResponseHolder response, 
-	       corbaComErrorHolder error) {
+		       corbaFilterRequest request, 
+		       corbaFilterResponseHolder response, 
+		       corbaComErrorHolder error) {
     String collectionName = NzdlCorbaFactory.toString(collection);
     System.err.println("TO BE IMPLEMENTED: DON'T KNOW HOW YET !!!");
+    error.value = corbaComError.from_int(corbaComError. _corbaProtocolError);
     return;
   }
