Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java	(revision 29420)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java	(revision 29421)
@@ -678,6 +678,6 @@
 
 			inlineTemplate = (String) params.get(GSParams.INLINE_TEMPLATE);
-
-			if (params.get(GSParams.DEBUG) != null && (((String) params.get(GSParams.DEBUG)).equals("on") || ((String) params.get(GSParams.DEBUG)).equals("1") || ((String) params.get(GSParams.DEBUG)).equals("true")))
+			String debug_p = (String) params.get(GSParams.DEBUG);
+			if (debug_p != null && (debug_p.equals("on") || debug_p.equals("1") || debug_p.equals("true")))
 			{
 				String[] groups = new UserContext(request).getGroups();
@@ -689,4 +689,16 @@
 					{
 						found = true;
+						break;
+					}
+					if (!collection.equals("")) {
+					  if (g.equals("all-collections-editor")) {
+					    found = true;
+					    break;
+					  }
+					 
+					  if (g.equals(collection+"-collection-editor")) {
+					    found = true;
+					    break;
+					  }
 					}
 				}
@@ -1035,4 +1047,5 @@
 			formatFile = "text_fragment_format.xsl";
 		}
+
 		String configStylesheet_file = GSFile.stylesheetFile(GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME), collection, (String) this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces, formatFile);
 		Document configStylesheet_doc = this.converter.getDOM(new File(configStylesheet_file));
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DebugService.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DebugService.java	(revision 29420)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DebugService.java	(revision 29421)
@@ -89,20 +89,4 @@
 		}
 
-		UserContext context = new UserContext(request);
-		boolean found = false;
-		for (String group : context.getGroups())
-		{
-			if (group.equals("administrator"))
-			{
-				found = true;
-			}
-		}
-
-		if (!found)
-		{
-			GSXML.addError(result, "This user does not have the required permissions to perform this action.");
-			return result;
-		}
-
 		// Get the parameters of the request
 		Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
@@ -116,7 +100,13 @@
 		HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
 
+		String collectionName = (String) params.get("collectionName");
+
+		// check permissions
+		if (!userHasEditPermissions(collectionName, request)) {
+		  GSXML.addError(result, "This user does not have the required permissions to perform this action.");
+		  return result;
+		}
 		String interfaceName = (String) params.get("interfaceName");
 		String siteName = (String) params.get("siteName");
-		String collectionName = (String) params.get("collectionName");
 		String fileName = (String) params.get("fileName");
 		String nameToGet = (String) params.get("templateName");
@@ -164,20 +154,4 @@
 		}
 
-		UserContext context = new UserContext(request);
-		boolean found = false;
-		for (String group : context.getGroups())
-		{
-			if (group.equals("administrator"))
-			{
-				found = true;
-			}
-		}
-
-		if (!found)
-		{
-			GSXML.addError(result, "This user does not have the required permissions to perform this action.");
-			return result;
-		}
-
 		// Get the parameters of the request
 		Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
@@ -190,9 +164,16 @@
 
 		HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
+
+
+		String collectionName = (String) params.get("collectionName");
+		// check permissions
+		if (!userHasEditPermissions(collectionName, request)) {
+		  GSXML.addError(result, "This user does not have the required permissions to perform this action.");
+		  return result;
+		}
 
 		String locationName = (String) params.get("locationName");
 		String interfaceName = (String) params.get("interfaceName");
 		String siteName = (String) params.get("siteName");
-		String collectionName = (String) params.get("collectionName");
 		String fileName = (String) params.get("fileName");
 		String namespace = (String) params.get("namespace");
@@ -202,4 +183,6 @@
 		String xPath = (String) params.get("xpath");
 
+
+
 		String fullNamespace;
 		if (namespace.toLowerCase().equals("gsf"))
@@ -318,20 +301,4 @@
 		}
 
-		UserContext context = new UserContext(request);
-		boolean foundGroup = false;
-		for (String group : context.getGroups())
-		{
-			if (group.equals("administrator"))
-			{
-				foundGroup = true;
-			}
-		}
-
-		if (!foundGroup)
-		{
-			GSXML.addError(result, "This user does not have the required permissions to perform this action.");
-			return result;
-		}
-
 		// Get the parameters of the request
 		Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
@@ -344,4 +311,11 @@
 
 		HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
+
+		String collectionName = (String) params.get("collectionName");
+		// check permissions
+		if (!userHasEditPermissions(collectionName, request)) {
+		  GSXML.addError(result, "This user does not have the required permissions to perform this action.");
+		  return result;
+		}
 
 		String locationName = (String) params.get("locationName");
@@ -349,5 +323,4 @@
 		String interfaceName = (String) params.get("interfaceName");
 		String siteName = (String) params.get("siteName");
-		String collectionName = (String) params.get("collectionName");
 		String namespace = (String) params.get("namespace");
 		String nodeName = (String) params.get("nodename");
@@ -485,20 +458,4 @@
 		}
 
-		UserContext context = new UserContext(request);
-		boolean found = false;
-		for (String group : context.getGroups())
-		{
-			if (group.equals("administrator"))
-			{
-				found = true;
-			}
-		}
-
-		if (!found)
-		{
-			GSXML.addError(result, "This user does not have the required permissions to perform this action.");
-			return result;
-		}
-
 		// Get the parameters of the request
 		Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
@@ -512,7 +469,12 @@
 		HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
 
+		String collectionName = (String) params.get("collectionName");
+		// check permissions
+		if (!userHasEditPermissions(collectionName, request)) {
+		  GSXML.addError(result, "This user does not have the required permissions to perform this action.");
+		  return result;
+		}
 		String locationName = (String) params.get("locationName");
 		String siteName = (String) params.get("siteName");
-		String collectionName = (String) params.get("collectionName");
 		String interfaceName = (String) params.get("interfaceName");
 		String fileName = (String) params.get("fileName");
@@ -597,20 +559,4 @@
 		}
 
-		UserContext context = new UserContext(request);
-		boolean found = false;
-		for (String group : context.getGroups())
-		{
-			if (group.equals("administrator"))
-			{
-				found = true;
-			}
-		}
-
-		if (!found)
-		{
-			GSXML.addError(result, "This user does not have the required permissions to perform this action.");
-			return result;
-		}
-
 		// Get the parameters of the request
 		Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
@@ -624,7 +570,12 @@
 		HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
 
+		String collectionName = (String) params.get("collectionName");
+		// check permissions
+		if (!userHasEditPermissions(collectionName, request)) {
+		  GSXML.addError(result, "This user does not have the required permissions to perform this action.");
+		  return result;
+		}
 		String interfaceName = (String) params.get("interfaceName");
 		String siteName = (String) params.get("siteName");
-		String collectionName = (String) params.get("collectionName");
 
 		Element fileList = result_doc.createElement("fileListJSON");
@@ -700,3 +651,26 @@
 		return result;
 	}
+
+  protected boolean userHasEditPermissions(String collection, Element request) {
+    UserContext context = new UserContext(request);
+    for (String group : context.getGroups()) {
+      // administrator always has permission
+      if (group.equals("administrator")) {
+	return true;
+      }
+      // all-collections-editor can edit any collection
+      if (!collection.equals("")) {
+	if (group.equals("all-collections-editor")) {
+	  return true;
+	}
+	if (group.equals(collection+"-collection-editor")) {
+	  return true;
+	}
+      }
+    }
+    // haven't found a group with edit permissions
+    return false;
+    
+  }
 }
+
