Index: /trunk/gsdl/src/recpt/configaction.cpp
===================================================================
--- /trunk/gsdl/src/recpt/configaction.cpp	(revision 4290)
+++ /trunk/gsdl/src/recpt/configaction.cpp	(revision 4290)
@@ -0,0 +1,136 @@
+/**********************************************************************
+ *
+ * configaction.cpp -- 
+ * Copyright (C) 2003 DL Consulting Ltd
+ *
+ * A component of the Greenstone digital library software
+ * from the New Zealand Digital Library Project at the
+ * University of Waikato, New Zealand.
+ *
+ * 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.
+ *
+ *********************************************************************/
+
+
+#include "configaction.h"
+#include "recptconfig.h"
+
+configaction::configaction () {
+
+  recpt = NULL;
+
+  cgiarginfo arg_ainfo;
+  arg_ainfo.shortname = "a";
+  arg_ainfo.longname = "action";
+  arg_ainfo.multiplechar = true;
+  arg_ainfo.defaultstatus = cgiarginfo::weak;
+  arg_ainfo.argdefault = "config";
+  arg_ainfo.savedarginfo = cgiarginfo::must;
+  argsinfo.addarginfo (NULL, arg_ainfo);
+
+  /* 
+     The cmd argument may be one of the following:
+     -- release-collection - release the collection specified by the "c"
+        argument
+     -- add-collection - add and configure a collection server for the
+        collection specified by the "c" argument
+  */
+  arg_ainfo.shortname = "cmd";
+  arg_ainfo.longname = "config command";
+  arg_ainfo.multiplechar = true;
+  arg_ainfo.defaultstatus = cgiarginfo::weak;
+  arg_ainfo.argdefault = "configure-all";
+  arg_ainfo.savedarginfo = cgiarginfo::mustnot;
+  argsinfo.addarginfo (NULL, arg_ainfo);
+}
+
+configaction::~configaction () {
+}
+
+void configaction::get_cgihead_info (cgiargsclass &args, recptprotolistclass *protos,
+				     response_t &response, text_t &response_data, 
+				     ostream &logout) {
+  response = content;
+  response_data = "text/html";
+}
+
+bool configaction::do_action (cgiargsclass &args, recptprotolistclass *protos, 
+			      browsermapclass *browsers, displayclass &disp,
+			      outconvertclass &outconvert, ostream &textout,
+			      ostream &logout) {
+
+  if (recpt == NULL) return false;
+
+  if ((args["cmd"] == "add-collection") && (!args["c"].empty())) {
+    create_colservr(args["c"], logout);
+    textout << "configured add-collection\n";
+
+  } else if ((args["cmd"] == "release-collection") && (!args["c"].empty())) {
+    remove_colservr(args["c"], logout);
+    textout << "configured release-collection\n";
+
+  }
+
+  return true;
+}
+
+
+// create and initialize a new collection server and
+// add it to the null protocol.
+void configaction::create_colservr (const text_t &collection, ostream &logout) {
+
+  recptprotolistclass *protos = recpt->get_recptprotolist_ptr();
+  recptprotolistclass::iterator rprotolist_here = protos->begin();
+  recptprotolistclass::iterator rprotolist_end = protos->end();
+  while (rprotolist_here != rprotolist_end) {
+    comerror_t err = noError;
+    if ((*rprotolist_here).p != NULL) {
+      if ((*rprotolist_here).p->get_protocol_name(err) == "nullproto") {
+	// create collection server and add it to nullproto
+	(*rprotolist_here).p->add_collection(collection, recpt, gsdlhome, gsdlhome);
+	// re-initialize the null protocol
+	if (!(*rprotolist_here).p->init(err, logout)) {
+	  logout << "configaction::create_colservr: nullproto init failed\n";
+	}
+	return;
+      }
+    }
+    rprotolist_here ++;
+  }
+
+  logout << "configaction::create_colservr: no valid nullproto found\n";
+}
+
+// delete a collection server from the null protocol
+void configaction::remove_colservr (const text_t &collection, ostream &logout) {
+
+  recpt->uncache_collection(collection);
+
+  recptprotolistclass *protos = recpt->get_recptprotolist_ptr();
+  recptprotolistclass::iterator rprotolist_here = protos->begin();
+  recptprotolistclass::iterator rprotolist_end = protos->end();
+  while (rprotolist_here != rprotolist_end) {
+    comerror_t err = noError;
+    if ((*rprotolist_here).p != NULL) {
+      if ((*rprotolist_here).p->get_protocol_name(err) == "nullproto") {
+	(*rprotolist_here).p->remove_collection(collection, logout);
+	return;
+      }
+    }
+    rprotolist_here ++;
+  }
+
+  logout << "configaction::create_colserver: no valid nullproto found\n";
+}
Index: /trunk/gsdl/src/recpt/configaction.h
===================================================================
--- /trunk/gsdl/src/recpt/configaction.h	(revision 4290)
+++ /trunk/gsdl/src/recpt/configaction.h	(revision 4290)
@@ -0,0 +1,60 @@
+/**********************************************************************
+ *
+ * configaction.h -- 
+ * Copyright (C) 2003 DL Consulting Ltd
+ *
+ * A component of the Greenstone digital library software
+ * from the New Zealand Digital Library Project at the
+ * University of Waikato, New Zealand.
+ *
+ * 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.
+ *
+ *********************************************************************/
+
+
+#ifndef CONFIGACTION_H
+#define CONFIGACTION_H
+
+#include "action.h"
+#include "receptionist.h"
+
+class configaction : public action {
+
+protected:
+  receptionist *recpt;
+
+  void create_colservr (const text_t &collection, ostream &logout);
+  void remove_colservr (const text_t &collection, ostream &logout);
+
+public:
+  configaction ();
+  virtual ~configaction ();
+
+  void set_receptionist (receptionist *therecpt) {recpt=therecpt;}
+
+  text_t get_action_name () {return "config";}
+  void get_cgihead_info (cgiargsclass &args, recptprotolistclass *protos,
+			 response_t &response, text_t &response_data, 
+			 ostream &logout);
+
+  bool do_action (cgiargsclass &args, recptprotolistclass *protos, 
+		  browsermapclass *browsers, displayclass &disp,
+		  outconvertclass &outconvert, ostream &textout,
+		  ostream &logout);
+};
+
+
+
+#endif
Index: /trunk/gsdl/src/recpt/receptionist.cpp
===================================================================
--- /trunk/gsdl/src/recpt/receptionist.cpp	(revision 4289)
+++ /trunk/gsdl/src/recpt/receptionist.cpp	(revision 4290)
@@ -1076,5 +1076,5 @@
   // "ccs" argument is set and make "cc" default to
   // all collections in "ccs"
-  if (!args["c"].empty()) {
+  if (args["a"] != "config" && !args["c"].empty()) {
 
     text_t &arg_c = args["c"];
Index: /trunk/gsdl/src/recpt/win32.mak
===================================================================
--- /trunk/gsdl/src/recpt/win32.mak	(revision 4289)
+++ /trunk/gsdl/src/recpt/win32.mak	(revision 4290)
@@ -80,5 +80,5 @@
 		htmlbrowserclass.h historydb.h phindbrowserclass.h collectoraction.h \
 		nullproto.h argdb.h browseaction.h browseactiontools.h phindaction.h \
-		summarise.h highlighttext.h
+		summarise.h highlighttext.h configaction.h
 
 CGIHEADERS = cgiwrapper.h
@@ -97,5 +97,5 @@
 		historydb.cpp phindbrowserclass.cpp collectoraction.cpp nullproto.cpp \
 		argdb.cpp browseaction.cpp browseactiontools.cpp phindaction.cpp \
-		summarise.cpp highlighttext.cpp
+		summarise.cpp highlighttext.cpp configaction.cpp
 
 CGISOURCES = librarymain.cpp cgiwrapper.cpp
@@ -114,5 +114,5 @@
 		historydb.obj phindbrowserclass.obj collectoraction.obj nullproto.obj \
 		argdb.obj browseaction.obj browseactiontools.obj phindaction.obj \
-		summarise.obj highlighttext.obj
+		summarise.obj highlighttext.obj configaction.obj
 
 CGIOBJECTS = librarymain.obj cgiwrapper.obj
