Index: /gs3-extensions/iiif-servlet/trunk/src/README.txt
===================================================================
--- /gs3-extensions/iiif-servlet/trunk/src/README.txt	(revision 32873)
+++ /gs3-extensions/iiif-servlet/trunk/src/README.txt	(revision 32874)
@@ -15,2 +15,6 @@
 e.g. jdbm.jar needs to be here to avoid Class Not Found
 
+
+pushd $GSDL3SRCHOME
+cp -i ./packages/tomcat/webapps/gs-cantaloupe/WEB-INF/classes/lib/jdbm.jar ./packages/tomcat/webapps/gs-cantaloupe/WEB-INF/lib/.
+popd
Index: /gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/IIIFServerBridge.java
===================================================================
--- /gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/IIIFServerBridge.java	(revision 32873)
+++ /gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/IIIFServerBridge.java	(revision 32874)
@@ -170,5 +170,6 @@
 	        //response.setContentType("text/xml;charset=UTF-8");
 		//PrintWriter out = response.getWriter();
-
+	    String result = "";
+	    
 	    String[] pairs = new String[2];
 	    pairs[0] = "verb=GetRecord";
@@ -185,5 +186,5 @@
 		Element xml_request = request_doc.createElement(GSXML.REQUEST_ELEM);
 		// The type attribute is set to be 'oaiService' from OAIServer to OAIReceptionist.
-		////xml_request.setAttribute(GSXML.TYPE_ATT, OAIXML.OAI_SERVICE);
+		////xml_request.setAttribute(GSXML.TYPE_ATT, OAIXML.OAI_SERVICE); // ****
 		//xml_request.setAttribute(GSXML.LANG_ATT, lang);
 		xml_request.setAttribute(GSXML.TO_ATT, verb);
@@ -211,10 +212,21 @@
 			if (res == null)
 			{
-				logger.info("response element in xml_result is null");
-				verb_elem = IIIFXML.createErrorElement(response_doc, "Internal error", "");
-			}
-			else
-			{
-				verb_elem = GSXML.getFirstElementChild(res);
+			    logger.info("response element in xml_result is null");
+			    verb_elem = IIIFXML.createErrorElement(response_doc, "Internal error", "");
+			}
+			else {
+			    System.err.println("*** res (verb_elem) = " + XMLConverter.getPrettyString(res));
+			    
+			    verb_elem = GSXML.getFirstElementChild(res); // GetRecord
+			    Node record_node = GSXML.getFirstElementChild(verb_elem); // record
+			    Element metadata_list_elem = (Element)GSXML.getChildByTagName(record_node,"metadata"); // metadata
+
+			    System.err.println("*** metadata_list_elem = " + XMLConverter.getPrettyString(metadata_list_elem));
+			    String assocfilepath_metadata = GSXML.getMetadataValue(metadata_list_elem,"assocfilepath");
+			    String image_metadata = GSXML.getMetadataValue(metadata_list_elem,"Image");
+			    //Node assocfilepath_metadata_node = GSXML.getChildByTagName("assocfilepath");
+			    //Node image_metadata_node = GSXML.getChildByTagName("Image");
+
+			    result = assocfilepath_metadata + "/" + image_metadata;
 			}
 
@@ -243,5 +255,7 @@
 		*/
 		
-		return XMLConverter.getPrettyString(xml_response);
+		//return XMLConverter.getPrettyString(xml_response);
+		return result;
+		//return xml_response;
 	}
 
@@ -264,5 +278,5 @@
 			if (index != -1)
 			{ //just a double check
-			  Element param = GSXML.createParameter(doc, pairs[i].substring(0, index), IIIFXML.oaiDecode(pairs[i].substring(index + 1)));
+			  Element param = GSXML.createParameter(doc, pairs[i].substring(0, index), IIIFXML.iiifDecode(pairs[i].substring(index + 1)));
 			  request.appendChild(param);
 			}
Index: /gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/service/IIIFPMH.java
===================================================================
--- /gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/service/IIIFPMH.java	(revision 32873)
+++ /gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/service/IIIFPMH.java	(revision 32874)
@@ -23,5 +23,5 @@
 import org.greenstone.gsdl3.util.GSXML;
 import org.greenstone.gsdl3.util.IIIFXML;
-import org.greenstone.gsdl3.util.OAIXML; // ****
+//import org.greenstone.gsdl3.util.OAIXML; // ****
 import org.greenstone.gsdl3.util.OID;
 import org.greenstone.gsdl3.util.GSFile;
@@ -70,5 +70,4 @@
   protected Element meta_formats_definition = null;
   protected HashMap<String, HashSet<String>> format_elements_map = null;
-  protected HashMap<String, Element> format_response_map = null;
   protected HashMap<String, Element> format_meta_elem_map = null;
   
@@ -134,5 +133,5 @@
     Element get_record = this.desc_doc.createElement(GSXML.SERVICE_ELEM);
     get_record.setAttribute(GSXML.NAME_ATT, IIIFXML.GET_RECORD);
-    get_record.setAttribute(GSXML.TYPE_ATT, "oai");
+    get_record.setAttribute(GSXML.TYPE_ATT, "iiif");
     this.short_service_info.appendChild(get_record);
     
@@ -165,5 +164,5 @@
       Element get_record = doc.createElement(GSXML.SERVICE_ELEM);
       get_record.setAttribute(GSXML.NAME_ATT, IIIFXML.GET_RECORD);
-      get_record.setAttribute(GSXML.TYPE_ATT, "oai");
+      get_record.setAttribute(GSXML.TYPE_ATT, "iiif");
       return get_record;
     }
@@ -172,9 +171,8 @@
   }
     
-  /** returns the actual record element used in the OAI GetRecord response */
+  /** returns the actual record element used in the IIIF GetRecord response */
   protected Element processGetRecord(Element req) {
     /** arguments:
         identifier: required
-        metadataPrefix: required
      *  Exceptions: badArgument; cannotDisseminateFormat; idDoesNotExist
      */ 
@@ -182,29 +180,14 @@
     HashMap<String, String> param_map = GSXML.getParamMap(params);    
     
-    String prefix = param_map.get(OAIXML.METADATA_PREFIX);
-    if (prefix == null || prefix.equals("")) {
-      //Just a double-check
-      logger.error("the value of metadataPrefix att is not present in the request.");
-      return IIIFXML.createErrorResponse(OAIXML.CANNOT_DISSEMINATE_FORMAT, "");
-    }
-    
-    // check that we support this format
-    if (!format_response_map.containsKey(prefix)) {
-      logger.error("metadata prefix is not supported for collection "+this.coll_name);
-      return IIIFXML.createErrorResponse(OAIXML.CANNOT_DISSEMINATE_FORMAT, "");
-    }
-
     Document doc = XMLConverter.newDOM();
     
     String oid = param_map.get(IIIFXML.OID); // TODO should this be identifier???
     
-    //get a DBInfo object of the identifier; if this identifier is not present in the database,
+    // Get a DBInfo object of the identifier; if this identifier is not present in the database,
     // null is returned.
     DBInfo info = this.coll_db.getInfo(oid);
     if (info == null) {
-	//if(!OID_is_deleted) { // we don't expect to find entries for deleted docs in index db. // ****
-	    logger.error("OID: " + oid + " is not present in the collection index database.");
-	    return IIIFXML.createErrorResponse(IIIFXML.ID_DOES_NOT_EXIST, "");
-	    //} // if doc deleted, id missing in indexdb is not an error: doc id would exist only in oai-inf db, marked as deleted 'D' // ****
+	logger.error("OID: " + oid + " is not present in the collection index database.");
+	return IIIFXML.createErrorResponse(IIIFXML.ID_DOES_NOT_EXIST, "");
     }
 
@@ -218,5 +201,5 @@
     record.appendChild(createHeaderElement(doc, oid));      
     //compose the metadata element
-    record.appendChild(createMetadataElement(doc, prefix, info));
+    record.appendChild(createMetadataElement(doc, info));
     get_record.appendChild(record);
     return get_record_response;
@@ -224,46 +207,60 @@
 
     
- /** create the metadata element used when processing ListRecords/GetRecord requests
+ /** create the metadata element used when processing GetRecord request
    */
 
-  protected Element createMetadataElement(Document doc, String prefix, DBInfo info) {
+  protected Element createMetadataElement(Document doc, DBInfo info) {
     // the <metadata> element
-    Element metadata = doc.createElement(OAIXML.METADATA);
+    Element metadata_message = doc.createElement(IIIFXML.METADATA);
+
     // the <oai:dc namespace...> element
-    Element prfx_str_elem = (Element)doc.importNode(this.format_meta_elem_map.get(prefix), true); 
-    metadata.appendChild(prfx_str_elem);
-    
-    Element meta_format_element = GSXML.getNamedElement(this.meta_formats_definition, OAIXML.METADATA_FORMAT, GSXML.NAME_ATT, prefix);
-    NodeList elements = meta_format_element.getElementsByTagName(OAIXML.ELEMENT);
+    //Element prfx_str_elem = (Element)doc.importNode(this.format_meta_elem_map.get(prefix), true); 
+    //metadata.appendChild(prfx_str_elem);
+    
+    //Element meta_format_element = GSXML.getNamedElement(this.meta_formats_definition, OAIXML.METADATA_FORMAT, GSXML.NAME_ATT, prefix);
+    //NodeList elements = meta_format_element.getElementsByTagName(OAIXML.ELEMENT);
     // for each element in the definition
+
+    addFirstMetadata(metadata_message, "assocfilepath", info);
+    addFirstMetadata(metadata_message, "Image", info);
+
+    /*	    
+    Set<String> keys = info.getKeys();
+    if (keys != null && keys.size()!=0) {
+	for (String metaname: keys) {
+	    addMetadata(metadata_message, metaname, info);
+	}
+    }
+    */
+    
+    /*
     for (int i=0; i<elements.getLength(); i++) {
       Element e = (Element)elements.item(i);
-      Element map = (Element)GSXML.getChildByTagName(e, OAIXML.MAPPING);
-      if (map == null) {
-	// look up the element name
-	addMetadata(prfx_str_elem, e.getAttribute(GSXML.NAME_ATT), info);
-      } else {
-	// we go though the list of names in the mapping
-	addMetadata(prfx_str_elem, e.getAttribute(GSXML.NAME_ATT), map.getAttribute(OAIXML.SELECT), map.getAttribute(OAIXML.ELEMENTS), info);
-      }
-    }
+
+      // look up the element name
+      //addMetadata(prfx_str_elem, e.getAttribute(GSXML.NAME_ATT), info);
+      addMetadata(metadata, e.getAttribute(GSXML.NAME_ATT), info);
+    }
+    */
+    
     // output any metadata that is not just a simple mapping
-    // addCustomMetadata(prfx_str_elem, prefix, info); // ****
-    return metadata;
+    //addCustomMetadata(prfx_str_elem, prefix, info); // ****
+    return metadata_message;
   }
 
   /** a simple addMetadata where we look for meta_name metadata, and add as that name*/
 
-  protected void addMetadata(Element meta_list_elem, String meta_name, DBInfo info) {
-    Vector<String> values = info.getMultiInfo(meta_name);
-    if (values != null && values.size()!=0) {
-      for (int i=0; i<values.size(); i++) {
-	addMetadataElement(meta_list_elem, meta_name, values.get(i));
-      }
-    }
-  }
-
+    
+  protected void addFirstMetadata(Element meta_list_elem, String meta_name, DBInfo info) {
+      Vector<String> values = info.getMultiInfo(meta_name);
+      if (values != null && values.size()>0) {
+	  addMetadataElement(meta_list_elem, meta_name, values.get(0));
+	  
+      }
+  }
+    
+    
   /** more complicated addMetadata - can add multiple items. */
-
+    /*
   protected void addMetadata(Element meta_list_elem, String new_meta_name, String select_type, String name_list, DBInfo info) {
     String[] names = name_list.split(",");
@@ -307,12 +304,15 @@
     }
   }
-  
+    */
+    
   // specific metadata formats might need to do some custom metadata that is not
   //just a standard mapping.
+    /*
   protected void addCustomMetadata(Element meta_list_elem, String prefix, DBInfo info) {
     
 
   }
-
+    */
+    
   /** create the actual metadata element for the list */
 
@@ -328,5 +328,5 @@
   protected Element createHeaderElement(Document doc, String oid) {
 
-        Element header = doc.createElement(OAIXML.HEADER);
+        Element header = doc.createElement(IIIFXML.HEADER);
 	
         Element identifier = doc.createElement(IIIFXML.IDENTIFIER);
Index: /gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/util/IIIFXML.java
===================================================================
--- /gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/util/IIIFXML.java	(revision 32873)
+++ /gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/util/IIIFXML.java	(revision 32874)
@@ -37,5 +37,5 @@
   static Logger logger = Logger.getLogger(org.greenstone.gsdl3.util.IIIFXML.class.getName());
 
-  // the leading keyword of oai protocol
+  // the leading keyword of IIIF protocol // ****
   public static final String VERB = "verb";
 
@@ -67,8 +67,9 @@
     
   // record response data
-  // SET_SPEC
   public static final String RECORD = "record";
-
-    public static final String OAIPMH = "OAIPMH"; // ****
+  public static final String HEADER = "header";
+  public static final String METADATA = "metadata";
+
+    //public static final String OAIPMH = "OAIPMH"; // ****
     
     //public static final String OAI_SET_LIST = "oaiSetList"; // ****
@@ -80,5 +81,5 @@
   //public static final String FILE_SEPARATOR = File.separator;
     //public static final String OAI_VERSION1 = "1.0";
-    public static final String IIIF_VERSION2 = "2.1"; // ****
+    //public static final String IIIF_VERSION2 = "2.1"; // ****
   /*************************above are final values****************************/
     
@@ -143,5 +144,5 @@
 
     
-  /** TODO: returns a basic response for appropriate oai version
+  /** TODO: returns a basic response (loosely based on OAI XML message)
    *  
    */
@@ -161,5 +162,5 @@
 	String[] strs = pairs[i].split("=");
 	if(strs != null && strs.length == 2) {
-	  request_elem.setAttribute(strs[0], oaiDecode(strs[1]));
+	  request_elem.setAttribute(strs[0], iiifDecode(strs[1]));
 	}
       }
@@ -168,5 +169,5 @@
     GSXML.setNodeText(request_elem, baseURL);
       
-    Node resp_date = GSXML.getChildByTagName(response, RESPONSE_DATE); // ****
+    //Node resp_date = GSXML.getChildByTagName(response, RESPONSE_DATE); // ****
     
     return response;
@@ -265,6 +266,6 @@
    *  original form (eg, ':'). 
    */
-  public static String oaiDecode(String escaped_str) {
-    logger.info("oaiDecode() " +escaped_str);
+  public static String iiifDecode(String escaped_str) {
+    logger.info("iiifDecode() " +escaped_str);
     for (int i=0; i<special_char.length; i++) {
       if (escaped_str.indexOf(escape_sequence[i]) != -1) {
@@ -277,6 +278,6 @@
    *  escaped sequences (eg, '%3A'). 
    */
-    public static String oaiEncode(String original_str) { // ****
-    logger.info("oaiEncode() " + original_str);      
+    public static String iiifEncode(String original_str) { // ****
+    logger.info("iiifEncode() " + original_str);      
     for (int i=0; i<special_char.length; i++) {
       if (original_str.indexOf(special_char[i]) != -1) {
@@ -288,24 +289,16 @@
 
   public static Element createResponseHeader(Document response_doc, String verb) {
-      String tag_name = (iiif_version.equals(IIIF_VERSION2))? IIIF_PMH : verb; // ****
-    Element oai = response_doc.createElement(tag_name);
-    Element resp_date = response_doc.createElement(RESPONSE_DATE); // ****
+      //String tag_name = (iiif_version.equals(IIIF_VERSION2))? IIIF_PMH : verb; // ****
+      String tag_name = IIIF_PMH;
+    Element iiif = response_doc.createElement(tag_name);
+    //Element resp_date = response_doc.createElement(RESPONSE_DATE); // ****
     Element req = response_doc.createElement(REQUEST);
-    oai.appendChild(resp_date);
-    oai.appendChild(req);
-
-    if(iiif_version.equals(IIIF_VERSION2)) { // ****
-      oai.setAttribute("xmlns", "http://www.openarchives.org/OAI/2.0/");
-      oai.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
-      oai.setAttribute("xsi:schemaLocation", "http://www.openarchives.org/OAI/2.0/ \n http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd");
-    } else {
-      oai.setAttribute("xmlns", "http://www.openarchives.com/OAI/1.1/OAI_" + verb);
-      oai.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
-      oai.setAttribute("xsi:schemaLocation", "http://www.openarchives.org/OAI/1.1/OAI_" + verb + "\n http://www.openarchives.org/OAI/1.1/OAI_" + verb + ".xsd");
-    }
-    return oai;
-  }
-
-    
+    //oai.appendChild(resp_date);
+    iiif.appendChild(req);
+
+    return iiif;
+  }
+
+    /*
   public static Element createOAIIdentifierXML(Document doc, String repository_id, String sample_collection, String sample_doc_id) {
     String xml = "<oai-identifier xmlns=\"http://www.openarchives.org/OAI/2.0/oai-identifier\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/oai-identifier\n http://www.openarchives.org/OAI/2.0/oai-identifier.xsd\">\n <scheme>oai</scheme>\n<repositoryIdentifier>" + repository_id + "</repositoryIdentifier>\n<delimiter>:</delimiter>\n<sampleIdentifier>oai:"+repository_id+":"+sample_collection+":"+sample_doc_id+"</sampleIdentifier>\n</oai-identifier>";
@@ -316,5 +309,7 @@
 
   }
-
+    */
+
+    /*
   public static Element createGSDLElement(Document doc) {
     String xml = "<gsdl xmlns=\"http://www.greenstone.org/namespace/gsdl_oaiinfo/1.0/gsdl_oaiinfo\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.greenstone.org/namespace/gsdl_oaiinfo/1.0/gsdl_oaiinfo\n   http://www.greenstone.org/namespace/gsdl_oaiinfo/1.0/gsdl_oaiinfo.xsd\"></gsdl>";
@@ -322,4 +317,6 @@
     return (Element)doc.importNode(xml_doc.getDocumentElement(), true);    
   }
+    */
+    
 }
 
Index: /gs3-extensions/iiif-servlet/trunk/src/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v2/GSInformationResource.java
===================================================================
--- /gs3-extensions/iiif-servlet/trunk/src/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v2/GSInformationResource.java	(revision 32873)
+++ /gs3-extensions/iiif-servlet/trunk/src/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v2/GSInformationResource.java	(revision 32874)
@@ -102,5 +102,9 @@
 	IIIFServerBridge gs_iiif_bridge = new IIIFServerBridge();
 	gs_iiif_bridge.init(site_name);
-	String gs_message = gs_iiif_bridge.doGetDocumentMessage(coll_name + ":" + doc_id);
+	String collect_image_filename = gs_iiif_bridge.doGetDocumentMessage(coll_name + ":" + doc_id);
+	String site_image_filename = site_name + "/collect/" + coll_name + "/index/assoc/" + collect_image_filename;
+	
+	//System.err.println("**** gs_message = " + XMLConverter.getPrettyString(gs_message_elem));
+	System.err.println("**** Greenstone site image filename = " + site_image_filename);
 	
         final Source source = new SourceFactory().newSource(
