Index: /main/trunk/gli/src/org/greenstone/gatherer/cdm/CollectionConfigXMLReadWrite.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/cdm/CollectionConfigXMLReadWrite.java	(revision 29220)
+++ /main/trunk/gli/src/org/greenstone/gatherer/cdm/CollectionConfigXMLReadWrite.java	(revision 29221)
@@ -376,4 +376,129 @@
 	}
 
+    	//This processes <sort> and <facet> subelements of <search> for a solr collection
+    // Note that GLI at present does not allow the user to set or modify the solr-specific elements 
+    // <sort> and <facet>. This function, and its inverse convertSolrFacetsAndSorts, is only here to preserve such
+    // elements if they already exist in the collectionConfig.xml. At present they need to be manually added there.
+	static private void doSolrFacetsAndSorts(Document to, Node searchNode)
+	{
+		Element toElement = to.getDocumentElement();
+		Element solr_element = to.createElement(StaticStrings.SOLR_ELEMENT);//<Solr>
+		solr_element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.TRUE_STR);
+		solr_element.setAttribute(StaticStrings.MGPP_ATTRIBUTE, StaticStrings.TRUE_STR);
+
+
+		NodeList sort_children = ((Element) searchNode).getElementsByTagName(StaticStrings.SORT_LOW_STR);//<sort>
+		int num_nodes = sort_children.getLength();
+
+		for (int i = 0; i < num_nodes; i++)
+		{
+
+			Element sort_element = to.createElement(StaticStrings.SORT_ELEMENT);//<Sort>
+			Element e = (Element) sort_children.item(i);
+			String sort_str = e.getAttribute(StaticStrings.NAME_ATTRIBUTE);
+			String sort_str_display = sort_str;//for creating collectionmetadata for this sort element
+
+			// Handling 'sort' element
+			sort_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, sort_str);
+			
+			Element displayItem = (Element) XMLTools.getChildByTagName(e, StaticStrings.DISPLAYITEM_STR); // gets the first <displayItem> child of <sort>
+
+			if(displayItem != null) {
+			    String lang_str = displayItem.getAttribute(StaticStrings.LANG_ATTRIBUTE);
+			    
+			    String name_str = displayItem.getAttribute(StaticStrings.NAME_ATTRIBUTE);
+			    
+			    String value_str = XMLTools.getNodeText(displayItem);
+			    
+			    Element displayItem_element = to.createElement(StaticStrings.DISPLAYITEM_ELEMENT); // <DisplayItem> not <displayItem>!
+			    displayItem_element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.TRUE_STR);
+
+			        if (lang_str != null && !lang_str.equals(""))
+				{
+					displayItem_element.setAttribute(StaticStrings.LANG_ATTRIBUTE, lang_str);
+				}
+				if (name_str != null && !name_str.equals(""))
+				{
+					displayItem_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name_str);
+				}
+				if (value_str != null && !value_str.equals(""))
+				{
+				    //XMLTools.setNodeText(displayItem_element, value_str);
+				    displayItem_element.setAttribute(StaticStrings.VALUE_ATTRIBUTE, value_str);
+				}
+				sort_element.appendChild(displayItem_element);
+
+			}
+
+			solr_element.appendChild(sort_element);
+
+			sort_element = null;
+
+			// Handling 'displayItem' element of this 'sort' element
+			// 'e' is the parent 'sort' element of 'displayItem' element
+			///ArrayList collectionmetadata_list = doDisplayItemList(to, e, StaticStrings.NAME_ATTRIBUTE, sort_str_display);
+			///appendArrayList(toElement, collectionmetadata_list);
+
+		} // for loop on sort elements ends
+
+
+		NodeList facet_children = ((Element) searchNode).getElementsByTagName(StaticStrings.FACET_LOW_STR);//facet
+		num_nodes = facet_children.getLength();
+
+		for (int i = 0; i < num_nodes; i++)
+		{
+
+			Element facet_element = to.createElement(StaticStrings.FACET_ELEMENT);//<Facet>
+			Element e = (Element) facet_children.item(i);
+			String facet_str = e.getAttribute(StaticStrings.NAME_ATTRIBUTE);
+			String facet_str_display = facet_str;//for creating collectionmetadata for this facet
+
+			// Handling 'facet' element
+			facet_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, facet_str);
+			
+			Element displayItem = (Element) XMLTools.getChildByTagName(e, StaticStrings.DISPLAYITEM_STR); // gets the first <displayItem> child of <sort>
+
+			if(displayItem != null) {
+			    String lang_str = displayItem.getAttribute(StaticStrings.LANG_ATTRIBUTE);
+			    
+			    String name_str = displayItem.getAttribute(StaticStrings.NAME_ATTRIBUTE);
+			    
+			    String value_str = XMLTools.getNodeText(displayItem);
+			    
+			    Element displayItem_element = to.createElement(StaticStrings.DISPLAYITEM_ELEMENT); // <DisplayItem> not <displayItem>!
+			    displayItem_element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.TRUE_STR);
+
+			        if (lang_str != null && !lang_str.equals(""))
+				{
+					displayItem_element.setAttribute(StaticStrings.LANG_ATTRIBUTE, lang_str);
+				}
+				if (name_str != null && !name_str.equals(""))
+				{
+					displayItem_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name_str);
+				}
+				if (value_str != null && !value_str.equals(""))
+				{
+				    //XMLTools.setNodeText(displayItem_element, value_str);
+				    displayItem_element.setAttribute(StaticStrings.VALUE_ATTRIBUTE, value_str);
+				}
+				facet_element.appendChild(displayItem_element);
+
+			}
+			solr_element.appendChild(facet_element);
+
+			facet_element = null;
+
+			// Handling 'displayItem' element of this 'facet' element
+			// 'e' is the parent 'facet' element of 'displayItem' element
+			///ArrayList collectionmetadata_list = doDisplayItemList(to, e, StaticStrings.NAME_ATTRIBUTE, facet_str_display);
+			///appendArrayList(toElement, collectionmetadata_list);
+
+		} // for loop on facet elements ends
+
+		// finished processing sort and facet elements
+		toElement.appendChild(solr_element);
+
+	}
+
 	static private void doGlobalFormat(Document to, Element from)
 	{
@@ -2077,4 +2202,123 @@
 		convertDefaultIndex(from, to, search);
 		convertIndexOptions(from, to, search);
+	}
+
+    	//convert <facet> and <sort> elements and their displayItem subelements, 
+        //which go in 'search' element in collectionConfig.xml
+	//parameter 'to' is the document to be saved as collectionConfig.xml
+	//parameter 'from' is the internal xml structure
+    // Note that GLI at present does not allow the user to set or modify the solr-specific elements 
+    // <sort> and <facet>. This function, and its inverse convertSolrFacetsAndSorts, is only here to preserve such
+    // elements if they already exist in the collectionConfig.xml. At present they need to be manually added there.
+	static private void convertSolrFacetsAndSorts(Document from, Document to)
+	{
+		Element source = from.getDocumentElement();
+		//Get the 'search' element from 'to' which has already been created in 'convertBuildType'
+		Element search = (Element) XMLTools.getChildByTagName(to.getDocumentElement(), StaticStrings.SEARCH_STR);
+
+		//There are two sets of <Solr> elements, find the one which is assigned 'true'
+		Element solr = XMLTools.getNamedElement(source, StaticStrings.SOLR_ELEMENT, StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.TRUE_STR);
+		if (solr == null)
+		{
+			return;
+		}
+		NodeList sort_elements = solr.getElementsByTagName(StaticStrings.SORT_ELEMENT); //<Sort>
+		int sort_elements_length = sort_elements.getLength();
+		NodeList facet_elements = solr.getElementsByTagName(StaticStrings.FACET_ELEMENT); //<Facet>
+		int facet_elements_length = facet_elements.getLength();
+
+		for (int j = 0; j < sort_elements_length; j++)
+		{
+			Element sort_element = (Element) sort_elements.item(j);
+			if (sort_element.getAttribute(StaticStrings.ASSIGNED_ATTRIBUTE).equals(StaticStrings.FALSE_STR))
+			{
+				continue;
+			}
+
+			Element sort_ele = to.createElement(StaticStrings.SORT_LOW_STR);//<sort>
+			String name_attr = sort_element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
+
+			/*if (name_attr.startsWith(StaticStrings.EXTRACTED_NAMESPACE) && name_attr.indexOf(StaticStrings.NS_SEP, StaticStrings.EXTRACTED_NAMESPACE.length()) == -1)
+			    {
+				name_attr = name_str.substring(StaticStrings.EXTRACTED_NAMESPACE.length());
+			    }
+			*/
+			sort_ele.setAttribute(StaticStrings.NAME_ATTRIBUTE, name_attr);
+
+			// Now constructing 'displayItem' element for this 'sort_ele' element
+			Element displayItem = (Element) XMLTools.getChildByTagName(sort_element, StaticStrings.DISPLAYITEM_ELEMENT); // gets the first <DisplayItem> (not <displayItem>!) child of <Sort>
+
+			if(displayItem != null) {
+			    if (displayItem.hasAttribute(StaticStrings.ASSIGNED_ATTRIBUTE) && displayItem.getAttribute(StaticStrings.ASSIGNED_ATTRIBUTE).equals(StaticStrings.TRUE_STR)) {
+				Element displayItem_element = to.createElement(StaticStrings.DISPLAYITEM_STR);//<displayItem>
+				
+				String lang_str = displayItem.getAttribute(StaticStrings.LANG_ATTRIBUTE);
+				String name_str = displayItem.getAttribute(StaticStrings.NAME_ATTRIBUTE);
+				String value_str = displayItem.getAttribute(StaticStrings.VALUE_ATTRIBUTE);
+				
+				if (lang_str != null && !lang_str.equals(""))
+				    {
+					displayItem_element.setAttribute(StaticStrings.LANG_ATTRIBUTE, lang_str);
+				    }
+				if (name_str != null && !name_str.equals(""))
+				    {
+					displayItem_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name_str);
+				    }
+				if (value_str != null && !value_str.equals(""))
+				    {
+					XMLTools.setNodeText(displayItem_element, value_str);
+				    }
+				sort_ele.appendChild(displayItem_element);
+			    }
+			}
+
+			search.appendChild(sort_ele);
+
+		} //for loop on sort_elements ends
+
+		for (int j = 0; j < facet_elements_length; j++)
+		{
+			Element facet_element = (Element) facet_elements.item(j);
+			if (facet_element.getAttribute(StaticStrings.ASSIGNED_ATTRIBUTE).equals(StaticStrings.FALSE_STR))
+			{
+				continue;
+			}
+
+			Element facet_ele = to.createElement(StaticStrings.FACET_LOW_STR);//<facet>
+			String name_attr = facet_element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
+
+			facet_ele.setAttribute(StaticStrings.NAME_ATTRIBUTE, name_attr);
+
+			// Now constructing 'displayItem' element for this 'facet_ele' element
+			Element displayItem = (Element) XMLTools.getChildByTagName(facet_element, StaticStrings.DISPLAYITEM_ELEMENT); // gets the first <DisplayItem> (not <displayItem>!) child of <Facet>
+			
+			if(displayItem != null) {
+			    if (displayItem.hasAttribute(StaticStrings.ASSIGNED_ATTRIBUTE) && displayItem.getAttribute(StaticStrings.ASSIGNED_ATTRIBUTE).equals(StaticStrings.TRUE_STR)) {
+				Element displayItem_element = to.createElement(StaticStrings.DISPLAYITEM_STR);//<displayItem>
+				
+				String lang_str = displayItem.getAttribute(StaticStrings.LANG_ATTRIBUTE);
+				String name_str = displayItem.getAttribute(StaticStrings.NAME_ATTRIBUTE);
+				String value_str = displayItem.getAttribute(StaticStrings.VALUE_ATTRIBUTE);
+
+				if (lang_str != null && !lang_str.equals(""))
+				    {
+					displayItem_element.setAttribute(StaticStrings.LANG_ATTRIBUTE, lang_str);
+				    }
+				if (name_str != null && !name_str.equals(""))
+				    {
+					displayItem_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name_str);
+				    }
+				if (value_str != null && !value_str.equals(""))
+				{
+				    XMLTools.setNodeText(displayItem_element, value_str);				    
+				}
+				facet_ele.appendChild(displayItem_element);
+			    }
+			}
+
+			search.appendChild(facet_ele);
+
+		} //for loop on facet_elements ends
+
 	}
 
@@ -2504,4 +2748,8 @@
 		}
 
+		if(buildtype_value.equalsIgnoreCase("solr")) {
+		    doSolrFacetsAndSorts(dOc, searchNode); // <facet><displayItem /></facet> and <sort><displayItem /></sort>
+		}
+
 		doDefaultIndex(dOc, searchNode);
 		doDefaultLevel(dOc, searchNode);
@@ -2604,4 +2852,5 @@
 		convertDatabaseType(dOc, skeleton);
 		convertIndex(dOc, skeleton);
+		convertSolrFacetsAndSorts(dOc, skeleton);
 		convertPlugin(dOc, skeleton);//also do the plugout element
 		convertClassifier(dOc, skeleton);
Index: /main/trunk/gli/src/org/greenstone/gatherer/util/StaticStrings.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/util/StaticStrings.java	(revision 29220)
+++ /main/trunk/gli/src/org/greenstone/gatherer/util/StaticStrings.java	(revision 29221)
@@ -94,4 +94,5 @@
     static final public String DISPLAY_STR = "display";
     static final public String DISPLAYITEM_STR = "displayItem";
+    static final public String DISPLAYITEM_ELEMENT = "DisplayItem"; // Note: 1st letter is titlecase
     static final public String DOCUMENT_STR = "document";
     static final public String DOT_CHARACTER = ".";
@@ -107,4 +108,7 @@
     static final public String EXTENSION_ATTRIBUTE = "extension";
     static final public String EXTRACTED_NAMESPACE = "ex.";
+    static final public String FACET_ELEMENT = "Facet";
+    static final public String FACET_STR = "Facet";
+    static final public String FACET_LOW_STR = "facet";
     static final public String FALSE_STR = "false";
     static final public String FEEDBACK_ARGUMENT = "-feedback";
@@ -238,4 +242,8 @@
     static final public String SITE_ARGUMENT = "-site";
     static final public String SMALLICON_STR = "smallicon";
+    static final public String SOLR_ELEMENT = "Solr";
+    static final public String SORT_ELEMENT = "Sort";
+    static final public String SORT_STR = "Sort";
+    static final public String SORT_LOW_STR = "sort";
     static final public String SPACE_CHARACTER = " ";
     static final public String SPECIAL_ATTRIBUTE = "special";
