Index: main/trunk/greenstone2/runtime-src/src/corba/corbaServer.mpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/corba/corbaServer.mpp	(revision 24959)
+++ main/trunk/greenstone2/runtime-src/src/corba/corbaServer.mpp	(revision 25231)
@@ -1,5 +1,7 @@
+#define USE_POA
+
 // Standard headers
-#include <iostream.h>
-#include <fstream.h>
+#include <iostream>
+#include <fstream>
 
 // protocol headers
@@ -44,5 +46,5 @@
       here ++;
     }
-  cout << "Terminfo " << i << endl;
+  std::cout << "Terminfo " << i << std::endl;
 }
 
@@ -57,5 +59,5 @@
       corbaconv_text_t::setCorbatext(option.value,corba[i].value);
 
-      // cout << corbatext_string(corba[i].name) << "?" << option
+      // std::cout << corbatext_string(corba[i].name) << "?" << option
 
       array.push_back(option);
@@ -63,5 +65,7 @@
 }
 
-class corbaServer : virtual public corbaiface_skel
+// corbaServer no longer inherits from corbaiface_skel since the change from using 
+// BOA to POA in the Corba code upon updating Mico from version 2.3.5 to 2.3.13.
+class corbaServer : virtual public POA_gsdlInterface::corbaiface
 {
 private:
@@ -88,17 +92,17 @@
     char * cdirname;
 
-    cout << "CorbaServer: gsdlhome = " << home << endl;
+    std::cout << "CorbaServer: gsdlhome = " << home << std::endl;
 
     this->gsdlhome = home;
-    cout << gsdlhome.getcstr() << endl;
+    std::cout << gsdlhome.getcstr() << std::endl;
     dirname = filename_cat(gsdlhome, "/collect");
     cdirname = dirname.getcstr();
     if (!read_dir (cdirname, collections)) {
-      cout << "Unable to read the gsdl directory; terminating" << endl;
+      std::cout << "Unable to read the gsdl directory; terminating" << std::endl;
       exit (1);
     }
     delete cdirname;
 
-    cout << "Constructing set list server" << endl;
+    std::cout << "Constructing set list server" << std::endl;
     this->protocol = protocol;
 
@@ -128,10 +132,10 @@
 
       // ****
-      cout << "Recieved " << key << " = ";
+      std::cout << "Recieved " << key << " = ";
       for (int unsigned i=0; i<cfgline.size(); i++)
 	{
-	  cout << cfgline[i] << " ";
-	}
-      cout << endl;
+	  std::cout << cfgline[i] << " ";
+	}
+      std::cout << std::endl;
 
       // DB // ****
@@ -140,5 +144,5 @@
 	  text_tarray cfgline;
 	  cfgline.push_back (gsdlhome);
-	  cout << "Changing gsdlhome to " << gsdlhome << endl;
+	  std::cout << "Changing gsdlhome to " << gsdlhome << std::endl;
 	  protocol->configure(key, cfgline, error);
 	}
@@ -146,9 +150,9 @@
 	{
 	  // Only let gsdlhome through !!!! // ****
-	  cout << "Supressing httpdomain" << endl;
+	  std::cout << "Supressing httpdomain" << std::endl;
 	}
       else if (key=="httpprefix")
 	{
-	  cout << "Supressing httpprefix" << endl;
+	  std::cout << "Supressing httpprefix" << std::endl;
 	}
       else
@@ -170,5 +174,5 @@
     cct = new corbaconv_text_t(corbaCollect);
 
-    cout << "Collection: " << cct->getcstr() << endl;
+    std::cout << "Collection: " << cct->getcstr() << std::endl;
 
     protocol->has_collection(*cct, _has, err, logout); // 'cct' typecast to text_t
@@ -182,5 +186,5 @@
       }
 
-    // cout << "  " << has << endl;
+    // std::cout << "  " << has << std::endl;
 
     delete cct;
@@ -245,5 +249,5 @@
     logout.close();
     corbaError = (corbaComError) error;
-    cout << "Filter prepared" << corbaResponse.docInfo.length() << "," << corbaResponse.numDocs << endl;
+    std::cout << "Filter prepared" << corbaResponse.docInfo.length() << "," << corbaResponse.numDocs << std::endl;
   }
 
@@ -262,11 +266,11 @@
     protocol->get_collectinfo(collection, response, error, logout);
 
-    cout << "IsPublic  = " << ((response.isPublic)?"True":"False") << endl;
-    cout << "IsBeta    = " << ((response.isBeta)  ?"True":"False") << endl;
-    cout << "BuildDate = " << response.buildDate << endl;
-    cout << "NumDocs   = " << response.numDocs << endl;
-    cout << "NumBytes  = " << response.numBytes << endl;
-    cout << "NumWords  = " << response.numWords << endl;
-    cout << "UseBook   = " << ((response.useBook)  ?"True":"False") << endl;
+    std::cout << "IsPublic  = " << ((response.isPublic)?"True":"False") << std::endl;
+    std::cout << "IsBeta    = " << ((response.isBeta)  ?"True":"False") << std::endl;
+    std::cout << "BuildDate = " << response.buildDate << std::endl;
+    std::cout << "NumDocs   = " << response.numDocs << std::endl;
+    std::cout << "NumBytes  = " << response.numBytes << std::endl;
+    std::cout << "NumWords  = " << response.numWords << std::endl;
+    std::cout << "UseBook   = " << ((response.useBook)  ?"True":"False") << std::endl;
     
     corbaResponse.useBook   = response.useBook;
@@ -280,5 +284,5 @@
     corbaResponse.numWords  = response.numWords;
 
-    corbatext_mapToCorbaMap(response.collectionmeta, &corbaResponse.collectionMeta);
+    corbatext_colmetamapToCorbaColmetamap(response.collectionmeta, &corbaResponse.collectionMeta);
     corbatext_mapToCorbaMap(response.format, &corbaResponse.format);
     corbatext_mapToCorbaMap(response.building, &corbaResponse.building);
@@ -292,5 +296,5 @@
     while (f_here!=f_end)
     {
-      cout << "**** format: " << f_here->first << " = " << f_here->second << endl;
+      std::cout << "**** format: " << f_here->first << " = " << f_here->second << std::endl;
       f_here++;
     } 
@@ -362,5 +366,5 @@
 
     corbaconv_text_t::setCorbatext(collection,corbaCollect);
-    cout << collection.getcstr() << endl;
+    std::cout << collection.getcstr() << std::endl;
 			    
     protocol->get_filterinfo(collection, response, error, logout);
@@ -399,5 +403,5 @@
   void getRssItems (const struct corbatext_t &corbaCollect,
 		  const struct corbatext_t &corbaGsdlHome,
-		  const struct corbatext_t &corbaRssItems,
+		  struct corbatext_t &corbaRssItems,
 		  enum corbaComError &corbaError)
   {   
@@ -416,5 +420,5 @@
     protocol->get_rss_items(collection, gsdlhome, rss_items, error, logout);
     corbaconv_text_t::getCorbatext(rss_items,corbaRssItems);
-
+    
     // decode response
     corbaError = (corbaComError) error;
@@ -433,5 +437,5 @@
     ofstream logout;
 
-    cout << "Received collection list request" << endl;
+    std::cout << "Received collection list request" << std::endl;
 
     this->openLogfile("/etc/corbaout.txt", logout);
@@ -453,12 +457,12 @@
 
     corbatext_arrayToCorbaArray(collist, &corbalist);
-    cout << "Replying " << collist.size() << ": " << endl;
+    std::cout << "Replying " << collist.size() << ": " << std::endl;
 
     for (int unsigned i = 0; i < collist.size(); i ++)
       {
-	cout << collist[i];
-	if (i<collist.size()-1) cout << ", ";
+	std::cout << collist[i];
+	if (i<collist.size()-1) std::cout << ", ";
       }
-    cout << endl;
+    std::cout << std::endl;
 
     logout.close();
@@ -472,46 +476,77 @@
   collectset *cservers;
   text_t     gsdlhome;
-
-  cservers = new collectset(gsdlhome);
+  text_t     collecthome;
+
+  cservers = new collectset(gsdlhome, collecthome);
   protocol.set_collectset(cservers);
 
-  cout << "Started Corba ..." << endl;
+  std::cout << "Started Corba ..." << std::endl;
 
   // ORB initialization
+  // Initialize the ORB
   CORBA::ORB_var orb = CORBA::ORB_init( argc, argv, "mico-local-orb" );
+
+#if defined(USE_POA)
+  // Obtain a reference to the RootPOA and its Manager
+  CORBA::Object_var poaobj = orb->resolve_initial_references ("RootPOA");
+  PortableServer::POA_var poa = PortableServer::POA::_narrow (poaobj);
+  PortableServer::POAManager_var mgr = poa->the_POAManager();
+#else
   CORBA::BOA_var boa = orb->BOA_init( argc, argv, "mico-local-boa" );
-
-  cout << "Initialised ORB and BOA" << endl;
-
+#endif
+
+  std::cout << "Initialised ORB and P/BOA" << std::endl;
+
+
+  // Create the Server object (the object that inherits from the POA_gsdlInterface::corbaiface
   corbaServer* server = new corbaServer(&protocol, gsdlhome);
 
-  cout << "Initialised server" << endl;
-
-  CORBA::String_var ref = orb->object_to_string( server );
-
-  cout << "Mapped Corba object to string" << endl;
-
+  // Activate the Servant (server)
+#if defined(USE_POA)
+  PortableServer::ObjectId_var oid = poa->activate_object (server);
+#endif
+
+  std::cout << "Initialised server" << std::endl;
+
+  CORBA::Object_var ref = poa->id_to_reference ( oid.in() );
+  CORBA::String_var str = orb->object_to_string( ref.in() );
+
+  std::cout << "Mapped Corba object to string" << std::endl;
+
+  // Write referene to file
   // write id to "naming service"
   ofstream out ("/tmp/localcorba.objid");
 	if (out.is_open()) {
-		out << ref << endl;
+	  	out << str.in() << std::endl;
 		if (out.fail() || out.bad()) {
-			cout << "Failed " << endl;
+			std::cout << "Failed " << std::endl;
 		}
 		out.close ();
 	}
 	else {
-		cout << "Unable to write string to file /tmp/localcorba.objid" << endl;
-		cout << "Please check the file permissions/ownership" << endl;
+	  	std::cout << "Unable to write string" << str.in() << " to file /tmp/localcorba.objid" << std::endl;
+		std::cout << "Please check the file permissions/ownership" << std::endl;
 		return 0;
 	}
-  cout << "Corba string is " << ref << endl;
-
+	std::cout << "Corba string is " << str.in() << std::endl;
+
+	// Activate the POA and start serving requests
   // indicate readiness and run
+#if defined(USE_POA)
+  mgr->activate ();
+  //poa->the_POAManager()->activate();
+#else
   boa->impl_is_ready( CORBA::ImplementationDef::_nil() );
+#endif
   orb->run ();
+
+#if defined(USE_POA)
+  // Shutdown (never reached)
+  poa->destroy (TRUE, TRUE);
+  delete server; // should I include this????
+#else
   CORBA::release( server );
+#endif
   return 0;
 }
 
-
