Index: /gsdl/trunk/runtime-src/src/colservr/collectset.cpp
===================================================================
--- /gsdl/trunk/runtime-src/src/colservr/collectset.cpp	(revision 19805)
+++ /gsdl/trunk/runtime-src/src/colservr/collectset.cpp	(revision 19806)
@@ -237,123 +237,169 @@
   text_t infodbtype = "gdbm"; // gdbm is default
 
+  collectserver *cserver = NULL;
+
   text_tarray cfgline;
   text_t key;
 
   text_t build_cfg = filename_cat(collecthome, collection, "index", "build.cfg");
-  if (!file_exists (build_cfg)) {
-    // don't add in unbuilt collections
-    return;
-  }
-  char *build_cfgc = build_cfg.getcstr();
-  ifstream confin(build_cfgc);
-
-  if (confin) {
-    while (read_cfg_line(confin, cfgline) >= 0) {
-      if (cfgline.size() == 2) {
-	key = cfgline[0];
-	cfgline.erase(cfgline.begin());
-	if (key == "buildtype") {
-	  buildtype = cfgline[0];
+  if (file_exists (build_cfg)) {
+    char *build_cfgc = build_cfg.getcstr();
+    ifstream confin(build_cfgc);
+    
+    if (confin) {
+      while (read_cfg_line(confin, cfgline) >= 0) {
+	if (cfgline.size() == 2) {
+	  key = cfgline[0];
+	  cfgline.erase(cfgline.begin());
+	  if (key == "buildtype") {
+	    buildtype = cfgline[0];
+	  }
+	  if (key == "infodbtype") {
+	    infodbtype = cfgline[0];
+	  }
 	}
-	if (key == "infodbtype") {
-	  infodbtype = cfgline[0];
-	}
-      }
-    }
-    confin.close();
-  }
-  delete []build_cfgc;
-
-  collectserver *cserver = new collectserver();
-
-  // Create a dbclass of the correct type
-  dbclass *db_ptr = NULL;
+      }
+      confin.close();
+    }
+    delete []build_cfgc;
+
+    cserver = new collectserver();
+
+    // Create a dbclass of the correct type
+    dbclass *db_ptr = NULL;
 
 #ifdef USE_SQLITE
-  if (infodbtype == "sqlite")
-  {
-    sqlitedbclass *sql_db_ptr = new sqlitedbclass();
-    db_ptr = sql_db_ptr;
-
-    // add a sql browse filter
-    sqlbrowsefilterclass *sqlbrowsefilter = new sqlbrowsefilterclass();
-    sqlbrowsefilter->set_sql_db_ptr(sql_db_ptr);
-    cserver->add_filter (sqlbrowsefilter);  
-  }
+    if (infodbtype == "sqlite")
+      {
+	sqlitedbclass *sql_db_ptr = new sqlitedbclass();
+	db_ptr = sql_db_ptr;
+
+	// add a sql browse filter
+	sqlbrowsefilterclass *sqlbrowsefilter = new sqlbrowsefilterclass();
+	sqlbrowsefilter->set_sql_db_ptr(sql_db_ptr);
+	cserver->add_filter (sqlbrowsefilter);  
+      }
 #endif
   
 #ifdef USE_MSSQL
-  if (infodbtype == "mssql")
-  {
-    mssqldbclass *mssql_db_ptr = new mssqldbclass();
-    db_ptr = mssql_db_ptr;
-
-    // add a sql browse filter
-    sqlbrowsefilterclass *sqlbrowsefilter = new sqlbrowsefilterclass();
-    sqlbrowsefilter->set_sql_db_ptr(mssql_db_ptr);
-    cserver->add_filter (sqlbrowsefilter);  
-  }
+    if (infodbtype == "mssql")
+      {
+	mssqldbclass *mssql_db_ptr = new mssqldbclass();
+	db_ptr = mssql_db_ptr;
+
+	// add a sql browse filter
+	sqlbrowsefilterclass *sqlbrowsefilter = new sqlbrowsefilterclass();
+	sqlbrowsefilter->set_sql_db_ptr(mssql_db_ptr);
+	cserver->add_filter (sqlbrowsefilter);  
+      }
 #endif
   
-  // Use GDBM if the infodb type is empty or not one of the values above
-  if (db_ptr == NULL)
-  {
-    db_ptr = new gdbmclass();
-  }
-
-  // add a null filter
-  filterclass *filter = new filterclass ();
-  cserver->add_filter (filter);
+    // Use GDBM if the infodb type is empty or not one of the values above
+    if (db_ptr == NULL) {
+      db_ptr = new gdbmclass();
+    }
+
+    // add a null filter
+    filterclass *filter = new filterclass ();
+    cserver->add_filter (filter);
+  
+    // add a browse filter
+    browsefilterclass *browsefilter = new browsefilterclass();
+    browsefilter->set_db_ptr(db_ptr);
+    cserver->add_filter (browsefilter);  
+
+    if (buildtype == "mg") {
+      mgsearch = new mgsearchclass();
+ 
+      // add a query filter
+      mgqueryfilterclass *queryfilter = new mgqueryfilterclass();
+      queryfilter->set_db_ptr(db_ptr);
+      queryfilter->set_textsearchptr (mgsearch);
+      cserver->add_filter (queryfilter);
+    
+      // add a mg source
+      mgsourceclass *mgsource = new mgsourceclass ();
+      mgsource->set_db_ptr(db_ptr);
+      mgsource->set_textsearchptr (mgsearch);
+      cserver->add_source (mgsource);
+    }
+    else if (buildtype == "mgpp") {
+      mgppsearch = new mgppsearchclass();
+
+      // add a query filter
+      mgppqueryfilterclass *queryfilter = new mgppqueryfilterclass();
+      queryfilter->set_db_ptr(db_ptr);
+      queryfilter->set_textsearchptr (mgppsearch);
+      cserver->add_filter (queryfilter);
       
-  // add a browse filter
-  browsefilterclass *browsefilter = new browsefilterclass();
-  browsefilter->set_db_ptr(db_ptr);
-  cserver->add_filter (browsefilter);  
- 
-  if (buildtype == "mg") {
-    mgsearch = new mgsearchclass();
- 
-    // add a query filter
-    mgqueryfilterclass *queryfilter = new mgqueryfilterclass();
-    queryfilter->set_db_ptr(db_ptr);
-    queryfilter->set_textsearchptr (mgsearch);
-    cserver->add_filter (queryfilter);
-    
-    // add a mg source
-    mgsourceclass *mgsource = new mgsourceclass ();
-    mgsource->set_db_ptr(db_ptr);
-    mgsource->set_textsearchptr (mgsearch);
-    cserver->add_source (mgsource);
-  }
-  else if (buildtype == "mgpp") {
-    mgppsearch = new mgppsearchclass();
-
-    // add a query filter
-    mgppqueryfilterclass *queryfilter = new mgppqueryfilterclass();
-    queryfilter->set_db_ptr(db_ptr);
-    queryfilter->set_textsearchptr (mgppsearch);
-    cserver->add_filter (queryfilter);
+      // add a mg source
+      mgsourceclass *mgsource = new mgsourceclass ();
+      mgsource->set_db_ptr(db_ptr);
+      mgsource->set_textsearchptr (mgppsearch);
+      cserver->add_source (mgsource);
+    }
+    else if (buildtype == "lucene") {
+      lucenesearch = new lucenesearchclass();
+      lucenesearch->set_gsdlhome(gsdlhome); 
+
+      // add a query filter
+      lucenequeryfilterclass *queryfilter = new lucenequeryfilterclass();
+      queryfilter->set_db_ptr(db_ptr);
+      queryfilter->set_textsearchptr (lucenesearch);
+      cserver->add_filter (queryfilter);
       
-    // add a mg source
-    mgsourceclass *mgsource = new mgsourceclass ();
-    mgsource->set_db_ptr(db_ptr);
-    mgsource->set_textsearchptr (mgppsearch);
-    cserver->add_source (mgsource);
-  }
-  else if (buildtype == "lucene") {
-    lucenesearch = new lucenesearchclass();
-    lucenesearch->set_gsdlhome(gsdlhome); 
-
-    // add a query filter
-    lucenequeryfilterclass *queryfilter = new lucenequeryfilterclass();
-    queryfilter->set_db_ptr(db_ptr);
-    queryfilter->set_textsearchptr (lucenesearch);
-    cserver->add_filter (queryfilter);
+      // add a lucene source
+      lucenesourceclass *lucenesource = new lucenesourceclass ();
+      lucenesource->set_db_ptr(db_ptr);
+      lucenesource->set_textsearchptr (lucenesearch);
+      cserver->add_source (lucenesource);
+    }
+    else {
+      cerr << "Warning: unrecognized buildtype" << buildtype << endl;
+    }
+
+  }
+  else {
+    // see if it is a collectgroup col
+
+
+    // This routine essentially exists twice in the code now (see add_collection_group)
+    // factor out as support routine
+
+    text_t collect_cfg = filename_cat(collecthome, collection, "etc", "collect.cfg");
+    if (file_exists (collect_cfg)) {
+      char *collect_cfgc = collect_cfg.getcstr();
+      ifstream confin(collect_cfgc);     
+
+      text_t is_collect_group = "false";
+
+      if (confin) {
+	while (read_cfg_line(confin, cfgline) >= 0) {
+	  if (cfgline.size() == 2) {
+	    key = cfgline[0];
+	    
+	    cfgline.erase(cfgline.begin());
+	    if (key == "collectgroup") {
+	      is_collect_group = cfgline[0];
+	    }
+	  }
+	}
+	confin.close();
+      }
+      delete []collect_cfgc;
       
-    // add a lucene source
-    lucenesourceclass *lucenesource = new lucenesourceclass ();
-    lucenesource->set_db_ptr(db_ptr);
-    lucenesource->set_textsearchptr (lucenesearch);
-    cserver->add_source (lucenesource);
+      if (is_collect_group != "true") {
+	// an unbuilt leaf collection
+	return;
+      }
+
+      // by this point we know we will need a cserver
+      cserver = new collectserver();
+
+    }
+    else {
+      // no collect.cfg => filter it out from list of collections added
+      return;
+    }
   }
 
