Index: trunk/java-client/org/nzdl/gsdl/SimpleClient.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/SimpleClient.java	(revision 2069)
+++ trunk/java-client/org/nzdl/gsdl/SimpleClient.java	(revision 2070)
@@ -26,4 +26,5 @@
 
 // java libraries we're using
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
@@ -31,7 +32,8 @@
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.io.LineNumberReader;
 import java.io.Serializable;
-import java.util.Vector;
+import java.net.URL;
 import java.util.Enumeration;
 import java.util.Iterator;
@@ -41,4 +43,5 @@
 import java.util.Properties;
 import java.util.Set;
+import java.util.Vector;
 
 // local libraries
@@ -56,20 +59,21 @@
  * A class to test the workings of Corba interface from the client side.
  *
+ * @author stuart yeates (say1@cs.waikato.ac.nz)
+ * @author Brett Sheeran (bsheeran@xtra.co.nz)
  * @author Dave Nichols (daven@cs.waikato.ac.nz)
  * @author Gordon Paynter (paynter@cs.waikato.ac.nz)
- * @author stuart yeates (say1@cs.waikato.ac.nz)
  * @version $Revision$
- * @see org.nzdl.service.NzdlCollectionInfo;
- * @see org.nzdl.service.NzdlQuery;
- * @see org.nzdl.service.NzdlRequest;
- * @see org.nzdl.service.NzdlResponse;
- * @see org.nzdl.service.NzdlResultSet;
- * @see org.nzdl.service.NzdlService;
- * @see org.nzdl.service.NzdlServiceImpl;
+ * @see org.nzdl.service.NzdlCollectionInfo
+ * @see org.nzdl.service.NzdlQuery
+ * @see org.nzdl.service.NzdlRequest
+ * @see org.nzdl.service.NzdlResponse
+ * @see org.nzdl.service.NzdlResultSet
+ * @see org.nzdl.service.NzdlService
+ * @see org.nzdl.service.NzdlServiceImpl
  * @see gnu.getopt.Getopt;
  * @see gnu.getopt.LongOpt;
  */
 
-public class SimpleClient implements Cloneable, Serializable{
+public class SimpleClient implements Cloneable, Serializable {
 
   /** The collection of CORBA IORs we know about */
@@ -129,5 +133,5 @@
     
     if (nzdl == null) {
-      String IOR = getIorKey();
+      String IOR = getIorKey(IORFileName);
       System.err.println("ior = " + IOR);
       System.err.println("after IOR");
@@ -151,12 +155,36 @@
   }
 
-  private String getIorKey() {
+  /** 
+   * Pre:  Accept SourceOfID as either: URL or IOR string or Filename
+   * Post: extract localcorba.objid from source of ID
+   */
+  private String getIorKey(String sourceOfID) {
     String ior = null;
     try  {
-      LineNumberReader input
-	= new LineNumberReader(new FileReader(IORFileName));
-      ior = input.readLine();
-    } 
-    catch (java.io.IOException e) { 
+      sourceOfID = sourceOfID.trim();
+      System.err.println("Reading IOR from: " + sourceOfID);
+
+      String firstChars = sourceOfID.substring(0, Math.min(4,sourceOfID.length())).toUpperCase();
+	// if sourceOfID is a URL ---------------------------------------
+	if (sourceOfID.length() > 4 && firstChars.equalsIgnoreCase("HTTP"))	{
+	  URL myUrl = new URL(sourceOfID);
+	  BufferedReader input =new
+	    BufferedReader(new InputStreamReader(myUrl.openStream()));
+	  ior = input.readLine();
+	}
+	    
+	// if sourceOfID is an IOR --------------------------------------
+	else if (sourceOfID.length() > 4 && firstChars.equalsIgnoreCase("IOR:"))	{
+	  ior = sourceOfID;      		  	
+	}
+
+	// else assume sourceOfID is a file name ------------------------
+	else {
+	  BufferedReader input
+	    = new BufferedReader(new FileReader(sourceOfID));
+	  ior = input.readLine();      		  	
+	}
+    }  //end of try
+    catch (java.io.IOException e) {
       System.err.println("Error reading IOR key:\n" + e);
       System.err.println("Aborting service...");
@@ -164,5 +192,7 @@
     }
     return ior;
-  }
+  }   // end of getIorKey
+
+
 
   private boolean attemptToInitialise(String [] _args, 
@@ -281,24 +311,24 @@
       Map metaData = nzdl.getMetaData( collName, docIDs, metaTag );
       
-	for (ListIterator i = docIDs.listIterator(); i.hasNext(); ) {
-	  String id = (String) i.next();
-	  Set meta = (Set) metaData.get( id );
-	  if (loadDocs) { 
-	    if (verbosity > 3) {
-	      System.out.println(meta.toString()); 
-	      System.out.println("getting document contents ... ");
-	    }
-	    String documentContents = nzdl.getDocument(collName, id);
-	    if (verbosity > 3) {
-	      System.out.println("got document contents. ");
-	      System.out.println(" *************** START DOC " + id + " ***************"); 
-	      System.out.println(documentContents);
-	      System.out.println(" *************** END DOC " + id + " ***************"); 
-	    }
-	  } else {
-	    if (verbosity > 3) 
-	      System.out.println(meta.toString()); 
+      for (ListIterator i = docIDs.listIterator(); i.hasNext(); ) {
+	String id = (String) i.next();
+	Set meta = (Set) metaData.get( id );
+	if (loadDocs) { 
+	  if (verbosity > 3) {
+	    System.out.println(meta.toString()); 
+	    System.out.println("getting document contents ... ");
 	  }
-	}
+	  String documentContents = nzdl.getDocument(collName, id);
+	  if (verbosity > 3) {
+	    System.out.println("got document contents. ");
+	    System.out.println(" *************** START DOC " + id + " ***************"); 
+	    System.out.println(documentContents);
+	    System.out.println(" *************** END DOC " + id + " ***************"); 
+	  }
+	} else {
+	  if (verbosity > 3) 
+	    System.out.println(meta.toString()); 
+	}
+      }
     }
   }
