Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java	(revision 24887)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java	(revision 24888)
@@ -167,12 +167,22 @@
 	protected Element processActivateCollection(Element request)
 	{
-		Element response = runCommand(request, GS2PerlConstructor.ACTIVATE);
 		// this activates the collection on disk. but now we need to tell
 		// the MR about it. but we have to wait until the process is finished.
-		Element status = (Element) GSXML.getChildByTagName(response, GSXML.STATUS_ELEM);
 		Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 		HashMap params = GSXML.extractParams(param_list, false);
 		String coll_name = (String) params.get(COL_PARAM);
 		String lang = request.getAttribute(GSXML.LANG_ATT);
+
+		systemRequest("delete", coll_name, null, lang);
+
+		Element response = runCommand(request, GS2PerlConstructor.ACTIVATE);
+		Element status = (Element) GSXML.getChildByTagName(response, GSXML.STATUS_ELEM);
+
+		String request_type = request.getAttribute(GSXML.TYPE_ATT);
+		if (request_type.equals(GSXML.REQUEST_TYPE_STATUS))
+		{
+			return response;
+		}
+
 		// check for finished
 		int status_code = Integer.parseInt(status.getAttribute(GSXML.STATUS_ERROR_CODE_ATT));
@@ -320,5 +330,4 @@
 	protected void systemRequest(String action_name, String coll_name, Element status, String lang)
 	{
-
 		// send the request to the MR
 		Element message = this.doc.createElement(GSXML.MESSAGE_ELEM);
@@ -348,16 +357,19 @@
 		String[] args = { coll_name };
 
-		if (response == null)
-		{
-			t = this.doc.createTextNode(getTextString(action_name + ".configure_error", lang, args));
-			status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
+		if (status != null)
+		{
+			if (response == null)
+			{
+				t = this.doc.createTextNode(getTextString(action_name + ".configure_error", lang, args));
+				status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
+				status.appendChild(t);
+				return;
+			}
+
+			// if we got here, we have succeeded!
+			t = this.doc.createTextNode(getTextString(action_name + ".success", lang, args));
+			status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.SUCCESS));
 			status.appendChild(t);
-			return;
-		}
-
-		// if we got here, we have succeeded!
-		t = this.doc.createTextNode(getTextString(action_name + ".success", lang, args));
-		status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.SUCCESS));
-		status.appendChild(t);
+		}
 	}
 
@@ -421,5 +433,4 @@
 	protected Element runCommand(Element request, int type)
 	{
-
 		// the response to send back
 		String name = GSPath.getFirstLink(request.getAttribute(GSXML.TO_ATT));
@@ -430,4 +441,5 @@
 
 		String lang = request.getAttribute(GSXML.LANG_ATT);
+		String uid = request.getAttribute(GSXML.USER_ID_ATT);
 		String request_type = request.getAttribute(GSXML.TYPE_ATT);
 
@@ -479,10 +491,9 @@
 			coll_name = (String) params.get(COL_PARAM);
 		}
-		logger.error("Coll name = " + coll_name);
+		logger.info("Coll name = " + coll_name);
 		// makes a paramList of the relevant params
 		Element other_params = extractOtherParams(params, type);
 
 		//create the constructor to do the work
-
 		GS2PerlConstructor constructor = new GS2PerlConstructor("perl_build");
 		if (!constructor.configure())
@@ -494,10 +505,10 @@
 		}
 
+		GS2PerlListener listener = new GS2PerlListener();
 		constructor.setSiteHome(this.site_home);
 		constructor.setCollectionName(coll_name);
 		constructor.setActionType(type);
 		constructor.setProcessParams(other_params);
-		// the listener
-		GS2PerlListener listener = new GS2PerlListener();
+
 		constructor.addListener(listener);
 		constructor.start();
@@ -511,5 +522,4 @@
 		status.appendChild(t);
 		return response;
-
 	}
 
