Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java	(revision 33699)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java	(revision 33700)
@@ -55,4 +55,5 @@
 import org.greenstone.gsdl3.core.Receptionist;
 import org.greenstone.gsdl3.service.Authentication;
+import org.greenstone.gsdl3.util.Dictionary;
 import org.greenstone.gsdl3.util.GSConstants;
 import org.greenstone.gsdl3.util.GSParams;
@@ -87,4 +88,6 @@
 public class LibraryServlet extends BaseGreenstoneServlet
 {
+  protected static final String LOGIN_MESSAGE_PARAM = "loginMessage";
+  protected static final String REDIRECT_URL_PARAM = "redirectURL";
 	/** the receptionist to send messages to */
 	protected Receptionist recept = null;
@@ -346,5 +349,5 @@
 			  String q = queryIter.next();
 			  String[] vals = queryMap.get(q);
-			  queryParamStr += q +"="+String.join(",",vals)+" ";
+			  queryParamStr += q +"="+StringUtils.join(vals, ",")+" ";
 			}
 		}
@@ -493,9 +496,10 @@
 		userContext.setLanguage(lang);
 		userContext.setUserID(uid);
+		logger.error("LS new user context");
 		if (request.getAuthType() != null)
 		{
 			//Get the username
   		  userContext.setUsername(request.getUserPrincipal().getName());
-
+		  logger.error("setting username = "+request.getUserPrincipal().getName());
 			//Get the groups for the user
 			Document msg_doc = XMLConverter.newDOM();
@@ -858,9 +862,11 @@
 		xml_request.setAttribute("fullURL", fullURL.replace("&", "&amp;"));
 
-		if (!runSecurityChecks(request, xml_request, userContext, out, baseURL, collection, document, queryMap))
+		if (!runSecurityChecks(request, xml_request, userContext, out, baseURL, collection, document, queryMap, lang))
 		{
 			return;
 		}
 
+		logger.error("about to process this message");
+		logger.error(XMLConverter.getPrettyString(xml_message));
 		Node xml_result = this.recept.process(xml_message);
 		encodeURLs(xml_result, response);
@@ -895,6 +901,7 @@
 	} //end of doGet(HttpServletRequest, HttpServletResponse)
 
-	private boolean runSecurityChecks(HttpServletRequest request, Element xml_request, UserContext userContext, PrintWriter out, String baseURL, String collection, String document, Map<String, String[]> queryMap) throws ServletException
+  private boolean runSecurityChecks(HttpServletRequest request, Element xml_request, UserContext userContext, PrintWriter out, String baseURL, String collection, String document, Map<String, String[]> queryMap, String lang) throws ServletException
 	{
+	  logger.error("kk in run security");
 		//Check if we need to login or logout
 		String username = getFirstParam(GSParams.USERNAME, queryMap);
@@ -909,4 +916,5 @@
 		if (username != null && password != null)
 		{
+		  logger.error("kk u&p not null");
 			//We are changing to another user, so log out first
 			if (request.getAuthType() != null)
@@ -946,10 +954,10 @@
 
 					Element messageParam = loginPageDoc.createElement(GSXML.PARAM_ELEM);
-					messageParam.setAttribute(GSXML.NAME_ATT, "loginMessage");
-					messageParam.setAttribute(GSXML.VALUE_ATT, "Either your username or password was incorrect, please try again.");
+					messageParam.setAttribute(GSXML.NAME_ATT, LOGIN_MESSAGE_PARAM);
+					messageParam.setAttribute(GSXML.VALUE_ATT, getTextString("auth.error.un_or_pw_err", lang));
 					paramList.appendChild(messageParam);
 
 					Element urlParam = loginPageDoc.createElement(GSXML.PARAM_ELEM);
-					urlParam.setAttribute(GSXML.NAME_ATT, "redirectURL");
+					urlParam.setAttribute(GSXML.NAME_ATT, REDIRECT_URL_PARAM);
 					String queryString = "";
 					if (request.getQueryString() != null)
@@ -971,7 +979,8 @@
 		if (request.getAuthType() != null)
 		{
+		  logger.error("kk auth type not null "+ request.getAuthType());
 		  Element userInformation = xml_request.getOwnerDocument().createElement(GSXML.USER_INFORMATION_ELEM);
 			userInformation.setAttribute(GSXML.USERNAME_ATT, request.getUserPrincipal().getName());
-
+			logger.error("setting user info username "+request.getUserPrincipal().getName());
 			Document msg_doc = XMLConverter.newDOM();
 			Element userInfoMessage = msg_doc.createElement(GSXML.MESSAGE_ELEM);
@@ -1000,5 +1009,5 @@
 
 				userInformation.setAttribute(GSXML.GROUPS_ATT, groups);
-				userInformation.setAttribute("editEnabled", (editEnabled != null) ? editEnabled : "false");
+				userInformation.setAttribute(GSXML.EDIT_ENABLED_ATT, (editEnabled != null) ? editEnabled : "false");
 				xml_request.appendChild(userInformation);
 			}
@@ -1008,4 +1017,5 @@
 		if (collection != null && !collection.equals(""))
 		{
+		  logger.error("kk in a coll"+collection);
 			//Get the security info for this collection
 		  Document msg_doc = XMLConverter.newDOM();
@@ -1042,4 +1052,5 @@
 				if (!found)
 				{
+				  logger.error("kk current user not allowed to access");
 				  Document loginPageDoc = XMLConverter.newDOM();
 					Element loginPageMessage = loginPageDoc.createElement(GSXML.MESSAGE_ELEM);
@@ -1055,17 +1066,17 @@
 
 					Element messageParam = loginPageDoc.createElement(GSXML.PARAM_ELEM);
-					messageParam.setAttribute(GSXML.NAME_ATT, "loginMessage");
+					messageParam.setAttribute(GSXML.NAME_ATT, LOGIN_MESSAGE_PARAM);
 					if (request.getAuthType() == null)
 					{
-						messageParam.setAttribute(GSXML.VALUE_ATT, "Please log in to view this page");
+					  messageParam.setAttribute(GSXML.VALUE_ATT, getTextString("auth.error.login", lang));
 					}
 					else
 					{
-						messageParam.setAttribute(GSXML.VALUE_ATT, "You are not in the correct group to view this page, would you like to log in as a different user?");
+					  messageParam.setAttribute(GSXML.VALUE_ATT, getTextString("auth.error.incorrect_login", lang));
 					}
 					paramList.appendChild(messageParam);
 
 					Element urlParam = loginPageDoc.createElement(GSXML.PARAM_ELEM);
-					urlParam.setAttribute(GSXML.NAME_ATT, "redirectURL");
+					urlParam.setAttribute(GSXML.NAME_ATT, REDIRECT_URL_PARAM);
 					if (request.getQueryString() != null && request.getQueryString().length() > 0)
 					{
@@ -1078,4 +1089,12 @@
 					paramList.appendChild(urlParam);
 
+					// for debugging purposes, eg adding o=xml to the url
+					String output_p = getFirstParam(GSParams.OUTPUT, queryMap);
+					if (output_p !=null && !output_p.equals("")) {
+					  loginPageRequest.setAttribute(GSXML.OUTPUT_ATT, output_p);
+					}
+					  
+					logger.error("login page request=");
+					logger.error(XMLConverter.getPrettyString(loginPageMessage));
 					Node loginPageResponse = this.recept.process(loginPageMessage);
 					out.println(XMLConverter.getPrettyString(loginPageResponse));
@@ -1085,7 +1104,12 @@
 			}
 		}
+		logger.error("kk reurned true");
 		return true;
 	}
 
+  private String getTextString(String key, String lang) {
+    return Dictionary.getTextString(key, lang, "ServiceRack", null, null);
+  
+  }
 	//a debugging method
 	private void displaySize(Hashtable<String, UserSessionCache> table)
