Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/Library2.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/Library2.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/Library2.java	(revision 24993)
@@ -132,5 +132,5 @@
 
 		Element xml_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element xml_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PAGE, "", "", "");
+		Element xml_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PAGE, "", new UserContext());
 		xml_message.appendChild(xml_request);
 		Element xml_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java	(revision 24993)
@@ -544,4 +544,7 @@
 			}
 		}
+		UserContext userContext = new UserContext();
+		userContext.setLanguage(lang);
+		userContext.setUserID(uid);
 
 		// set the lang in the session
@@ -582,5 +585,5 @@
 		// the request to the receptionist
 		Element xml_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element xml_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PAGE, "", lang, uid);
+		Element xml_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PAGE, "", userContext);
 		xml_request.setAttribute(GSXML.OUTPUT_ATT, output);
 
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/Action.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/Action.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/Action.java	(revision 24993)
@@ -232,8 +232,8 @@
 	 *            the current user id
 	 */
-	protected void addSiteMetadata(Element element, String lang, String uid)
+	protected void addSiteMetadata(Element element, UserContext userContext)
 	{
 		//ADD SITE METADATA
-		Element metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", lang, uid);
+		Element metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
 		//create a hashmap of params
 		HashMap subset_params = new HashMap(1);
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/AppletAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/AppletAction.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/AppletAction.java	(revision 24993)
@@ -45,6 +45,5 @@
 		boolean coll_specified = true;
 		String service_name = (String) params.get(GSParams.SERVICE);
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 		String to = null;
 		if (collection == null || collection.equals(""))
@@ -63,5 +62,5 @@
 
 			Element mr_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-			Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+			Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 			mr_message.appendChild(mr_request);
 			// just append all the params for now - should filter out unneeded ones
@@ -81,5 +80,5 @@
 
 		Element mr_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element applet_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, lang, uid);
+		Element applet_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
 		mr_message.appendChild(applet_request);
 
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/BrowseAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/BrowseAction.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/BrowseAction.java	(revision 24993)
@@ -64,6 +64,5 @@
 	}
 
-	String lang = request.getAttribute(GSXML.LANG_ATT);
-	String uid = request.getAttribute(GSXML.USER_ID_ATT);	
+	UserContext userContext = new UserContext(request);	
 	String to = GSPath.appendLink(collection, service_name);
 	
@@ -73,9 +72,9 @@
 	
 	Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-	Element info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, lang, uid); 
+	Element info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext); 
 	info_message.appendChild(info_request);
 	
 	// also get the format stuff now if there is some
-	Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, to, lang, uid);
+	Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
 	info_message.appendChild(format_request);
 	// process the requests
@@ -92,5 +91,5 @@
 	
 	//append site metadata
-	addSiteMetadata(page_response, lang, uid);
+	addSiteMetadata(page_response, userContext);
 
 	// if rt=d, then we are just displaying the service
@@ -135,5 +134,5 @@
 	// get the browse structure for the selected node
 	Element classify_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-	Element classify_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+	Element classify_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 	classify_message.appendChild(classify_request);
 	    
@@ -200,5 +199,5 @@
 	if (cl_nodes.getLength() > 0) {
 	    did_classifier = true;
-	    Element cl_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to+"MetadataRetrieve", lang, uid);
+	    Element cl_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to+"MetadataRetrieve", userContext);
 	    metadata_message.appendChild(cl_meta_request);
 	    
@@ -237,5 +236,5 @@
 	if (doc_nodes.getLength() > 0) {
 	    did_documents = true;
-	    Element doc_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(collection, "DocumentMetadataRetrieve"), lang, uid);
+	    Element doc_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(collection, "DocumentMetadataRetrieve"), userContext);
 	    metadata_message.appendChild(doc_meta_request);
 	    
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DocumentAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DocumentAction.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DocumentAction.java	(revision 24993)
@@ -97,6 +97,5 @@
 		has_rl = (String) params.get("rl");//for an external link : get the rl value if it is existing in the params list
 		String collection = (String) params.get(GSParams.COLLECTION);
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 		String document_name = (String) params.get(GSParams.DOCUMENT);
 		if ((document_name == null || document_name.equals("")) && (has_href == null || has_href.equals("")))
@@ -147,8 +146,8 @@
 
 		//append site metadata
-		addSiteMetadata(page_response, lang, uid);
+		addSiteMetadata(page_response, userContext);
 
 		// get the additional data needed for the page
-		getBackgroundData(page_response, collection, lang, uid);
+		getBackgroundData(page_response, collection, userContext);
 		Element format_elem = (Element) GSXML.getChildByTagName(page_response, GSXML.FORMAT_ELEM);
 
@@ -263,5 +262,5 @@
 			Element ds_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
 			String to = GSPath.appendLink(collection, "DocumentStructureRetrieve");// Hard-wired?
-			Element ds_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+			Element ds_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 			ds_message.appendChild(ds_request);
 			ds_request.appendChild(ds_param_list);
@@ -339,5 +338,5 @@
 		Element dm_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
 		String to = GSPath.appendLink(collection, "DocumentMetadataRetrieve"); // Hard-wired?
-		Element dm_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+		Element dm_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		dm_message.appendChild(dm_request);
 		// Create a parameter list to specify the required metadata information
@@ -378,5 +377,5 @@
 		// we also want a metadata request to the top level document to get
 		// assocfilepath - this could be cached too
-		Element doc_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+		Element doc_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		dm_message.appendChild(doc_meta_request);
 		Element doc_meta_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
@@ -432,5 +431,5 @@
 		Element dc_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
 		to = GSPath.appendLink(collection, "DocumentContentRetrieve"); // Hard-wired?
-		Element dc_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+		Element dc_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		dc_message.appendChild(dc_request);
 
@@ -517,5 +516,5 @@
 					// send a message to the service
 					Element enrich_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-					Element enrich_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, enrich_service, lang, uid);
+					Element enrich_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, enrich_service, userContext);
 					enrich_message.appendChild(enrich_request);
 					// check for parameters
@@ -610,5 +609,5 @@
 	 * whatever the query is - should be cached
 	 */
-	protected boolean getBackgroundData(Element page_response, String collection, String lang, String uid)
+	protected boolean getBackgroundData(Element page_response, String collection, UserContext userContext)
 	{
 
@@ -619,5 +618,5 @@
 		String path = GSPath.appendLink(collection, "DocumentContentRetrieve");
 		// the format request - ignore for now, where does this request go to??
-		Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, path, lang, uid);
+		Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, path, userContext);
 		info_message.appendChild(format_request);
 
@@ -626,5 +625,5 @@
 		if (provide_annotations)
 		{
-			Element enrich_services_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", lang, uid);
+			Element enrich_services_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
 			enrich_services_request.setAttribute(GSXML.INFO_ATT, "serviceList");
 			info_message.appendChild(enrich_services_request);
@@ -659,5 +658,5 @@
 				if (((Element) e_services.item(j)).getAttribute(GSXML.TYPE_ATT).equals("enrich"))
 				{
-					Element s = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, ((Element) e_services.item(j)).getAttribute(GSXML.NAME_ATT), lang, uid);
+					Element s = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, ((Element) e_services.item(j)).getAttribute(GSXML.NAME_ATT), userContext);
 					enrich_message.appendChild(s);
 					service_found = true;
@@ -711,10 +710,9 @@
 		}
 		String collection = (String) params.get(GSParams.COLLECTION);
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 		String to = GSPath.appendLink(collection, service_name);
 
 		Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+		Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		mr_query_message.appendChild(mr_query_request);
 
@@ -899,5 +897,5 @@
 		{
 			//We don't want to find words inside HTML tags
-			if(content_characters[i] == '<')
+			if (content_characters[i] == '<')
 			{
 				inTag = true;
@@ -912,7 +910,7 @@
 				continue;
 			}
-			
+
 			boolean is_character_letter_or_digit = Character.isLetterOrDigit(content_characters[i]);
-			
+
 			// Has a word just started?
 			if (in_word == false && is_character_letter_or_digit == true)
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/FormatAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/FormatAction.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/FormatAction.java	(revision 24993)
@@ -12,5 +12,4 @@
 // other java stuff
 import java.io.File;
-import java.util.HashMap;
 import java.util.*;
 import java.io.StringReader;
@@ -46,6 +45,5 @@
 	
     	String subaction = request.getAttribute(GSXML.SUBACTION_ATT);
-	    String lang = request.getAttribute(GSXML.LANG_ATT);
-    	String uid = request.getAttribute(GSXML.USER_ID_ATT);
+    	UserContext userContext = new UserContext(request);
 	    // get the param list
     	Element cgi_param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
@@ -64,5 +62,5 @@
 
         Element mr_request_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-        Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT_STRING, to, lang, uid);
+        Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT_STRING, to, userContext);
 
         mr_request.setAttribute("service", service);
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GS2BrowseAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GS2BrowseAction.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GS2BrowseAction.java	(revision 24993)
@@ -58,6 +58,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 		String to = GSPath.appendLink(collection, service_name);
 
@@ -67,9 +66,9 @@
 
 		Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, lang, uid);
+		Element info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
 		info_message.appendChild(info_request);
 
 		// also get the format stuff now if there is some
-		Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, to, lang, uid);
+		Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
 		info_message.appendChild(format_request);
 		// process the requests
@@ -86,5 +85,5 @@
 
 		//append site metadata
-		addSiteMetadata(page_response, lang, uid);
+		addSiteMetadata(page_response, userContext);
 
 		// if rt=d, then we are just displaying the service
@@ -154,5 +153,5 @@
 		// get the browse structure for the selected node
 		Element classify_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element classify_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+		Element classify_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		classify_message.appendChild(classify_request);
 
@@ -252,5 +251,5 @@
 		{
 			did_classifier = true;
-			Element cl_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to + "MetadataRetrieve", lang, uid);
+			Element cl_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to + "MetadataRetrieve", userContext);
 			metadata_message.appendChild(cl_meta_request);
 
@@ -281,5 +280,5 @@
 		{
 			did_documents = true;
-			Element doc_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(collection, "DocumentMetadataRetrieve"), lang, uid);
+			Element doc_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(collection, "DocumentMetadataRetrieve"), userContext);
 			metadata_message.appendChild(doc_meta_request);
 
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GeneralAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GeneralAction.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GeneralAction.java	(revision 24993)
@@ -26,6 +26,5 @@
 		logger.debug(" request=" + this.converter.getString(request));
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		// get the param list
@@ -66,5 +65,5 @@
 
 			Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-			Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+			Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 			
 			if(request_type.equals("s"))
@@ -91,5 +90,5 @@
 			{
 				// just send the reponse as is
-				addSiteMetadata(result_response, lang, uid);
+				addSiteMetadata(result_response, userContext);
 				return result_response;
 			}
@@ -105,5 +104,5 @@
 		// request the service info for the selected service - should be cached
 		Element mr_info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element mr_info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, lang, uid);
+		Element mr_info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
 		mr_info_message.appendChild(mr_info_request);
 		Element mr_info_response = (Element) this.mr.process(mr_info_message);
@@ -118,5 +117,5 @@
 		}
 
-		addSiteMetadata(page_response, lang, uid);
+		addSiteMetadata(page_response, userContext);
 		
 		return result;
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/NoCollQueryAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/NoCollQueryAction.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/NoCollQueryAction.java	(revision 24993)
@@ -65,6 +65,5 @@
 
 		String request_type = (String) params.get(GSParams.REQUEST_TYPE);
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 		if (request_type.equals("d"))
 		{
@@ -72,5 +71,5 @@
 			// the only info we need to return is the collection list cos the xslt does teh rest
 
-			Element coll_list = getCollectionList(lang, uid);
+			Element coll_list = getCollectionList(userContext);
 			page_response.appendChild(this.doc.importNode(coll_list, true));
 			return page_response;
@@ -89,5 +88,5 @@
 		{
 			logger.error("no collections were specified!");
-			Element coll_list = getCollectionList(lang, uid);
+			Element coll_list = getCollectionList(userContext);
 			page_response.appendChild(this.doc.importNode(coll_list, true));
 			return page_response;
@@ -111,5 +110,5 @@
 		{
 			String to = GSPath.appendLink(colls[i], service_name);
-			Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+			Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 			mr_query_message.appendChild(mr_query_request);
 			mr_query_request.appendChild(query_param_list.cloneNode(true));
@@ -130,5 +129,5 @@
 				String coll_name = extractCollName(((Element) responses.item(j)).getAttribute(GSXML.FROM_ATT));
 				String path = GSPath.appendLink(coll_name, "DocumentMetadataRetrieve");
-				Element mr_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, path, lang, uid);
+				Element mr_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, path, userContext);
 				mr_meta_message.appendChild(mr_meta_request);
 				mr_meta_request.appendChild(this.doc.importNode(document_list, true));
@@ -182,10 +181,10 @@
 	}
 
-	protected Element getCollectionList(String lang, String uid)
+	protected Element getCollectionList(UserContext userContext)
 	{
 
 		// first, get the message router info
 		Element coll_list_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element coll_list_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", lang, uid);
+		Element coll_list_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
 		coll_list_message.appendChild(coll_list_request);
 		Element coll_list_response = (Element) this.mr.process(coll_list_message);
@@ -209,5 +208,5 @@
 			String name = c.getAttribute(GSXML.NAME_ATT);
 
-			Element metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, name, lang, uid);
+			Element metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, name, userContext);
 			metadata_request.appendChild(coll_param_list.cloneNode(true));
 			metadata_message.appendChild(metadata_request);
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/PageAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/PageAction.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/PageAction.java	(revision 24993)
@@ -69,9 +69,8 @@
 	{
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 		// first, get the message router info
 		Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element coll_list_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", lang, uid);
+		Element coll_list_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
 		info_message.appendChild(coll_list_request);
 		Element info_response_message = (Element) this.mr.process(info_message);
@@ -97,5 +96,5 @@
 			if (colls.getLength() > 0)
 			{
-				sendMultipleRequests(colls, null, GSXML.REQUEST_TYPE_DESCRIBE, lang, uid);
+				sendMultipleRequests(colls, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
 			}
 		}
@@ -108,5 +107,5 @@
 			if (services.getLength() > 0)
 			{
-				sendMultipleRequests(services, null, GSXML.REQUEST_TYPE_DESCRIBE, lang, uid);
+				sendMultipleRequests(services, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
 			}
 		}
@@ -119,5 +118,5 @@
 			if (clusters.getLength() > 0)
 			{
-				sendMultipleRequests(clusters, null, GSXML.REQUEST_TYPE_DESCRIBE, lang, uid);
+				sendMultipleRequests(clusters, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
 
 			}
@@ -132,6 +131,5 @@
 	{
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 		// extract the params from the cgi-request, 
 		Element cgi_paramList = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
@@ -144,5 +142,5 @@
 			// return an empty response
 			Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
-			addSiteMetadata(response, lang, uid);
+			addSiteMetadata(response, userContext);
 			return response;
 		}
@@ -151,5 +149,5 @@
 		Element coll_about_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
 
-		Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, lang, uid);
+		Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, userContext);
 		coll_about_message.appendChild(coll_about_request);
 		Element coll_about_response = (Element) this.mr.process(coll_about_message);
@@ -196,10 +194,10 @@
 		if (services.getLength() > 0)
 		{
-			sendMultipleRequests(services, coll_name, GSXML.REQUEST_TYPE_DESCRIBE, lang, uid);
+			sendMultipleRequests(services, coll_name, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
 		}
 
 		Element response = (Element) GSXML.getChildByTagName(coll_about_response, GSXML.RESPONSE_ELEM);
 		//add the site metadata
-		addSiteMetadata(response, lang, uid);
+		addSiteMetadata(response, userContext);
 		return response;
 	}
@@ -213,7 +211,5 @@
 	protected Element unknownPage(Element request)
 	{
-
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 		String page_name = request.getAttribute(GSXML.SUBACTION_ATT);
 
@@ -227,5 +223,5 @@
 			// just return an empty response
 			Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
-			addSiteMetadata(response, lang, uid);
+			addSiteMetadata(response, userContext);
 			return response;
 		}
@@ -237,5 +233,5 @@
 		Element coll_about_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
 
-		Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, lang, uid);
+		Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, userContext);
 		coll_about_message.appendChild(coll_about_request);
 
@@ -245,5 +241,5 @@
 
 		//add the site metadata
-		addSiteMetadata(response, lang, uid);
+		addSiteMetadata(response, userContext);
 
 		return response;
@@ -251,5 +247,5 @@
 	}
 
-	protected boolean sendMultipleRequests(NodeList items, String path_prefix, String request_type, String lang, String uid)
+	protected boolean sendMultipleRequests(NodeList items, String path_prefix, String request_type, UserContext userContext)
 	{
 
@@ -264,5 +260,5 @@
 				path = GSPath.appendLink(path_prefix, path);
 			}
-			Element request = GSXML.createBasicRequest(this.doc, request_type, path, lang, uid);
+			Element request = GSXML.createBasicRequest(this.doc, request_type, path, userContext);
 			message.appendChild(request);
 		}
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/ProcessAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/ProcessAction.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/ProcessAction.java	(revision 24993)
@@ -43,6 +43,5 @@
 		}
 		String request_type = (String) params.get(GSParams.REQUEST_TYPE);
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 		// what is carried out depends on the request_type
 		// if rt=d, then a describe request is done,
@@ -94,5 +93,5 @@
 
 			}
-			Element mr_query_request = GSXML.createBasicRequest(this.doc, request_type_att, to, lang, uid);
+			Element mr_query_request = GSXML.createBasicRequest(this.doc, request_type_att, to, userContext);
 			if (param_list != null)
 			{
@@ -119,5 +118,5 @@
 		// request the service info for the selected service - should be cached
 		Element mr_info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element mr_info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, lang, uid);
+		Element mr_info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
 		mr_info_message.appendChild(mr_info_request);
 		Element mr_info_response = (Element) this.mr.process(mr_info_message);
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/QueryAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/QueryAction.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/QueryAction.java	(revision 24993)
@@ -68,6 +68,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 		String to = service_name;
 		if (collection != null)
@@ -80,5 +79,5 @@
 			// we have been asked for the service description
 			Element mr_info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-			Element mr_info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, lang, uid);
+			Element mr_info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
 			mr_info_message.appendChild(mr_info_request);
 
@@ -86,4 +85,5 @@
 			Element mr_info_response = (Element) this.mr.process(mr_info_message);
 			// the response
+			
 			Element service_response = (Element) GSXML.getChildByTagName(mr_info_response, GSXML.RESPONSE_ELEM);
 
@@ -96,5 +96,5 @@
 			// just a display request, no actual processing to do
 			//append site metadata
-			addSiteMetadata(page_response, lang, uid);
+			addSiteMetadata(page_response, userContext);
 			return page_response;
 		}
@@ -105,5 +105,5 @@
 		{ // no query
 			//append site metadata
-			addSiteMetadata(page_response, lang, uid);
+			addSiteMetadata(page_response, userContext);
 			return page_response;
 		}
@@ -111,5 +111,5 @@
 		// create the query request
 		Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+		Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		mr_query_message.appendChild(mr_query_request);
 
@@ -119,5 +119,5 @@
 
 		// also get the format stuff now if there is some
-		Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, to, lang, uid);
+		Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
 		mr_query_message.appendChild(format_request);
 
@@ -131,5 +131,5 @@
 		{
 			//append site metadata
-			addSiteMetadata(page_response, lang, uid);
+			addSiteMetadata(page_response, userContext);
 			return page_response;
 		}
@@ -167,5 +167,5 @@
 			page_response.appendChild(this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER));
 			//append site metadata
-			addSiteMetadata(page_response, lang, uid);
+			addSiteMetadata(page_response, userContext);
 			return page_response;
 		}
@@ -179,5 +179,5 @@
 			page_response.appendChild(this.doc.importNode(document_list, true));
 			//append site metadata
-			addSiteMetadata(page_response, lang, uid);
+			addSiteMetadata(page_response, userContext);
 			return page_response;
 		}
@@ -207,5 +207,5 @@
 			to = GSPath.prependLink(to, collection);
 		}
-		Element mr_metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+		Element mr_metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		mr_metadata_message.appendChild(mr_metadata_request);
 
@@ -235,5 +235,5 @@
 		logger.debug("Query page:\n" + this.converter.getPrettyString(page_response));
 		//append site metadata
-		addSiteMetadata(page_response, lang, uid);
+		addSiteMetadata(page_response, userContext);
 		return page_response;
 	}
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/SystemAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/SystemAction.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/SystemAction.java	(revision 24993)
@@ -11,5 +11,4 @@
 // other java stuff
 import java.io.File;
-import java.util.HashMap;
 import java.util.*;
 import java.io.StringReader;
@@ -46,6 +45,5 @@
 
 		String subaction = request.getAttribute(GSXML.SUBACTION_ATT);
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 		// get the param list
 		Element cgi_param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
@@ -63,5 +61,5 @@
 
 		Element mr_request_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_SYSTEM, to, lang, uid);
+		Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_SYSTEM, to, userContext);
 		mr_request_message.appendChild(mr_request);
 
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/XMLDocumentAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/XMLDocumentAction.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/XMLDocumentAction.java	(revision 24993)
@@ -52,6 +52,5 @@
 			return result;
 		}
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		// subaction used to decide if we are returning content or structure
@@ -74,5 +73,5 @@
 		Element mr_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
 
-		Element ret_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+		Element ret_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		mr_message.appendChild(ret_request);
 
@@ -85,5 +84,5 @@
 		// also add in a request for the Title metadata
 		to = GSPath.appendLink(collection, "DocumentMetadataRetrieve");
-		Element meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+		Element meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		// copy the doc list
 		meta_request.appendChild(doc_list.cloneNode(true));
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java	(revision 24993)
@@ -347,5 +347,5 @@
 			// services it provides
 			Element message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-			Element request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", "", "");
+			Element request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", new UserContext());
 			message.appendChild(request);
 
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/DefaultReceptionist.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/DefaultReceptionist.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/DefaultReceptionist.java	(revision 24993)
@@ -55,6 +55,5 @@
 		// see if the collection/cluster element is already there
 		String coll_name = coll_param.getAttribute(GSXML.VALUE_ATT);
-		String lang = page_request.getAttribute(GSXML.LANG_ATT);
-		String uid = page_request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(page_request);
 
 		if (coll_name.equals(""))
@@ -84,5 +83,5 @@
 			// we dont have one yet - get it
 			Element coll_about_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-			Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, lang, uid);
+			Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, userContext);
 			coll_about_message.appendChild(coll_about_request);
 
@@ -158,5 +157,5 @@
 			String name = c.getAttribute(GSXML.NAME_ATT);
 			String address = GSPath.appendLink(coll_name, name);
-			Element info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, address, lang, uid);
+			Element info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, address, userContext);
 			//Element req_param_list = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
 			//req_param_list.appendChild(GSXML.createParameter(this.doc, GSXML.SUBSET_PARAM, GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER));
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/MessageRouter.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/MessageRouter.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/MessageRouter.java	(revision 24993)
@@ -454,5 +454,5 @@
     
     Element service_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-    Element service_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", "", "");
+    Element service_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", new UserContext());
     service_message.appendChild(service_request);
     
@@ -774,5 +774,5 @@
     
     Element info_request = this.doc.createElement(GSXML.MESSAGE_ELEM);
-    Element req = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", "", "");
+    Element req = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", new UserContext());
     info_request.appendChild(req);
     
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java	(revision 24993)
@@ -763,5 +763,5 @@
 		//Transformation of the XML message from the receptionist to HTML with doctype
 
-		if(inlineTemplate != null)
+		if (inlineTemplate != null)
 		{
 			try
@@ -770,13 +770,13 @@
 				GSXSLT.mergeStylesheets(skinAndLibraryDoc, inlineTemplateDoc.getDocumentElement());
 			}
-			catch(Exception ex)
+			catch (Exception ex)
 			{
 				ex.printStackTrace();
 			}
 		}
-		
+
 		if (skinAndLibraryDoc.getElementsByTagName("gsf:metadata").getLength() > 0)
 		{
-			secondConfigFormatPass(collection, skinAndLibraryDoc, doc, request.getAttribute("lang"), request.getAttribute("uid"));
+			secondConfigFormatPass(collection, skinAndLibraryDoc, doc, new UserContext(request));
 		}
 
@@ -795,9 +795,9 @@
 	}
 
-	protected void secondConfigFormatPass(String collection, Document skinAndLibraryDoc, Document doc, String lang, String uid)
+	protected void secondConfigFormatPass(String collection, Document skinAndLibraryDoc, Document doc, UserContext userContext)
 	{
 		String to = GSPath.appendLink(collection, "DocumentMetadataRetrieve"); // Hard-wired?
 		Element metaMessage = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element metaRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+		Element metaRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		Element paramList = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 		Element docNodeList = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/ArchiveIO.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/ArchiveIO.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/ArchiveIO.java	(revision 24993)
@@ -28,4 +28,5 @@
 import org.greenstone.gsdl3.util.GSXML;
 import org.greenstone.gsdl3.util.SimpleCollectionDatabase;
+import org.greenstone.gsdl3.util.UserContext;
 
 import org.w3c.dom.Element;
@@ -108,6 +109,5 @@
 		result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		// Get the parameters of the request
@@ -123,5 +123,5 @@
 		String collection = (String) params.get(GSXML.COLLECTION_ATT);
 
-		String filePath = _GSDM.archiveGetDocumentFilePath(oid, collection, lang, uid);
+		String filePath = _GSDM.archiveGetDocumentFilePath(oid, collection, userContext);
 		
 		Element metadataList = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
@@ -139,6 +139,5 @@
 		result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		// Get the parameters of the request
@@ -154,5 +153,5 @@
 		String collection = (String) params.get(GSXML.COLLECTION_ATT);
 
-		String oid = _GSDM.archiveGetSourceFileOID(srcFile, collection, lang, uid);
+		String oid = _GSDM.archiveGetSourceFileOID(srcFile, collection, userContext);
 		if(_GSDM.checkError(result, ARCHIVE_GET_SOURCE_FILE_OID))
 		{
@@ -174,6 +173,5 @@
 		result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		// Get the parameters of the request
@@ -189,5 +187,5 @@
 		String collection = (String) params.get(GSXML.COLLECTION_ATT);
 		
-		boolean exists = _GSDM.archiveCheckDocumentOrSectionExists(oid, collection, lang, uid);
+		boolean exists = _GSDM.archiveCheckDocumentOrSectionExists(oid, collection, userContext);
 		if(_GSDM.checkError(result, ARCHIVE_CHECK_DOCUMENT_OR_SECTION_EXISTS))
 		{
@@ -207,6 +205,5 @@
 		result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		// Get the parameters of the request
@@ -255,5 +252,5 @@
 		}
 		
-		_GSDM.archiveWriteEntryToDatabase(oid, collection, info, lang, uid);
+		_GSDM.archiveWriteEntryToDatabase(oid, collection, info, userContext);
 		_GSDM.checkError(result, ARCHIVE_WRITE_ENTRY_TO_DATABASE);
 
@@ -268,6 +265,5 @@
 		result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		// Get the parameters of the request
@@ -299,5 +295,5 @@
 		}
 		
-		_GSDM.archiveRemoveEntryFromDatabase(oid, collection, lang, uid);
+		_GSDM.archiveRemoveEntryFromDatabase(oid, collection, userContext);
 		_GSDM.checkError(result, ARCHIVE_REMOVE_ENTRY_FROM_DATABASE);
 
@@ -312,6 +308,5 @@
 		result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		// Get the parameters of the request
@@ -327,5 +322,5 @@
 		String collection = (String) params.get(GSXML.COLLECTION_ATT);
 
-		ArrayList<String> assocFiles = _GSDM.archiveGetAssociatedImportFiles(oid, collection, lang, uid);
+		ArrayList<String> assocFiles = _GSDM.archiveGetAssociatedImportFiles(oid, collection, userContext);
 		if(_GSDM.checkError(result, ARCHIVE_GET_ASSOCIATED_IMPORT_FILES))
 		{
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/ArchiveRetrieve.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/ArchiveRetrieve.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/ArchiveRetrieve.java	(revision 24993)
@@ -25,4 +25,5 @@
 import org.greenstone.gsdl3.util.GSXML;
 import org.greenstone.gsdl3.util.SimpleCollectionDatabase;
+import org.greenstone.gsdl3.util.UserContext;
 
 import org.w3c.dom.Element; 
@@ -106,6 +107,5 @@
 		result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
 		
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 		
 		// Get the parameters of the request
@@ -120,5 +120,5 @@
 		String collection = (String) params.get("c");
 		
-		String assocFilePath = getAssocFilePathFromDocID(oid, collection, lang, uid);
+		String assocFilePath = getAssocFilePathFromDocID(oid, collection, userContext);
 		
 		String docFilePath = this.site_home + File.separatorChar + 
@@ -143,6 +143,5 @@
 		result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
 		
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 		
 		// Get the parameters of the request
@@ -159,5 +158,5 @@
 		
 		//Find out what kind of database we have
-		String databaseType = getDatabaseTypeFromCollection(collection, lang, uid);
+		String databaseType = getDatabaseTypeFromCollection(collection, userContext);
 		if (databaseType == null || databaseType.equals("")) 
 		{
@@ -215,6 +214,5 @@
 		result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
 		
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 		
 		// Get the parameters of the request
@@ -230,5 +228,5 @@
 		String collection = (String) params.get("c");
 		
-		String databaseType = getDatabaseTypeFromCollection(collection, lang, uid);
+		String databaseType = getDatabaseTypeFromCollection(collection, userContext);
 		if (databaseType == null || databaseType.equals("")) 
 		{
@@ -294,8 +292,8 @@
 	}
 	
-	public String getAssocFilePathFromDocID(String oid, String collection, String lang, String uid)
+	public String getAssocFilePathFromDocID(String oid, String collection, UserContext userContext)
 	{
 		Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element mr_query_request = GSXML.createBasicRequest (this.doc, GSXML.REQUEST_TYPE_PAGE, collection + "/DocumentMetadataRetrieve", lang, uid);
+		Element mr_query_request = GSXML.createBasicRequest (this.doc, GSXML.REQUEST_TYPE_PAGE, collection + "/DocumentMetadataRetrieve", userContext);
 		mr_query_message.appendChild(mr_query_request);
 		
@@ -322,9 +320,9 @@
 	}
 	
-	public String getDatabaseTypeFromCollection(String collection, String lang, String uid)
+	public String getDatabaseTypeFromCollection(String collection, UserContext userContext)
 	{
 		//Find out what kind of database we have
 		Element dbTypeMessage = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element dbTypeRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, collection, lang, uid);
+		Element dbTypeRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, collection, userContext);
 		dbTypeMessage.appendChild(dbTypeRequest);
 		Element dbTypeResponse = (Element)this.router.process(dbTypeMessage);
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/BerryBasket.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/BerryBasket.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/BerryBasket.java	(revision 24993)
@@ -33,4 +33,5 @@
 import org.greenstone.gsdl3.util.GSXML;
 import org.greenstone.gsdl3.util.GSPath;
+import org.greenstone.gsdl3.util.UserContext;
 
 import java.net.InetAddress;
@@ -262,5 +263,9 @@
 		ArrayList tmp = new ArrayList();
 		tmp.add(id);
-		Element response = getDocumentMetadata(to, "en", "dumy", tmp.iterator());
+		
+		UserContext userContext = new UserContext();
+		userContext.setLanguage("en");
+		userContext.setUserID("dumy");
+		Element response = getDocumentMetadata(to, userContext, tmp.iterator());
 		Element doc_node = (Element) response.getElementsByTagName(GSXML.DOC_NODE_ELEM).item(0);
 
@@ -432,10 +437,10 @@
 	}
 
-	private Element getDocumentMetadata(String to, String lang, String uid, Iterator ids)
+	private Element getDocumentMetadata(String to, UserContext userContext, Iterator ids)
 	{
 
 		// Build a request to obtain some document metadata
 		Element dm_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element dm_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+		Element dm_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		dm_message.appendChild(dm_request);
 
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/CrossCollectionSearch.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/CrossCollectionSearch.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/CrossCollectionSearch.java	(revision 24993)
@@ -21,4 +21,5 @@
 import org.greenstone.gsdl3.util.GSXML;
 import org.greenstone.gsdl3.util.GSPath;
+import org.greenstone.gsdl3.util.UserContext;
 
 import org.w3c.dom.Element;
@@ -147,5 +148,6 @@
 		result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
+		UserContext userContext = new UserContext(request);
+		
 		// Get the parameters of the request
 		Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
@@ -182,5 +184,5 @@
 		}
 		// send the query to all colls
-		Element query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to_att.toString(), lang, "");
+		Element query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to_att.toString(), userContext);
 		query_message.appendChild(query_request);
 		// should we add params individually?
@@ -257,9 +259,11 @@
 	protected boolean initCollectionList()
 	{
-		String lang = "en";
-		String uid = "";
+		UserContext userContext = new UserContext();
+		userContext.setLanguage("en");
+		userContext.setUserID("");
+
 		// first, get the message router info
 		Element coll_list_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element coll_list_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", lang, ""); // uid
+		Element coll_list_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext); // uid
 		coll_list_message.appendChild(coll_list_request);
 		logger.debug("coll list request = " + this.converter.getPrettyString(coll_list_request));
@@ -281,5 +285,5 @@
 			Element c = (Element) colls.item(i);
 			String name = c.getAttribute(GSXML.NAME_ATT);
-			Element metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, name, lang, uid);
+			Element metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, name, userContext);
 			metadata_message.appendChild(metadata_request);
 		}
@@ -331,5 +335,5 @@
 		result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
+		UserContext userContext = new UserContext(request);
 		// Get the parameters of the request
 		Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
@@ -382,5 +386,5 @@
 			String cname = (String) e.getKey();
 			Element doc_nodes = (Element) e.getValue();
-			Element meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(cname, DOCUMENT_METADATA_RETRIEVE_SERVICE), lang, "");
+			Element meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(cname, DOCUMENT_METADATA_RETRIEVE_SERVICE), userContext);
 			meta_request.appendChild(doc_nodes);
 			meta_request.appendChild(new_param_list.cloneNode(true));
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocXMLUtil.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocXMLUtil.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocXMLUtil.java	(revision 24993)
@@ -24,4 +24,5 @@
 import org.greenstone.gsdl3.util.GSPath;
 import org.greenstone.gsdl3.util.GSXML;
+import org.greenstone.gsdl3.util.UserContext;
 
 import org.w3c.dom.Document;
@@ -122,6 +123,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Go through each of the document items that are requested
@@ -133,5 +133,5 @@
 			String collection = currentDoc.getAttribute(GSXML.COLLECTION_ATT);
 
-			_GSDM.documentXMLCreateDocXML(oid, collection, lang, uid);
+			_GSDM.documentXMLCreateDocXML(oid, collection, userContext);
 			if(_GSDM.checkError(result, DOC_XML_CREATE_EMPTY_FILE))
 			{
@@ -152,6 +152,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Go through each of the metadata items that are requested
@@ -164,5 +163,5 @@
 			String metadataName = currentMetadata.getAttribute(GSXML.NAME_ATT);
 
-			ArrayList<Element> metadataValues = _GSDM.documentXMLGetMetadata(oid, collection, metadataName, lang, uid);
+			ArrayList<Element> metadataValues = _GSDM.documentXMLGetMetadata(oid, collection, metadataName, userContext);
 			if(_GSDM.checkError(result, DOC_XML_GET_METADATA))
 			{
@@ -192,6 +191,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Go through each of the metadata items that are requested
@@ -237,5 +235,5 @@
 					return result;
 				}
-				_GSDM.documentXMLSetMetadata(oid, collection, metadataName, newMetadataValue, pos, op, lang, uid);
+				_GSDM.documentXMLSetMetadata(oid, collection, metadataName, newMetadataValue, pos, op, userContext);
 				if(_GSDM.checkError(result, DOC_XML_SET_METADATA))
 				{
@@ -246,5 +244,5 @@
 			else if (oldMetadataValue != null && !oldMetadataValue.equals(""))
 			{
-				_GSDM.documentXMLReplaceMetadata(oid, collection, metadataName, oldMetadataValue, newMetadataValue, lang, uid);
+				_GSDM.documentXMLReplaceMetadata(oid, collection, metadataName, oldMetadataValue, newMetadataValue, userContext);
 				if(_GSDM.checkError(result, DOC_XML_SET_METADATA))
 				{
@@ -272,6 +270,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Go through each of the requests 
@@ -283,5 +280,5 @@
 			String collection = currentSection.getAttribute(GSXML.COLLECTION_ATT);
 
-			_GSDM.documentXMLCreateSection(oid, collection, lang, uid);
+			_GSDM.documentXMLCreateSection(oid, collection, userContext);
 			if(_GSDM.checkError(result, DOC_XML_CREATE_SECTION))
 			{
@@ -302,6 +299,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Go through each of the requests 
@@ -313,5 +309,5 @@
 			String collection = currentSection.getAttribute(GSXML.COLLECTION_ATT);
 
-			_GSDM.documentXMLDeleteSection(oid, collection, lang, uid);
+			_GSDM.documentXMLDeleteSection(oid, collection, userContext);
 			if(_GSDM.checkError(result, DOC_XML_DELETE_SECTION))
 			{
@@ -332,6 +328,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Go through each of the requests 
@@ -343,5 +338,5 @@
 			String collection = currentSection.getAttribute(GSXML.COLLECTION_ATT);
 
-			_GSDM.documentXMLGetSection(oid, collection, lang, uid);
+			_GSDM.documentXMLGetSection(oid, collection, userContext);
 			if(_GSDM.checkError(result, DOC_XML_GET_SECTION))
 			{
@@ -362,6 +357,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Go through each of the requests 
@@ -388,5 +382,5 @@
 			}
 			
-			_GSDM.documentXMLSetSection(oid, collection, currentSection, op, lang, uid);
+			_GSDM.documentXMLSetSection(oid, collection, currentSection, op, userContext);
 			if(_GSDM.checkError(result, DOC_XML_SET_SECTION))
 			{
@@ -408,6 +402,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Go through each of the requests 
@@ -419,5 +412,5 @@
 			String collection = currentContent.getAttribute(GSXML.COLLECTION_ATT);
 
-			String content = _GSDM.documentXMLGetText(oid, collection, lang, uid);
+			String content = _GSDM.documentXMLGetText(oid, collection, userContext);
 			if(_GSDM.checkError(result, DOC_XML_GET_TEXT))
 			{
@@ -451,6 +444,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Go through each of the requests 
@@ -462,5 +454,5 @@
 			String collection = currentContent.getAttribute(GSXML.COLLECTION_ATT);
 
-			_GSDM.documentXMLSetText(oid, collection, currentContent, lang, uid);
+			_GSDM.documentXMLSetText(oid, collection, currentContent, userContext);
 			if(_GSDM.checkError(result, DOC_XML_SET_TEXT))
 			{
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocumentBasket.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocumentBasket.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocumentBasket.java	(revision 24993)
@@ -33,4 +33,5 @@
 import org.greenstone.gsdl3.util.GSXML;
 import org.greenstone.gsdl3.util.GSPath;
+import org.greenstone.gsdl3.util.UserContext;
 
 import java.net.InetAddress;
@@ -45,7 +46,5 @@
 import javax.swing.Timer;
 
-import java.io.FileOutputStream;
 import java.io.*;
-import java.io.IOException;
 
 import org.apache.log4j.*;
@@ -364,5 +363,10 @@
 		ArrayList tmp = new ArrayList();
 		tmp.add(id);
-		Element response = getDocumentMetadata(to, "en", "dumy", tmp.iterator());
+		
+		UserContext userContext = new UserContext();
+		userContext.setLanguage("en");
+		userContext.setUserID("dumy");
+		
+		Element response = getDocumentMetadata(to, userContext, tmp.iterator());
 		Element doc_node = (Element) response.getElementsByTagName(GSXML.DOC_NODE_ELEM).item(0);
 
@@ -539,10 +543,10 @@
 	}
 
-	private Element getDocumentMetadata(String to, String lang, String uid, Iterator ids)
+	private Element getDocumentMetadata(String to, UserContext userContext, Iterator ids)
 	{
 
 		// Build a request to obtain some document metadata
 		Element dm_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element dm_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
+		Element dm_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		dm_message.appendChild(dm_request);
 
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocumentMaker.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocumentMaker.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocumentMaker.java	(revision 24993)
@@ -38,4 +38,5 @@
 import org.greenstone.gsdl3.util.GSPath;
 import org.greenstone.gsdl3.util.GSXML;
+import org.greenstone.gsdl3.util.UserContext;
 
 import org.w3c.dom.Element;
@@ -123,6 +124,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Get the list of documents to create
@@ -135,5 +135,5 @@
 			String collection = currentDoc.getAttribute(GSXML.COLLECTION_ATT);
 
-			_GSDM.documentCreate(oid, collection, lang, uid);
+			_GSDM.documentCreate(oid, collection, userContext);
 			if (_GSDM.checkError(result, DOCUMENT_CREATE))
 			{
@@ -155,6 +155,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Get the list of documents to delete
@@ -166,5 +165,5 @@
 			String collection = currentDoc.getAttribute(GSXML.COLLECTION_ATT);
 
-			_GSDM.documentDelete(oid, collection, lang, uid);
+			_GSDM.documentDelete(oid, collection, userContext);
 			if (_GSDM.checkError(result, DOCUMENT_DELETE))
 			{
@@ -186,6 +185,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Get the list of documents to duplicate
@@ -200,5 +198,5 @@
 			String operation = currentDoc.getAttribute("operation");
 
-			_GSDM.documentMoveOrDuplicate(oid, collection, newOID, newCollection, _GSDM.operationStringToInt(operation), false, lang, uid);
+			_GSDM.documentMoveOrDuplicate(oid, collection, newOID, newCollection, _GSDM.operationStringToInt(operation), false, userContext);
 			if (_GSDM.checkError(result, DOCUMENT_DUPLICATE))
 			{
@@ -220,6 +218,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Get the list of documents to duplicate
@@ -239,5 +236,5 @@
 			}
 
-			_GSDM.documentGetInformation(oid, collection, requestedInfo, lang, uid);
+			_GSDM.documentGetInformation(oid, collection, requestedInfo, userContext);
 			if (_GSDM.checkError(result, DOCUMENT_GET_INFORMATION))
 			{
@@ -259,6 +256,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Get the list of documents to duplicate
@@ -273,5 +269,5 @@
 			String operation = currentDoc.getAttribute("operation");
 
-			_GSDM.documentMoveOrDuplicate(oid, collection, newOID, newCollection, _GSDM.operationStringToInt(operation), true, lang, uid);
+			_GSDM.documentMoveOrDuplicate(oid, collection, newOID, newCollection, _GSDM.operationStringToInt(operation), true, userContext);
 			if (_GSDM.checkError(result, DOCUMENT_MOVE))
 			{
@@ -292,6 +288,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Get the list of documents to duplicate
@@ -304,5 +299,5 @@
 			String mergeOID = currentDoc.getAttribute("merge" + GSXML.NODE_ID_ATT);
 
-			_GSDM.documentMerge(oid, collection, mergeOID, lang, uid);
+			_GSDM.documentMerge(oid, collection, mergeOID, userContext);
 			if (_GSDM.checkError(result, DOCUMENT_MERGE))
 			{
@@ -324,6 +319,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		//Get the list of documents to duplicate
@@ -347,5 +341,5 @@
 			}
 
-			_GSDM.documentSplit(oid, collection, split, lang, uid);
+			_GSDM.documentSplit(oid, collection, split, userContext);
 			if (_GSDM.checkError(result, DOCUMENT_SPLIT))
 			{
@@ -367,6 +361,5 @@
 		}
 
-		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
+		UserContext userContext = new UserContext(request);
 
 		Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
@@ -401,5 +394,5 @@
 					String subOperation = (String) keyValueMap.get("subOperation");
 
-					_GSDM.documentMoveOrDuplicate(origOID, origCollection, newOID, newCollection, _GSDM.operationStringToInt(subOperation), operation.equals("move"), lang, uid);
+					_GSDM.documentMoveOrDuplicate(origOID, origCollection, newOID, newCollection, _GSDM.operationStringToInt(subOperation), operation.equals("move"), userContext);
 
 					if (_GSDM.getErrorStatus() == GSDocumentModel.NO_ERROR && origCollection != null && !collectionsToBuild.contains(origCollection))
@@ -419,6 +412,6 @@
 					String subOperation = (String) keyValueMap.get("subOperation");
 
-					//_GSDM.documentCreate(oid, collection, lang, uid); <--- Maybe go back to this
-					_GSDM.documentXMLSetSection(oid, collection, this.doc.createElement(GSXML.DOCXML_SECTION_ELEM), _GSDM.operationStringToInt(subOperation), lang, uid);
+					//_GSDM.documentCreate(oid, collection, userContext); <--- Maybe go back to this
+					_GSDM.documentXMLSetSection(oid, collection, this.doc.createElement(GSXML.DOCXML_SECTION_ELEM), _GSDM.operationStringToInt(subOperation), userContext);
 
 					if (_GSDM.getErrorStatus() == GSDocumentModel.NO_ERROR && collection != null && !collectionsToBuild.contains(collection))
@@ -432,5 +425,5 @@
 					String collection = (String) keyValueMap.get("collection");
 
-					_GSDM.documentDelete(oid, collection, lang, uid);
+					_GSDM.documentDelete(oid, collection, userContext);
 
 					if (_GSDM.getErrorStatus() == GSDocumentModel.NO_ERROR && collection != null && !collectionsToBuild.contains(collection))
@@ -445,5 +438,5 @@
 					String newContent = (String) keyValueMap.get("text");
 					
-					_GSDM.documentXMLSetText(oid, collection, newContent, lang, uid);
+					_GSDM.documentXMLSetText(oid, collection, newContent, userContext);
 					
 					System.err.println(newContent);
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java	(revision 24993)
@@ -174,5 +174,7 @@
 		String lang = request.getAttribute(GSXML.LANG_ATT);
 
-		systemRequest("delete", coll_name, null, lang);
+		UserContext userContext = new UserContext(request);
+		
+		systemRequest("delete", coll_name, null, userContext);
 
 		Element response = runCommand(request, GS2PerlConstructor.ACTIVATE);
@@ -227,5 +229,5 @@
 		// once have got here, we assume
 		// the first bit proceeded successfully, now reload the collection
-		systemRequest("reload", coll_name, status, lang); // this will append more messages to the status, and overwrite the error code att
+		systemRequest("reload", coll_name, status, userContext); // this will append more messages to the status, and overwrite the error code att
 		return response;
 
@@ -282,5 +284,8 @@
 			return response;
 		}
-		systemRequest("delete", coll_name, status, lang);
+		
+		UserContext userContext = new UserContext(request);
+
+		systemRequest("delete", coll_name, status, userContext);
 		return response;
 	}
@@ -319,5 +324,8 @@
 
 		String coll_name = (String) params.get(COL_PARAM);
-		systemRequest("reload", coll_name, status, lang);
+		
+		UserContext userContext = new UserContext(request);
+
+		systemRequest("reload", coll_name, status, userContext);
 		return response;
 
@@ -328,9 +336,9 @@
 	 * "delete" or "reload" response will be put into the status element
 	 */
-	protected void systemRequest(String action_name, String coll_name, Element status, String lang)
+	protected void systemRequest(String action_name, String coll_name, Element status, UserContext userContext)
 	{
 		// send the request to the MR
 		Element message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_SYSTEM, "", lang, "");
+		Element request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_SYSTEM, "", userContext);
 		message.appendChild(request);
 		Element command = this.doc.createElement(GSXML.SYSTEM_ELEM);
@@ -361,5 +369,5 @@
 			if (response == null)
 			{
-				t = this.doc.createTextNode(getTextString(action_name + ".configure_error", lang, args));
+				t = this.doc.createTextNode(getTextString(action_name + ".configure_error", userContext.getLanguage(), args));
 				status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
 				status.appendChild(t);
@@ -368,5 +376,5 @@
 
 			// if we got here, we have succeeded!
-			t = this.doc.createTextNode(getTextString(action_name + ".success", lang, args));
+			t = this.doc.createTextNode(getTextString(action_name + ".success", userContext.getLanguage(), args));
 			status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.SUCCESS));
 			status.appendChild(t);
@@ -441,5 +449,4 @@
 
 		String lang = request.getAttribute(GSXML.LANG_ATT);
-		String uid = request.getAttribute(GSXML.USER_ID_ATT);
 		String request_type = request.getAttribute(GSXML.TYPE_ATT);
 
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSDocumentModel.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSDocumentModel.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSDocumentModel.java	(revision 24993)
@@ -121,5 +121,5 @@
 	 *            is the collection we want to create the document/section in.
 	 */
-	public void documentCreate(String oid, String collection, String lang, String uid)
+	public void documentCreate(String oid, String collection, UserContext userContext)
 	{
 		_errorStatus = NO_ERROR;
@@ -136,5 +136,5 @@
 			oid = generateOID();
 		}
-		else if (archiveCheckDocumentOrSectionExists(oid, collection, lang, uid))
+		else if (archiveCheckDocumentOrSectionExists(oid, collection, userContext))
 		{
 			_errorStatus = ERROR_DESTINATION_DOCUMENT_OR_SECTION_ALREADY_EXISTS;
@@ -164,5 +164,5 @@
 
 			//Write the new entry to the archive database 
-			archiveWriteEntryToDatabase(oid, collection, entries, lang, uid);
+			archiveWriteEntryToDatabase(oid, collection, entries, userContext);
 			if (_errorStatus != NO_ERROR)
 			{
@@ -171,9 +171,9 @@
 
 			//Create a basic doc.xml file to go in the new folder
-			documentXMLCreateDocXML(oid, collection, lang, uid);
+			documentXMLCreateDocXML(oid, collection, userContext);
 		}
 		else
 		{
-			documentXMLCreateSection(oid, collection, lang, uid);
+			documentXMLCreateSection(oid, collection, userContext);
 		}
 	}
@@ -187,5 +187,5 @@
 	 *            is the collection to delete the document/section from.
 	 */
-	public void documentDelete(String oid, String collection, String lang, String uid)
+	public void documentDelete(String oid, String collection, UserContext userContext)
 	{
 		_errorStatus = NO_ERROR;
@@ -201,5 +201,5 @@
 		}
 
-		if (!archiveCheckDocumentOrSectionExists(oid, collection, lang, uid))
+		if (!archiveCheckDocumentOrSectionExists(oid, collection, userContext))
 		{
 			_errorStatus = ERROR_SOURCE_DOCUMENT_OR_SECTION_DOES_NOT_EXIST;
@@ -225,9 +225,9 @@
 
 			//Remove the entry from the archive database 
-			archiveRemoveEntryFromDatabase(oid, collection, lang, uid);
+			archiveRemoveEntryFromDatabase(oid, collection, userContext);
 		}
 		else
 		{
-			documentXMLDeleteSection(oid, collection, lang, uid);
+			documentXMLDeleteSection(oid, collection, userContext);
 		}
 	}
@@ -249,7 +249,7 @@
 	 *            instead.
 	 */
-	public void documentMoveOrDuplicate(String oid, String collection, String newOID, String newCollection, int operation, boolean move, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
+	public void documentMoveOrDuplicate(String oid, String collection, String newOID, String newCollection, int operation, boolean move, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
 		{
 			return;
@@ -275,5 +275,5 @@
 		case OPERATION_TYPE_DOC_TO_DOC:
 		{
-			String archiveDir = archiveGetDocumentFilePath(oid, collection, lang, uid);
+			String archiveDir = archiveGetDocumentFilePath(oid, collection, userContext);
 			if (_errorStatus != NO_ERROR)
 			{
@@ -312,8 +312,8 @@
 		case OPERATION_TYPE_DOC_TO_SEC:
 		{
-			Document originalDocument = getDocXML(oid, collection, lang, uid);
+			Document originalDocument = getDocXML(oid, collection, userContext);
 			Element originalSection = getTopLevelSectionElement(originalDocument);
 
-			documentXMLCreateSection(newOID, newCollection, lang, uid);
+			documentXMLCreateSection(newOID, newCollection, userContext);
 			if (_errorStatus != NO_ERROR)
 			{
@@ -321,9 +321,9 @@
 			}
 
-			documentXMLSetSection(newOID, newCollection, originalSection, operation, lang, uid);
+			documentXMLSetSection(newOID, newCollection, originalSection, operation, userContext);
 
 			if (move)
 			{
-				String archiveDirStr = archiveGetDocumentFilePath(oid, collection, lang, uid);
+				String archiveDirStr = archiveGetDocumentFilePath(oid, collection, userContext);
 				if (_errorStatus != NO_ERROR)
 				{
@@ -342,8 +342,8 @@
 		case OPERATION_TYPE_SEC_TO_DOC:
 		{
-			Document originalDocument = getDocXML(oid, collection, lang, uid);
+			Document originalDocument = getDocXML(oid, collection, userContext);
 			Element originalSection = getSectionBySectionNumber(originalDocument, getSectionFromOID(oid));
 
-			documentCreate(newOID, newCollection, lang, uid);
+			documentCreate(newOID, newCollection, userContext);
 			if (_errorStatus != NO_ERROR)
 			{
@@ -351,5 +351,5 @@
 			}
 
-			documentXMLCreateSection(newOID, newCollection, lang, uid);
+			documentXMLCreateSection(newOID, newCollection, userContext);
 			if (_errorStatus != NO_ERROR)
 			{
@@ -357,13 +357,13 @@
 			}
 
-			documentXMLSetSection(newOID, newCollection, originalSection, operation, lang, uid);
+			documentXMLSetSection(newOID, newCollection, originalSection, operation, userContext);
 
 			if (move)
 			{
-				originalDocument = getDocXML(oid, collection, lang, uid);
+				originalDocument = getDocXML(oid, collection, userContext);
 				originalSection.getParentNode().removeChild(originalSection);
 
 				//Write the new change back into the file
-				if (!writeXMLFile(originalDocument, oid, collection, lang, uid))
+				if (!writeXMLFile(originalDocument, oid, collection, userContext))
 				{
 					_errorStatus = ERROR_COULD_NOT_WRITE_TO_DOC_XML;
@@ -377,10 +377,10 @@
 		case OPERATION_TYPE_SEC_TO_SEC:
 		{
-			Document originalDocument = getDocXML(oid, collection, lang, uid);
+			Document originalDocument = getDocXML(oid, collection, userContext);
 			Element originalSection = getSectionBySectionNumber(originalDocument, getSectionFromOID(oid));
 
 			if (operation == OPERATION_REPLACE)
 			{
-				documentXMLCreateSection(newOID, newCollection, lang, uid);
+				documentXMLCreateSection(newOID, newCollection, userContext);
 				if (_errorStatus != NO_ERROR)
 				{
@@ -389,5 +389,5 @@
 			}
 
-			documentXMLSetSection(newOID, newCollection, originalSection, operation, lang, uid);
+			documentXMLSetSection(newOID, newCollection, originalSection, operation, userContext);
 			if (_errorStatus != NO_ERROR)
 			{
@@ -397,9 +397,9 @@
 			if (move)
 			{
-				originalDocument = getDocXML(oid, collection, lang, uid);
+				originalDocument = getDocXML(oid, collection, userContext);
 				originalSection.getParentNode().removeChild(originalSection);
 
 				//Write the new change back into the file
-				if (!writeXMLFile(originalDocument, oid, collection, lang, uid))
+				if (!writeXMLFile(originalDocument, oid, collection, userContext))
 				{
 					_errorStatus = ERROR_COULD_NOT_WRITE_TO_DOC_XML;
@@ -420,5 +420,5 @@
 
 			//Write the new entry to the archive database 
-			archiveWriteEntryToDatabase(newOID, newCollection, entries, lang, uid);
+			archiveWriteEntryToDatabase(newOID, newCollection, entries, userContext);
 		}
 	}
@@ -435,7 +435,7 @@
 	 * @return This returns an array containing the requested information.
 	 */
-	public String[] documentGetInformation(String oid, String collection, String[] requestedInfo, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
+	public String[] documentGetInformation(String oid, String collection, String[] requestedInfo, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
 		{
 			return null;
@@ -467,12 +467,12 @@
 	 *            merged into.
 	 */
-	public void documentMerge(String oid, String collection, String mergeOID, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
-		{
-			return;
-		}
-
-		if ((_errorStatus = checkOIDandCollection(mergeOID, collection, lang, uid)) != NO_ERROR)
+	public void documentMerge(String oid, String collection, String mergeOID, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
+		{
+			return;
+		}
+
+		if ((_errorStatus = checkOIDandCollection(mergeOID, collection, userContext)) != NO_ERROR)
 		{
 			return;
@@ -504,5 +504,5 @@
 		}
 
-		Document docXML = getDocXML(oid, collection, lang, uid);
+		Document docXML = getDocXML(oid, collection, userContext);
 		if (docXML == null)
 		{
@@ -569,5 +569,5 @@
 		}
 
-		documentXMLSetSection(mergeOID, collection, sourceSection, OPERATION_REPLACE, lang, uid);
+		documentXMLSetSection(mergeOID, collection, sourceSection, OPERATION_REPLACE, userContext);
 		if (_errorStatus != NO_ERROR)
 		{
@@ -575,5 +575,5 @@
 		}
 
-		documentXMLDeleteSection(oid, collection, lang, uid);
+		documentXMLDeleteSection(oid, collection, userContext);
 	}
 
@@ -590,12 +590,12 @@
 	 *            is the point in the text we want to split at.
 	 */
-	public void documentSplit(String oid, String collection, int splitPoint, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
-		{
-			return;
-		}
-
-		Document docXML = getDocXML(oid, collection, lang, uid);
+	public void documentSplit(String oid, String collection, int splitPoint, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
+		{
+			return;
+		}
+
+		Document docXML = getDocXML(oid, collection, userContext);
 		if (docXML == null)
 		{
@@ -644,5 +644,5 @@
 		newSection.appendChild(newContent);
 
-		documentXMLSetSection(oid, collection, newSection, OPERATION_INSERT_BEFORE, lang, uid);
+		documentXMLSetSection(oid, collection, newSection, OPERATION_INSERT_BEFORE, userContext);
 		if (_errorStatus != NO_ERROR)
 		{
@@ -652,5 +652,5 @@
 
 		//Write the new change back into the file
-		if (!writeXMLFile(docXML, oid, collection, lang, uid))
+		if (!writeXMLFile(docXML, oid, collection, userContext))
 		{
 			_errorStatus = ERROR_COULD_NOT_WRITE_TO_DOC_XML;
@@ -666,5 +666,5 @@
 	 *            is the collection the new document will reside in.
 	 */
-	public void documentXMLCreateDocXML(String oid, String collection, String lang, String uid)
+	public void documentXMLCreateDocXML(String oid, String collection, UserContext userContext)
 	{
 		_errorStatus = NO_ERROR;
@@ -673,5 +673,5 @@
 			Document docXML = null;
 
-			String filePath = archiveGetDocumentFilePath(oid, collection, lang, uid);
+			String filePath = archiveGetDocumentFilePath(oid, collection, userContext);
 			File docFile = new File(filePath);
 			if (!docFile.exists() && !docFile.createNewFile())
@@ -714,7 +714,7 @@
 	 * @return an array of metadata elements containing the resquested metadata
 	 */
-	public ArrayList<Element> documentXMLGetMetadata(String oid, String collection, String metadataName, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
+	public ArrayList<Element> documentXMLGetMetadata(String oid, String collection, String metadataName, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
 		{
 			return null;
@@ -726,5 +726,5 @@
 		}
 
-		Document docXML = getDocXML(oid, collection, lang, uid);
+		Document docXML = getDocXML(oid, collection, userContext);
 		if (docXML == null)
 		{
@@ -753,7 +753,7 @@
 	 *            OPERATION_INSERT_AFTER or OPERATION_APPEND.
 	 */
-	public void documentXMLSetMetadata(String oid, String collection, String metadataName, String newMetadataValue, int position, int operation, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
+	public void documentXMLSetMetadata(String oid, String collection, String metadataName, String newMetadataValue, int position, int operation, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
 		{
 			return;
@@ -770,5 +770,5 @@
 		}
 
-		Document docXML = getDocXML(oid, collection, lang, uid);
+		Document docXML = getDocXML(oid, collection, userContext);
 		if (docXML == null)
 		{
@@ -825,5 +825,5 @@
 
 		//Write the new change back into the file
-		if (!writeXMLFile(docXML, oid, collection, lang, uid))
+		if (!writeXMLFile(docXML, oid, collection, userContext))
 		{
 			_errorStatus = ERROR_COULD_NOT_WRITE_TO_DOC_XML;
@@ -845,7 +845,7 @@
 	 *            is position of the item that is to be deleted.
 	 */
-	public void documentXMLDeleteMetadata(String oid, String collection, String metadataName, int position, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
+	public void documentXMLDeleteMetadata(String oid, String collection, String metadataName, int position, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
 		{
 			return;
@@ -857,5 +857,5 @@
 		}
 
-		Document docXML = getDocXML(oid, collection, lang, uid);
+		Document docXML = getDocXML(oid, collection, userContext);
 		if (docXML == null)
 		{
@@ -884,7 +884,7 @@
 	 *            is the name of the metadata to delete.
 	 */
-	public void documentXMLDeleteMetadata(String oid, String collection, String metadataName, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
+	public void documentXMLDeleteMetadata(String oid, String collection, String metadataName, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
 		{
 			return;
@@ -896,5 +896,5 @@
 		}
 
-		Document docXML = getDocXML(oid, collection, lang, uid);
+		Document docXML = getDocXML(oid, collection, userContext);
 		if (docXML == null)
 		{
@@ -929,7 +929,7 @@
 	 *            value.
 	 */
-	public void documentXMLReplaceMetadata(String oid, String collection, String metadataName, String oldMetadataValue, String newMetadataValue, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
+	public void documentXMLReplaceMetadata(String oid, String collection, String metadataName, String oldMetadataValue, String newMetadataValue, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
 		{
 			return;
@@ -951,5 +951,5 @@
 		}
 
-		Document docXML = getDocXML(oid, collection, lang, uid);
+		Document docXML = getDocXML(oid, collection, userContext);
 		if (docXML == null)
 		{
@@ -971,5 +971,5 @@
 
 		//Write the new change back into the file
-		if (!writeXMLFile(docXML, oid, collection, lang, uid))
+		if (!writeXMLFile(docXML, oid, collection, userContext))
 		{
 			_errorStatus = ERROR_COULD_NOT_WRITE_TO_DOC_XML;
@@ -985,5 +985,5 @@
 	 *            is the collection the document resides in.
 	 */
-	public void documentXMLCreateSection(String oid, String collection, String lang, String uid)
+	public void documentXMLCreateSection(String oid, String collection, UserContext userContext)
 	{
 		_errorStatus = NO_ERROR;
@@ -999,7 +999,7 @@
 		}
 
-		if (oid.contains(".") && !archiveCheckDocumentOrSectionExists(oid.substring(0, oid.indexOf(".")), collection, lang, uid))
-		{
-			documentCreate(oid.substring(0, oid.indexOf(".")), collection, lang, uid);
+		if (oid.contains(".") && !archiveCheckDocumentOrSectionExists(oid.substring(0, oid.indexOf(".")), collection, userContext))
+		{
+			documentCreate(oid.substring(0, oid.indexOf(".")), collection, userContext);
 			if (_errorStatus != NO_ERROR)
 			{
@@ -1008,5 +1008,5 @@
 		}
 
-		Document docXML = getDocXML(oid, collection, lang, uid);
+		Document docXML = getDocXML(oid, collection, userContext);
 		if (docXML == null)
 		{
@@ -1068,5 +1068,5 @@
 
 		//Write the new change back into the file
-		if (!writeXMLFile(docXML, oid, collection, lang, uid))
+		if (!writeXMLFile(docXML, oid, collection, userContext))
 		{
 			_errorStatus = ERROR_COULD_NOT_WRITE_TO_DOC_XML;
@@ -1082,12 +1082,12 @@
 	 *            is the collection the document resides in.
 	 */
-	public void documentXMLDeleteSection(String oid, String collection, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
-		{
-			return;
-		}
-
-		Document docXML = getDocXML(oid, collection, lang, uid);
+	public void documentXMLDeleteSection(String oid, String collection, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
+		{
+			return;
+		}
+
+		Document docXML = getDocXML(oid, collection, userContext);
 		if (docXML == null)
 		{
@@ -1106,5 +1106,5 @@
 
 		//Write the new change back into the file
-		if (!writeXMLFile(docXML, oid, collection, lang, uid))
+		if (!writeXMLFile(docXML, oid, collection, userContext))
 		{
 			_errorStatus = ERROR_COULD_NOT_WRITE_TO_DOC_XML;
@@ -1121,12 +1121,12 @@
 	 * @return the requested section.
 	 */
-	public Element documentXMLGetSection(String oid, String collection, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
-		{
-			return null;
-		}
-
-		Document docXML = getDocXML(oid, collection, lang, uid);
+	public Element documentXMLGetSection(String oid, String collection, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
+		{
+			return null;
+		}
+
+		Document docXML = getDocXML(oid, collection, userContext);
 		if (docXML == null)
 		{
@@ -1168,12 +1168,12 @@
 	 * @throws IOException
 	 */
-	public void documentXMLSetSection(String oid, String collection, Element newSection, int operation, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
-		{
-			return;
-		}
-
-		Document docXML = getDocXML(oid, collection, lang, uid);
+	public void documentXMLSetSection(String oid, String collection, Element newSection, int operation, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
+		{
+			return;
+		}
+
+		Document docXML = getDocXML(oid, collection, userContext);
 		if (docXML == null)
 		{
@@ -1240,5 +1240,5 @@
 		
 		//Write the new change back into the file
-		if (!writeXMLFile(docXML, oid, collection, lang, uid))
+		if (!writeXMLFile(docXML, oid, collection, userContext))
 		{
 			_errorStatus = ERROR_COULD_NOT_WRITE_TO_DOC_XML;
@@ -1256,12 +1256,12 @@
 	 * @return the text from the section.
 	 */
-	public String documentXMLGetText(String oid, String collection, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
-		{
-			return null;
-		}
-
-		Document docXML = getDocXML(oid, collection, lang, uid);
+	public String documentXMLGetText(String oid, String collection, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
+		{
+			return null;
+		}
+
+		Document docXML = getDocXML(oid, collection, userContext);
 		if (docXML == null)
 		{
@@ -1311,12 +1311,12 @@
 	 *            is the new content element for the section.
 	 */
-	public void documentXMLSetText(String oid, String collection, Element newContent, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
-		{
-			return;
-		}
-
-		Document docXML = getDocXML(oid, collection, lang, uid);
+	public void documentXMLSetText(String oid, String collection, Element newContent, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
+		{
+			return;
+		}
+
+		Document docXML = getDocXML(oid, collection, userContext);
 		if (docXML == null)
 		{
@@ -1363,5 +1363,5 @@
 
 		//Write the new change back into the file
-		if (!writeXMLFile(docXML, oid, collection, lang, uid))
+		if (!writeXMLFile(docXML, oid, collection, userContext))
 		{
 			_errorStatus = ERROR_COULD_NOT_WRITE_TO_DOC_XML;
@@ -1380,12 +1380,12 @@
 	 *            is the new text for the section.
 	 */
-	public void documentXMLSetText(String oid, String collection, String newContent, String lang, String uid)
-	{
-		if ((_errorStatus = checkOIDandCollection(oid, collection, lang, uid)) != NO_ERROR)
-		{
-			return;
-		}
-
-		Document docXML = getDocXML(oid, collection, lang, uid);
+	public void documentXMLSetText(String oid, String collection, String newContent, UserContext userContext)
+	{
+		if ((_errorStatus = checkOIDandCollection(oid, collection, userContext)) != NO_ERROR)
+		{
+			return;
+		}
+
+		Document docXML = getDocXML(oid, collection, userContext);
 		if (docXML == null)
 		{
@@ -1433,5 +1433,5 @@
 
 		//Write the new change back into the file
-		if (!writeXMLFile(docXML, oid, collection, lang, uid))
+		if (!writeXMLFile(docXML, oid, collection, userContext))
 		{
 			_errorStatus = ERROR_COULD_NOT_WRITE_TO_DOC_XML;
@@ -1451,5 +1451,5 @@
 	 * @return the file path to the doc.xml file.
 	 */
-	public String archiveGetDocumentFilePath(String oid, String collection, String lang, String uid)
+	public String archiveGetDocumentFilePath(String oid, String collection, UserContext userContext)
 	{
 		_errorStatus = NO_ERROR;
@@ -1460,5 +1460,5 @@
 		}
 
-		String assocFilePath = getDocFilePathFromDatabase(oid, collection, lang, uid);
+		String assocFilePath = getDocFilePathFromDatabase(oid, collection, userContext);
 		if (assocFilePath == null)
 		{
@@ -1485,8 +1485,8 @@
 	 * @return the OID of the document that the source file is used in.
 	 */
-	public String archiveGetSourceFileOID(String srcFile, String collection, String lang, String uid)
+	public String archiveGetSourceFileOID(String srcFile, String collection, UserContext userContext)
 	{
 		_errorStatus = NO_ERROR;
-		SimpleCollectionDatabase coll_db = openDatabase(collection, ARCHIVEINFSRC, SimpleCollectionDatabase.READ, lang, uid);
+		SimpleCollectionDatabase coll_db = openDatabase(collection, ARCHIVEINFSRC, SimpleCollectionDatabase.READ, userContext);
 		if (coll_db == null)
 		{
@@ -1518,8 +1518,8 @@
 	 * @return true if the document/section exists, false otherwise.
 	 */
-	public boolean archiveCheckDocumentOrSectionExists(String oid, String collection, String lang, String uid)
+	public boolean archiveCheckDocumentOrSectionExists(String oid, String collection, UserContext userContext)
 	{
 		_errorStatus = NO_ERROR;
-		SimpleCollectionDatabase coll_db = openDatabase(collection, ARCHIVEINFDOC, SimpleCollectionDatabase.READ, lang, uid);
+		SimpleCollectionDatabase coll_db = openDatabase(collection, ARCHIVEINFDOC, SimpleCollectionDatabase.READ, userContext);
 		if (coll_db == null)
 		{
@@ -1548,5 +1548,5 @@
 		if (section && exists)
 		{
-			Document docXML = getDocXML(oid, collection, lang, uid);
+			Document docXML = getDocXML(oid, collection, userContext);
 			if (getSectionBySectionNumber(docXML, getSectionFromOID(oid)) == null)
 			{
@@ -1569,5 +1569,5 @@
 	 *            is the list of entries to write.
 	 */
-	public void archiveWriteEntryToDatabase(String oid, String collection, HashMap<String, ArrayList<String>> infoList, String lang, String uid)
+	public void archiveWriteEntryToDatabase(String oid, String collection, HashMap<String, ArrayList<String>> infoList, UserContext userContext)
 	{
 		_errorStatus = NO_ERROR;
@@ -1593,5 +1593,5 @@
 		}
 
-		SimpleCollectionDatabase coll_db = openDatabase(collection, ARCHIVEINFDOC, SimpleCollectionDatabase.WRITE, lang, uid);
+		SimpleCollectionDatabase coll_db = openDatabase(collection, ARCHIVEINFDOC, SimpleCollectionDatabase.WRITE, userContext);
 		if (coll_db == null)
 		{
@@ -1611,5 +1611,5 @@
 	 *            is the collection whose database will have the entry removed.
 	 */
-	public void archiveRemoveEntryFromDatabase(String oid, String collection, String lang, String uid)
+	public void archiveRemoveEntryFromDatabase(String oid, String collection, UserContext userContext)
 	{
 		_errorStatus = NO_ERROR;
@@ -1625,5 +1625,5 @@
 		}
 
-		SimpleCollectionDatabase coll_db = openDatabase(collection, ARCHIVEINFDOC, SimpleCollectionDatabase.WRITE, lang, uid);
+		SimpleCollectionDatabase coll_db = openDatabase(collection, ARCHIVEINFDOC, SimpleCollectionDatabase.WRITE, userContext);
 		if (coll_db == null)
 		{
@@ -1645,5 +1645,5 @@
 	 * @return the list of associated files.
 	 */
-	public ArrayList<String> archiveGetAssociatedImportFiles(String oid, String collection, String lang, String uid)
+	public ArrayList<String> archiveGetAssociatedImportFiles(String oid, String collection, UserContext userContext)
 	{
 		_errorStatus = NO_ERROR;
@@ -1659,5 +1659,5 @@
 		}
 
-		SimpleCollectionDatabase coll_db = openDatabase(collection, ARCHIVEINFDOC, SimpleCollectionDatabase.READ, lang, uid);
+		SimpleCollectionDatabase coll_db = openDatabase(collection, ARCHIVEINFDOC, SimpleCollectionDatabase.READ, userContext);
 		if (coll_db == null)
 		{
@@ -1756,7 +1756,7 @@
 	}
 
-	public String getDocFilePathFromDatabase(String oid, String collection, String lang, String uid)
-	{
-		SimpleCollectionDatabase coll_db = openDatabase(collection, ARCHIVEINFDOC, SimpleCollectionDatabase.WRITE, lang, uid);
+	public String getDocFilePathFromDatabase(String oid, String collection, UserContext userContext)
+	{
+		SimpleCollectionDatabase coll_db = openDatabase(collection, ARCHIVEINFDOC, SimpleCollectionDatabase.WRITE, userContext);
 		if (coll_db == null)
 		{
@@ -1810,5 +1810,5 @@
 	}
 
-	public int checkOIDandCollection(String oid, String collection, String lang, String uid)
+	public int checkOIDandCollection(String oid, String collection, UserContext userContext)
 	{
 		if (oid == null || oid.equals(""))
@@ -1822,5 +1822,5 @@
 		}
 
-		if (!archiveCheckDocumentOrSectionExists(oid, collection, lang, uid))
+		if (!archiveCheckDocumentOrSectionExists(oid, collection, userContext))
 		{
 			return ERROR_SOURCE_DOCUMENT_OR_SECTION_DOES_NOT_EXIST;
@@ -1883,5 +1883,5 @@
 	}
 
-	public boolean writeXMLFile(Document doc, String oid, String collection, String lang, String uid)
+	public boolean writeXMLFile(Document doc, String oid, String collection, UserContext userContext)
 	{
 		try
@@ -1889,5 +1889,5 @@
 			DOMSource source = new DOMSource(doc);
 
-			String test = archiveGetDocumentFilePath(oid, collection, lang, uid);
+			String test = archiveGetDocumentFilePath(oid, collection, userContext);
 			File xmlFile = new File(test);
 			Result result = new StreamResult(xmlFile);
@@ -1903,5 +1903,5 @@
 	}
 
-	public Document getDocXML(String oid, String collection, String lang, String uid)
+	public Document getDocXML(String oid, String collection, UserContext userContext)
 	{
 		if (oid.contains("."))
@@ -1913,5 +1913,5 @@
 		if ((docXML = _docCache.get(oid + "__" + collection)) == null)
 		{
-			String filePath = archiveGetDocumentFilePath(oid, collection, lang, uid);
+			String filePath = archiveGetDocumentFilePath(oid, collection, userContext);
 			File docFile = new File(filePath);
 
@@ -2005,9 +2005,9 @@
 	}
 
-	public String getDatabaseTypeFromCollection(String collection, String lang, String uid)
+	public String getDatabaseTypeFromCollection(String collection, UserContext userContext)
 	{
 		//Find out what kind of database we have
 		Element dbTypeMessage = _mainDoc.createElement(GSXML.MESSAGE_ELEM);
-		Element dbTypeRequest = GSXML.createBasicRequest(_mainDoc, GSXML.REQUEST_TYPE_DESCRIBE, collection, lang, uid);
+		Element dbTypeRequest = GSXML.createBasicRequest(_mainDoc, GSXML.REQUEST_TYPE_DESCRIBE, collection, userContext);
 		dbTypeMessage.appendChild(dbTypeRequest);
 		Element dbTypeResponse = (Element) _router.process(dbTypeMessage);
@@ -2023,8 +2023,8 @@
 	}
 
-	public SimpleCollectionDatabase openDatabase(String collection, String dbName, int readWrite, String lang, String uid)
+	public SimpleCollectionDatabase openDatabase(String collection, String dbName, int readWrite, UserContext userContext)
 	{
 		//Find out what kind of database we have
-		String databaseType = getDatabaseTypeFromCollection(collection, lang, uid);
+		String databaseType = getDatabaseTypeFromCollection(collection, userContext);
 		String dbExt = DBHelper.getDBExtFromDBType(databaseType);
 
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java	(revision 24992)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java	(revision 24993)
@@ -727,11 +727,11 @@
 
 	/** returns a basic request message */
-	public static Element createBasicRequest(Document owner, String request_type, String to, String lang, String uid)
+	public static Element createBasicRequest(Document owner, String request_type, String to, UserContext userContext)
 	{
 		Element request = owner.createElement(REQUEST_ELEM);
 		request.setAttribute(TYPE_ATT, request_type);
-		request.setAttribute(LANG_ATT, lang);
+		request.setAttribute(LANG_ATT, userContext._lang);
 		request.setAttribute(TO_ATT, to);
-		request.setAttribute(USER_ID_ATT, uid);
+		request.setAttribute(USER_ID_ATT, userContext._userID);
 		return request;
 	}
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/UserContext.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/UserContext.java	(revision 24993)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/UserContext.java	(revision 24993)
@@ -0,0 +1,45 @@
+package org.greenstone.gsdl3.util;
+
+import org.w3c.dom.Element;
+
+public class UserContext
+{
+	protected String _userID = null;
+	protected String _lang = null;
+	
+	public UserContext(){}
+	
+	public UserContext(Element xmlRequest)
+	{
+		_lang = xmlRequest.getAttribute(GSXML.LANG_ATT);
+		_userID = xmlRequest.getAttribute(GSXML.USER_ID_ATT);
+	}
+	
+	public void setLanguage(String lang)
+	{
+		_lang = lang;
+	}
+	
+	public void setUserID(String userID)
+	{
+		_userID = userID;
+	}
+	
+	public String getLanguage()
+	{
+		if(_lang != null)
+		{
+			return _lang;
+		}
+		return "";
+	}
+	
+	public String getUserID()
+	{
+		if(_userID != null)
+		{
+			return _userID;
+		}
+		return "";
+	}
+}
