Index: /main/trunk/gli/src/org/greenstone/gatherer/cdm/SearchMetadataManager.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/cdm/SearchMetadataManager.java	(revision 36241)
+++ /main/trunk/gli/src/org/greenstone/gatherer/cdm/SearchMetadataManager.java	(revision 36242)
@@ -30,4 +30,5 @@
 import javax.swing.table.*;
 import java.util.ArrayList;
+import java.util.LinkedHashSet;
 
 import org.greenstone.gatherer.Configuration;
@@ -80,7 +81,5 @@
 
     public SearchMeta getMetadatum(String name, String type, boolean add_if_not_found) {
-	System.err.println("Get the metadata for " + name + " type="+type+" in the default language.");
 	int size = getSize();
-	System.err.println("size of searchmeta = "+size);
 	if (size == 0) {
 	    return null;
@@ -88,7 +87,6 @@
 	for(int i = 0; i < size; i++) {
 	    SearchMeta metadatum = (SearchMeta) getElementAt(i);
-	    System.err.println("checking meta = "+metadatum);
 	    if(metadatum.getName().equals(name) && metadatum.getType().equals(type) && metadatum.getLanguage().equals(Configuration.getLanguage())) {
-		DebugStream.println("Found '" + metadatum + "'");
+		//DebugStream.println("Found '" + metadatum + "'");
 		return metadatum;
 	    }
@@ -101,5 +99,5 @@
 	    SearchMeta result = new SearchMeta(name, type);
 	    addMetadatum(result);
-	    DebugStream.println("Added new metadata: " + name);
+	    //DebugStream.println("Added new metadata: " + name);
 	    return result;
 	}
@@ -183,5 +181,5 @@
     
     private ArrayList getEntries() {
-	ArrayList entries = new ArrayList();
+	LinkedHashSet entries = new LinkedHashSet();
 	
 	ArrayList indexes = CollectionDesignManager.index_manager.getIndexes();
@@ -191,16 +189,7 @@
 	      String index_id = ((Index)indexes.get(i)).getID();
 	      if (!index_id.equals(METADATA_INDEX)) {
-		  System.err.println("new sme, id="+index_id);
 		SearchMetadataEntry sme = new SearchMetadataEntry(index_id, SearchMeta.TYPE_INDEX);
 		entries.add(sme);
 	      }
-	    }
-	}
-	ArrayList levels = CollectionDesignManager.index_manager.getLevels();
-	if (levels != null) {
-	    int levels_size = levels.size();
-	    for (int i=0; i<levels_size; i++) {
-		SearchMetadataEntry sme = new SearchMetadataEntry(((IndexOption)levels.get(i)).getName(), SearchMeta.TYPE_LEVEL);
-		entries.add(sme);
 	    }
 	}
@@ -212,4 +201,5 @@
               SearchMetadataEntry sme = new SearchMetadataEntry(sf_id, SearchMeta.TYPE_SORT);
 		entries.add(sme);
+
 	    }
 	}
@@ -224,4 +214,13 @@
 	}
 
+	ArrayList levels = CollectionDesignManager.index_manager.getLevels();
+	if (levels != null) {
+	    int levels_size = levels.size();
+	    for (int i=0; i<levels_size; i++) {
+		SearchMetadataEntry sme = new SearchMetadataEntry(((IndexOption)levels.get(i)).getName(), SearchMeta.TYPE_LEVEL);
+		entries.add(sme);
+	    }
+	}
+
         
 	ArrayList partitions = CollectionDesignManager.subcollectionindex_manager.getSubcollectionIndexes();
@@ -242,5 +241,7 @@
 	    }
 	}
-	return entries;
+	ArrayList list_entries = new ArrayList();
+	list_entries.addAll(entries);
+	return list_entries;
     }
     
@@ -254,9 +255,14 @@
 
 	public SearchMetadataEntry(String id, String type) {
+	    if (!Gatherer.GS3) {
+		type = SearchMeta.TYPE_SEARCH;
+	    }
 	    this.id = id;
 	    this.type = type;
 	    //coll_meta = collmeta_manager.getMetadatum(getMetaID(), type);
 	    this.coll_meta = getMetadatum(id, type); //getMetaID(), type);
-	    this.value = coll_meta.getValue(CollectionMeta.GREENSTONE);
+	    if (this.coll_meta != null) {
+		this.value = coll_meta.getValue(CollectionMeta.GREENSTONE);
+	    }
 	}
 	
@@ -264,5 +270,14 @@
 	    return Dictionary.get("CDM.SearchMetadataManager.Type_"+type)+": "+id;
 	}
-	
+	public boolean equals(Object sme) {
+	    if (sme instanceof SearchMetadataEntry) {
+		if (id.equals(((SearchMetadataEntry)sme).id) && type.equals(((SearchMetadataEntry)sme).type)) {
+		    return true;
+		}
+		return false;
+	    }
+	    return toString().equals(sme.toString());
+	
+	}
 	public String getMetaID() {
 	  if (Gatherer.GS3) {
