Index: greenstone3/branches/customizingGreenstone3/src/java/org/greenstone/gsdl3/core/MessageRouter.java
===================================================================
--- greenstone3/branches/customizingGreenstone3/src/java/org/greenstone/gsdl3/core/MessageRouter.java	(revision 14684)
+++ greenstone3/branches/customizingGreenstone3/src/java/org/greenstone/gsdl3/core/MessageRouter.java	(revision 15191)
@@ -61,7 +61,7 @@
  * @see Communicator
  *
-  * Since some service classes are moved into a separate directory in order for them to be checked out from a different repository,
+ * Since some service classes are moved into a separate directory in order for them to be checked out from a different repository,
  * we modify the configureServices method to search some of the classes in other place if they are not found in the service directory.
-*/
+ */
 public class MessageRouter implements  ModuleInterface {
   
@@ -75,4 +75,5 @@
   protected String site_http_address=null;
   
+  
   protected String library_name = null;
 
@@ -91,5 +92,8 @@
   /** list of collections that can be reached */
   protected Element collection_list = null;
-  
+  /** list of collections that are loaded but are private */
+  protected Element private_collection_list = null;
+    
+       
   /** list of collections that are public and OAI-supportive */
   protected Element oai_collection_list = null;
@@ -117,10 +121,5 @@
   
   public void cleanUp() {
-    if (this.module_map != null) {
-      Iterator i = this.module_map.values().iterator();
-      while (i.hasNext()) {
-        ((ModuleInterface)i.next()).cleanUp();
-      }
-    }
+    cleanUpModuleMapEntire();
   }
   
@@ -133,5 +132,5 @@
   }
   
- /** site_name must be set before configure is called */
+  /** library_name must be set before configure is called */
   public void setLibraryName(String library_name) {
     this.library_name = library_name;
@@ -150,5 +149,5 @@
   public boolean configure() {
     
-    logger.info("configuring site");
+    logger.info("configuring the Message Router");
     
     if (this.site_name==null) {
@@ -175,8 +174,8 @@
           // set up the authenticator
           Authenticator.setDefault(new Authenticator(){
-            protected PasswordAuthentication getPasswordAuthentication(){
-              return new PasswordAuthentication(user, new String(passwd).toCharArray());
-            }
-          });
+	      protected PasswordAuthentication getPasswordAuthentication(){
+		return new PasswordAuthentication(user, new String(passwd).toCharArray());
+	      }
+	    });
           
         } catch (Exception e) {
@@ -187,40 +186,9 @@
     }
     
-    // read thru own config file - create services and connect to sites
-    File configFile = new File(GSFile.siteConfigFile(this.site_home));
-    
-    if (!configFile.exists() ) {
-      logger.error(" site config file: "+configFile.getPath()+" not found!");
-      return false;
-    }
-    
-    Document config_doc = this.converter.getDOM(configFile);
-    if (config_doc == null) {
-      logger.error(" couldn't parse site config file: "+configFile.getPath());
-      return false;
-    }
-    
-    config_info = config_doc.getDocumentElement();
-    
     this.module_map = new HashMap();
     
-    // load up the services: serviceRackList
-    Element service_rack_list = (Element)GSXML.getChildByTagName(config_info, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER);
-    configureServices(service_rack_list);
-    
-    // load up the service clusters
-    Element cluster_list = (Element)GSXML.getChildByTagName(config_info, GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER);
-    configureClusters(cluster_list);
-    
-    // load up the collections
-    configureCollections();
-    
-    // load up the external sites - this also adds their services/clusters/collections to the other lists - so must be done last
-    Element site_list = (Element)GSXML.getChildByTagName(config_info, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER);
-    configureSites(site_list);
-    
-    
-    return true;
-    
+    // This stuff may be done at a reconfigure also
+    return configureLocalSite();
+  
   }
   
@@ -250,6 +218,4 @@
   public Element process(Element message) {
     
-    logger.debug("MR received request");
-    //logger.info(this.converter.getString(message));
     // check that its a correct message tag
     if (!message.getTagName().equals(GSXML.MESSAGE_ELEM)) {
@@ -288,9 +254,4 @@
           // its a messaging request - modifies the requests/responses
           result = modifyMessages(req, message, mainResult);
-        } else if (type_att.equals(OAIXML.OAI_SET_LIST)) {
-            logger.info("oaiSetList request received");
-            //this is the oai receptionist asking for a list of oai-support collections
-            result = this.doc.createElement(GSXML.RESPONSE_ELEM);
-            result.appendChild(oai_collection_list);//getCollectionList();
         } else {
           // standard request
@@ -300,4 +261,7 @@
         mainResult.appendChild(this.doc.importNode(result, true));
       } else {
+	// The message needs to go to another module. The same message can 
+	// be passed to multiple modules  - they will be in a comma 
+	// separated list in the 'to' attribute
         String [] modules = path.split(",");
         
@@ -315,5 +279,4 @@
           if (this.module_map.containsKey(obj)) {
             copied_request.setAttribute(GSXML.TO_ATT, this_mod);
-//            logger.info("::::::::::::::: \n"+this.converter.getString(req));
             result = ((ModuleInterface)this.module_map.get(obj)).process(mess);
             if (result !=null ) {
@@ -345,13 +308,114 @@
     return mainResult;    
   }
-  
+  public Element getCollectionList() {
+	    return collection_list;
+  }
   // ********************************************************************
-  // auxiliary configure methods
+  // auxiliary configure and cleanup methods
   // *******************************************************************
   
-  
+  /** Calls clean up on all modules referenced in the module_map and 
+      removes them . */
+  protected void cleanUpModuleMapEntire() {
+    if (this.module_map != null) {
+      Iterator i = this.module_map.values().iterator();
+      while (i.hasNext()) {
+        ((ModuleInterface)i.next()).cleanUp();
+	i.remove();
+      }
+    }
+  }
+
+  /**
+     Goes through the children of list, and for each local/site-specific
+     name attribute, calls cleanUp on the module and removes it from the 
+     module_map and removes it from the list
+  */
+  protected void cleanUpModuleMapSubset(Element list, String remote_site) {
+    logger.error(this.converter.getString(list));
+    NodeList elements = list.getChildNodes(); // we are assuming no extraneous nodes
+    for(int i=elements.getLength()-1; i>=0; i--) {
+      Element item = (Element)elements.item(i);
+      String name = item.getAttribute(GSXML.NAME_ATT);
+      String potential_site_name = GSPath.getFirstLink(name);
+      if (remote_site != null) {
+	if (remote_site.equals(potential_site_name)) {
+	  list.removeChild(item);
+	}
+      } else {
+	if (name.equals(potential_site_name)) {// there was no site
+	  list.removeChild(item);
+	  ModuleInterface m = (ModuleInterface)this.module_map.remove(name);
+	  m.cleanUp(); // clean up any open files/connections etc 
+	  m=null;
+	}
+      }
+    }
+		    
+    logger.error(this.converter.getString(list));	    
+	    
+  }
+
+  /** removes all site modules from module_map, and any stored info about this sites collections and services */
+  protected void cleanUpAllExternalSiteInfo() {
+
+    NodeList site_nodes = this.site_list.getChildNodes();
+    for(int i=site_nodes.getLength()-1; i>=0; i--) {
+      Element item = (Element)site_nodes.item(i);
+      String name = item.getAttribute(GSXML.NAME_ATT);
+      // will remove the node from site_list
+      deactivateModule(GSXML.SITE_ELEM, name);	    
+    }
+	
+  }
+  /** read thru own site config file - create services and connect to sites
+   */
+  protected boolean configureLocalSite() {
+	
+    // this may be a reconfigure, so clean up the old moduleMap
+    cleanUpModuleMapEntire();
+
+    File configFile = new File(GSFile.siteConfigFile(this.site_home));
+    
+    if (!configFile.exists() ) {
+      logger.error(" site config file: "+configFile.getPath()+" not found!");
+      return false;
+    }
+    
+    Document config_doc = this.converter.getDOM(configFile);
+    if (config_doc == null) {
+      logger.error(" couldn't parse site config file: "+configFile.getPath());
+      return false;
+    }
+    
+    this.config_info = config_doc.getDocumentElement();
+    
+    // load up the services: serviceRackList
+    this.service_list = this.doc.createElement(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER);
+    Element service_rack_list_elem = (Element)GSXML.getChildByTagName(config_info, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER);
+    configureServices(service_rack_list_elem);
+    
+    // load up the service clusters
+    this.cluster_list = this.doc.createElement(GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER);
+    Element cluster_list_elem = (Element)GSXML.getChildByTagName(config_info, GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER);
+    configureClusters(cluster_list_elem);
+    
+    // load up the collections
+    this.collection_list = this.doc.createElement(GSXML.COLLECTION_ELEM+GSXML.LIST_MODIFIER);
+    this.private_collection_list = this.doc.createElement(GSXML.COLLECTION_ELEM+GSXML.LIST_MODIFIER);
+    this.oai_collection_list = this.doc.createElement(GSXML.COLLECTION_ELEM+GSXML.LIST_MODIFIER);
+    configureCollections();
+    
+    // load up the external sites - this also adds their services/clusters/collections to the other lists - so must be done last
+    this.site_list = this.doc.createElement(GSXML.SITE_ELEM+GSXML.LIST_MODIFIER);
+    Element site_list_elem = (Element)GSXML.getChildByTagName(config_info, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER);
+    configureExternalSites(site_list_elem);
+        
+    return true;
+    
+  }
+
   protected boolean configureServices(Element service_rack_list) {
     
-    this.service_list = this.doc.createElement(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER);
     
     // load up the individual services
@@ -380,18 +444,17 @@
       Class service_class = null;
       try {
-    	  service_class = Class.forName("org.greenstone.gsdl3.service."+service_name);
+	service_class = Class.forName("org.greenstone.gsdl3.service."+service_name);
       } catch(ClassNotFoundException e) {
     	  
-    	  try {
-    		  //try the service_name alone in case the package name is already specified
-    		  service_class = Class.forName(service_name);
+	try {
+	  //try the service_name alone in case the package name is already specified
+	  service_class = Class.forName(service_name);
     		  
-    	  }catch(ClassNotFoundException ae) {
-    		  logger.info(ae.getMessage());
-    	  }
+	}catch(ClassNotFoundException ae) {
+	  logger.info(ae.getMessage());
+	}
       }
       try {
     	  
-        //ServiceRack s = (ServiceRack)Class.forName("org.greenstone.gsdl3.service."+service_name).newInstance();
     	ServiceRack s = (ServiceRack)service_class.newInstance();
 	s.setSiteHome(this.site_home);
@@ -400,5 +463,8 @@
         s.setMessageRouter(this);
         // pass the XML node to the service for service configuration
-        s.configure(n, null);
+        if (!s.configure(n, null)) {
+	  logger.error ("couldn't configure ServiceRack "+service_name);
+	  continue;
+	}
         
         // find out the supported services for this service module
@@ -426,5 +492,4 @@
   protected boolean configureClusters(Element config_cluster_list) {
     
-    this.cluster_list = this.doc.createElement(GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER);
     // load up the service clusters
     logger.info("loading service clusters ...");
@@ -448,5 +513,9 @@
       sc.setClusterName(name);
       sc.setMessageRouter(this);
-      sc.configure(cluster);
+      if (!sc.configure(cluster)) {
+	logger.error ("couldn't configure ServiceCluster "+name);
+	continue;
+      }
+
       this.module_map.put(name, sc); // this replaces the old one if there was one already present
       //add short info to cluster list
@@ -459,8 +528,6 @@
   }
   
+  /** looks through the collect directory and activates any collections it finds. If this is a reconfigure, clean up must be done first before calling this */
   protected boolean configureCollections() {
-    
-    this.collection_list = this.doc.createElement(GSXML.COLLECTION_ELEM+GSXML.LIST_MODIFIER);
-    this.oai_collection_list = this.doc.createElement(GSXML.COLLECTION_ELEM+GSXML.LIST_MODIFIER);
     
     // read thru the collect directory and activate all the valid collections
@@ -482,7 +549,79 @@
   }
   
-  protected boolean configureSites(Element config_site_list) {
-    
-    this.site_list = this.doc.createElement(GSXML.SITE_ELEM+GSXML.LIST_MODIFIER);
+  /** creates and configures a new collection
+      if this is done for a reconfigure, the collection should be deactivated first.
+      *
+      *@param col_name the name of the collection
+      *@return true if collection created ok
+      */
+  protected boolean activateCollectionByName(String col_name) {
+    
+    logger.info("Activating collection: "+col_name+".");
+    
+    // Look for the etc/collectionInit.xml file, and see what sort of Collection to load
+    Collection c = null;
+    File init_file = new File(GSFile.collectionInitFile(this.site_home, col_name));
+    
+    if (init_file.exists()) {
+      Document init_doc = this.converter.getDOM(init_file);
+      if (init_doc != null) {
+        Element init_elem = init_doc.getDocumentElement();
+        if (init_elem != null) {
+          String coll_class_name = init_elem.getAttribute("class");
+          if (!coll_class_name.equals("")) {
+            try {
+              c = (Collection)Class.forName("org.greenstone.gsdl3.collection."+coll_class_name).newInstance();
+            } catch (Exception e) {
+              logger.info(" couldn't create a new collection, type "+coll_class_name+", defaulting to class Collection");
+            }
+          }
+        }
+      }
+    }
+    if (c==null) { // we haven't found another classname to use
+      c = new Collection();
+    }
+    
+    c.setCollectionName(col_name);
+    c.setSiteHome(this.site_home);
+    c.setSiteAddress(this.site_http_address);
+    c.setMessageRouter(this);
+    if (c.configure()) {
+      logger.info("have just configured collection " + col_name);
+      // add to list of collections
+      this.module_map.put(col_name, c);
+      Element e = this.doc.createElement(GSXML.COLLECTION_ELEM);
+      e.setAttribute(GSXML.NAME_ATT, col_name);
+      
+      if(c.isPublic()) {
+        // only public collections will appear on the home page
+        // add short description_ to collection_list_
+	this.collection_list.appendChild(e);
+	
+        if (c.hasOAI()) {
+          Element ane = this.doc.createElement(GSXML.COLLECTION_ELEM);
+          //The collection name is returned as site_name:coll_name, which is in fact the set specification
+          ane.setAttribute(GSXML.NAME_ATT, site_name + ":" + col_name);
+          ane.setAttribute(OAIXML.LASTMODIFIED, "" + c.getLastmodified());
+          
+          this.oai_collection_list.appendChild(ane);
+          //logger.info(GSXML.xmlNodeToString(oai_collection_list));
+        }      
+        
+      } else {
+	this.private_collection_list.appendChild(e);
+      }
+      return true;
+    } else {
+      logger.error("Couldn't configure collection: "+
+		   col_name+".");
+      return false;
+    }
+  }
+  
+
+  /** Goes through the siteList and activates each site found. If this is done for a reconfigure, a clean up must be done first ****HOW??? */
+  protected boolean configureExternalSites(Element config_site_list) {
+    
     // load up the sites
     logger.info("loading external sites...");
@@ -511,9 +650,47 @@
   }
   
+  protected boolean activateSiteByName(String site_name) {
+    logger.info("Activating site: "+site_name+".");
+    
+    File configFile = new File(GSFile.siteConfigFile(this.site_home));
+    
+    if (!configFile.exists() ) {
+      logger.error(" site config file: "+configFile.getPath()+" not found!");
+      return false;
+    }
+    Document config_doc = this.converter.getDOM(configFile);
+    if (config_doc == null) {
+      logger.error(" couldn't parse site config file: "+configFile.getPath());
+      return false;
+    }
+    Element config_elem = config_doc.getDocumentElement();
+    
+    Element config_site_list = (Element)GSXML.getChildByTagName(config_elem, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER);
+    if (config_site_list ==null ) {
+      logger.error("activateSite, no sites found");
+      return false;
+    }
+    // this is a name to identify the current site in the Communicator
+    String local_site_name = config_site_list.getAttribute("localSiteName");
+    if (local_site_name.equals("")) {
+      local_site_name = site_name;
+    }
+    
+    Element this_site_elem = GSXML.getNamedElement(config_site_list, GSXML.SITE_ELEM, GSXML.NAME_ATT, site_name);
+    if (this_site_elem == null) {
+      logger.error("activateSite, site "+site_name+" not found");
+      return false;
+    }
+    
+    return activateSite(this_site_elem, local_site_name);
+  }
+
   protected boolean activateSite(Element site_elem, String local_site_name) {
+    
     Communicator comm=null;
     String type = site_elem.getAttribute(GSXML.TYPE_ATT);
     String name = site_elem.getAttribute(GSXML.NAME_ATT);
     if (type.equals(GSXML.COMM_TYPE_SOAP_JAVA)) {
+      logger.info("activating SOAP site "+name);
       comm = new SOAPCommunicator();
       if (comm.configure(site_elem)) {
@@ -527,8 +704,8 @@
         // have to be added later
         if (!getRemoteSiteInfo(comm, name)) {
-          logger.error(" couldn't get info from site "+name);
+          logger.error(" couldn't get info from site");
         }
       } else {
-        logger.error(" couldn't configure soap site:"+name);
+        logger.error(" couldn't configure site");
         return false;
       }
@@ -599,4 +776,77 @@
   
   
+  
+  protected boolean activateServiceClusterByName(String cluster_name) {
+    return false;
+    
+  }
+  
+  protected boolean activateServiceRackByName(String module_name) {
+    return false;
+  }
+  
+  protected boolean deactivateModule(String type, String name) {
+    
+    logger.info("deactivating "+ type+"  module: "+name);
+    if (this.module_map.containsKey(name)) {
+      
+      logger.info("found the module");
+      ModuleInterface m = (ModuleInterface)this.module_map.remove(name);
+      // also remove the xml bit from description list
+      if (type.equals(GSXML.COLLECTION_ELEM)) {
+	if (((Collection)m).isPublic()) { 
+	  Element this_col = GSXML.getNamedElement(this.collection_list, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name);
+	  if (this_col != null) {
+	    this.collection_list.removeChild(this_col);
+	  }
+	  if (((Collection)m).hasOAI()) {
+	    this_col = GSXML.getNamedElement(this.oai_collection_list, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name);
+	    if (this_col != null) {
+	      this.oai_collection_list.removeChild(this_col);
+	    }
+	  }
+	} else {
+	  // a private collection
+	  Element this_col = GSXML.getNamedElement(this.private_collection_list, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name);
+	  if (this_col != null) {
+	    this.private_collection_list.removeChild(this_col);
+	  } 
+	}
+      } else if (type.equals(GSXML.SERVICE_ELEM)) {
+        Element this_service = GSXML.getNamedElement(this.service_list, GSXML.SERVICE_ELEM, GSXML.NAME_ATT, name);
+        if (this_service != null) {
+          this.service_list.removeChild(this_service);
+        }
+      } else if (type.equals(GSXML.CLUSTER_ELEM)) {
+        Element this_cluster = GSXML.getNamedElement(this.cluster_list, GSXML.CLUSTER_ELEM, GSXML.NAME_ATT, name);
+        if (this_cluster != null) {
+          this.cluster_list.removeChild(this_cluster);
+        }
+      } else if (type.equals(GSXML.SITE_ELEM)) {
+        Element this_site = GSXML.getNamedElement(this.site_list, GSXML.SITE_ELEM, GSXML.NAME_ATT, name);
+        if (this_site != null) {
+          this.site_list.removeChild(this_site);
+         
+          // also remove this sites colls, services, clusters etc
+          cleanUpModuleMapSubset(this.collection_list, name);
+          cleanUpModuleMapSubset(this.cluster_list, name);
+          cleanUpModuleMapSubset(this.service_list, name);
+	  
+	  // can remote collections be in the oai_coll list, or private coll list ??
+        }
+      } else {
+        logger.error("invalid module type: "+type+", can't remove info about this module");
+      }	
+      
+      m.cleanUp(); // clean up any open files/connections etc - can cause trouble on windows
+      m=null;
+      return true;
+    }
+    // else not deactivated
+    logger.error(name+" module not found");
+    return false;
+    
+  }
+   
   //*****************************************************************
   // auxiliary process methods
@@ -650,5 +900,14 @@
       
     }
-    
+        
+    if (type.equals(OAIXML.OAI_SET_LIST)) {
+      logger.info("oaiSetList request received");
+      //this is the oai receptionist asking for a list of oai-support collections
+      response.setAttribute(GSXML.TYPE_ATT, OAIXML.OAI_SET_LIST );
+      response.appendChild(this.oai_collection_list);
+      return response;
+    } 
+
+
     if (type.equals(GSXML.REQUEST_TYPE_SYSTEM)) {
       
@@ -667,5 +926,5 @@
           if (subset.equals("")) {
             // need to reconfigure the MR
-            this.configure();
+            this.configureLocalSite();
             Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM,  "MessageRouter reconfigured successfully");
             response.appendChild(s);
@@ -674,4 +933,7 @@
             // else it a specific request
             if (subset.equals(GSXML.COLLECTION_ELEM+GSXML.LIST_MODIFIER)) {
+	      // get rid of all the old collection stuff (not counting remote ones) before activating all the new ones
+	      cleanUpModuleMapSubset(this.collection_list, null);
+	      cleanUpModuleMapSubset(this.private_collection_list, null);
               success = configureCollections();
             } else {
@@ -694,13 +956,14 @@
               if (subset.equals(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER)) {
                 Element service_rack_list = (Element)GSXML.getChildByTagName(site_config_elem, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER);
-                
+                cleanUpModuleMapSubset(this.service_list, null);
                 success = configureServices(service_rack_list);
               } else if (subset.equals(GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER)) {
                 Element cluster_list = (Element)GSXML.getChildByTagName(site_config_elem, GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER);
-                
+                cleanUpModuleMapSubset(this.cluster_list, null);
                 success = configureClusters(cluster_list);
               } else if (subset.equals(GSXML.SITE_ELEM+GSXML.LIST_MODIFIER)) {
                 Element site_list = (Element)GSXML.getChildByTagName(site_config_elem, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER);
-                success = configureSites(site_list);
+		cleanUpAllExternalSiteInfo();
+                success = configureExternalSites(site_list);
               }
             }
@@ -721,8 +984,17 @@
           
           if (action.equals(GSXML.SYSTEM_TYPE_DEACTIVATE)) {
-            deactivateModule(module_type, module_name);
-            Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" deactivated");
-            response.appendChild(s);
+            success = deactivateModule(module_type, module_name);
+	    if (success) {
+	      Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" deactivated");
+	      response.appendChild(s);
+	    } else {
+	      Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" could not be deactivated");
+	      response.appendChild(s);
+	    }
+            
           } else if (action.equals(GSXML.SYSTEM_TYPE_ACTIVATE)) {
+	    // we need to deactivate the module first, in case this is a 
+	    // reconfigure
+	    deactivateModule(module_type, module_name);
             if (module_type.equals(GSXML.COLLECTION_ELEM)) {
               success = activateCollectionByName(module_name);
@@ -753,4 +1025,7 @@
     
   }
+
+  //* Used to copy nodes from one message to another. E.g. copy a response node to the next request. Not sure if this is actually used anywhere yet... */
+
   protected Element modifyMessages(Element request, Element message, Element result) {
     Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
@@ -814,192 +1089,5 @@
   // ****************************************************
   
-  /** creates and configures a new collection
-   *
-   *@param col_name the name of the collection
-   *@return true if collection created ok
-   */
-  protected boolean activateCollectionByName(String col_name) {
-    
-    logger.info("Activating collection: "+col_name+".");
-    
-    // Look for the etc/collectionInit.xml file, and see what sort of Collection to load
-    Collection c = null;
-    File init_file = new File(GSFile.collectionInitFile(this.site_home, col_name));
-    
-    if (init_file.exists()) {
-      Document init_doc = this.converter.getDOM(init_file);
-      if (init_doc != null) {
-        Element init_elem = init_doc.getDocumentElement();
-        if (init_elem != null) {
-          String coll_class_name = init_elem.getAttribute("class");
-          if (!coll_class_name.equals("")) {
-            try {
-              c = (Collection)Class.forName("org.greenstone.gsdl3.collection."+coll_class_name).newInstance();
-            } catch (Exception e) {
-              logger.info(" couldn't create a new collection, type "+coll_class_name+", defaulting to class Collection");
-            }
-          }
-        }
-      }
-    }
-    if (c==null) { // we haven't found another classname to use
-      c = new Collection();
-    }
-    
-    c.setCollectionName(col_name);
-    c.setSiteHome(this.site_home);
-    c.setSiteAddress(this.site_http_address);
-    c.setMessageRouter(this);
-    if (c.configure()) {
-      // this could be a reactivation, so delete the old version
-      deactivateModule(GSXML.COLLECTION_ELEM, col_name);
-      // add to list of collections
-      this.module_map.put(col_name, c);
-      
-      if(c.isPublic()) {
-        // only public collections will appear on the home page
-        // add short description_ to collection_list_
-        Element e = this.doc.createElement(GSXML.COLLECTION_ELEM);
-        e.setAttribute(GSXML.NAME_ATT, col_name);
-//        if (c.hasOAI()) {
-//          e.setAttribute(OAIXML.HAS_OAI, "true");
-//        } else {
-//          e.setAttribute(OAIXML.HAS_OAI, "false");
-//        } 
-        if (c.hasOAI() == true) {
-          Element ane = this.doc.createElement(GSXML.COLLECTION_ELEM);
-          //The collection name is returned as site_name:coll_name, which is in fact the set specification
-          ane.setAttribute(GSXML.NAME_ATT, site_name + ":" + col_name);
-          ane.setAttribute(OAIXML.LASTMODIFIED, "" + c.getLastmodified());
-          
-          this.oai_collection_list.appendChild(ane);
-          //logger.info(GSXML.xmlNodeToString(oai_collection_list));
-        }      
-        this.collection_list.appendChild(e);
-      }
-      return true;
-    } else {
-      logger.error("Couldn't configure collection: "+
-        col_name+".");
-      return false;
-    }
-  }
-  protected Element getCollectionList() {
-    return collection_list;
-  }
-  
-  
-  protected boolean activateSiteByName(String site_name) {
-    logger.info("Activating site: "+site_name+".");
-    
-    // just in case this is a reactivation, deactivate this site first
-    deactivateModule(GSXML.SITE_ELEM, site_name);
-    File configFile = new File(GSFile.siteConfigFile(this.site_home));
-    
-    if (!configFile.exists() ) {
-      logger.error(" site config file: "+configFile.getPath()+" not found!");
-      return false;
-    }
-    Document config_doc = this.converter.getDOM(configFile);
-    if (config_doc == null) {
-      logger.error(" couldn't parse site config file: "+configFile.getPath());
-      return false;
-    }
-    Element config_elem = config_doc.getDocumentElement();
-    
-    Element config_site_list = (Element)GSXML.getChildByTagName(config_elem, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER);
-    if (config_site_list ==null ) {
-      logger.error("activateSite, no sites found");
-      return false;
-    }
-    // this is a name to identify the current site in the Communicator
-    String local_site_name = config_site_list.getAttribute("localSiteName");
-    if (local_site_name.equals("")) {
-      local_site_name = site_name;
-    }
-    
-    Element this_site_elem = GSXML.getNamedElement(config_site_list, GSXML.SITE_ELEM, GSXML.NAME_ATT, site_name);
-    if (this_site_elem == null) {
-      logger.error("activateSite, site "+site_name+" not found");
-      return false;
-    }
-    
-    return activateSite(this_site_elem, local_site_name);
-  }
-  
-  protected boolean activateServiceClusterByName(String cluster_name) {
-    return false;
-    
-  }
-  
-  protected boolean activateServiceRackByName(String module_name) {
-    return false;
-  }
-  
-  protected boolean deactivateModule(String type, String name) {
-    
-    if (this.module_map.containsKey(name)) {
-      
-      logger.info(" deactivating "+name);
-      ModuleInterface m = (ModuleInterface)this.module_map.remove(name);
-      m.cleanUp(); // clean up any open files/connections etc - can cause trouble on windows
-      // also remove the xml bit from description list
-      if (type.equals(GSXML.COLLECTION_ELEM)) {
-        Element this_col = GSXML.getNamedElement(this.collection_list, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name);
-        if (this_col != null) {
-          this.collection_list.removeChild(this_col);
-        }
-        return true;
-      } else if (type.equals(GSXML.SERVICE_ELEM)) {
-        Element this_service = GSXML.getNamedElement(this.service_list, GSXML.SERVICE_ELEM, GSXML.NAME_ATT, name);
-        if (this_service != null) {
-          this.service_list.removeChild(this_service);
-        }
-        return true;
-      } else if (type.equals(GSXML.CLUSTER_ELEM)) {
-        Element this_cluster = GSXML.getNamedElement(this.cluster_list, GSXML.CLUSTER_ELEM, GSXML.NAME_ATT, name);
-        if (this_cluster != null) {
-          this.cluster_list.removeChild(this_cluster);
-        }
-        return true;
-      } else if (type.equals(GSXML.SITE_ELEM)) {
-        Element this_site = GSXML.getNamedElement(this.site_list, GSXML.SITE_ELEM, GSXML.NAME_ATT, name);
-        if (this_site != null) {
-          this.site_list.removeChild(this_site);
-          
-          // also remove this sites colls, services, clusters etc
-          removeRemoteSiteInfo(this.collection_list, GSXML.COLLECTION_ELEM, name);
-          removeRemoteSiteInfo(this.cluster_list, GSXML.CLUSTER_ELEM, name);
-          removeRemoteSiteInfo(this.service_list, GSXML.SERVICE_ELEM, name);
-        }
-      } else {
-        logger.error(" couldn't deactivate coll");
-        // couldn't do it
-        return false;
-      }
-    }
-    // else not deactivated
-    return false;
-    
-  }
-  
-  /**
-   * this looks through a list (module_list) of elements named module_name,
-   * and removes any whose names start with site_name
-   */
-  protected void removeRemoteSiteInfo(Element module_list,
-    String module_name,
-    String site_name) {
-    
-    NodeList modules = module_list.getElementsByTagName(module_name);
-    // will this work??
-    for (int i=modules.getLength()-1; i>=0; i--) {
-      
-      String name = ((Element)modules.item(i)).getAttribute(GSXML.NAME_ATT);
-      if (GSPath.getFirstLink(name).equals(site_name)) {
-        module_list.removeChild(modules.item(i));
-      }
-    }
-  }
+ 
   
 }
