Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/CollectionGroups.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/CollectionGroups.java	(revision 38845)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/CollectionGroups.java	(revision 38846)
@@ -30,6 +30,6 @@
 	private Element hierarchy = null;
 	private Element groupDesc = null;
-  private HashMap<String, Element> group_descriptions_map = null; // new one for display items
-
+    private HashMap<String, Element> group_displayitems_map = null; // new one for display items
+    private HashMap<String, Element> group_extras_map = null; // all additional elements go in here, eg <title>
 	public static final String GROUP_CONTENT_SERVICE = "GroupCurrentContent";
   // not used??
@@ -54,5 +54,6 @@
 		}
 
-                group_descriptions_map = new HashMap<String, Element>();
+                group_displayitems_map = new HashMap<String, Element>();
+		group_extras_map = new HashMap<String, Element>();
 		logger.info("Configuring CollectionGroups...");
 		this.config_info = info;
@@ -130,7 +131,9 @@
 					if (checkedCollection != null) {
 						//Set position value
-						checkedCollection.setAttribute(GSXML.POSITION_ATT, String.valueOf(i));
-						// Add collection to response
-						result_collection_list.appendChild(doc.importNode(checkedCollection, true));
+					    //	checkedCollection.setAttribute(GSXML.POSITION_ATT, String.valueOf(i));
+					    Element coll_copy = (Element)doc.importNode(checkedCollection, true);
+					    coll_copy.setAttribute(GSXML.POSITION_ATT, String.valueOf(i));
+					    // Add collection to response
+					    result_collection_list.appendChild(coll_copy);
 					}
 					
@@ -162,5 +165,5 @@
 			} else {
                           Element groupDescription = getPathInfo(groupPath, lang);
-				if (groupContent != null){
+				if (groupDescription != null){
 					result.appendChild(doc.importNode(groupDescription, true));
 				}
@@ -314,9 +317,9 @@
 
 		
-		Element currentContent = (Element) hierarchy.cloneNode(true);
+		Element currentContent = (Element)doc.importNode( hierarchy, true);//.cloneNode(true);
 		// Get the current view
 		for (int i = 0; i < pathSteps.length; i++) {
 			if (!pathSteps[i].isEmpty()) {
-				currentContent = GSXML.getNamedElement(currentContent, GSXML.GROUP_ELEM, GSXML.NAME_ATT, pathSteps[i]);
+			    currentContent = GSXML.getNamedElement(currentContent, GSXML.GROUP_ELEM, GSXML.NAME_ATT, pathSteps[i]);
 				if (currentContent == null){
 					break;
@@ -336,12 +339,14 @@
 		}
 		NodeList nodes = currentContent.getElementsByTagName(GSXML.COLLECTION_ELEM);
-		for (int i = 0; i < nodes.getLength(); i++) {
-			Element element = (Element) nodes.item(i);
-			String name = element.getAttribute(GSXML.NAME_ATT);
-			Element checkedCollection = GSXML.getNamedElement(checkedCollectionList, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name);
-			if (checkedCollection == null) {
-				element.getParentNode().removeChild(element);
-				i--;
-			}
+	
+		int num_nodes = nodes.getLength();
+		for (int i=num_nodes-1; i>=0; i--) {
+		    Element element = (Element) nodes.item(i);
+		    String name = element.getAttribute(GSXML.NAME_ATT);
+		    Element checkedCollection = GSXML.getNamedElement(checkedCollectionList, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name);
+		    if (checkedCollection == null) {
+			currentContent.removeChild(element);
+			
+		    }
 		}
 	}
@@ -417,4 +422,5 @@
 	  
 	  //	Document doc = groupDesc.getOwnerDocument();
+	  Document new_doc = XMLConverter.newDOM(); // use for the hash map
 		NodeList groups = hierarchy.getElementsByTagName(GSXML.GROUP_ELEM);
 		for (int i = 0; i < groups.getLength(); i++) {
@@ -432,12 +438,34 @@
                                 defaultDescription.appendChild(titleDisplayItem);
 				groupDesc.appendChild(defaultDescription);
-			}
-                        Element this_di_list = doc.createElement("dummy");
+				foundDescription = defaultDescription;
+			}
+		
+			Element this_di_list = doc.createElement("dummy"+name);
                         DisplayItemUtil.storeDisplayItems(this_di_list, foundDescription);
-                        group_descriptions_map.put(name, this_di_list);
-		} 
-		
-	}
-
+                        group_displayitems_map.put(name, this_di_list);
+			// find all elements that are not dis
+			Element this_extras_list = doc.createElement("dummy"+name);
+			boolean found_items = storeNonDisplayItems(this_extras_list, foundDescription);
+			if (found_items) {
+			    group_extras_map.put(name, this_extras_list);
+			}
+		}
+		
+	}
+
+    private boolean storeNonDisplayItems(Element new_list, Element description) {
+	Document doc = new_list.getOwnerDocument();
+	Node child = description.getFirstChild();
+	boolean found_some = false;
+	while (child != null) {
+	    if (child.getNodeType() == Node.ELEMENT_NODE && !child.getNodeName().equals(GSXML.DISPLAY_TEXT_ELEM)) {
+		new_list.appendChild(doc.importNode(child, true));
+		found_some = true;
+	    }
+	    child = child.getNextSibling();
+	}
+	return found_some;
+	
+    }
 	private Element getGroupDescriptionOld(String name) {
 		Element description = (Element) GSXML.getNamedElement(groupDesc, GSXML.GROUP_ELEM, GSXML.NAME_ATT, name);
@@ -449,10 +477,18 @@
   private Element getGroupDescription(Document doc, String name, String lang) {
     // get all the display items for group
-    Element all_di = group_descriptions_map.get(name);
+    Element all_di = group_displayitems_map.get(name);
     Element new_di_list = doc.createElement(GSXML.GROUP_ELEM);
     new_di_list.setAttribute(GSXML.NAME_ATT, name);
-    DisplayItemUtil.addLanguageSpecificDisplayItems(new_di_list, all_di, lang, DEFAULT_LANG, this.class_loader);
-
-    // now merge in the old style metadata - to be backwards compatible
+    synchronized( all_di) {
+	DisplayItemUtil.addLanguageSpecificDisplayItems(new_di_list, all_di, lang, DEFAULT_LANG, this.class_loader);
+
+    }
+
+    Element extras = group_extras_map.get(name);
+    if (extras != null) {
+	GSXML.copyAllChildren(new_di_list, extras);
+    }
+    /**
+	// now merge in the old style metadata - to be backwards compatible
     Element old_style_desc = (Element) GSXML.getNamedElement(groupDesc, GSXML.GROUP_ELEM, GSXML.NAME_ATT, name);
     if (old_style_desc != null) {
@@ -475,4 +511,6 @@
       }
     }
+    */
+    
     return new_di_list;
     
