Index: trunk/java-client/org/nzdl/gsdl/service/NzdlMultiWayWrapper.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/service/NzdlMultiWayWrapper.java	(revision 2182)
+++ trunk/java-client/org/nzdl/gsdl/service/NzdlMultiWayWrapper.java	(revision 2182)
@@ -0,0 +1,250 @@
+/*
+ *    NzdlMultiWayWrapper.java
+ *    Copyright (C) 2001 New Zealand Digital Library Project
+ *
+ *    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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+//the package we're in
+package org.nzdl.gsdl.service;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.Properties;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.io.Writer;
+import java.io.FileWriter;
+import org.nzdl.gsdl.util.NzdlServiceFactory;
+
+
+/**
+ *  A NzdlMultiWayWrapper multiple NzdlServices 
+ *
+ * @author Brett Sheeran (bsheeran@xtra.co.nz) (comments)
+ * @author Stuart Yeates  (say1@cs.waikato.ac.nz)
+ * @version $Revision$
+ */
+public class NzdlMultiWayWrapper
+  extends NzdlWrapper {
+
+  Hashtable services;
+   
+  /** 
+   * The bean constructor ...
+   */
+  public NzdlMultiWayWrapper() {
+    super(null);
+    services = new Hashtable();
+  }
+  /** 
+   * The normal constructor
+   */
+  public NzdlMultiWayWrapper(String [] _args,
+			     Properties _props,
+			     String _URL,
+			     String _filename,
+			     String _IOR) {
+    super(null);
+    services = new Hashtable();
+    
+    Hashtable servers = NzdlServiceFactory.findIORs(_args,_props,_URL,_filename,_IOR);
+    
+    Enumeration e = servers.keys() ;
+    for (int i = 0; e.hasMoreElements(); i++) {
+      String key = (String)  e.nextElement();
+      NzdlService server = (NzdlService) servers.get(key);
+      if (NzdlServiceFactory.logMultiple)
+	server = new NzdlLogWrapper(server, 
+				    "log.file.after.split." + key + "cache", 
+				    "AFTER:" + key + ": ");
+      services.put("" +i, server);
+    }
+  }
+
+  String findServer(String _name) {
+    int separator = _name.indexOf(':');   
+    String result = _name.substring(0,separator);
+    return result;
+  }
+  String findCollection(String _name) {
+    String result = "";
+    try {
+      int separator = _name.indexOf(':');   
+      result = _name.substring(separator+1,_name.length());
+    } catch (Throwable t) {
+      System.err.println("Throwable: "+ t);
+    }
+    return result;
+  }
+   
+  /**
+   * Allow the client to configure a CORBA server.
+   * @param key the parameter to be set.
+   * @param values what that parameter will be set to.
+   */
+  public void configure( String _key, Set _values ) {
+    Enumeration e = services.keys();
+    for (int i = 0; e.hasMoreElements(); i++) {
+      NzdlService server = (NzdlService) e.nextElement();
+      server.configure(_key,_values);
+    }
+  }
+
+  /**
+   * Obtain the set of collection names for a Greenstone library.
+   * @return A set of collection names in string format.
+   */
+  public Set getCollectionSet( ) {
+    Set results = new HashSet();
+
+    Enumeration e = services.keys();
+    for (int i = 0; e.hasMoreElements(); i++) {
+      String name = (String) e.nextElement();
+      NzdlService server = (NzdlService) services.get(name);
+      Set set = server.getCollectionSet();
+      Iterator s = set.iterator();
+      while (s.hasNext()) {
+	String coll = (String) s.next();
+	results.add("" + i + ":" + coll); 
+      }
+    }
+    return results;
+  }
+
+  /**
+   * Check if ORB knows of this collection.
+   * @param name the name of a collecion to be searched for.
+   * @return boolean <TT>true</TT> if collection is found, else <TT>false</TT>.
+   */
+  public boolean hasCollection( String _name ) {
+
+    NzdlService server = (NzdlService) services.get( findServer(_name));
+    return  server.hasCollection(findCollection(_name));
+   }
+
+  /**
+   * Check if ORB can communicate with of this collection.
+   * @param name the name of a collecion to be pinged.
+   * @return boolean <TT>true</TT> if collection returned ping, else
+   * <TT>false</TT>.
+   */
+  public boolean pingCollection( String _name ) {
+    NzdlService server = (NzdlService) services.get( findServer(_name));
+    return server.pingCollection(findCollection(_name));
+  }
+
+  /**
+   * Extract information on this collection into a
+   * {@link NzdlCollectionInfo NzdlCollectionInfo} object
+   * @param name the collection to be retrieved.
+   * @return an instance of
+   * {@link NzdlCollectionInfo NzdlCollectionInfo} containing data on a
+   * collection
+   */
+  public NzdlCollectionInfo getCollectionInfo( String _name ) {
+    NzdlService server = (NzdlService) services.get( findServer(_name));
+    NzdlCollectionInfo result = server.getCollectionInfo(findCollection(_name));
+    return result;
+  }
+
+  /**
+   * Returns the set of filters for the service object.
+   * @param name the collection name
+   * @return a set of strings that name the filters, for example
+   * BrowseFilter, QueryFilter and NullFilter.
+   */
+  public Set getFilterSet( String _name ) {
+    NzdlService server = (NzdlService) services.get( findServer(_name));
+    Set result = server.getFilterSet(findCollection(_name));
+    return result;
+  }
+
+  /**
+   * @param name the collection name
+   * @return the Set of (name, value) value pairs for all metadata 
+   * associated with a collection  
+   */
+  public Set getMetaTagSet( String _name ) {
+    NzdlService server = (NzdlService) services.get( findServer(_name));
+    Set result = server.getMetaTagSet(findCollection(_name));
+    return result;
+  }
+
+  /**
+   * Returns the Greenstone Markup Language (GML) text for a particular
+   * document from a collection.
+   * @param name the name of the collection.
+   * @param docID the document identity string
+   * @return the GML document in the form of a string.
+   */
+  public String getDocument( String _name, String _docID ) {
+    NzdlService server = (NzdlService) services.get( findServer(_name));
+    String result = server.getDocument(findCollection(_name), _docID);
+    return result;
+  }
+
+  /**
+   * Returns the set of value(s) for a metatag from a particular document.
+   * @param name collection name
+   * @param docID the document identifier.
+   * @param metaTag the metatag name such as: Title, Author, Date and Images.
+   * @return The set of value(s) for the requested metatag and document. In
+   * cases such as Title, Author, Date there will probably be only one value
+   * per document.
+   */
+  public Set getMetaData( String _name, String _docID, String _metaTag ) {
+    NzdlService server = (NzdlService) services.get( findServer(_name));
+    Set result = server.getMetaData( findCollection(_name), _docID, _metaTag );
+    return result;
+  }
+
+  /**
+   * Returns a map of value(s) for a metatag from a list of documents.
+   * @param name collection name
+   * @param docIDs a list of document identifier strings.
+   * @param metaTag the metatag name such as: Title, Author, Date and Images.
+   * @return The map of value(s) for the requested metatag and document. In
+   * cases such as Title, Author, Date there will probably be only one value
+   * per document.
+   */
+  public Map getMetaData( String _name, List _docIDs, String _metaTag ) {
+    NzdlService server = (NzdlService) services.get( findServer(_name));
+    Map result = server.getMetaData( findCollection(_name), _docIDs, _metaTag );
+    return result;
+  }
+
+  /**
+   * Services a {@link NzdlRequest NzdlRequest} to a collection and places
+   * the results into a {@link NzdlResponse NzdlResponse} object. <br>
+   * Pre:   Created instances of NzdlRequest and NzdlResponse. <br>
+   * Post: Placed the result data into NzdlResponse object.
+   * @param name the collection name.
+   * @param request an instance of NzdlRequest with query data to be serviced
+   * @param response an instance of NzdlResponse. where the results of
+   * sevciving the query will be placed
+   */
+  public void service( String _name, NzdlRequest _request, 
+		       NzdlResponse _response ) {    
+    NzdlService server = (NzdlService) services.get( findServer(_name));
+    server.service(findCollection(_name),_request,_response);
+  }
+  
+}
