Index: greenstone3/trunk/src/java/org/greenstone/gsdl3/action/Action.java
===================================================================
--- greenstone3/trunk/src/java/org/greenstone/gsdl3/action/Action.java	(revision 20381)
+++ greenstone3/trunk/src/java/org/greenstone/gsdl3/action/Action.java	(revision 20402)
@@ -35,18 +35,19 @@
 
     public Action() {
-	this.converter = new XMLConverter();
-	this.doc = this.converter.newDOM();
+        this.converter = new XMLConverter();
+        this.doc = this.converter.newDOM();
     }
+
     /** the config variables must be set before configure is called */
     public void setConfigParams(HashMap params) {
-	this.config_params = params;
+        this.config_params = params;
     }
     /** sets the message router */
     public void setMessageRouter(ModuleInterface m) {
-       this.mr = m;
+        this.mr = m;
     }
     public boolean configure() {
-	// does nothing yet
-	return true;
+        // does nothing yet
+        return true;
     }
     
@@ -56,12 +57,12 @@
     public String process(String xml_in) {
        
-	Document message_doc = this.converter.getDOM(xml_in);
-	if (message_doc == null) {
-	    logger.error("Couldn't parse request");
-	    logger.error(xml_in);
-	    return null;
-	}
-	Node result = process(message_doc);
-	return this.converter.getString(result);
+        Document message_doc = this.converter.getDOM(xml_in);
+        if (message_doc == null) {
+            logger.error("Couldn't parse request");
+            logger.error(xml_in);
+            return null;
+       }
+       Node result = process(message_doc);
+       return this.converter.getString(result);
     }
     
@@ -73,90 +74,95 @@
      * object - particularly important for args that should not be saved */
     public boolean getActionParameters(GSParams params) {
-	return true;
+        return true;
     }
 
     protected void extractMetadataNames(Element format, HashSet meta_names) {
-	//NodeList nodes = format.getElementsByTagNameNS("metadata", "http://www.greenstone.org/configformat");
-	NodeList nodes = format.getElementsByTagName("gsf:metadata");
+    //NodeList nodes = format.getElementsByTagNameNS("metadata", "http://www.greenstone.org/configformat");
+    NodeList nodes = format.getElementsByTagName("gsf:metadata");
         for (int i=0; i<nodes.getLength(); i++) {
-	    Element elem = (Element)nodes.item(i);
-	    StringBuffer metadata = new StringBuffer();
-	    String all = elem.getAttribute("multiple");
-	    String name = elem.getAttribute("name");
-	    String select = elem.getAttribute("select");
-	    String sep = elem.getAttribute("separator");
-	    if (all.equals("true")) {
-		metadata.append("all");
-		metadata.append(GSConstants.META_RELATION_SEP);
-	    }
-	    if (!select.equals("")) {
-		metadata.append(select);
-		metadata.append(GSConstants.META_RELATION_SEP);
-	    }
-	    if (!sep.equals("")) {
-		metadata.append(GSConstants.META_SEPARATOR_SEP);
-		metadata.append(sep);
-		metadata.append(GSConstants.META_SEPARATOR_SEP);
-		metadata.append(GSConstants.META_RELATION_SEP);
-	    }
+            Element elem = (Element)nodes.item(i);
+            StringBuffer metadata = new StringBuffer();
+            String all = elem.getAttribute("multiple");
+            String name = elem.getAttribute("name");
+            String select = elem.getAttribute("select");
+            String sep = elem.getAttribute("separator");
+            if (all.equals("true")) {
+                metadata.append("all");
+                metadata.append(GSConstants.META_RELATION_SEP);
+            }
+            if (!select.equals("")) {
+                metadata.append(select);
+                metadata.append(GSConstants.META_RELATION_SEP);
+            }
+            if (!sep.equals("")) {
+                metadata.append(GSConstants.META_SEPARATOR_SEP);
+                metadata.append(sep);
+                metadata.append(GSConstants.META_SEPARATOR_SEP);
+                metadata.append(GSConstants.META_RELATION_SEP);
+            }
 
-	    metadata.append(name);
-	    meta_names.add(metadata.toString());
-	}
-		
+            metadata.append(name);
+            meta_names.add(metadata.toString());
+        }
     }
 
     protected Element createMetadataParamList(HashSet metadata_names) {
-	Element param_list  = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
-	
-	Element param = null;
-	Iterator i = metadata_names.iterator();
-	while (i.hasNext()) {
-	    String name = (String)i.next();
-	    param = this.doc.createElement(GSXML.PARAM_ELEM);
-	    param_list.appendChild(param);
-	    param.setAttribute(GSXML.NAME_ATT, "metadata");
-	    param.setAttribute(GSXML.VALUE_ATT, name);
-	
-	}
-	return param_list;
+        Element param_list  = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
+        
+        Element param = null;
+        Iterator i = metadata_names.iterator();
+        while (i.hasNext()) {
+            String name = (String)i.next();
+            param = this.doc.createElement(GSXML.PARAM_ELEM);
+            param_list.appendChild(param);
+            param.setAttribute(GSXML.NAME_ATT, "metadata");
+            param.setAttribute(GSXML.VALUE_ATT, name);
+        
+        }
+        return param_list;
     }
 
     protected boolean processErrorElements(Element message, Element page) {
-	NodeList error_nodes = message.getElementsByTagName(GSXML.ERROR_ELEM);
-	if (error_nodes.getLength()==0) {
-	    return false;
-	}
-	Document owner = page.getOwnerDocument();
-	for (int i=0; i<error_nodes.getLength(); i++) {
-	    page.appendChild(owner.importNode(error_nodes.item(i), true));
-	}
-	return true;
+        NodeList error_nodes = message.getElementsByTagName(GSXML.ERROR_ELEM);
+        if (error_nodes.getLength()==0) {
+            return false;
+        }
+        Document owner = page.getOwnerDocument();
+        for (int i=0; i<error_nodes.getLength(); i++) {
+            page.appendChild(owner.importNode(error_nodes.item(i), true));
+        }
+        return true;
     }
 
-	void addSiteMetadata( Element element, String lang, String uid ) {
-		//ADD SITE METADATA
-		Element metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", lang, uid);
-		//create a hashmap of params
-		HashMap subset_params = new HashMap(1);
-		subset_params.put(GSXML.SUBSET_PARAM, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
-		//create the element to put the params in
-		Element param_list = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
-		//put them in
-		GSXML.addParametersToList( this.doc, param_list, subset_params );
-		metadata_request.appendChild(param_list);
-		//create the message
-		Element metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		metadata_message.appendChild(metadata_request);
+    /**
+     * Takes an XML element and adds the metadata of the current site to it.
+     * Useful for adding the current site's metadata to a response before sending it
+     *
+     * @param  element   the element to add site metadata to
+     * @param  lang      the current language
+     * @param  uid       the current user id
+     */
+    void addSiteMetadata( Element element, String lang, String uid ) {
+        //ADD SITE METADATA
+        Element metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", lang, uid);
+        //create a hashmap of params
+        HashMap subset_params = new HashMap(1);
+        subset_params.put(GSXML.SUBSET_PARAM, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
+        //create the element to put the params in
+        Element param_list = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
+        //put them in
+        GSXML.addParametersToList( this.doc, param_list, subset_params );
+        metadata_request.appendChild(param_list);
+        //create the message
+        Element metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+        metadata_message.appendChild(metadata_request);
+        //get response
+        Element metadata_response_message = (Element)this.mr.process(metadata_message);
+        //drill down to response
+        Element metadata_response = (Element)GSXML.getChildByTagName(metadata_response_message, GSXML.RESPONSE_ELEM);
+        //merge in metadata
+        GSXML.mergeMetadataLists(element,metadata_response);
+    }
 
-		//get response
-		Element metadata_response_message = (Element)this.mr.process(metadata_message);
-
-		//drill down to response
-		Element metadata_response = (Element)GSXML.getChildByTagName(metadata_response_message, GSXML.RESPONSE_ELEM);
-
-		GSXML.mergeMetadataLists(element,metadata_response);
-
-	}
 }
 
