Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/BerryBasket.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/BerryBasket.java	(revision 32307)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/BerryBasket.java	(revision 32308)
@@ -26,4 +26,5 @@
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.Set;
 
 import org.w3c.dom.Document;
@@ -74,5 +75,7 @@
 	protected String password = "";
 
-	/** constructor */
+        HashSet<String> meta_names = null;
+
+        /** constructor */
 	public BerryBasket()
 	{
@@ -148,4 +151,24 @@
 		this.short_service_info.appendChild(mail_service);
 
+
+		// set up the metadata names - this is the list of metadata retrieved for each item in the berry basket.
+		meta_names = new HashSet<String>();
+		meta_names.add("Title"); // the default
+		meta_names.add("root_Title");
+		meta_names.add("Date");
+		meta_names.add("root_assocfilepath"); // these two needed for source linking
+		meta_names.add("root_srclinkFile");
+
+		// are there any custom ones in the config file?
+		Element meta_list_elem = (Element) GSXML.getChildByTagName(info, GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
+		if (meta_list_elem !=null) {
+		  NodeList meta_list = meta_list_elem.getElementsByTagName(GSXML.METADATA_ELEM);
+		  for (int i = 0; i < meta_list.getLength(); i++) {
+		    
+		    Element s = (Element) meta_list.item(i);
+		    meta_names.add(s.getAttribute(GSXML.NAME_ATT));
+		  }
+
+		}
 		return true;
 
@@ -277,41 +300,17 @@
 		Element metadata_list = (Element) doc_node.getElementsByTagName(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER).item(0);
 
-		//assign title metadata if any
-		Element metadata = GSXML.getNamedElement(metadata_list, "metadata", "name", "Title");
-		if (metadata != null)
-		{
-			item.title = GSXML.getNodeText(metadata).trim();
-		}
-		//assign date metadata if any
-		metadata = GSXML.getNamedElement(metadata_list, "metadata", "name", "Date");
-		if (metadata != null)
-		{
-			item.date = GSXML.getNodeText(metadata).trim();
-		}
-
-		//assign root title metadata if any
-		metadata = GSXML.getNamedElement(metadata_list, "metadata", "name", "root_Title");
-		if (metadata != null)
-		{
-			String rootTitle = GSXML.getNodeText(metadata).trim();
-			if (!rootTitle.equals(item.title) && !rootTitle.equals(""))
-			{
-				item.rootTitle = rootTitle;
-			}
-
-		}
-		// assign assocfilepath if any
-		metadata = GSXML.getNamedElement(metadata_list, "metadata", "name", "root_assocfilepath");
-		if (metadata != null)
-		{
-		  item.assocfilepath = GSXML.getNodeText(metadata).trim();
-		}
-		// assign srclinkFile if any
-		metadata = GSXML.getNamedElement(metadata_list, "metadata", "name", "root_srclinkFile");
-		if (metadata != null)
-		{
-		  item.srclinkFile = GSXML.getNodeText(metadata).trim();
+		NodeList meta_elems = metadata_list.getElementsByTagName(GSXML.METADATA_ELEM);
+		for (int i=0; i<meta_elems.getLength(); i++) {
+		  Element m = (Element)meta_elems.item(i);
+		  String name = m.getAttribute(GSXML.NAME_ATT);
+		  item.metadata.put(name, GSXML.getNodeText(m).trim());
+		}
+		// check for root_title == title
+		if (item.metadata.get("root_Title").equals(item.metadata.get("Title"))) {
+		  item.metadata.remove("root_Title");
+		  
 		}
 		return item;
+
 	}
 
@@ -373,54 +372,4 @@
 	}
 
-	protected Element processDeleteItem(Element request)
-	{
-		Hashtable<String, Hashtable<String, Item>> docsMap = updateDocMap(request);
-
-		// Create a new (empty) result message
-		Document result_doc = XMLConverter.newDOM();
-		Element result = result_doc.createElement(GSXML.RESPONSE_ELEM);
-
-		// Get the parameters of the request
-		Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
-
-		if (param_list == null)
-		{
-			logger.error("BerryBasket Error: DeleteItem request had no paramList.");
-			return result; // Return the empty result
-		}
-
-		HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
-
-		String param = (String) params.get("item");
-
-		if (param == null)
-			return result;
-
-		String item = param;
-
-		String collection = "";
-		int pos = item.indexOf(":");
-
-		if (pos != -1)
-		{
-			collection = item.substring(0, pos);
-			item = item.substring(pos + 1);
-		}
-
-		if (docsMap.containsKey(collection))
-		{
-			Hashtable itemMap = docsMap.get(collection);
-			if (itemMap.containsKey(item))
-			{
-				itemMap.remove(item);
-			}
-			if (itemMap.size() == 0)
-			{
-				docsMap.remove(collection);
-			}
-		}
-
-		return result;
-	}
 
 	protected Element processItemNum(Element request)
@@ -465,11 +414,4 @@
 
 		// Create a parameter list to specify the required metadata information
-		HashSet<String> meta_names = new HashSet<String>();
-		meta_names.add("Title"); // the default
-		meta_names.add("root_Title");
-		meta_names.add("Date");
-		meta_names.add("root_assocfilepath");
-		meta_names.add("root_srclinkFile");
-
 		Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 
@@ -527,20 +469,13 @@
 			{
 				Item item = (Item) itemItr.next();
-				Element itemElement = result_doc.createElement("item");
-
-				collectionNode.appendChild(itemElement);
-				itemElement.setAttribute("name", item.docid);
-				itemElement.setAttribute("collection", item.collection);
-				itemElement.setAttribute("title", item.title);
-				itemElement.setAttribute("date", item.date);
-				itemElement.setAttribute("root_title", item.rootTitle);
-				itemElement.setAttribute("srclinkFile", item.srclinkFile);
-				itemElement.setAttribute("assocfilepath", item.assocfilepath);
+				collectionNode.appendChild(item.wrapIntoElement(result_doc));
 			}
 		}
 
 		return result;
-
-	}
+	}
+
+
+
 
 	public Element processSendMail(Element request)
@@ -670,14 +605,11 @@
 		public String collection;
 		public String docid;
-		public String title = "";
-		public String query = "";
-		public String date = "";
-		public String rootTitle = "";
-	  public String assocfilepath = "";
-	  public String srclinkFile = "";
-		public Item(String coll, String id)
+	        public HashMap<String,String> metadata;
+
+	        public Item(String coll, String id)
 		{
 			this.collection = coll;
 			this.docid = id;
+			this.metadata = new HashMap<String,String>();
 		}
 
@@ -695,10 +627,4 @@
 		}
 
-		public String toString()
-		{
-
-			return collection + ":" + docid + ":" + "[" + ((!rootTitle.equals("")) ? (rootTitle + ":") : "") + title + "]";
-		}
-
 		public Element wrapIntoElement(Document doc)
 		{
@@ -706,9 +632,11 @@
 			itemElement.setAttribute("name", docid);
 			itemElement.setAttribute("collection", collection);
-			itemElement.setAttribute("title", title);
-			itemElement.setAttribute("date", date);
-			itemElement.setAttribute("root_title", rootTitle);
-			itemElement.setAttribute("assocfilepath", assocfilepath);
-			itemElement.setAttribute("srclinkFile", srclinkFile);
+
+			Set<String> metas = metadata.keySet();
+			Iterator<String> i = metas.iterator();
+			while (i.hasNext()) {
+			  String meta_name = i.next();
+			  itemElement.setAttribute(meta_name, metadata.get(meta_name));
+			}
 			return itemElement;
 		}
