Index: /gli/trunk/src/org/greenstone/gatherer/Gatherer.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/Gatherer.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/Gatherer.java	(revision 17612)
@@ -85,4 +85,5 @@
 
     static private Dimension size = new Dimension(800, 540);
+    static public RemoteGreenstoneServer remoteGreenstoneServer = null;
 
     /** Has the exit flag been set? */
@@ -299,9 +300,12 @@
 	    // Finally, we're ready to find out the version of the remote Greenstone server 
 	    if(isGsdlRemote) {
+		// instantiate the RemoteGreenstoneServer object first
+		remoteGreenstoneServer = new RemoteGreenstoneServer();
+
 		int greenstoneVersion = 2;
 		requestGLIServerURL();
 		gliserver_url_string = Configuration.gliserver_url.toString();
 		
-		greenstoneVersion = RemoteGreenstoneServer.getGreenstoneVersion();
+		greenstoneVersion = remoteGreenstoneServer.getGreenstoneVersion();
 		// Display the version to make error reports a lot more useful
 		System.err.println("Remote Greenstone server version: " + greenstoneVersion);
@@ -316,5 +320,5 @@
 		    library_url_string = fedora_info.getLibraryURL();
 		} else {
-		    library_url_string = RemoteGreenstoneServer.getLibraryURL(Configuration.gliserver_url.toString());
+		    library_url_string = remoteGreenstoneServer.getLibraryURL(Configuration.gliserver_url.toString());
 		}
 	    }
@@ -472,5 +476,5 @@
 	// If using a remote Greenstone we need to download the collection configurations now
 	if (Gatherer.isGsdlRemote) {
-	    if (RemoteGreenstoneServer.downloadCollectionConfigurations().equals("")) {
+	    if (remoteGreenstoneServer.downloadCollectionConfigurations().equals("")) {
 		// !! Something went wrong downloading the collection configurations
 		System.err.println("Error: Could not download collection configurations.");
@@ -551,5 +555,5 @@
 	// If using a remote Greenstone we need to download the collection configurations now
 	if (Gatherer.isGsdlRemote) {
-	    if (RemoteGreenstoneServer.downloadCollectionConfigurations().equals("")) {
+	    if (remoteGreenstoneServer.downloadCollectionConfigurations().equals("")) {
 		// !! Something went wrong downloading the collection configurations
 		System.err.println("Error: Could not download collection configurations.");
@@ -616,5 +620,5 @@
 	// If we're using a remote Greenstone server we need to make sure that all jobs have completed first
 	if (isGsdlRemote) {
-	    RemoteGreenstoneServer.exit();
+	    remoteGreenstoneServer.exit();
 	}
 
Index: /gli/trunk/src/org/greenstone/gatherer/cdm/CollectionConfiguration.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/cdm/CollectionConfiguration.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/cdm/CollectionConfiguration.java	(revision 17612)
@@ -3707,5 +3707,5 @@
         // If we're using a remote Greenstone server, upload the new 'collectionConfig.xml' file
         if (Gatherer.isGsdlRemote) {
-            RemoteGreenstoneServer.uploadCollectionFile (collection_name, collect_cfg_file);
+            Gatherer.remoteGreenstoneServer.uploadCollectionFile (collection_name, collect_cfg_file);
         }
         
@@ -3799,5 +3799,5 @@
             // If we're using a remote Greenstone server, upload the new collect.cfg file
             if (Gatherer.isGsdlRemote) {
-                RemoteGreenstoneServer.uploadCollectionFile (collection_name, collect_cfg_file);
+                Gatherer.remoteGreenstoneServer.uploadCollectionFile (collection_name, collect_cfg_file);
             }
         }
Index: /gli/trunk/src/org/greenstone/gatherer/cdm/GeneralManager.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/cdm/GeneralManager.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/cdm/GeneralManager.java	(revision 17612)
@@ -344,5 +344,6 @@
 			    // If we're using a remote Greenstone server, upload the image
 			    if (Gatherer.isGsdlRemote) {
-				RemoteGreenstoneServer.uploadCollectionFile(CollectionManager.getLoadedCollectionName(), collection_image_file);
+				Gatherer.remoteGreenstoneServer.uploadCollectionFile(
+                                   CollectionManager.getLoadedCollectionName(), collection_image_file);
 			    }
 			}
Index: /gli/trunk/src/org/greenstone/gatherer/cdm/MacrosManager.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/cdm/MacrosManager.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/cdm/MacrosManager.java	(revision 17612)
@@ -217,5 +217,5 @@
 		// Users need to wait until the upload has finished before pressing Preview Collection!
 		if (Gatherer.isGsdlRemote) {
-		    RemoteGreenstoneServer.uploadCollectionFile(CollectionManager.getLoadedCollectionName(), extra_dm_file);
+		    Gatherer.remoteGreenstoneServer.uploadCollectionFile(CollectionManager.getLoadedCollectionName(), extra_dm_file);
 		}
 	    }
Index: /gli/trunk/src/org/greenstone/gatherer/collection/CollectionManager.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/collection/CollectionManager.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/collection/CollectionManager.java	(revision 17612)
@@ -379,5 +379,5 @@
 	// Remove the lock file on the server
 	if (Gatherer.isGsdlRemote) {
-	    RemoteGreenstoneServer.deleteCollectionFile(collection.getName(), lock_file);
+	    Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection.getName(), lock_file);
 	}
 
@@ -547,5 +547,5 @@
 		collection_import_directory.mkdirs();
 		if (Gatherer.isGsdlRemote) {
-		    RemoteGreenstoneServer.newCollectionDirectory(name, collection_import_directory);
+		    Gatherer.remoteGreenstoneServer.newCollectionDirectory(name, collection_import_directory);
 		}
 	    }
@@ -581,5 +581,5 @@
 		if (Gatherer.isGsdlRemote) {
 		    String base_collection_name = base_collection_directory.getName();
-		    RemoteGreenstoneServer.downloadCollection(base_collection_name);
+		    Gatherer.remoteGreenstoneServer.downloadCollection(base_collection_name);
 		}
 
@@ -765,5 +765,5 @@
 	// Delete the collection on the server if we're using a remote Greenstone
 	if (Gatherer.isGsdlRemote) {
-	    RemoteGreenstoneServer.deleteCollection(collection_name);
+	    Gatherer.remoteGreenstoneServer.deleteCollection(collection_name);
 	}
 
@@ -1056,5 +1056,5 @@
 		// If we're using a remote Greenstone server, upload the metadata file
 		if (Gatherer.isGsdlRemote) {
-		    RemoteGreenstoneServer.uploadCollectionFile(collection.getName(), metadata_set_file);
+		    Gatherer.remoteGreenstoneServer.uploadCollectionFile(collection.getName(), metadata_set_file);
 		}
 	    }
@@ -1122,5 +1122,5 @@
 	if (Gatherer.isGsdlRemote) {
 	    String collection_name = location.substring(location.lastIndexOf(File.separator) + 1, location.length() - ".col".length());
-	    if (RemoteGreenstoneServer.downloadCollection(collection_name).equals("")) {
+	    if (Gatherer.remoteGreenstoneServer.downloadCollection(collection_name).equals("")) {
 		return;
 	    }
@@ -1618,5 +1618,5 @@
 	    // If we're using a remote Greenstone server, delete the metadata file on the server
 	    if (Gatherer.isGsdlRemote) {
-		RemoteGreenstoneServer.deleteCollectionFile(collection.getName(), metadata_set_file);
+		Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection.getName(), metadata_set_file);
 	    }
 	}
@@ -1750,6 +1750,8 @@
 
 		if (Gatherer.isGsdlRemote) {
-		    RemoteGreenstoneServer.deleteCollectionFile(collection.getName(), new File(getLoadedCollectionIndexDirectoryPath()));
-		    RemoteGreenstoneServer.moveCollectionFile(collection.getName(), new File(getLoadedCollectionBuildingDirectoryPath()), new File(getLoadedCollectionIndexDirectoryPath()));
+		    Gatherer.remoteGreenstoneServer.deleteCollectionFile(
+                             collection.getName(), new File(getLoadedCollectionIndexDirectoryPath()));
+		    Gatherer.remoteGreenstoneServer.moveCollectionFile(collection.getName(), 
+                    new File(getLoadedCollectionBuildingDirectoryPath()), new File(getLoadedCollectionIndexDirectoryPath()));
 		}
 
Index: /gli/trunk/src/org/greenstone/gatherer/collection/ScriptOptions.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/collection/ScriptOptions.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/collection/ScriptOptions.java	(revision 17612)
@@ -225,5 +225,5 @@
 
 	    if (Gatherer.isGsdlRemote) {
-		String script_output = RemoteGreenstoneServer.getScriptOptions(filename, "");
+		String script_output = Gatherer.remoteGreenstoneServer.getScriptOptions(filename, "");
 		document = XMLTools.parseXML(new StringReader(script_output));
 	    }
Index: /gli/trunk/src/org/greenstone/gatherer/file/FileManager.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/file/FileManager.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/file/FileManager.java	(revision 17612)
@@ -180,10 +180,10 @@
 			    source_files[i] = source_nodes[i].getFile();
 			}
-			RemoteGreenstoneServer.uploadFilesIntoCollection(collection_name, source_files, target_node.getFile());
+			Gatherer.remoteGreenstoneServer.uploadFilesIntoCollection(collection_name, source_files, target_node.getFile());
 		    }
 		    else if (type == FileJob.DELETE) {
 			// Deletes: delete each top-level file/directory one at a time
 			for (int i = 0; i < source_nodes.length; i++) {
-			    RemoteGreenstoneServer.deleteCollectionFile(collection_name, source_nodes[i].getFile());
+			    Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection_name, source_nodes[i].getFile());
 			}
 		    }
@@ -191,5 +191,6 @@
 			// Moves: move each top-level file/directory one at a time
 			for (int i = 0; i < source_nodes.length; i++) {
-			    RemoteGreenstoneServer.moveCollectionFile(collection_name, source_nodes[i].getFile(), target_node.getFile());
+			    Gatherer.remoteGreenstoneServer.moveCollectionFile(
+                                     collection_name, source_nodes[i].getFile(), target_node.getFile());
 			}
 		    }
@@ -272,5 +273,6 @@
 		// ... but only if it is inside the collection and we haven't already downloaded it
 		if (file.getAbsolutePath().startsWith(Gatherer.getCollectDirectoryPath()) && file.length() == 0) {
-		    if (RemoteGreenstoneServer.downloadCollectionFile(CollectionManager.getLoadedCollectionName(), file).equals("")) {
+		    if (Gatherer.remoteGreenstoneServer.downloadCollectionFile(
+                                 CollectionManager.getLoadedCollectionName(), file).equals("")) {
 			// Something has gone wrong downloading the file
 			return;
@@ -347,5 +349,6 @@
 			    folder_file.createNewFile();
 			    if (Gatherer.isGsdlRemote) {
-				RemoteGreenstoneServer.uploadCollectionFile(CollectionManager.getLoadedCollectionName(), folder_file);
+				Gatherer.remoteGreenstoneServer.uploadCollectionFile(
+                                         CollectionManager.getLoadedCollectionName(), folder_file);
 			    }
 			}
@@ -353,5 +356,6 @@
 			    folder_file.mkdirs();
 			    if (Gatherer.isGsdlRemote) {
-				RemoteGreenstoneServer.newCollectionDirectory(CollectionManager.getLoadedCollectionName(), folder_file);
+				Gatherer.remoteGreenstoneServer.newCollectionDirectory(
+                                         CollectionManager.getLoadedCollectionName(), folder_file);
 			    }
 			}
@@ -413,5 +417,6 @@
 		file_queue.addJob(System.currentTimeMillis(), collection_tree, new FileNode[] { collection_tree_node }, collection_tree, new_collection_tree_node, FileJob.RENAME);
 		if (Gatherer.isGsdlRemote) {
-		    RemoteGreenstoneServer.moveCollectionFile(CollectionManager.getLoadedCollectionName(), collection_file, new_collection_file);
+		    Gatherer.remoteGreenstoneServer.moveCollectionFile(
+                             CollectionManager.getLoadedCollectionName(), collection_file, new_collection_file);
 		}
 	    }
@@ -462,5 +467,6 @@
 	    file_queue.addJob(System.currentTimeMillis(), Gatherer.g_man.gather_pane.workspace_tree, new FileNode[] { source_node }, collection_tree, (FileNode)collection_tree_node.getParent(),  FileJob.COPY_FILE_ONLY);
 	    if (Gatherer.isGsdlRemote) {
-		RemoteGreenstoneServer.uploadFilesIntoCollection(CollectionManager.getLoadedCollectionName(), new File[] { new_file }, target_directory);
+		Gatherer.remoteGreenstoneServer.uploadFilesIntoCollection(
+                         CollectionManager.getLoadedCollectionName(), new File[] { new_file }, target_directory);
 	    }
 	    // do a replace of old file with new file
Index: /gli/trunk/src/org/greenstone/gatherer/greenstone/Classifiers.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/greenstone/Classifiers.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/greenstone/Classifiers.java	(revision 17612)
@@ -134,5 +134,5 @@
 		    classinfo_options += "&collection=" + collection_name;
 		}
-		classinfo_xml = RemoteGreenstoneServer.getScriptOptions("classinfo.pl", classinfo_options);
+		classinfo_xml = Gatherer.remoteGreenstoneServer.getScriptOptions("classinfo.pl", classinfo_options);
 	    }
 	    else {
@@ -195,5 +195,5 @@
 		    classinfo_options += "&collection=" + collection_name;
 		}
-		String classinfo_output = RemoteGreenstoneServer.getScriptOptions("classinfo.pl", classinfo_options);
+		String classinfo_output = Gatherer.remoteGreenstoneServer.getScriptOptions("classinfo.pl", classinfo_options);
 		xml = new StringBuffer(classinfo_output);
 	    }
Index: /gli/trunk/src/org/greenstone/gatherer/greenstone/Plugins.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/greenstone/Plugins.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/greenstone/Plugins.java	(revision 17612)
@@ -135,5 +135,5 @@
 		    pluginfo_options += "&collection=" + collection_name;
 		}
-		pluginfo_xml = RemoteGreenstoneServer.getScriptOptions("pluginfo.pl", pluginfo_options);
+		pluginfo_xml = Gatherer.remoteGreenstoneServer.getScriptOptions("pluginfo.pl", pluginfo_options);
 	    }
 	    else {
@@ -198,5 +198,5 @@
 		    pluginfo_options += "&collection=" + collection_name;
 		}
-		String pluginfo_output = RemoteGreenstoneServer.getScriptOptions("pluginfo.pl", pluginfo_options);
+		String pluginfo_output = Gatherer.remoteGreenstoneServer.getScriptOptions("pluginfo.pl", pluginfo_options);
 		xml = new StringBuffer(pluginfo_output);
 	    }
Index: /gli/trunk/src/org/greenstone/gatherer/greenstone3/ServletConfiguration.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/greenstone3/ServletConfiguration.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/greenstone3/ServletConfiguration.java	(revision 17612)
@@ -70,5 +70,5 @@
 
 	if (Gatherer.isGsdlRemote){
-	    if (RemoteGreenstoneServer.downloadWebXMLFile().equals("")) {
+	    if (Gatherer.remoteGreenstoneServer.downloadWebXMLFile().equals("")) {
 		System.err.println("Error: Could not download web.xml.");
 		System.exit(0);
@@ -89,5 +89,5 @@
 	this.sites = new ArrayList();
 	if (Gatherer.isGsdlRemote){
-	    String sites_on_server = RemoteGreenstoneServer.getSiteNames();
+	    String sites_on_server = Gatherer.remoteGreenstoneServer.getSiteNames();
 	    if (sites_on_server.equals("")) {
 		// !! Something went wrong : could not get names of the sites
Index: /gli/trunk/src/org/greenstone/gatherer/gui/ExplodeMetadataDatabasePrompt.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/gui/ExplodeMetadataDatabasePrompt.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/gui/ExplodeMetadataDatabasePrompt.java	(revision 17612)
@@ -274,5 +274,6 @@
 	    String collection_name = CollectionManager.getLoadedCollectionName();
 	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
-	    String metadata_file_relative_path = RemoteGreenstoneServer.getPathRelativeToDirectory(metadata_file, collection_directory_path);
+	    String metadata_file_relative_path = Gatherer.remoteGreenstoneServer.getPathRelativeToDirectory(
+                                                          metadata_file, collection_directory_path);
 	    command_parts_list.add("-file");
 	    command_parts_list.add(metadata_file_relative_path);
@@ -345,5 +346,6 @@
 		if (Gatherer.isGsdlRemote) {
 		    Utility.delete(metadata_file.getParentFile());
-		    RemoteGreenstoneServer.downloadCollectionFile(CollectionManager.getLoadedCollectionName(), metadata_file.getParentFile());
+		    Gatherer.remoteGreenstoneServer.downloadCollectionFile(
+                             CollectionManager.getLoadedCollectionName(), metadata_file.getParentFile());
 		}
 
Index: /gli/trunk/src/org/greenstone/gatherer/gui/GUIManager.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/gui/GUIManager.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/gui/GUIManager.java	(revision 17612)
@@ -438,5 +438,5 @@
 		remote_greenstone_server_progress_panel.setLayout(new BorderLayout());
 		remote_greenstone_server_progress_panel.add(remote_greenstone_server_progress_label, BorderLayout.WEST);
-		remote_greenstone_server_progress_panel.add(RemoteGreenstoneServer.getProgressBar(), BorderLayout.CENTER);
+		remote_greenstone_server_progress_panel.add(Gatherer.remoteGreenstoneServer.getProgressBar(), BorderLayout.CENTER);
 		content_pane.add(remote_greenstone_server_progress_panel, BorderLayout.SOUTH);
 	    }
Index: /gli/trunk/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java	(revision 17612)
@@ -259,5 +259,5 @@
 	// Remote collections that aren't shared have the user's username prefixed to the collection name
 	if (Gatherer.isGsdlRemote && personal_collection_button.isSelected()) {
-	    name_buffer = new StringBuffer(RemoteGreenstoneServer.getUsername() + "-" + name_buffer.toString());
+	    name_buffer = new StringBuffer(Gatherer.remoteGreenstoneServer.getUsername() + "-" + name_buffer.toString());
 	}
 
Index: /gli/trunk/src/org/greenstone/gatherer/gui/Preferences.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/gui/Preferences.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/gui/Preferences.java	(revision 17612)
@@ -826,5 +826,5 @@
 	    Configuration.save();
 	    if (Gatherer.isGsdlRemote && Gatherer.GS3 && site_changed ){
-		RemoteGreenstoneServer.downloadCollectionConfigurations();
+		Gatherer.remoteGreenstoneServer.downloadCollectionConfigurations();
 	    }
 	    // Refresh the GLI to account for the configuration changes
@@ -956,10 +956,10 @@
 		    if (Gatherer.c_man.getCollection()!=null){
 			File lock_file = new File(Gatherer.c_man.getLoadedCollectionDirectoryPath() + "gli.lck");
-			RemoteGreenstoneServer.deleteCollectionFile(Gatherer.c_man.getLoadedCollectionName(),lock_file);
+			Gatherer.remoteGreenstoneServer.deleteCollectionFile(Gatherer.c_man.getLoadedCollectionName(),lock_file);
 			Gatherer.g_man.closeCurrentCollection();
 		    }
 		    Configuration.site_name=site;
-		    RemoteGreenstoneServer.set_remote_greenstone_server_authentication_to_null();
-		    RemoteGreenstoneServer.downloadCollectionConfigurations();
+		    Gatherer.remoteGreenstoneServer.set_remote_greenstone_server_authentication_to_null();
+		    Gatherer.remoteGreenstoneServer.downloadCollectionConfigurations();
 		}
 	    }
Index: /gli/trunk/src/org/greenstone/gatherer/gui/ReplaceSrcDocWithHtmlPrompt.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/gui/ReplaceSrcDocWithHtmlPrompt.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/gui/ReplaceSrcDocWithHtmlPrompt.java	(revision 17612)
@@ -272,5 +272,5 @@
 	    String collection_name = CollectionManager.getLoadedCollectionName();
 	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
-	    String srcdoc_file_relative_path = RemoteGreenstoneServer.getPathRelativeToDirectory(
+	    String srcdoc_file_relative_path = Gatherer.remoteGreenstoneServer.getPathRelativeToDirectory(
 		this.srcdoc_files[fileNum], collection_directory_path); // preserves spaces in filename
 	    command_parts_list.add("-file");
@@ -382,5 +382,5 @@
 			// download the generated html file from the server side to put it 
 			// into the import directory on the client side
-			RemoteGreenstoneServer.downloadCollectionFile(
+			Gatherer.remoteGreenstoneServer.downloadCollectionFile(
 					      CollectionManager.getLoadedCollectionName(),
 					      new File(srcdoc_files[i].getParentFile(), htmlFile));
@@ -389,6 +389,6 @@
 			File assoc_folder = new File(srcdoc_files[i].getParentFile(), suffixlessFilename+"_files");
 			// If an associated_folder by such a name exists, download it
-			if(RemoteGreenstoneServer.exists(CollectionManager.getLoadedCollectionName(), assoc_folder)) {
-			  RemoteGreenstoneServer.downloadCollectionFile(
+			if(Gatherer.remoteGreenstoneServer.exists(CollectionManager.getLoadedCollectionName(), assoc_folder)) {
+			  Gatherer.remoteGreenstoneServer.downloadCollectionFile(
 			                        CollectionManager.getLoadedCollectionName(), assoc_folder);
 			}
Index: /gli/trunk/src/org/greenstone/gatherer/metadata/MetadataXMLFileManager.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/metadata/MetadataXMLFileManager.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/metadata/MetadataXMLFileManager.java	(revision 17612)
@@ -368,5 +368,6 @@
 
 	    // Upload the files modified since last time, then reset the list
-	    RemoteGreenstoneServer.uploadCollectionFiles(CollectionManager.getLoadedCollectionName(), (File[]) modified_metadata_xml_files.toArray(new File[0]));
+	    Gatherer.remoteGreenstoneServer.uploadCollectionFiles(
+                  CollectionManager.getLoadedCollectionName(), (File[]) modified_metadata_xml_files.toArray(new File[0]));
 	    modified_metadata_xml_files.clear();
 	}
Index: /gli/trunk/src/org/greenstone/gatherer/metadata/ProfileXMLFile.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/metadata/ProfileXMLFile.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/metadata/ProfileXMLFile.java	(revision 17612)
@@ -110,5 +110,5 @@
 	// This is inefficient but for simplicity we'll just upload the file every time it is changed
 	if (Gatherer.isGsdlRemote) {
-	    RemoteGreenstoneServer.uploadCollectionFile(CollectionManager.getLoadedCollectionName(), this);
+	    Gatherer.remoteGreenstoneServer.uploadCollectionFile(CollectionManager.getLoadedCollectionName(), this);
 	}
 
Index: /gli/trunk/src/org/greenstone/gatherer/remote/ActionQueue.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/remote/ActionQueue.java	(revision 17612)
+++ /gli/trunk/src/org/greenstone/gatherer/remote/ActionQueue.java	(revision 17612)
@@ -0,0 +1,165 @@
+/**
+ *#########################################################################
+ *
+ * A component of the Greenstone Librarian Interface application, part of 
+ * the Greenstone digital library suite from the New Zealand Digital 
+ * Library Project at the University of Waikato, New Zealand.
+ *
+ * Author: Michael Dewsnip, NZDL Project, University of Waikato
+ *
+ * Copyright (C) 2005 New Zealand Digital Library Project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *########################################################################
+ */
+
+package org.greenstone.gatherer.remote;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import java.util.zip.*;
+import javax.swing.*;
+import java.io.ByteArrayOutputStream;
+import org.greenstone.gatherer.Configuration;
+import org.greenstone.gatherer.DebugStream;
+import org.greenstone.gatherer.Dictionary;
+import org.greenstone.gatherer.FedoraInfo;
+import org.greenstone.gatherer.GAuthenticator;
+import org.greenstone.gatherer.Gatherer;
+import org.greenstone.gatherer.collection.CollectionManager;
+import org.greenstone.gatherer.shell.GShell;
+import org.greenstone.gatherer.util.UnzipTools;
+import org.greenstone.gatherer.util.Utility;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.multipart.FilePart;
+import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
+import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.commons.httpclient.methods.multipart.*;
+import org.apache.commons.httpclient.params.*;
+import org.apache.commons.httpclient.HttpStatus;
+
+// ----------------------------------------------------------------------------------------------------
+//   Part of the RemoteGreenstoneServer's QUEUE LAYER
+// ----------------------------------------------------------------------------------------------------
+
+// Moved here. Previously called RemoteGreenstoneServerActionQueue
+/** 
+ * A Thread that maintains a queue of RemoteGreenstoneServer Actions
+ * that are to be executed in FIFO fashion.
+*/
+class ActionQueue extends Thread
+{
+    /** The queue of waiting jobs. */
+    private ArrayList queue = null;
+    
+    
+    public ActionQueue()
+    {
+	if (Gatherer.isGsdlRemote) {
+	    queue = new ArrayList();
+	    start();
+	}
+    }
+    
+    
+    synchronized public void addAction(RemoteGreenstoneServerAction remote_greenstone_server_action)
+    {
+	queue.add(remote_greenstone_server_action);
+	notifyAll();
+    }
+    
+    
+    public int size()
+    {
+	return queue.size();
+    }
+    
+    
+    public void run()
+    {
+	boolean exit = false;
+	while (!exit) {
+	    // If there are jobs on the queue, get the next in line and process it
+	    if (queue.size() > 0) {
+		RemoteGreenstoneServerAction remote_greenstone_server_action = (RemoteGreenstoneServerAction) queue.get(0);
+		
+		try {
+		    remote_greenstone_server_action.perform();
+		    
+		    // No exceptions were thrown, so the action was successful
+		    remote_greenstone_server_action.processed_successfully = true;
+		}
+		catch (RemoteGreenstoneServerAction.ActionCancelledException exception) {
+		    remote_greenstone_server_action.processed_successfully = false;
+		    exit = true;
+		} 
+		catch(java.net.ConnectException exception) {
+		    if(exception.getMessage().trim().startsWith("Connection refused")) {
+			exit = true;
+		    } else {
+			DebugStream.printStackTrace(exception);
+		    }
+		    JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("RemoteGreenstoneServer.Error", exception.getMessage()), Dictionary.get("RemoteGreenstoneServer.Error_Title"), JOptionPane.ERROR_MESSAGE);
+		    remote_greenstone_server_action.processed_successfully = false;			
+		}
+		catch (FileNotFoundException exception) {
+		    // FileNotFoundException happens when there's no GS server at the user-provided
+		    // url (the address of gliserver.pl is wrong).
+		    exit = true;
+		    DebugStream.printStackTrace(exception);
+		    JOptionPane.showMessageDialog(Gatherer.g_man, 
+						  Dictionary.get("RemoteGreenstoneServer.Error", 
+								 "No gliserver.pl found. " + exception.getMessage()), 
+						  Dictionary.get("RemoteGreenstoneServer.Error_Title"), 
+						  JOptionPane.ERROR_MESSAGE);
+		    remote_greenstone_server_action.processed_successfully = false;
+		}
+		catch (Exception exception) {
+		    DebugStream.printStackTrace(exception);
+		    JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("RemoteGreenstoneServer.Error", exception.getMessage()), Dictionary.get("RemoteGreenstoneServer.Error_Title"), JOptionPane.ERROR_MESSAGE);
+		    remote_greenstone_server_action.processed_successfully = false;
+		}
+		
+		// We're done with this action, for better or worse
+		remote_greenstone_server_action.processed = true;
+		queue.remove(0);
+	    }
+	    
+	    // Otherwise the queue is empty
+	    else {
+		Gatherer.remoteGreenstoneServer.getProgressBar().setAction(null);
+		
+		// Wait until we are notify()ed by addAction that there is a new job on the queue
+		synchronized (this) {
+		    try {
+			wait();
+		    }
+		    catch (InterruptedException exception) { }
+		}
+	    }
+	    
+	}
+	// stop the gazillion annoying error messages when the connection was simply
+	// refused or when the user pressed Cancel in the opening dialog, by exitting
+	// cleanly in one go.
+	//if(exit == true) {
+	    //Gatherer.exit();
+	//}
+    }
+}
Index: /gli/trunk/src/org/greenstone/gatherer/remote/RemoteGreenstoneServer.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/remote/RemoteGreenstoneServer.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/remote/RemoteGreenstoneServer.java	(revision 17612)
@@ -58,99 +58,114 @@
 public class RemoteGreenstoneServer
 {
+    // A PasswordAuthentication object is created whenever it is required
+    static private PasswordAuthentication remote_greenstone_server_authentication = null;
+    // static private PasswordAuthentication remote_greenstone_server_authentication = new PasswordAuthentication(System.getProperty("user.name"), new char[] { });
+
+    private ActionQueue remote_greenstone_server_action_queue;
+    private RemoteGreenstoneServer.ProgressBar progress_bar;
+
+    public RemoteGreenstoneServer() {
+	remote_greenstone_server_action_queue = new ActionQueue();
+	progress_bar = new RemoteGreenstoneServer.ProgressBar();
+    }
+
     // ----------------------------------------------------------------------------------------------------
     //   PUBLIC LAYER
     // ----------------------------------------------------------------------------------------------------
-
-
-    static public String deleteCollection(String collection_name)
-    {
-	return performAction(new RemoteGreenstoneServerDeleteCollectionAction(collection_name));
-    }
-
-
-    static public String deleteCollectionFile(String collection_name, File collection_file)
-    {
-	return performAction(new RemoteGreenstoneServerDeleteCollectionFileAction(collection_name, collection_file));
-    }
-
-
-    static public String downloadCollection(String collection_name)
-    {
-	return performAction(new RemoteGreenstoneServerDownloadCollectionAction(collection_name));
-    }
-
-
-    static public String downloadCollectionArchives(String collection_name)
-    {
-	return performAction(new RemoteGreenstoneServerDownloadCollectionArchivesAction(collection_name));
-    }
-
-
-    static public String downloadCollectionConfigurations()
-    {
-	return performAction(new RemoteGreenstoneServerDownloadCollectionConfigurationsAction());
-    }
-
-
-    static public String downloadCollectionFile(String collection_name, File collection_file)
-    {
-	return performAction(new RemoteGreenstoneServerDownloadCollectionFileAction(collection_name, collection_file));
+    public String deleteCollection(String collection_name)
+    {
+	return performAction(new RemoteGreenstoneServerAction.DeleteCollectionAction(collection_name));
+    }
+
+
+    public String deleteCollectionFile(String collection_name, File collection_file)
+    {
+	return performAction(new RemoteGreenstoneServerAction.DeleteCollectionFileAction(collection_name, collection_file));
+    }
+
+
+    public String downloadCollection(String collection_name)
+    {
+	return performAction(new RemoteGreenstoneServerAction.DownloadCollectionAction(collection_name));
+    }
+
+
+    public String downloadCollectionArchives(String collection_name)
+    {
+	return performAction(new RemoteGreenstoneServerAction.DownloadCollectionArchivesAction(collection_name));
+    }
+
+
+    public String downloadCollectionConfigurations()
+    {
+	return performAction(new RemoteGreenstoneServerAction.DownloadCollectionConfigurationsAction());
+    }
+
+
+    public String downloadCollectionFile(String collection_name, File collection_file)
+    {
+	return performAction(new RemoteGreenstoneServerAction.DownloadCollectionFileAction(collection_name, collection_file));
     }
     
     // get web.xml from the server -- for a remote gli of GS3
-    static public String downloadWebXMLFile()
-    {
-	return performAction(new RemoteGreenstoneServerDownloadWebXMLFileAction());
-    }
-
-    static public String getScriptOptions(String script_name, String script_arguments)
-    {
-	return performAction(new RemoteGreenstoneServerGetScriptOptionsAction(script_name, script_arguments));
+    public String downloadWebXMLFile()
+    {
+	return performAction(new RemoteGreenstoneServerAction.DownloadWebXMLFileAction());
+    }
+
+    public String getScriptOptions(String script_name, String script_arguments)
+    {
+	return performAction(new RemoteGreenstoneServerAction.GetScriptOptionsAction(script_name, script_arguments));
     }
     
     //get all available site names from the server -- for a remote gli of GS3
-    static public String getSiteNames()
-    {
-	return performAction(new RemoteGreenstoneServerGetSiteNamesAction());
-    }
-
-    static public String moveCollectionFile(String collection_name, File source_collection_file, File target_collection_file)
-    {
-	return performAction(new RemoteGreenstoneServerMoveCollectionFileAction(collection_name, source_collection_file, target_collection_file));
-    }
-
-
-    static public String newCollectionDirectory(String collection_name, File new_collection_directory)
-    {
-	return performAction(new RemoteGreenstoneServerNewCollectionDirectoryAction(collection_name, new_collection_directory));
-    }
-
-
-    static public String runScript(String collection_name, String script_name, String script_arguments, GShell shell)
-    {
-	return performAction(new RemoteGreenstoneServerRunScriptAction(collection_name, script_name, script_arguments, shell));
-    }
-
-
-    static public String uploadCollectionFile(String collection_name, File collection_file)
-    {
-	return performAction(new RemoteGreenstoneServerUploadCollectionFilesAction(collection_name, new File[] { collection_file }));
-    }
-
-
-    static public String uploadCollectionFiles(String collection_name, File[] collection_files)
-    {
-	return performAction(new RemoteGreenstoneServerUploadCollectionFilesAction(collection_name, collection_files));
-    }
-
-
-    static public String uploadFilesIntoCollection(String collection_name, File[] source_files, File target_collection_directory)
-    {
-	return performAction(new RemoteGreenstoneServerUploadFilesIntoCollectionAction(collection_name, source_files, target_collection_directory));
-    }
-
-    static public boolean exists(String collection_name, File collection_file)
-    {
-	String result = performAction(new RemoteGreenstoneServerExistsAction(collection_name, collection_file));
+    public String getSiteNames()
+    {
+	return performAction(new RemoteGreenstoneServerAction.GetSiteNamesAction());
+    }
+
+    public String moveCollectionFile(String collection_name, File source_collection_file, File target_collection_file)
+    {
+	return performAction(new RemoteGreenstoneServerAction.MoveCollectionFileAction(
+                             collection_name, source_collection_file, target_collection_file));
+    }
+
+
+    public String newCollectionDirectory(String collection_name, File new_collection_directory)
+    {
+	return performAction(new RemoteGreenstoneServerAction.NewCollectionDirectoryAction(
+                             collection_name, new_collection_directory));
+    }
+
+
+    public String runScript(String collection_name, String script_name, String script_arguments, GShell shell)
+    {
+	return performAction(new RemoteGreenstoneServerAction.RunScriptAction(
+                             collection_name, script_name, script_arguments, shell));
+    }
+
+
+    public String uploadCollectionFile(String collection_name, File collection_file)
+    {
+	return performAction(new RemoteGreenstoneServerAction.UploadCollectionFilesAction(
+                             collection_name, new File[] { collection_file }));
+    }
+
+
+    public String uploadCollectionFiles(String collection_name, File[] collection_files)
+    {
+	return performAction(new RemoteGreenstoneServerAction.UploadCollectionFilesAction(collection_name, collection_files));
+    }
+
+
+    public String uploadFilesIntoCollection(String collection_name, File[] source_files, File target_collection_directory)
+    {
+	return performAction(new RemoteGreenstoneServerAction.UploadFilesIntoCollectionAction(
+                             collection_name, source_files, target_collection_directory));
+    }
+
+    public boolean exists(String collection_name, File collection_file)
+    {
+	String result = performAction(new RemoteGreenstoneServerAction.ExistsAction(collection_name, collection_file));
 	if(result.indexOf("exists") != -1) {
 	    return true;
@@ -162,8 +177,8 @@
     }
 
-    static public int getGreenstoneVersion()
+    public int getGreenstoneVersion()
     {
 	// returns message "Greenstone version is: <version number of the Greenstone remote server>"
-	String result = performAction(new RemoteGreenstoneServerVersionAction());
+	String result = performAction(new RemoteGreenstoneServerAction.VersionAction());
 	int index = result.indexOf(":"); 
 	if(index != -1) {
@@ -175,8 +190,8 @@
 
     /** For constructing the preview command (the library URL) with */
-    static public String getLibraryURL(String serverHomeURL)
+    public String getLibraryURL(String serverHomeURL)
     {
 	// returns message "Greenstone library URL suffix is: <e.g. /greenstone3/library or /gsdl/cgi-bin/library>"
-	String libSuffix = performAction(new RemoteGreenstoneServerLibraryURLSuffixAction());
+	String libSuffix = performAction(new RemoteGreenstoneServerAction.LibraryURLSuffixAction());
 	int index = libSuffix.indexOf(":"); 
 	if(index != -1) {
@@ -200,5 +215,5 @@
 
 
-    static public void exit()
+    public void exit()
     {
 	System.err.println("Exiting, number of jobs on queue: " + remote_greenstone_server_action_queue.size());
@@ -223,5 +238,5 @@
 
     /** Returns null if we cannot wait for the action to finish, "" if the action failed, or the action output. */
-    static private String performAction(RemoteGreenstoneServerAction remote_greenstone_server_action)
+    private String performAction(RemoteGreenstoneServerAction remote_greenstone_server_action)
     {
 	// Add the action to the queue
@@ -255,122 +270,12 @@
 
 
-    static private RemoteGreenstoneServerActionQueue remote_greenstone_server_action_queue = new RemoteGreenstoneServerActionQueue();
-
-
-    static private class RemoteGreenstoneServerActionQueue
-	extends Thread
-    {
-	/** The queue of waiting jobs. */
-	private ArrayList queue = null;
-
-
-	public RemoteGreenstoneServerActionQueue()
-	{
-	    if (Gatherer.isGsdlRemote) {
-		queue = new ArrayList();
-		start();
-	    }
-	}
-
-
-	synchronized public void addAction(RemoteGreenstoneServerAction remote_greenstone_server_action)
-	{
-	    queue.add(remote_greenstone_server_action);
-	    notifyAll();
-	}
-
-
-	public int size()
-	{
-	    return queue.size();
-	}
-
-
-	public void run()
-	{
-	    boolean exit = false;
-	    while (true) {
-		// If there are jobs on the queue, get the next in line and process it
-		if (queue.size() > 0) {
-		    RemoteGreenstoneServerAction remote_greenstone_server_action = (RemoteGreenstoneServerAction) queue.get(0);
-
-		    try {
-			remote_greenstone_server_action.perform();
-			
-			// No exceptions were thrown, so the action was successful
-			remote_greenstone_server_action.processed_successfully = true;
-		    }
-		    catch (RemoteGreenstoneServerActionCancelledException exception) {
-			remote_greenstone_server_action.processed_successfully = false;
-			exit = true;
-		    } 
-		    catch(java.net.ConnectException exception) {
-			if(exception.getMessage().trim().startsWith("Connection refused")) {
-			    exit = true;
-			} else {
-			    DebugStream.printStackTrace(exception);
-			}
-			JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("RemoteGreenstoneServer.Error", exception.getMessage()), Dictionary.get("RemoteGreenstoneServer.Error_Title"), JOptionPane.ERROR_MESSAGE);
-			remote_greenstone_server_action.processed_successfully = false;			
-		    }
-		    catch (FileNotFoundException exception) {
-			// FileNotFoundException happens when there's no GS server at the user-provided
-			// url (the address of gliserver.pl is wrong).
-			exit = true;
-			DebugStream.printStackTrace(exception);
-			JOptionPane.showMessageDialog(Gatherer.g_man, 
-						      Dictionary.get("RemoteGreenstoneServer.Error", 
-								     "No gliserver.pl found. " + exception.getMessage()), 
-						      Dictionary.get("RemoteGreenstoneServer.Error_Title"), 
-						      JOptionPane.ERROR_MESSAGE);
-			remote_greenstone_server_action.processed_successfully = false;
-		    }
-		    catch (Exception exception) {
-			DebugStream.printStackTrace(exception);
-			JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("RemoteGreenstoneServer.Error", exception.getMessage()), Dictionary.get("RemoteGreenstoneServer.Error_Title"), JOptionPane.ERROR_MESSAGE);
-			remote_greenstone_server_action.processed_successfully = false;
-		    }
-
-		    // We're done with this action, for better or worse
-		    remote_greenstone_server_action.processed = true;
-		    queue.remove(0);
-		}
-
-		// Otherwise the queue is empty
-		else {
-		    progress_bar.setAction(null);
-
-		    // Wait until we are notify()ed by addAction that there is a new job on the queue
-		    synchronized (this) {
-			try {
-			    wait();
-			}
-			catch (InterruptedException exception) { }
-		    }
-		}
-		
-		// stop the gazillion annoying error messages when the connection was simply
-		// refused or when the user pressed Cancel in the opening dialog, by exitting
-		// cleanly in one go.
-		if(exit == true) {
-		    Gatherer.exit();
-		}
-	    }
-	}
-    }
-
-
     // ----------------------------------------------------------------------------------------------------
     //   PROGRESS BAR
     // ----------------------------------------------------------------------------------------------------
 
-
-    static private RemoteGreenstoneServerProgressBar progress_bar = new RemoteGreenstoneServerProgressBar();
-
-
-    static private class RemoteGreenstoneServerProgressBar
+    static class ProgressBar
 	extends JProgressBar
     {
-	public RemoteGreenstoneServerProgressBar()
+	public ProgressBar()
 	{
 	    setBackground(Configuration.getColor("coloring.collection_tree_background", false));
@@ -404,7 +309,6 @@
 	}
     }
-
-
-    static public RemoteGreenstoneServerProgressBar getProgressBar()
+    
+    public RemoteGreenstoneServer.ProgressBar getProgressBar()
     {
 	return progress_bar;
@@ -413,577 +317,6 @@
 
     // ----------------------------------------------------------------------------------------------------
-    //   ACTIONS
-    // ----------------------------------------------------------------------------------------------------
-
-
-    static private abstract class RemoteGreenstoneServerAction
-    {
-	public String action_output = null;
-	public boolean processed = false;
-	public boolean processed_successfully;
-
-	abstract public void perform()
-	    throws Exception;
-    }
-
-
-    static private class RemoteGreenstoneServerActionCancelledException
-	extends Exception
-    {
-    }
-
-
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    DELETE COLLECTION
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerDeleteCollectionAction
-	extends RemoteGreenstoneServerAction
-    {
-	private String collection_name;
-
-	public RemoteGreenstoneServerDeleteCollectionAction(String collection_name)
-	{
-	    this.collection_name = collection_name;
-	}
-
-	public void perform()
-	    throws Exception
-	{
-	    progress_bar.setAction("Deleting collection " + collection_name + "...");
-
-	    String delete_collection_command = "cmd=delete-collection";
-	    delete_collection_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
-	    action_output = sendCommandToServer(delete_collection_command, null);
-	}
-    }
-
-
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    DELETE COLLECTION FILE
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerDeleteCollectionFileAction
-	extends RemoteGreenstoneServerAction
-    {
-	private String collection_name;
-	private File collection_file;
-
-	public RemoteGreenstoneServerDeleteCollectionFileAction(String collection_name, File collection_file)
-	{
-	    this.collection_name = collection_name;
-	    this.collection_file = collection_file;
-	}
-
-	public void perform()
-	    throws Exception
-	{
-	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
-	    String collection_file_relative_path = getPathRelativeToDirectory(collection_file, collection_directory_path);
-	    collection_file_relative_path = collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
-	    progress_bar.setAction("Deleting collection file " + collection_file_relative_path + "...");
-
-	    String delete_collection_file_command = "cmd=delete-collection-file";
-	    delete_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
-	    delete_collection_file_command += "&file=" + URLEncoder.encode(collection_file_relative_path, "UTF-8");
-	    action_output = sendCommandToServer(delete_collection_file_command, null);
-	}
-    }
-
-
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    DOWNLOAD COLLECTION
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerDownloadCollectionAction
-	extends RemoteGreenstoneServerAction
-    {
-	private String collection_name;
-
-	public RemoteGreenstoneServerDownloadCollectionAction(String collection_name)
-	{
-	    this.collection_name = collection_name;
-	}
-
-	public void perform()
-	    throws Exception
-	{
-	    progress_bar.setAction("Downloading remote collection " + collection_name + "...");
-
-	    String download_collection_command = "cmd=download-collection";
-	    download_collection_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
-	    String zip_file_path = Gatherer.getCollectDirectoryPath() + collection_name + ".zip";
-	    action_output = downloadFile(download_collection_command, zip_file_path);
-
-	    // Delete the existing (local) collection directory
-	    Utility.delete(new File(CollectionManager.getCollectionDirectoryPath(collection_name)));
-
-	    // Unzip the collection just downloaded
-	    UnzipTools.unzipFile(zip_file_path, Gatherer.getCollectDirectoryPath());
-	}
-    }
-
-
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    DOWNLOAD COLLECTION ARCHIVES
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerDownloadCollectionArchivesAction
-	extends RemoteGreenstoneServerAction
-    {
-	private String collection_name;
-
-	public RemoteGreenstoneServerDownloadCollectionArchivesAction(String collection_name)
-	{
-	    this.collection_name = collection_name;
-	}
-
-	public void perform()
-	    throws Exception
-	{
-	    progress_bar.setAction("Downloading collection archives for " + collection_name + "...");
-
-	    String download_collection_archives_command = "cmd=download-collection-archives";
-	    download_collection_archives_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
-	    String zip_file_path = Gatherer.getCollectDirectoryPath() + collection_name + "-archives.zip";
-	    action_output = downloadFile(download_collection_archives_command, zip_file_path);
-
-	    // Delete the existing (local) collection archives
-	    Utility.delete(new File(CollectionManager.getLoadedCollectionArchivesDirectoryPath()));
-
-	    // Unzip the collection archives just downloaded
-	    UnzipTools.unzipFile(zip_file_path, Gatherer.getCollectDirectoryPath());
-	}
-    }
-
-
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    DOWNLOAD COLLECTION CONFIGURATIONS
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerDownloadCollectionConfigurationsAction
-	extends RemoteGreenstoneServerAction
-    {
-	public RemoteGreenstoneServerDownloadCollectionConfigurationsAction()
-	{
-	}
-
-	public void perform()
-	    throws Exception
-	{
-	    progress_bar.setAction("Downloading collection configurations...");
-
-	    // Delete the existing (local) collect directory
-	    Utility.delete(new File(Gatherer.getCollectDirectoryPath()));
-	    new File(Gatherer.getCollectDirectoryPath()).mkdirs();
-
-	    String download_collection_configurations_command = "cmd=download-collection-configurations";
-	    String zip_file_path = Gatherer.getCollectDirectoryPath() + "collections.zip";
-	    action_output = downloadFile(download_collection_configurations_command, zip_file_path);
-
-	    // Unzip the collection configurations just downloaded
-	    UnzipTools.unzipFile(zip_file_path, Gatherer.getCollectDirectoryPath());
-	}
-    }
-
-     /**
-     * --------------------------------------------------------------------------------------------
-     *    DISCOVERING WHAT VERSION THE REMOTE GREENSTONE SERVER IS (2 or 3)
-     * --------------------------------------------------------------------------------------------
-     */
-
-    static private class RemoteGreenstoneServerVersionAction
-	extends RemoteGreenstoneServerAction
-    {
-	public void perform()
-	    throws Exception
-	{
-	    action_output = sendCommandToServer("cmd=greenstone-server-version", null);
-	}	
-    }
-
-    static private class RemoteGreenstoneServerLibraryURLSuffixAction
-	extends RemoteGreenstoneServerAction
-    {
-	public void perform()
-	    throws Exception
-	{
-	    action_output = sendCommandToServer("cmd=get-library-url-suffix", null);
-	}	
-    }
-    
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    CHECKING IF A FILE/FOLDER EXISTS ON SERVER SIDE
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerExistsAction 
-	extends RemoteGreenstoneServerAction
-    {
-	private String collection_name;
-	private File collection_file;
-	
-	public RemoteGreenstoneServerExistsAction(String collection_name, File collection_file)
-	{
-	    this.collection_name = collection_name;
-	    this.collection_file = collection_file;
-	}
-	
-	public void perform()
-	    throws Exception
-	{
-	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
-	    String collection_file_relative_path = getPathRelativeToDirectory(collection_file, collection_directory_path);
-	    collection_file_relative_path = collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
-	    File file = new File(collection_directory_path, collection_file_relative_path);
-
-	    String file_exists_command = "cmd=file-exists";
-	    file_exists_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
-	    file_exists_command += "&file=" + URLEncoder.encode(collection_file_relative_path, "UTF-8");
-	    // returns either "File <filename> exists" or "File <filename> does not exist"
-	    // for the file/folder collection_file
-	    action_output = sendCommandToServer(file_exists_command, null);
-	}	
-    }
-    
-
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    DOWNLOAD COLLECTION FILE
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerDownloadCollectionFileAction
-	extends RemoteGreenstoneServerAction
-    {
-	private String collection_name;
-	private File collection_file;
-
-	public RemoteGreenstoneServerDownloadCollectionFileAction(String collection_name, File collection_file)
-	{
-	    this.collection_name = collection_name;
-	    this.collection_file = collection_file;
-	}
-
-	public void perform()
-	    throws Exception
-	{
-	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
-	    String collection_file_relative_path = getPathRelativeToDirectory(collection_file, collection_directory_path);
-	    collection_file_relative_path = collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
-	    progress_bar.setAction("Downloading collection file " + collection_file_relative_path + "...");
-
-	    String download_collection_file_command = "cmd=download-collection-file";
-	    download_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
-	    download_collection_file_command += "&file=" + URLEncoder.encode(collection_file_relative_path, "UTF-8");
-	    String zip_file_name = collection_name + "-" + collection_file.getName() + ".zip";
-	    String zip_file_path = collection_directory_path + zip_file_name;
-	    action_output = downloadFile(download_collection_file_command, zip_file_path);
-
-	    // Unzip the collection file just downloaded
-	    UnzipTools.unzipFile(zip_file_path, collection_directory_path);
-	}
-    }
-
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    DOWNLOAD web.xml FILE --for a remote GS3
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerDownloadWebXMLFileAction
-	extends RemoteGreenstoneServerAction
-    {
-	public RemoteGreenstoneServerDownloadWebXMLFileAction()
-	{}
-
-	public void perform()
-	    throws Exception
-	{
-	    String web_xml_directory_path=(Configuration.gli_user_directory_path);
-	    String download_web_xml_file_command = "cmd=download-web-xml-file";
-	    download_web_xml_file_command += "&file=" + URLEncoder.encode("web.xml", "UTF-8");
-	    String zip_file_name = "web-xml.zip";
-	    String zip_file_path = web_xml_directory_path + zip_file_name;
-	    action_output = downloadFile(download_web_xml_file_command, zip_file_path);
-
-	    // Unzip the web.xml file just downloaded
-	    UnzipTools.unzipFile(zip_file_path,web_xml_directory_path);
-	}
-    }
-
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    GET SCRIPT OPTIONS
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerGetScriptOptionsAction
-	extends RemoteGreenstoneServerAction
-    {
-	private String script_name;
-	private String script_arguments;
-
-	public RemoteGreenstoneServerGetScriptOptionsAction(String script_name, String script_arguments)
-	{
-	    this.script_name = script_name;
-	    this.script_arguments = script_arguments;
-	}
-
-	public void perform()
-	    throws Exception
-	{
-	    progress_bar.setAction("Getting options for " + script_name + "...");
-
-	    String get_script_options_command = "cmd=get-script-options";
-	    get_script_options_command += "&script=" + script_name;
-	    get_script_options_command += "&xml=";
-	    get_script_options_command += "&language=" + Configuration.getLanguage();
-	    get_script_options_command += script_arguments;
-	    action_output = sendCommandToServer(get_script_options_command, null);
-	}
-    }
-
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    GET ALL NAMES OF SITES // for a remote GS3 
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerGetSiteNamesAction
-	extends RemoteGreenstoneServerAction
-    {
-	public RemoteGreenstoneServerGetSiteNamesAction()
-	{}
-
-	public void perform()
-	    throws Exception
-	{
-	    progress_bar.setAction("Getting names of sites ...");
-
-	    String get_script_options_command = "cmd=get-site-names";
-	    action_output = sendCommandToServer(get_script_options_command, null);
-	}
-    }
-
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    MOVE COLLECTION FILE
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerMoveCollectionFileAction
-	extends RemoteGreenstoneServerAction
-    {
-	private String collection_name;
-	private File source_collection_file;
-	private File target_collection_file;
-
-	public RemoteGreenstoneServerMoveCollectionFileAction(String collection_name, File source_collection_file, File target_collection_file)
-	{
-	    this.collection_name = collection_name;
-	    this.source_collection_file = source_collection_file;
-	    this.target_collection_file = target_collection_file;
-	}
-
-	public void perform()
-	    throws Exception
-	{
-	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
-	    String source_collection_file_relative_path = getPathRelativeToDirectory(source_collection_file, collection_directory_path);
-	    source_collection_file_relative_path = source_collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
-	    String target_collection_file_relative_path = getPathRelativeToDirectory(target_collection_file, collection_directory_path);
-	    target_collection_file_relative_path = target_collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
-	    progress_bar.setAction("Moving file " + source_collection_file_relative_path + " -> " + target_collection_file_relative_path + "...");
-
-	    String move_collection_file_command = "cmd=move-collection-file";
-	    move_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
-	    move_collection_file_command += "&source=" + URLEncoder.encode(source_collection_file_relative_path, "UTF-8");
-	    move_collection_file_command += "&target=" + URLEncoder.encode(target_collection_file_relative_path, "UTF-8");
-	    action_output = sendCommandToServer(move_collection_file_command, null);
-	}
-    }
-
-
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    NEW COLLECTION DIRECTORY
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerNewCollectionDirectoryAction
-	extends RemoteGreenstoneServerAction
-    {
-	private String collection_name;
-	private File new_collection_directory;
-
-	public RemoteGreenstoneServerNewCollectionDirectoryAction(String collection_name, File new_collection_directory)
-	{
-	    this.collection_name = collection_name;
-	    this.new_collection_directory = new_collection_directory;
-	}
-
-	public void perform()
-	    throws Exception
-	{
-	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
-	    String new_collection_directory_relative_path = getPathRelativeToDirectory(new_collection_directory, collection_directory_path);
-	    new_collection_directory_relative_path = new_collection_directory_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
-	    progress_bar.setAction("Creating new directory " + new_collection_directory_relative_path + "...");
-
-	    String new_collection_directory_command = "cmd=new-collection-directory";
-	    new_collection_directory_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
-	    new_collection_directory_command += "&directory=" + URLEncoder.encode(new_collection_directory_relative_path, "UTF-8");
-	    action_output = sendCommandToServer(new_collection_directory_command, null);
-	}
-    }
-
-
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    RUN SCRIPT
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerRunScriptAction
-	extends RemoteGreenstoneServerAction
-    {
-	private String collection_name;
-	private String script_name;
-	private String script_arguments;
-	private GShell shell;
-
-	public RemoteGreenstoneServerRunScriptAction(String collection_name, String script_name, String script_arguments, GShell shell)
-	{
-	    this.collection_name = collection_name;
-	    this.script_name = script_name;
-	    this.script_arguments = script_arguments;
-	    this.shell = shell;
-	}
-
-	public void perform()
-	    throws Exception
-	{
-	    progress_bar.setAction("Running " + script_name + "...");
-
-	    String run_script_command = "cmd=run-script";
-	    run_script_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
-	    run_script_command += "&script=" + script_name;
-	    run_script_command += "&language=" + Configuration.getLanguage();
-	    run_script_command += script_arguments;
-	    action_output = sendCommandToServer(run_script_command, shell);
-	}
-    }
-
-
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    UPLOAD COLLECTION FILE
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerUploadCollectionFilesAction
-	extends RemoteGreenstoneServerAction
-    {
-	private String collection_name;
-	private File[] collection_files;
-
-
-	public RemoteGreenstoneServerUploadCollectionFilesAction(String collection_name, File[] collection_files)
-	{
-	    this.collection_name = collection_name;
-	    this.collection_files = collection_files;
-	}
-
-
-	public void perform()
-	    throws Exception
-	{
-	    progress_bar.setAction("Uploading collection files...");
-
-	    // Determine the file paths relative to the collection directory
-	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
-	    String[] collection_file_relative_paths = new String[collection_files.length];
-	    for (int i = 0; i < collection_files.length; i++) {
-		collection_file_relative_paths[i] = getPathRelativeToDirectory(collection_files[i], collection_directory_path);
-	    }
-
-	    // Zip up the files to send to the server
-	    String zip_file_name = collection_name + "-" + System.currentTimeMillis() + ".zip";
-	    String zip_file_path = collection_directory_path + zip_file_name;
-	    ZipTools.zipFiles(zip_file_path, collection_directory_path, collection_file_relative_paths);
-	    
-	    // Upload the zip file
-	    String upload_collection_file_command = "cmd=upload-collection-file";
-	    upload_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
-	    upload_collection_file_command += "&file=" + URLEncoder.encode(zip_file_name, "UTF-8");
-	    upload_collection_file_command += "&directory=";
-	    upload_collection_file_command += "&zip=true";
-	    action_output = uploadFile(upload_collection_file_command, zip_file_path);
-	}
-    }
-
-
-    /**
-     * --------------------------------------------------------------------------------------------
-     *    UPLOAD FILES INTO COLLECTION
-     * --------------------------------------------------------------------------------------------
-     */
-    static private class RemoteGreenstoneServerUploadFilesIntoCollectionAction
-	extends RemoteGreenstoneServerAction
-    {
-	private String collection_name;
-	private File[] source_files;
-	private File target_collection_directory;
-
-
-	public RemoteGreenstoneServerUploadFilesIntoCollectionAction(String collection_name, File[] source_files, File target_collection_directory)
-	{
-	    this.collection_name = collection_name;
-	    this.source_files = source_files;
-	    this.target_collection_directory = target_collection_directory;
-	}
-
-
-	public void perform()
-	    throws Exception
-	{
-	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
-	    String target_collection_directory_relative_path = getPathRelativeToDirectory(target_collection_directory, collection_directory_path);
-	    target_collection_directory_relative_path = target_collection_directory_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
-	    progress_bar.setAction("Uploading files into collection...");
-	   
-	    String zip_file_name = collection_name + "-" + System.currentTimeMillis() + ".zip";
-	    String zip_file_path = Gatherer.getCollectDirectoryPath() + zip_file_name;
-	    DebugStream.println("Zip file path: " + zip_file_path);
-
-	    String base_directory_path = source_files[0].getParentFile().getAbsolutePath();
-	    DebugStream.println("Base directory path: " + base_directory_path);
-	    String[] source_file_relative_paths = new String[source_files.length];
-	    for (int i = 0; i < source_files.length; i++) {
-		DebugStream.println("Source file path: " + source_files[i]);
-		source_file_relative_paths[i] = getPathRelativeToDirectory(source_files[i], base_directory_path);
-	    }
-	    
-	    ZipTools.zipFiles(zip_file_path, base_directory_path, source_file_relative_paths);
-
-	    String upload_collection_file_command = "cmd=upload-collection-file";
-	    upload_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
-	    upload_collection_file_command += "&file=" + URLEncoder.encode(zip_file_name, "UTF-8");
-	    upload_collection_file_command += "&directory=" + URLEncoder.encode(target_collection_directory_relative_path, "UTF-8");
-	    upload_collection_file_command += "&zip=true";
-	    action_output = uploadFile(upload_collection_file_command, zip_file_path);
-	}
-    }
-
-
-    // ----------------------------------------------------------------------------------------------------
     //   AUTHENTICATION LAYER
     // ----------------------------------------------------------------------------------------------------
-
-
-    static private PasswordAuthentication remote_greenstone_server_authentication = null;
-    // static private PasswordAuthentication remote_greenstone_server_authentication = new PasswordAuthentication(System.getProperty("user.name"), new char[] { });
-
-    static public void set_remote_greenstone_server_authentication_to_null(){
-	remote_greenstone_server_authentication = null;
-    }
 
     static private class RemoteGreenstoneServerAuthenticateTask
@@ -1018,8 +351,11 @@
  	}
     }
-
-
-    static private void authenticateUser()
-	throws RemoteGreenstoneServerActionCancelledException
+    
+    public void set_remote_greenstone_server_authentication_to_null() {
+	remote_greenstone_server_authentication = null;
+    }
+
+    private void authenticateUser()
+	throws RemoteGreenstoneServerAction.ActionCancelledException
     {
 	// If we don't have any authentication information then ask for it now
@@ -1035,11 +371,11 @@
 	    // If it is still null then the user has cancelled the authentication, so the action is cancelled
 	    if (remote_greenstone_server_authentication == null) {
-		throw new RemoteGreenstoneServerActionCancelledException();
-	    }
-	}
-    }
-
-
-    static public String getUsername()
+		throw new RemoteGreenstoneServerAction.ActionCancelledException();
+	    }
+	}
+    }
+
+
+    public String getUsername()
     {
 	if (remote_greenstone_server_authentication != null) {
@@ -1057,5 +393,5 @@
 
     /** Returns the command output if the action completed, throws some kind of exception otherwise. */
-    static private String downloadFile(String gliserver_args, String file_path)
+    String downloadFile(String gliserver_args, String file_path)
 	throws Exception
     {
@@ -1081,5 +417,5 @@
 		if (JOptionPane.showConfirmDialog(Gatherer.g_man, Dictionary.get("RemoteGreenstoneServer.Steal_Lock_Message", command_output.substring("ERROR: Collection is locked by: ".length())), Dictionary.get("RemoteGreenstoneServer.Error_Title"), JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
 		    // The user has decided to cancel the action
-		    throw new RemoteGreenstoneServerActionCancelledException();
+		    throw new RemoteGreenstoneServerAction.ActionCancelledException();
 		}
 
@@ -1101,5 +437,5 @@
      * string embedded in the given gliserver_args. No authentication is required for either 
      * of the commands greenstone-server-version and get-library-url-suffix. */
-    static private boolean isAuthenticationRequired(String gliserver_args) {
+    private boolean isAuthenticationRequired(String gliserver_args) {
 	return ((gliserver_args.indexOf("greenstone-server-version") == -1) 
 		&& (gliserver_args.indexOf("get-library-url-suffix") == -1));
@@ -1107,6 +443,8 @@
 
 
-    /** Returns the command output if the action completed, throws some kind of exception otherwise. */
-    static private String sendCommandToServer(String gliserver_args, GShell shell)
+    /** Returns the command output if the action completed, throws some kind of exception otherwise. 
+     *  Package access, so that RemoteGreenstoneServerAction.java can call this.
+     */
+    String sendCommandToServer(String gliserver_args, GShell shell)
 	throws Exception
     {
@@ -1135,5 +473,5 @@
 		if (JOptionPane.showConfirmDialog(Gatherer.g_man, Dictionary.get("RemoteGreenstoneServer.Steal_Lock_Message", command_output.substring("ERROR: Collection is locked by: ".length())), Dictionary.get("RemoteGreenstoneServer.Error_Title"), JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
 		    // The user has decided to cancel the action
-		    throw new RemoteGreenstoneServerActionCancelledException();
+		    throw new RemoteGreenstoneServerAction.ActionCancelledException();
 		}
 
@@ -1157,5 +495,5 @@
 
     /** Returns the command output if the action completed, throws some kind of exception otherwise. */
-    static private String uploadFile(String gliserver_args, String file_path)
+    String uploadFile(String gliserver_args, String file_path)
 	throws Exception
     {
@@ -1182,5 +520,5 @@
 		if (JOptionPane.showConfirmDialog(Gatherer.g_man, Dictionary.get("RemoteGreenstoneServer.Steal_Lock_Message", command_output.substring("ERROR: Collection is locked by: ".length())), Dictionary.get("RemoteGreenstoneServer.Error_Title"), JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
 		    // The user has decided to cancel the action
-		    throw new RemoteGreenstoneServerActionCancelledException();
+		    throw new RemoteGreenstoneServerAction.ActionCancelledException();
 		}
 
@@ -1206,5 +544,5 @@
 
     /** Returns the command output if the action completed, throws some kind of exception otherwise. */
-    static private String downloadFileInternal(String download_cgi, String cgi_args, String file_path)
+    private String downloadFileInternal(String download_cgi, String cgi_args, String file_path)
 	throws Exception
     {
@@ -1262,5 +600,5 @@
 
     /** Returns the command output if the action completed, throws some kind of exception otherwise. */
-    static private String sendCommandToServerInternal(String gliserver_url_string, String cgi_args, GShell shell)
+    private String sendCommandToServerInternal(String gliserver_url_string, String cgi_args, GShell shell)
 	throws Exception
     {
@@ -1290,5 +628,5 @@
 		shell.fireMessage(gliserver_output_line);
 		if (shell.hasSignalledStop()) {
-		    throw new RemoteGreenstoneServerActionCancelledException();
+		    throw new RemoteGreenstoneServerAction.ActionCancelledException();
 		}
 	    }
@@ -1303,5 +641,5 @@
 	       
     /** Returns the command output if the action completed, throws some kind of exception otherwise. */
-    static private String uploadFileInternal(String upload_cgi, String cgi_args, String file_path)
+    private String uploadFileInternal(String upload_cgi, String cgi_args, String file_path)
 	throws Exception
     {
@@ -1433,5 +771,5 @@
 
 
-    static public String getPathRelativeToDirectory(File file, String directory_path)
+    public String getPathRelativeToDirectory(File file, String directory_path)
     {
 	String file_path = file.getAbsolutePath();
Index: /gli/trunk/src/org/greenstone/gatherer/remote/RemoteGreenstoneServerAction.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/remote/RemoteGreenstoneServerAction.java	(revision 17612)
+++ /gli/trunk/src/org/greenstone/gatherer/remote/RemoteGreenstoneServerAction.java	(revision 17612)
@@ -0,0 +1,641 @@
+/**
+ *#########################################################################
+ *
+ * A component of the Greenstone Librarian Interface application, part of 
+ * the Greenstone digital library suite from the New Zealand Digital 
+ * Library Project at the University of Waikato, New Zealand.
+ *
+ * Author: Michael Dewsnip, NZDL Project, University of Waikato
+ *
+ * Copyright (C) 2005 New Zealand Digital Library Project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *########################################################################
+*/
+
+package org.greenstone.gatherer.remote;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import java.util.zip.*;
+import javax.swing.*;
+import java.io.ByteArrayOutputStream;
+import org.greenstone.gatherer.Configuration;
+import org.greenstone.gatherer.DebugStream;
+import org.greenstone.gatherer.Dictionary;
+import org.greenstone.gatherer.FedoraInfo;
+import org.greenstone.gatherer.GAuthenticator;
+import org.greenstone.gatherer.Gatherer;
+import org.greenstone.gatherer.collection.CollectionManager;
+import org.greenstone.gatherer.shell.GShell;
+import org.greenstone.gatherer.util.UnzipTools;
+import org.greenstone.gatherer.util.Utility;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.multipart.FilePart;
+import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
+import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.commons.httpclient.methods.multipart.*;
+import org.apache.commons.httpclient.params.*;
+import org.apache.commons.httpclient.HttpStatus;
+
+
+// Code moved here from RemoteGreenstoneServer.java
+// ----------------------------------------------------------------------------------------------------
+//   ACTIONS
+// ----------------------------------------------------------------------------------------------------
+/** RemoteGreenstoneServer Actions that can go into the remote GS server's  ActionQueue.
+ * Contains many package access inner classes that are Actions.   
+*/
+public abstract class RemoteGreenstoneServerAction
+{
+    public String action_output = null;
+    public boolean processed = false;
+    public boolean processed_successfully;
+    
+    protected RemoteGreenstoneServer remote = null;
+    protected RemoteGreenstoneServer.ProgressBar progress_bar = null;
+
+    public RemoteGreenstoneServerAction() {
+	remote = Gatherer.remoteGreenstoneServer;
+	progress_bar = remote.getProgressBar();
+    }
+
+    abstract public void perform()
+	throws Exception;
+
+    /*
+      protected String sendCommandToServer(String gliserver_args, GShell shell) 
+      throws Exception
+      {
+      return Gatherer.remoteGreenstoneServer.sendCommandToServer(gliserver_args, shell);
+      }
+      
+      protected void setAction(String action) {
+      Gatherer.remoteGreenstoneServer.progress_bar.setAction(action);
+    }*/
+    
+    static class ActionCancelledException
+	extends Exception
+    {
+    }
+
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    DELETE COLLECTION
+     * --------------------------------------------------------------------------------------------
+     */
+    static class DeleteCollectionAction
+	extends RemoteGreenstoneServerAction
+    {
+	private String collection_name;
+
+	public DeleteCollectionAction(String collection_name)
+	{
+	    this.collection_name = collection_name;
+	}
+
+	public void perform()
+	    throws Exception
+	{
+	    progress_bar.setAction("Deleting collection " + collection_name + "...");
+
+	    String delete_collection_command = "cmd=delete-collection";
+	    delete_collection_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
+	    action_output = remote.sendCommandToServer(delete_collection_command, null);
+	}
+    }
+
+
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    DELETE COLLECTION FILE
+     * --------------------------------------------------------------------------------------------
+     */
+    static class DeleteCollectionFileAction
+	extends RemoteGreenstoneServerAction
+    {
+	private String collection_name;
+	private File collection_file;
+
+	public DeleteCollectionFileAction(String collection_name, File collection_file)
+	{
+	    this.collection_name = collection_name;
+	    this.collection_file = collection_file;
+	}
+
+	public void perform()
+	    throws Exception
+	{
+	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
+	    String collection_file_relative_path = remote.getPathRelativeToDirectory(collection_file, collection_directory_path);
+	    collection_file_relative_path = collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
+	    progress_bar.setAction("Deleting collection file " + collection_file_relative_path + "...");
+
+	    String delete_collection_file_command = "cmd=delete-collection-file";
+	    delete_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
+	    delete_collection_file_command += "&file=" + URLEncoder.encode(collection_file_relative_path, "UTF-8");
+	    action_output = remote.sendCommandToServer(delete_collection_file_command, null);
+	}
+    }
+
+
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    DOWNLOAD COLLECTION
+     * --------------------------------------------------------------------------------------------
+     */
+    static class DownloadCollectionAction
+	extends RemoteGreenstoneServerAction
+    {
+	private String collection_name;
+
+	public DownloadCollectionAction(String collection_name)
+	{
+	    this.collection_name = collection_name;
+	}
+
+	public void perform()
+	    throws Exception
+	{
+	    progress_bar.setAction("Downloading remote collection " + collection_name + "...");
+
+	    String download_collection_command = "cmd=download-collection";
+	    download_collection_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
+	    String zip_file_path = Gatherer.getCollectDirectoryPath() + collection_name + ".zip";
+	    action_output = remote.downloadFile(download_collection_command, zip_file_path);
+
+	    // Delete the existing (local) collection directory
+	    Utility.delete(new File(CollectionManager.getCollectionDirectoryPath(collection_name)));
+
+	    // Unzip the collection just downloaded
+	    UnzipTools.unzipFile(zip_file_path, Gatherer.getCollectDirectoryPath());
+	}
+    }
+
+
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    DOWNLOAD COLLECTION ARCHIVES
+     * --------------------------------------------------------------------------------------------
+     */
+    static class DownloadCollectionArchivesAction
+	extends RemoteGreenstoneServerAction
+    {
+	private String collection_name;
+
+	public DownloadCollectionArchivesAction(String collection_name)
+	{
+	    this.collection_name = collection_name;
+	}
+
+	public void perform()
+	    throws Exception
+	{
+	    progress_bar.setAction("Downloading collection archives for " + collection_name + "...");
+
+	    String download_collection_archives_command = "cmd=download-collection-archives";
+	    download_collection_archives_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
+	    String zip_file_path = Gatherer.getCollectDirectoryPath() + collection_name + "-archives.zip";
+	    action_output = remote.downloadFile(download_collection_archives_command, zip_file_path);
+
+	    // Delete the existing (local) collection archives
+	    Utility.delete(new File(CollectionManager.getLoadedCollectionArchivesDirectoryPath()));
+
+	    // Unzip the collection archives just downloaded
+	    UnzipTools.unzipFile(zip_file_path, Gatherer.getCollectDirectoryPath());
+	}
+    }
+
+
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    DOWNLOAD COLLECTION CONFIGURATIONS
+     * --------------------------------------------------------------------------------------------
+     */
+    static class DownloadCollectionConfigurationsAction
+	extends RemoteGreenstoneServerAction
+    {
+	public DownloadCollectionConfigurationsAction()
+	{
+	}
+
+	public void perform()
+	    throws Exception
+	{
+	    progress_bar.setAction("Downloading collection configurations...");
+
+	    // Delete the existing (local) collect directory
+	    Utility.delete(new File(Gatherer.getCollectDirectoryPath()));
+	    new File(Gatherer.getCollectDirectoryPath()).mkdirs();
+
+	    String download_collection_configurations_command = "cmd=download-collection-configurations";
+	    String zip_file_path = Gatherer.getCollectDirectoryPath() + "collections.zip";
+	    action_output = remote.downloadFile(download_collection_configurations_command, zip_file_path);
+
+	    // Unzip the collection configurations just downloaded
+	    UnzipTools.unzipFile(zip_file_path, Gatherer.getCollectDirectoryPath());
+	}
+    }
+
+     /**
+     * --------------------------------------------------------------------------------------------
+     *    DISCOVERING WHAT VERSION THE REMOTE GREENSTONE SERVER IS (2 or 3)
+     * --------------------------------------------------------------------------------------------
+     */
+
+    static class VersionAction
+	extends RemoteGreenstoneServerAction
+    {
+	public void perform()
+	    throws Exception
+	{
+	    action_output = remote.sendCommandToServer("cmd=greenstone-server-version", null);
+	}	
+    }
+
+    static class LibraryURLSuffixAction
+	extends RemoteGreenstoneServerAction
+    {
+	public void perform()
+	    throws Exception
+	{
+	    action_output = remote.sendCommandToServer("cmd=get-library-url-suffix", null);
+	}	
+    }
+    
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    CHECKING IF A FILE/FOLDER EXISTS ON SERVER SIDE
+     * --------------------------------------------------------------------------------------------
+     */
+    static class ExistsAction 
+	extends RemoteGreenstoneServerAction
+    {
+	private String collection_name;
+	private File collection_file;
+	
+	public ExistsAction(String collection_name, File collection_file)
+	{
+	    this.collection_name = collection_name;
+	    this.collection_file = collection_file;
+	}
+	
+	public void perform()
+	    throws Exception
+	{
+	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
+	    String collection_file_relative_path = remote.getPathRelativeToDirectory(collection_file, collection_directory_path);
+	    collection_file_relative_path = collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
+	    File file = new File(collection_directory_path, collection_file_relative_path);
+
+	    String file_exists_command = "cmd=file-exists";
+	    file_exists_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
+	    file_exists_command += "&file=" + URLEncoder.encode(collection_file_relative_path, "UTF-8");
+	    // returns either "File <filename> exists" or "File <filename> does not exist"
+	    // for the file/folder collection_file
+	    action_output = remote.sendCommandToServer(file_exists_command, null);
+	}	
+    }
+    
+
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    DOWNLOAD COLLECTION FILE
+     * --------------------------------------------------------------------------------------------
+     */
+    static class DownloadCollectionFileAction
+	extends RemoteGreenstoneServerAction
+    {
+	private String collection_name;
+	private File collection_file;
+
+	public DownloadCollectionFileAction(String collection_name, File collection_file)
+	{
+	    this.collection_name = collection_name;
+	    this.collection_file = collection_file;
+	}
+
+	public void perform()
+	    throws Exception
+	{
+	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
+	    String collection_file_relative_path = remote.getPathRelativeToDirectory(collection_file, collection_directory_path);
+	    collection_file_relative_path = collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
+	    progress_bar.setAction("Downloading collection file " + collection_file_relative_path + "...");
+
+	    String download_collection_file_command = "cmd=download-collection-file";
+	    download_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
+	    download_collection_file_command += "&file=" + URLEncoder.encode(collection_file_relative_path, "UTF-8");
+	    String zip_file_name = collection_name + "-" + collection_file.getName() + ".zip";
+	    String zip_file_path = collection_directory_path + zip_file_name;
+	    action_output = remote.downloadFile(download_collection_file_command, zip_file_path);
+
+	    // Unzip the collection file just downloaded
+	    UnzipTools.unzipFile(zip_file_path, collection_directory_path);
+	}
+    }
+
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    DOWNLOAD web.xml FILE --for a remote GS3
+     * --------------------------------------------------------------------------------------------
+     */
+    static class DownloadWebXMLFileAction
+	extends RemoteGreenstoneServerAction
+    {
+	public DownloadWebXMLFileAction()
+	{}
+
+	public void perform()
+	    throws Exception
+	{
+	    String web_xml_directory_path=(Configuration.gli_user_directory_path);
+	    String download_web_xml_file_command = "cmd=download-web-xml-file";
+	    download_web_xml_file_command += "&file=" + URLEncoder.encode("web.xml", "UTF-8");
+	    String zip_file_name = "web-xml.zip";
+	    String zip_file_path = web_xml_directory_path + zip_file_name;
+	    action_output = remote.downloadFile(download_web_xml_file_command, zip_file_path);
+
+	    // Unzip the web.xml file just downloaded
+	    UnzipTools.unzipFile(zip_file_path,web_xml_directory_path);
+	}
+    }
+
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    GET SCRIPT OPTIONS
+     * --------------------------------------------------------------------------------------------
+     */
+    static class GetScriptOptionsAction
+	extends RemoteGreenstoneServerAction
+    {
+	private String script_name;
+	private String script_arguments;
+
+	public GetScriptOptionsAction(String script_name, String script_arguments)
+	{
+	    this.script_name = script_name;
+	    this.script_arguments = script_arguments;
+	}
+
+	public void perform()
+	    throws Exception
+	{
+	    progress_bar.setAction("Getting options for " + script_name + "...");
+
+	    String get_script_options_command = "cmd=get-script-options";
+	    get_script_options_command += "&script=" + script_name;
+	    get_script_options_command += "&xml=";
+	    get_script_options_command += "&language=" + Configuration.getLanguage();
+	    get_script_options_command += script_arguments;
+	    action_output = remote.sendCommandToServer(get_script_options_command, null);
+	}
+    }
+
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    GET ALL NAMES OF SITES // for a remote GS3 
+     * --------------------------------------------------------------------------------------------
+     */
+    static class GetSiteNamesAction
+	extends RemoteGreenstoneServerAction
+    {
+	public GetSiteNamesAction()
+	{}
+
+	public void perform()
+	    throws Exception
+	{
+	    progress_bar.setAction("Getting names of sites ...");
+
+	    String get_script_options_command = "cmd=get-site-names";
+	    action_output = remote.sendCommandToServer(get_script_options_command, null);
+	}
+    }
+
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    MOVE COLLECTION FILE
+     * --------------------------------------------------------------------------------------------
+     */
+    static class MoveCollectionFileAction
+	extends RemoteGreenstoneServerAction
+    {
+	private String collection_name;
+	private File source_collection_file;
+	private File target_collection_file;
+
+	public MoveCollectionFileAction(String collection_name, File source_collection_file, File target_collection_file)
+	{
+	    this.collection_name = collection_name;
+	    this.source_collection_file = source_collection_file;
+	    this.target_collection_file = target_collection_file;
+	}
+
+	public void perform()
+	    throws Exception
+	{
+	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
+	    String source_collection_file_relative_path = remote.getPathRelativeToDirectory(
+                                                          source_collection_file, collection_directory_path);
+	    source_collection_file_relative_path = source_collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
+	    String target_collection_file_relative_path = remote.getPathRelativeToDirectory(
+                                                          target_collection_file, collection_directory_path);
+	    target_collection_file_relative_path = target_collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
+	    progress_bar.setAction("Moving file " + source_collection_file_relative_path + " -> " + target_collection_file_relative_path + "...");
+
+	    String move_collection_file_command = "cmd=move-collection-file";
+	    move_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
+	    move_collection_file_command += "&source=" + URLEncoder.encode(source_collection_file_relative_path, "UTF-8");
+	    move_collection_file_command += "&target=" + URLEncoder.encode(target_collection_file_relative_path, "UTF-8");
+	    action_output = remote.sendCommandToServer(move_collection_file_command, null);
+	}
+    }
+
+
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    NEW COLLECTION DIRECTORY
+     * --------------------------------------------------------------------------------------------
+     */
+    static class NewCollectionDirectoryAction
+	extends RemoteGreenstoneServerAction
+    {
+	private String collection_name;
+	private File new_collection_directory;
+
+	public NewCollectionDirectoryAction(String collection_name, File new_collection_directory)
+	{
+	    this.collection_name = collection_name;
+	    this.new_collection_directory = new_collection_directory;
+	}
+
+	public void perform()
+	    throws Exception
+	{
+	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
+	    String new_collection_directory_relative_path = remote.getPathRelativeToDirectory(
+                                                            new_collection_directory, collection_directory_path);
+	    new_collection_directory_relative_path = new_collection_directory_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
+	    progress_bar.setAction("Creating new directory " + new_collection_directory_relative_path + "...");
+
+	    String new_collection_directory_command = "cmd=new-collection-directory";
+	    new_collection_directory_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
+	    new_collection_directory_command += "&directory=" + URLEncoder.encode(new_collection_directory_relative_path, "UTF-8");
+	    action_output = remote.sendCommandToServer(new_collection_directory_command, null);
+	}
+    }
+
+
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    RUN SCRIPT
+     * --------------------------------------------------------------------------------------------
+     */
+    static class RunScriptAction
+	extends RemoteGreenstoneServerAction
+    {
+	private String collection_name;
+	private String script_name;
+	private String script_arguments;
+	private GShell shell;
+
+	public RunScriptAction(String collection_name, String script_name, String script_arguments, GShell shell)
+	{
+	    this.collection_name = collection_name;
+	    this.script_name = script_name;
+	    this.script_arguments = script_arguments;
+	    this.shell = shell;
+	}
+
+	public void perform()
+	    throws Exception
+	{
+	    progress_bar.setAction("Running " + script_name + "...");
+
+	    String run_script_command = "cmd=run-script";
+	    run_script_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
+	    run_script_command += "&script=" + script_name;
+	    run_script_command += "&language=" + Configuration.getLanguage();
+	    run_script_command += script_arguments;
+	    action_output = remote.sendCommandToServer(run_script_command, shell);
+	}
+    }
+
+
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    UPLOAD COLLECTION FILE
+     * --------------------------------------------------------------------------------------------
+     */
+    static class UploadCollectionFilesAction
+	extends RemoteGreenstoneServerAction
+    {
+	private String collection_name;
+	private File[] collection_files;
+
+
+	public UploadCollectionFilesAction(String collection_name, File[] collection_files)
+	{
+	    this.collection_name = collection_name;
+	    this.collection_files = collection_files;
+	}
+
+
+	public void perform()
+	    throws Exception
+	{
+	    progress_bar.setAction("Uploading collection files...");
+
+	    // Determine the file paths relative to the collection directory
+	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
+	    String[] collection_file_relative_paths = new String[collection_files.length];
+	    for (int i = 0; i < collection_files.length; i++) {
+		collection_file_relative_paths[i] = remote.getPathRelativeToDirectory(collection_files[i], collection_directory_path);
+	    }
+
+	    // Zip up the files to send to the server
+	    String zip_file_name = collection_name + "-" + System.currentTimeMillis() + ".zip";
+	    String zip_file_path = collection_directory_path + zip_file_name;
+	    ZipTools.zipFiles(zip_file_path, collection_directory_path, collection_file_relative_paths);
+	    
+	    // Upload the zip file
+	    String upload_collection_file_command = "cmd=upload-collection-file";
+	    upload_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
+	    upload_collection_file_command += "&file=" + URLEncoder.encode(zip_file_name, "UTF-8");
+	    upload_collection_file_command += "&directory=";
+	    upload_collection_file_command += "&zip=true";
+	    action_output = remote.uploadFile(upload_collection_file_command, zip_file_path);
+	}
+    }
+
+
+    /**
+     * --------------------------------------------------------------------------------------------
+     *    UPLOAD FILES INTO COLLECTION
+     * --------------------------------------------------------------------------------------------
+     */
+    static class UploadFilesIntoCollectionAction
+	extends RemoteGreenstoneServerAction
+    {
+	private String collection_name;
+	private File[] source_files;
+	private File target_collection_directory;
+
+
+	public UploadFilesIntoCollectionAction(String collection_name, File[] source_files, File target_collection_directory)
+	{
+	    this.collection_name = collection_name;
+	    this.source_files = source_files;
+	    this.target_collection_directory = target_collection_directory;
+	}
+
+
+	public void perform()
+	    throws Exception
+	{
+	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
+	    String target_collection_directory_relative_path = remote.getPathRelativeToDirectory(
+                                                               target_collection_directory, collection_directory_path);
+	    target_collection_directory_relative_path = target_collection_directory_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
+	    progress_bar.setAction("Uploading files into collection...");
+	   
+	    String zip_file_name = collection_name + "-" + System.currentTimeMillis() + ".zip";
+	    String zip_file_path = Gatherer.getCollectDirectoryPath() + zip_file_name;
+	    DebugStream.println("Zip file path: " + zip_file_path);
+
+	    String base_directory_path = source_files[0].getParentFile().getAbsolutePath();
+	    DebugStream.println("Base directory path: " + base_directory_path);
+	    String[] source_file_relative_paths = new String[source_files.length];
+	    for (int i = 0; i < source_files.length; i++) {
+		DebugStream.println("Source file path: " + source_files[i]);
+		source_file_relative_paths[i] = remote.getPathRelativeToDirectory(source_files[i], base_directory_path);
+	    }
+	    
+	    ZipTools.zipFiles(zip_file_path, base_directory_path, source_file_relative_paths);
+
+	    String upload_collection_file_command = "cmd=upload-collection-file";
+	    upload_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
+	    upload_collection_file_command += "&file=" + URLEncoder.encode(zip_file_name, "UTF-8");
+	    upload_collection_file_command += "&directory=" + URLEncoder.encode(target_collection_directory_relative_path, "UTF-8");
+	    upload_collection_file_command += "&zip=true";
+	    action_output = remote.uploadFile(upload_collection_file_command, zip_file_path);
+	}
+    }
+}
Index: /gli/trunk/src/org/greenstone/gatherer/shell/GShell.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/shell/GShell.java	(revision 17611)
+++ /gli/trunk/src/org/greenstone/gatherer/shell/GShell.java	(revision 17612)
@@ -217,5 +217,5 @@
 	    System.err.println("Script args: " + script_args);
 	    buffered_output_stream = bos;
-	    String command_output = RemoteGreenstoneServer.runScript(collection_name, script_name, script_args, this);
+	    String command_output = Gatherer.remoteGreenstoneServer.runScript(collection_name, script_name, script_args, this);
 	    status = (command_output.equals("") ? CANCELLED : OK);
 	}
@@ -383,5 +383,5 @@
 	    if (type == NEW) {
 		if (Gatherer.isGsdlRemote) {
-		    RemoteGreenstoneServer.downloadCollection(col_name);
+		    Gatherer.remoteGreenstoneServer.downloadCollection(col_name);
 		}
 	    }
@@ -395,5 +395,5 @@
 		    }
 
-		    RemoteGreenstoneServer.downloadCollectionArchives(col_name);
+		    Gatherer.remoteGreenstoneServer.downloadCollectionArchives(col_name);
 
 		    if (progress!=null) {
@@ -428,9 +428,9 @@
 			// Only need to download build.cfg file
 			File build_cfg_file = new File(CollectionManager.getLoadedCollectionBuildingDirectoryPath(), "build.cfg");
-			RemoteGreenstoneServer.downloadCollectionFile(col_name, build_cfg_file);
+			Gatherer.remoteGreenstoneServer.downloadCollectionFile(col_name, build_cfg_file);
 		    }else{
 			// Only need to download buildConfig.xml file
 			File buildConfig_xml_file = new File(CollectionManager.getLoadedCollectionBuildingDirectoryPath(), "buildConfig.xml");
-			RemoteGreenstoneServer.downloadCollectionFile(col_name, buildConfig_xml_file);
+			Gatherer.remoteGreenstoneServer.downloadCollectionFile(col_name, buildConfig_xml_file);
 		    }
 
