Index: main/trunk/gli/src/org/greenstone/gatherer/gui/DownloadPane.java
===================================================================
--- main/trunk/gli/src/org/greenstone/gatherer/gui/DownloadPane.java	(revision 29972)
+++ main/trunk/gli/src/org/greenstone/gatherer/gui/DownloadPane.java	(revision 29974)
@@ -101,9 +101,14 @@
 	list_scroll = getter.getDownloadJobList();      
         list_scroll.setComponentOrientation(Dictionary.getOrientation());
+
 	// TODO should use Vector to store all loaded downloads!!
 	String lang = Configuration.getLanguage();
 	download_map = new HashMap();
 
-	ArrayList<String> downloaderNamesList = getDownloads(lang);	
+	// run downloadinfo.pl -describeall, load the downloaders into the download_map, 
+	// and get back their list of names, which are of the form "<downloader>Download". 
+	// Store these names in the CONTENTS[] array as "DOWNLOAD.MODE.<downloader>Download", 
+	// with z3950 as a minor exception: DOWNLOAD.MODE.ZDownload.
+	ArrayList<String> downloaderNamesList = loadDownloadersInfo(lang);	
 	int size = downloaderNamesList.size();
 	CONTENTS = new String[size];
@@ -112,7 +117,4 @@
 	    CONTENTS[i] = "DOWNLOAD.MODE."+downloadName.replace("3950", ""); // A special case is Z3950Download,
 	                                 // which has to be stored in CONTENTS array as DOWNLOAD.MODE.ZDownload
-
-	    String shortName = downloadName.replace("Download", ""); // e.g. "Web"
-	    download_map.put(shortName, loadDownload(downloadName,lang));	    
 	}
 
@@ -200,5 +202,6 @@
 	add(list_scroll);
 
-	mode = "Web";
+	//set the mode to the first downloader in the list
+	mode = convertCONTENTStoMode(CONTENTS[0]); // e.g. Web
 	generateOptions(options_pane,(Download)download_map.get(mode));
 	previous_path = tree.getSelectionPath();
@@ -233,6 +236,6 @@
     }
 
-    private ArrayList<String> getDownloads(String lang) {
-	ArrayList downloaders = null;
+    /** Supporting Functions */
+    private ArrayList<String> loadDownloadersInfo(String lang) {
 	Document document = null;
 	Process process = null;
@@ -240,5 +243,5 @@
 	try {
 	    if (Gatherer.isGsdlRemote) {
-		String output = Gatherer.remoteGreenstoneServer.getScriptOptions("downloadinfo.pl", "&listall");
+		String output = Gatherer.remoteGreenstoneServer.getScriptOptions("downloadinfo.pl", "&describeall");
 		Reader reader = new StringReader(output);
 		document = XMLTools.parseXML(reader);
@@ -256,5 +259,5 @@
 		args_list.add("-S");
 		args_list.add(LocalGreenstone.getBinScriptDirectoryPath()+"downloadinfo.pl");
-		args_list.add("-listall");
+		args_list.add("-describeall");
 		args_list.add("-xml");
 		args_list.add("-language");
@@ -274,5 +277,5 @@
 	}
 	catch (Exception error) {
-	    System.err.println("Failed when trying to parse downloadinfo.pl -listall");
+	    System.err.println("Failed when trying to parse downloadinfo.pl -describeall");
 	    error.printStackTrace();
 	} 
@@ -282,30 +285,44 @@
 
 	if(document != null) {
-	    //return parseXML(document.getDocumentElement());
-	    Element downloadList = document.getDocumentElement();
-	    int length = -1;
-	    if(downloadList.hasAttribute("length")) {
-		length = Integer.parseInt(downloadList.getAttribute("length"));
-		downloaders = new ArrayList<String>(length);		
-
-		for (Node node = downloadList.getFirstChild(); node != null; node = node.getNextSibling()) {
-		    // goes through each <DownloadInfo> of listAll
-
-		    String download_name = null;
-
-		    for(Node infoNode = node.getFirstChild(); 
-			infoNode != null; infoNode = infoNode.getNextSibling()) {
-
-			String node_name = infoNode.getNodeName();
-			if(node_name.equalsIgnoreCase("Name")) { // <Name>WebDownload</Name>
-			    download_name = XMLTools.getValue(infoNode);			
-			}
-			// skip all the downloaders that are Abstract, as these are pure superclasses
-			else if(node_name.equalsIgnoreCase("Abstract")) {
-			    String isAbstract = XMLTools.getValue(infoNode);
+	    return parseXML(document.getDocumentElement());
+	}
+
+	return null;
+    }
+
+    private ArrayList<String> parseXML(Node root) {
+	ArrayList<String> downloaders = null;
+	Element downloadList = (Element)root;
+	int length = -1;
+	if(downloadList.hasAttribute("length")) {
+	    length = Integer.parseInt(downloadList.getAttribute("length"));
+	    downloaders = new ArrayList<String>(length);		
+	    
+	    for (Node node = downloadList.getFirstChild(); node != null; node = node.getNextSibling()) {
+		// goes through each <DownloadInfo> of describeAll
+		
+		String download_name = null;
+		
+		for(Node infoNode = node.getFirstChild(); 
+		    infoNode != null; infoNode = infoNode.getNextSibling()) {
+		    
+		    String node_name = infoNode.getNodeName();
+		    if(node_name.equalsIgnoreCase("Name")) { // <Name>WebDownload</Name>
+			download_name = XMLTools.getValue(infoNode); // e.g. WebDownload		
+		    }
+		    
+		    // At this top level of <DownloadInfo> elements,
+		    // skip all the downloaders that are Abstract, as these are pure superclasses		
+		    else if(node_name.equalsIgnoreCase("Abstract")) {
+			String isAbstract = XMLTools.getValue(infoNode);
+			
+			if(isAbstract.equalsIgnoreCase("no") && download_name != null) {
+			    downloaders.add(download_name);
+			    Download downloader = parseDownloadInfoXML(node); // parse the <DownloadInfo> node properly
+			    // now embedded references to abstract superclasses (embedded <DownloadInfo> nodes)
+			    // will be handled
 			    
-			    if(isAbstract.equalsIgnoreCase("no") && download_name != null) {
-				downloaders.add(download_name);
-			    }
+			    String shortName = download_name.replace("Download", ""); // e.g. "Web"
+			    download_map.put(shortName, downloader);
 			}
 		    }
@@ -317,58 +334,6 @@
     }
 
-    /** Supporting Functions */
-    private Download loadDownload(String download_name, String lang) {
-	Document document = null;
-	Process process = null;
-	try {
-	    if (Gatherer.isGsdlRemote) {
-		String output = Gatherer.remoteGreenstoneServer.getScriptOptions("downloadinfo.pl", "&downloader="+download_name); //OR: "&listall";
-		Reader reader = new StringReader(output);
-		document = XMLTools.parseXML(reader);
-	    }
-	    else {
-		ArrayList args_list = new ArrayList();
-		String args[] = null;
-		if(Configuration.perl_path != null) {
-		    args_list.add(Configuration.perl_path);
-		} else if(Utility.isWindows()) {
-		    args_list.add("Perl.exe");
-		} else {
-		    args_list.add("perl");
-		}
-		args_list.add("-S");
-		args_list.add(LocalGreenstone.getBinScriptDirectoryPath()+"downloadinfo.pl");
-		args_list.add("-xml");
-		args_list.add("-language");
-		args_list.add(lang);
-		args_list.add(download_name);
-		
-		// Create the process.
-		args = (String []) args_list.toArray(new String[0]);
-		Runtime runtime = Runtime.getRuntime();
-		DebugStream.println("Getting Download Info: "+args_list);
-		process = runtime.exec(args);
-		
-		InputStream input_stream = process.getErrorStream();
-		document = XMLTools.parseXML(input_stream);
-	    }
-            
-	}
-	catch (Exception error) {
-	    System.err.println("Failed when trying to parse: " + download_name);
-	    error.printStackTrace();
-	}
-	finally {
-	    Utility.closeProcess(process);
-	}
-
-	if(document != null) {
-	    return parseXML(document.getDocumentElement());
-	}
-
-	return null;
-    }
-
-    private Download parseXML(Node root) {
+    private Download parseDownloadInfoXML(Node root) {
+
 	Download download = new Download();
 	String node_name = null;
@@ -398,5 +363,5 @@
 	    }
             else if(node_name.equalsIgnoreCase("DownloadInfo")) {
-                Download super_download = parseXML(node);
+                Download super_download = parseDownloadInfoXML(node);
 		download.setSuper(super_download);
 	    }
@@ -559,5 +524,5 @@
 		// type has the value DOWNLOAD.MODE.<downloader>Download,
 		// mode should then be of the form <downloader>
-		mode = type.replace("DOWNLOAD.MODE.", "").replace("Download", "");		
+		mode = convertCONTENTStoMode(type);
 		generateOptions(options_pane,(Download)download_map.get(mode));
 
@@ -569,4 +534,8 @@
 	    }
 	}
+    }
+
+    private String convertCONTENTStoMode(String content) {
+	return content.replace("DOWNLOAD.MODE.", "").replace("ZDownload", "Z3950").replace("Download", "");
     }
 
