Ignore:
Timestamp:
2019-03-07T22:47:07+13:00 (5 years ago)
Author:
davidb
Message:

Next round of changes, migrating from OAI imprint to what is needed for IIIF

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/util/IIIFXML.java

    r32860 r32874  
    3737  static Logger logger = Logger.getLogger(org.greenstone.gsdl3.util.IIIFXML.class.getName());
    3838
    39   // the leading keyword of oai protocol
     39  // the leading keyword of IIIF protocol // ****
    4040  public static final String VERB = "verb";
    4141
     
    6767   
    6868  // record response data
    69   // SET_SPEC
    7069  public static final String RECORD = "record";
    71 
    72     public static final String OAIPMH = "OAIPMH"; // ****
     70  public static final String HEADER = "header";
     71  public static final String METADATA = "metadata";
     72
     73    //public static final String OAIPMH = "OAIPMH"; // ****
    7374   
    7475    //public static final String OAI_SET_LIST = "oaiSetList"; // ****
     
    8081  //public static final String FILE_SEPARATOR = File.separator;
    8182    //public static final String OAI_VERSION1 = "1.0";
    82     public static final String IIIF_VERSION2 = "2.1"; // ****
     83    //public static final String IIIF_VERSION2 = "2.1"; // ****
    8384  /*************************above are final values****************************/
    8485   
     
    143144
    144145   
    145   /** TODO: returns a basic response for appropriate oai version
     146  /** TODO: returns a basic response (loosely based on OAI XML message)
    146147   * 
    147148   */
     
    161162    String[] strs = pairs[i].split("=");
    162163    if(strs != null && strs.length == 2) {
    163       request_elem.setAttribute(strs[0], oaiDecode(strs[1]));
     164      request_elem.setAttribute(strs[0], iiifDecode(strs[1]));
    164165    }
    165166      }
     
    168169    GSXML.setNodeText(request_elem, baseURL);
    169170     
    170     Node resp_date = GSXML.getChildByTagName(response, RESPONSE_DATE); // ****
     171    //Node resp_date = GSXML.getChildByTagName(response, RESPONSE_DATE); // ****
    171172   
    172173    return response;
     
    265266   *  original form (eg, ':').
    266267   */
    267   public static String oaiDecode(String escaped_str) {
    268     logger.info("oaiDecode() " +escaped_str);
     268  public static String iiifDecode(String escaped_str) {
     269    logger.info("iiifDecode() " +escaped_str);
    269270    for (int i=0; i<special_char.length; i++) {
    270271      if (escaped_str.indexOf(escape_sequence[i]) != -1) {
     
    277278   *  escaped sequences (eg, '%3A').
    278279   */
    279     public static String oaiEncode(String original_str) { // ****
    280     logger.info("oaiEncode() " + original_str);     
     280    public static String iiifEncode(String original_str) { // ****
     281    logger.info("iiifEncode() " + original_str);     
    281282    for (int i=0; i<special_char.length; i++) {
    282283      if (original_str.indexOf(special_char[i]) != -1) {
     
    288289
    289290  public static Element createResponseHeader(Document response_doc, String verb) {
    290       String tag_name = (iiif_version.equals(IIIF_VERSION2))? IIIF_PMH : verb; // ****
    291     Element oai = response_doc.createElement(tag_name);
    292     Element resp_date = response_doc.createElement(RESPONSE_DATE); // ****
     291      //String tag_name = (iiif_version.equals(IIIF_VERSION2))? IIIF_PMH : verb; // ****
     292      String tag_name = IIIF_PMH;
     293    Element iiif = response_doc.createElement(tag_name);
     294    //Element resp_date = response_doc.createElement(RESPONSE_DATE); // ****
    293295    Element req = response_doc.createElement(REQUEST);
    294     oai.appendChild(resp_date);
    295     oai.appendChild(req);
    296 
    297     if(iiif_version.equals(IIIF_VERSION2)) { // ****
    298       oai.setAttribute("xmlns", "http://www.openarchives.org/OAI/2.0/");
    299       oai.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    300       oai.setAttribute("xsi:schemaLocation", "http://www.openarchives.org/OAI/2.0/ \n http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd");
    301     } else {
    302       oai.setAttribute("xmlns", "http://www.openarchives.com/OAI/1.1/OAI_" + verb);
    303       oai.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    304       oai.setAttribute("xsi:schemaLocation", "http://www.openarchives.org/OAI/1.1/OAI_" + verb + "\n http://www.openarchives.org/OAI/1.1/OAI_" + verb + ".xsd");
    305     }
    306     return oai;
    307   }
    308 
    309    
     296    //oai.appendChild(resp_date);
     297    iiif.appendChild(req);
     298
     299    return iiif;
     300  }
     301
     302    /*
    310303  public static Element createOAIIdentifierXML(Document doc, String repository_id, String sample_collection, String sample_doc_id) {
    311304    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>";
     
    316309
    317310  }
    318 
     311    */
     312
     313    /*
    319314  public static Element createGSDLElement(Document doc) {
    320315    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>";
     
    322317    return (Element)doc.importNode(xml_doc.getDocumentElement(), true);   
    323318  }
     319    */
     320   
    324321}
    325322
Note: See TracChangeset for help on using the changeset viewer.