Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/PageAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/PageAction.java	(revision 24988)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/PageAction.java	(revision 24989)
@@ -5,5 +5,5 @@
 import org.greenstone.gsdl3.util.*;
 //XML classes
-import org.w3c.dom.Node; 
+import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.Document;
@@ -15,5 +15,6 @@
 import org.apache.log4j.*;
 
-public class PageAction extends Action {
+public class PageAction extends Action
+{
 
 	static Logger logger = Logger.getLogger(org.greenstone.gsdl3.action.PageAction.class.getName());
@@ -22,40 +23,49 @@
 	public static final String ABOUT_PAGE = "about";
 	public static final String PREFS_PAGE = "pref";
-	public static final String GLI4GS3_PAGE="gli4gs3";
-
-	public Node process (Node message_node) {
-
-	    Element message = this.converter.nodeToElement(message_node);
-
-	    Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
-	    // the page name is the subaction
-	    String page_name = request.getAttribute(GSXML.SUBACTION_ATT);
-	    if (page_name.equals("")) { // if no page specified, assume home page
-		page_name = HOME_PAGE;
-	    }
-	    Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
-	    Element response;
-	    if (page_name.equals(HOME_PAGE)) {
-		response = homePage(request);
-		//} else if (page_name.equals(ABOUT_PAGE)) {
-	    } else if (page_name.equals(ABOUT_PAGE) || page_name.equals(PREFS_PAGE)) {
-		response = aboutPage(request);
-		//}else if (page_name.equals(PREFS_PAGE)) {
-		//response = prefsPage(request);
-	    } else if (page_name.equals(GLI4GS3_PAGE)){
-		response = gli4gs3Page(request);
-	    }else { // unknown page
-		
-		logger.error("unknown page specified!");
-		response =  unknownPage(request);
-	    }
-	    
-	    result.appendChild(this.doc.importNode(response, true));
-	    logger.debug("page action result: "+this.converter.getPrettyString(result));
-	    return result;
-	}
-    
-
-	protected Element homePage(Element request) {
+	public static final String GLI4GS3_PAGE = "gli4gs3";
+
+	public Node process(Node message_node)
+	{
+
+		Element message = this.converter.nodeToElement(message_node);
+
+		Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
+		// the page name is the subaction
+		String page_name = request.getAttribute(GSXML.SUBACTION_ATT);
+		if (page_name.equals(""))
+		{ // if no page specified, assume home page
+			page_name = HOME_PAGE;
+		}
+		Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element response;
+		if (page_name.equals(HOME_PAGE))
+		{
+			response = homePage(request);
+			//} else if (page_name.equals(ABOUT_PAGE)) {
+		}
+		else if (page_name.equals(ABOUT_PAGE) || page_name.equals(PREFS_PAGE))
+		{
+			response = aboutPage(request);
+			//}else if (page_name.equals(PREFS_PAGE)) {
+			//response = prefsPage(request);
+		}
+		else if (page_name.equals(GLI4GS3_PAGE))
+		{
+			response = gli4gs3Page(request);
+		}
+		else
+		{ // unknown page
+
+			logger.error("unknown page specified!");
+			response = unknownPage(request);
+		}
+
+		result.appendChild(this.doc.importNode(response, true));
+		logger.debug("page action result: " + this.converter.getPrettyString(result));
+		return result;
+	}
+
+	protected Element homePage(Element request)
+	{
 
 		String lang = request.getAttribute(GSXML.LANG_ATT);
@@ -65,11 +75,13 @@
 		Element coll_list_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", lang, uid);
 		info_message.appendChild(coll_list_request);
-		Element info_response_message = (Element)this.mr.process(info_message);
-		if (info_response_message==null) {
+		Element info_response_message = (Element) this.mr.process(info_message);
+		if (info_response_message == null)
+		{
 			logger.error(" couldn't query the message router!");
 			return null;
 		}
-		Element info_response = (Element)GSXML.getChildByTagName(info_response_message, GSXML.RESPONSE_ELEM);
-		if (info_response==null) {
+		Element info_response = (Element) GSXML.getChildByTagName(info_response_message, GSXML.RESPONSE_ELEM);
+		if (info_response == null)
+		{
 			logger.error("couldn't query the message router!");
 			return null;
@@ -78,9 +90,11 @@
 		// second, get the metadata for each collection - we only want specific
 		// elements but for now, we'll just get it all
-		Element collection_list = (Element)GSXML.getChildByTagName(info_response, GSXML.COLLECTION_ELEM+GSXML.LIST_MODIFIER);
+		Element collection_list = (Element) GSXML.getChildByTagName(info_response, GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER);
 		logger.debug(GSXML.xmlNodeToString(collection_list, false));
-		if (collection_list != null) {
+		if (collection_list != null)
+		{
 			NodeList colls = GSXML.getChildrenByTagName(collection_list, GSXML.COLLECTION_ELEM);
-			if (colls.getLength()>0) {
+			if (colls.getLength() > 0)
+			{
 				sendMultipleRequests(colls, null, GSXML.REQUEST_TYPE_DESCRIBE, lang, uid);
 			}
@@ -88,8 +102,10 @@
 
 		// get metadata for any services
-		Element service_list = (Element)GSXML.getChildByTagName(info_response, GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER);
-		if (service_list != null) {
+		Element service_list = (Element) GSXML.getChildByTagName(info_response, GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER);
+		if (service_list != null)
+		{
 			NodeList services = GSXML.getChildrenByTagName(service_list, GSXML.SERVICE_ELEM);
-			if (services.getLength() > 0) {
+			if (services.getLength() > 0)
+			{
 				sendMultipleRequests(services, null, GSXML.REQUEST_TYPE_DESCRIBE, lang, uid);
 			}
@@ -97,8 +113,10 @@
 
 		// get metadata for service clusters
-		Element cluster_list = (Element)GSXML.getChildByTagName(info_response, GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER);
-		if (cluster_list != null) {
+		Element cluster_list = (Element) GSXML.getChildByTagName(info_response, GSXML.CLUSTER_ELEM + GSXML.LIST_MODIFIER);
+		if (cluster_list != null)
+		{
 			NodeList clusters = GSXML.getChildrenByTagName(cluster_list, GSXML.CLUSTER_ELEM);
-			if (clusters.getLength() > 0) {
+			if (clusters.getLength() > 0)
+			{
 				sendMultipleRequests(clusters, null, GSXML.REQUEST_TYPE_DESCRIBE, lang, uid);
 
@@ -111,14 +129,16 @@
 	} // homePage
 
-	protected Element aboutPage(Element request) {
+	protected Element aboutPage(Element request)
+	{
 
 		String lang = request.getAttribute(GSXML.LANG_ATT);
 		String uid = request.getAttribute(GSXML.USER_ID_ATT);
 		// extract the params from the cgi-request, 
-		Element cgi_paramList = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
+		Element cgi_paramList = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 		HashMap params = GSXML.extractParams(cgi_paramList, false);
-		
-		String coll_name = (String)params.get(GSParams.COLLECTION);
-		if (coll_name == null || coll_name.equals("")) {
+
+		String coll_name = (String) params.get(GSParams.COLLECTION);
+		if (coll_name == null || coll_name.equals(""))
+		{
 			logger.error("about page requested with no collection or cluster specified!");
 			// return an empty response
@@ -133,38 +153,47 @@
 		Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, lang, uid);
 		coll_about_message.appendChild(coll_about_request);
-		Element coll_about_response = (Element)this.mr.process(coll_about_message);
+		Element coll_about_response = (Element) this.mr.process(coll_about_message);
 
 		// add collection type attribute to paramList
 		String col_type = "";
-		NodeList collect_elem = coll_about_response.getElementsByTagName(GSXML.COLLECTION_ELEM);	
-		if(collect_elem.getLength() != 0) {
-			for (int i=0; i < collect_elem.getLength(); i++) {
-		      Element e = (Element) collect_elem.item(i);
-			  col_type = e.getAttribute(GSXML.TYPE_ATT);
-			}	
-		} else {
+		NodeList collect_elem = coll_about_response.getElementsByTagName(GSXML.COLLECTION_ELEM);
+		if (collect_elem.getLength() != 0)
+		{
+			for (int i = 0; i < collect_elem.getLength(); i++)
+			{
+				Element e = (Element) collect_elem.item(i);
+				col_type = e.getAttribute(GSXML.TYPE_ATT);
+			}
+		}
+		else
+		{
 			logger.error(GSXML.COLLECTION_ELEM + " element is null");
 		}
-				
-		NodeList paramList = request.getElementsByTagName(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);	
-		if(paramList.getLength() != 0) {
-			for (int i=0; i<paramList.getLength(); i++) {
-		      Element e = (Element) paramList.item(i);		      			  		      
-		      Element ct = GSXML.createParameter(request.getOwnerDocument(), GSParams.COLLECTION_TYPE, col_type.equalsIgnoreCase("mg") ? "0" : "1");
-			  e.appendChild(ct);
-			}	
-		} else {
+
+		NodeList paramList = request.getElementsByTagName(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		if (paramList.getLength() != 0)
+		{
+			for (int i = 0; i < paramList.getLength(); i++)
+			{
+				Element e = (Element) paramList.item(i);
+				Element ct = GSXML.createParameter(request.getOwnerDocument(), GSParams.COLLECTION_TYPE, col_type.equalsIgnoreCase("mg") ? "0" : "1");
+				e.appendChild(ct);
+			}
+		}
+		else
+		{
 			logger.info("paramList is null!!");
-		}	
-				
-		if (coll_about_response == null) {
+		}
+
+		if (coll_about_response == null)
+		{
 			return null;
 		}
-
 
 		// second, get the info for each service - we only want display items 
 		// but for now, we'll just get it all
 		NodeList services = coll_about_response.getElementsByTagName(GSXML.SERVICE_ELEM);
-		if (services.getLength() > 0) {
+		if (services.getLength() > 0)
+		{
 			sendMultipleRequests(services, coll_name, GSXML.REQUEST_TYPE_DESCRIBE, lang, uid);
 		}
@@ -175,12 +204,13 @@
 		return response;
 	}
-	
+
 	//protected Element prefsPage(Element request) {
-	
+
 	//	return null;
 	//}
-	
+
 	/** if we dont know the page type, use this method */
-	protected Element unknownPage(Element request) {
+	protected Element unknownPage(Element request)
+	{
 
 		String lang = request.getAttribute(GSXML.LANG_ATT);
@@ -189,9 +219,10 @@
 
 		// extract the params from the cgi-request, 
-		Element cgi_paramList = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
+		Element cgi_paramList = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 		HashMap params = GSXML.extractParams(cgi_paramList, false);
 
-		String coll_name = (String)params.get(GSParams.COLLECTION);
-		if (coll_name == null || coll_name.equals("")) {
+		String coll_name = (String) params.get(GSParams.COLLECTION);
+		if (coll_name == null || coll_name.equals(""))
+		{
 			// just return an empty response
 			Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
@@ -206,8 +237,8 @@
 		Element coll_about_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
 
-		Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE,  coll_name, lang, uid);
+		Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, lang, uid);
 		coll_about_message.appendChild(coll_about_request);
-		
-		Element coll_about_response = (Element)this.mr.process(coll_about_message);
+
+		Element coll_about_response = (Element) this.mr.process(coll_about_message);
 
 		Element response = (Element) GSXML.getChildByTagName(coll_about_response, GSXML.RESPONSE_ELEM);
@@ -220,13 +251,15 @@
 	}
 
-
-	protected boolean sendMultipleRequests(NodeList items, String path_prefix, String request_type, String lang, String uid) {
+	protected boolean sendMultipleRequests(NodeList items, String path_prefix, String request_type, String lang, String uid)
+	{
 
 		// we will send all the requests in a single message
 		Element message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		for (int i=0; i<items.getLength(); i++) {
-			Element c = (Element)items.item(i);
-			String path = c.getAttribute(GSXML.NAME_ATT);	    
-			if (path_prefix != null) {
+		for (int i = 0; i < items.getLength(); i++)
+		{
+			Element c = (Element) items.item(i);
+			String path = c.getAttribute(GSXML.NAME_ATT);
+			if (path_prefix != null)
+			{
 				path = GSPath.appendLink(path_prefix, path);
 			}
@@ -234,24 +267,29 @@
 			message.appendChild(request);
 		}
-		
-		Element response_message = (Element)this.mr.process(message);
+
+		Element response_message = (Element) this.mr.process(message);
 
 		NodeList responses = response_message.getElementsByTagName(GSXML.RESPONSE_ELEM);
 		// check that have same number of responses as requests
-		if (items.getLength() != responses.getLength()) {
+		if (items.getLength() != responses.getLength())
+		{
 			logger.error("didn't get a response for each request - somethings gone wrong!");
 			return false;
-		} 
-
-		for (int i=0; i<items.getLength(); i++) {
-			Element c1 = (Element)items.item(i);
-			Element c2 = (Element)GSXML.getChildByTagName((Element)responses.item(i), c1.getTagName());
-			if (c1 != null && c2 !=null && c1.getAttribute(GSXML.NAME_ATT).endsWith(c2.getAttribute(GSXML.NAME_ATT))) {
+		}
+
+		for (int i = 0; i < items.getLength(); i++)
+		{
+			Element c1 = (Element) items.item(i);
+			Element c2 = (Element) GSXML.getChildByTagName((Element) responses.item(i), c1.getTagName());
+			if (c1 != null && c2 != null && c1.getAttribute(GSXML.NAME_ATT).endsWith(c2.getAttribute(GSXML.NAME_ATT)))
+			{
 				//add the new data into the original element
 				GSXML.mergeElements(c1, c2);
-			} else {
+			}
+			else
+			{
 				logger.debug(" response does not correspond to request!");
-			} 
-			
+			}
+
 		}
 
@@ -260,5 +298,6 @@
 	}
 
-	protected Element gli4gs3Page(Element request) {
+	protected Element gli4gs3Page(Element request)
+	{
 		String lang = request.getAttribute(GSXML.LANG_ATT);
 		String uid = request.getAttribute(GSXML.USER_ID_ATT);
@@ -268,18 +307,18 @@
 		Element applet_elem = this.doc.createElement("Applet");
 		page_response.appendChild(applet_elem);
-		applet_elem.setAttribute("ARCHIVE","SignedGatherer.jar");
-		applet_elem.setAttribute("CODE","org.greenstone.gatherer.GathererApplet");
-		applet_elem.setAttribute("CODEBASE","applet");
-		applet_elem.setAttribute("HEIGHT","50");
-		applet_elem.setAttribute("WIDTH","380");
-		Element gwcgi_param_elem= this.doc.createElement("PARAM");
-		gwcgi_param_elem.setAttribute("name","gwcgi");
-		String library_name=GlobalProperties.getGSDL3WebAddress();
-		gwcgi_param_elem.setAttribute("value",library_name);
+		applet_elem.setAttribute("ARCHIVE", "SignedGatherer.jar");
+		applet_elem.setAttribute("CODE", "org.greenstone.gatherer.GathererApplet");
+		applet_elem.setAttribute("CODEBASE", "applet");
+		applet_elem.setAttribute("HEIGHT", "50");
+		applet_elem.setAttribute("WIDTH", "380");
+		Element gwcgi_param_elem = this.doc.createElement("PARAM");
+		gwcgi_param_elem.setAttribute("name", "gwcgi");
+		String library_name = GlobalProperties.getGSDL3WebAddress();
+		gwcgi_param_elem.setAttribute("value", library_name);
 		applet_elem.appendChild(gwcgi_param_elem);
 
-		Element gsdl3_param_elem= this.doc.createElement("PARAM");
-		gsdl3_param_elem.setAttribute("name","gsdl3");
-		gsdl3_param_elem.setAttribute("value","true");
+		Element gsdl3_param_elem = this.doc.createElement("PARAM");
+		gsdl3_param_elem.setAttribute("name", "gsdl3");
+		gsdl3_param_elem.setAttribute("value", "true");
 		applet_elem.appendChild(gsdl3_param_elem);
 
@@ -287,4 +326,3 @@
 	}
 
-
 }
