Index: main/trunk/greenstone2/perllib/servercontrol.pm
===================================================================
--- main/trunk/greenstone2/perllib/servercontrol.pm	(revision 32829)
+++ main/trunk/greenstone2/perllib/servercontrol.pm	(revision 32830)
@@ -117,8 +117,11 @@
 sub config {
     my $self = shift(@_);
-    my ($command, $check_message_against_regex, $expected_error_code, $silent) = @_;
+    my ($command, $check_message_against_regex, $expected_error_code, $silent, $oai_servlet) = @_;
 
     my $library_url = $self->get_library_URL(); #$self->{'library_url'};
-
+	if($oai_servlet) { # if asked to contact the oaiserver servlet, then
+		# replace the library servlet name with oaiserver servlet name
+		$library_url =~ s@([^/]*?)$@$oai_servlet@;
+	}
 
     # Gatherer.java's configGS3Server doesn't use the site variable
@@ -279,7 +282,15 @@
     }
     elsif ($gs_mode eq "gs3") {
+	$self->print_msg("\t- Main library servlet\n");	
 	my $DEACTIVATE_COMMAND = "?a=s&sa=d&st=collection&sn=";
 	my $check_message_against_regex = "collection: $qualified_collection deactivated";
 	$self->config($DEACTIVATE_COMMAND.$qualified_collection, $check_message_against_regex);
+	
+	# and deactivate the collection on OAIserver url too.
+	# NOTE: if it's not an OAI collection, then the message that the collection is "not enabled for OAI" is EXPECTED. Another possible valid outcome.
+	$self->print_msg("\t- OAI servlet\n");	
+	$DEACTIVATE_COMMAND = "?deactivate=";
+	$check_message_against_regex = "(collection\: $qualified_collection deactivated|collection\: $qualified_collection is not enabled for OAI.)";
+	$self->config($DEACTIVATE_COMMAND.$qualified_collection, $check_message_against_regex, undef, undef, "oaiserver");
     }	
 }
@@ -297,7 +308,15 @@
     }
     elsif ($gs_mode eq "gs3") {
+	$self->print_msg("\t- Main library servlet\n");	
 	my $ACTIVATE_COMMAND = "?a=s&sa=a&st=collection&sn=";
 	my $check_message_against_regex = "collection: $qualified_collection activated";
 	$self->config($ACTIVATE_COMMAND.$qualified_collection, $check_message_against_regex);
+	
+	# and activate the collection on OAIserver url too.
+	# NOTE: if it's not an OAI collection, then the message that the collection is "not enabled for OAI" is EXPECTED. Another possible valid outcome.
+	$self->print_msg("\t- OAI servlet\n");	
+	$ACTIVATE_COMMAND = "?activate=";
+	$check_message_against_regex = "(collection\: $qualified_collection activated|collection\: $qualified_collection is not enabled for OAI.)";
+	$self->config($ACTIVATE_COMMAND.$qualified_collection, $check_message_against_regex, undef, undef, "oaiserver");
     }	
 }
@@ -544,8 +563,11 @@
 sub config_old {
     my $self = shift(@_);
-    my ($command, $check_message_against_regex, $expected_error_code, $silent) = @_;
+    my ($command, $check_message_against_regex, $expected_error_code, $silent, $oai_servlet) = @_;
 
     my $library_url = $self->get_library_URL(); #$self->{'library_url'};
-
+	if($oai_servlet) { # if asked to contact the oaiserver servlet, then
+		# replace the library servlet name with oaiserver servlet name
+		$library_url =~ s@([^/]*?)$@$oai_servlet@;
+	}
 
     # Gatherer.java's configGS3Server doesn't use the site variable
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/OAIServer.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/OAIServer.java	(revision 32829)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/OAIServer.java	(revision 32830)
@@ -140,5 +140,5 @@
 		this.recept = new OAIReceptionist();
 
-		// the receptionist uses a OAIMessageRouter or Communicator to send its requests to. We either create a OAIMessageRouter here for the designated site (if site_name set), or we create a Communicator for a remote site. The is given to teh Receptionist, and the servlet never talks to it again.directly.
+		// the receptionist uses a OAIMessageRouter or Communicator to send its requests to. We either create a OAIMessageRouter here for the designated site (if site_name set), or we create a Communicator for a remote site. The is given to the Receptionist, and the servlet never talks to it again directly.
 		if (site_name != null)
 		{
@@ -342,5 +342,5 @@
 
 		if (query!=null && query.equals("reset")) {
-		  logger.error("reset was called*******************");
+		  logger.info("reset was called*******************");
 		  out.println("<?xml version='1.0' encoding='UTF-8' ?>");
 		  out.println(this.recept.process("<message><request reset='true'/></message>"));
@@ -348,4 +348,28 @@
 		}
 		String[] pairs = (query == null) ? null : query.split("&");//split into key/value pairs
+		
+		// besides "reset", the only other non-verb (non-OAI) requests allowed would be: (de)activate="collName"
+		if(pairs.length == 1) {
+			String command = pairs[0];
+			int index = command.indexOf('=');
+			if(index != -1) {
+				String collName = command.substring(index+1);
+				command = command.substring(0, index);
+				if(command.equals(GSXML.SYSTEM_TYPE_ACTIVATE)) {
+					logger.info("activating OAI collection " + collName + " was called*******************");
+					out.println("<?xml version='1.0' encoding='UTF-8' ?>");
+					out.println(this.recept.process("<message><request " + GSXML.SYSTEM_TYPE_ACTIVATE+"='"+collName+"'/></message>"));
+					return;
+					
+				} else if(command.equals(GSXML.SYSTEM_TYPE_DEACTIVATE)) {
+					logger.info("deactivating OAI collection " + collName + " was called*******************");
+					out.println("<?xml version='1.0' encoding='UTF-8' ?>");
+					out.println(this.recept.process("<message><request " + GSXML.SYSTEM_TYPE_DEACTIVATE+"='"+collName+"'/></message>"));
+					return;
+				}
+			}
+			// any other format for activate/deactivate command in query is wrong, continue processing and fail with "badVerb" message:
+		}
+		
 		
 		String verb = getVerb(query);
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/OAIReceptionist.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/OAIReceptionist.java	(revision 32829)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/OAIReceptionist.java	(revision 32830)
@@ -297,4 +297,40 @@
     logger.info("*** configure response = "+XMLConverter.getPrettyString(response));
   }
+  
+  protected boolean activateOrDeactivateCollection(String collName, int activationState) {
+    // Send a request like: a=s&sa=<a|d>&st=collection&sn=<collName>
+    Document doc = XMLConverter.newDOM();
+    Element mr_request_message = doc.createElement(GSXML.MESSAGE_ELEM);
+    Element mr_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_SYSTEM, "", null);
+    mr_request_message.appendChild(mr_request);
+    
+    Element system = doc.createElement(GSXML.SYSTEM_ELEM);
+    mr_request.appendChild(system);
+	if(activationState == OAIXML.ACTIVATION) {
+		system.setAttribute(GSXML.TYPE_ATT, GSXML.SYSTEM_TYPE_ACTIVATE);
+	} else {
+		system.setAttribute(GSXML.TYPE_ATT, GSXML.SYSTEM_TYPE_DEACTIVATE);
+	}
+	system.setAttribute(GSXML.SYSTEM_MODULE_TYPE_ATT, GSXML.COLLECTION_ELEM);
+	system.setAttribute(GSXML.SYSTEM_MODULE_NAME_ATT, collName);
+
+    Element response = (Element) this.mr.process(mr_request_message);
+    logger.info("*** (de)activate response = "+XMLConverter.getPrettyString(response));
+	
+	boolean success = false;
+	NodeList elements = response.getElementsByTagName(GSXML.STATUS_ELEM);
+	if(elements.getLength() <= 0) {
+		logger.error("***** No result status");
+		return false;
+	}
+	
+	String result = GSXML.getNodeText((Element)elements.item(0));
+	if(result.contains("could not be")) { // could not be (de)activated
+		return false;
+	} else {
+		return true;
+	}
+  }
+  
   /** process using strings - just calls process using Elements */
   public String process(String xml_in) {
@@ -337,4 +373,5 @@
     }
 
+	// Special cases: certain non-OAI commands/non-verbs are recognised
     // special case, reset=true for reloading the MR and recept data
     String reset = request.getAttribute("reset");
@@ -344,5 +381,23 @@
       return OAIXML.createResetResponse(true);
     }
-
+	
+	// special case 2: activate=<collname> or deactivate=<collname> can be passed to oaiserver servlet too
+    if (request.hasAttribute(GSXML.SYSTEM_TYPE_ACTIVATE)) {		
+		String collname = request.getAttribute(GSXML.SYSTEM_TYPE_ACTIVATE);
+		// don't bother activating if it's not an OAI collection
+		if (!this.set_set.contains(collname)) {
+			return OAIXML.createDeActivationOfNonOAICollResponse(OAIXML.ACTIVATION, collname);
+		}
+		boolean success = activateOrDeactivateCollection(collname, OAIXML.ACTIVATION);
+		return OAIXML.createActivationStateResponse(success, OAIXML.ACTIVATION, collname);
+    } else if (request.hasAttribute(GSXML.SYSTEM_TYPE_DEACTIVATE)) {
+		String collname = request.getAttribute(GSXML.SYSTEM_TYPE_DEACTIVATE);
+		// don't bother deactivating if it's not an OAI collection
+		if (!this.set_set.contains(collname)) {
+			return OAIXML.createDeActivationOfNonOAICollResponse(OAIXML.DEACTIVATION, collname);
+		}
+		boolean success = activateOrDeactivateCollection(collname, OAIXML.DEACTIVATION);
+		return OAIXML.createActivationStateResponse(success, OAIXML.DEACTIVATION, collname);
+    }
     
     //At this stage, the value of 'to' attribute of the request must be the 'verb'
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/OAIXML.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/OAIXML.java	(revision 32829)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/OAIXML.java	(revision 32830)
@@ -40,4 +40,8 @@
   public static final String VERB = "verb";
 
+  // Possible states for non-OAI/non-verb activate/deactivate requests  
+  public static final int DEACTIVATION = 0;
+  public static final int ACTIVATION = 1;
+  
   // six valid oai verbs
   public static final String GET_RECORD = "GetRecord";
@@ -383,4 +387,44 @@
   }
 
+  // This is the response message sent when there's a request to activate/deactivate a non-OAI collection
+  // A request to activate a non-existent/non-OAI collection is not invalid, it's just that we won't process it.
+  // So we still return status code OK (OK status code is needed for servercontrol.pm of activate.pl to recognise
+  // that the command had been "successful" when it runs de/activate).
+  public static Element createDeActivationOfNonOAICollResponse(int activationState, String collname) {
+	Document doc = converter.newDOM();
+    Element response = doc.createElement(GSXML.RESPONSE_ELEM);
+	response.setAttribute("status", "OK"); 
+	String message = "collection: " + collname + " is not enabled for OAI.";
+	if(activationState == ACTIVATION) {
+		message += " Not attempting to activate it.";
+	  } else {
+		message += " Not attempting to deactivate it.";
+	  }
+	  GSXML.setNodeText(response, message);
+	  return response;
+  }
+  
+  // The response message sent when a request comes in to activate/deactivate a proper OAI collection.
+   public static Element createActivationStateResponse(boolean success, int activationState, String collname) {
+    Document doc = converter.newDOM();
+    Element response = doc.createElement(GSXML.RESPONSE_ELEM);
+    if (success) {
+      response.setAttribute("status", "OK");
+	  if(activationState == ACTIVATION) {
+		GSXML.setNodeText(response, "collection: " + collname + " activated");
+	  } else {
+		GSXML.setNodeText(response, "collection: " + collname + " deactivated");  
+	  }
+    } else {
+      response.setAttribute("status", "FAIL");
+	  if(activationState == ACTIVATION) {
+		GSXML.setNodeText(response, "Failed to activate collection " + collname);
+	  } else {
+		GSXML.setNodeText(response, "Failed to deactivate collection " + collname);
+	  }
+    }
+    return response;
+  }
+  
   public static Element createResetResponse(boolean success) {
     Document doc = converter.newDOM();
