Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSDocumentModel.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSDocumentModel.java	(revision 24984)
+++ 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 24984)
+++ 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 "";
+	}
+}
