Changeset 32891

Show
Ignore:
Timestamp:
11.03.2019 09:37:51 (3 months ago)
Author:
davidb
Message:

Additional error checking

Location:
gs3-extensions/iiif-servlet/trunk/src
Files:
3 modified

Legend:

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

    r32883 r32891  
    171171        Document response_doc = XMLConverter.newDOM(); 
    172172        //Element xml_response = IIIFXML.createBasicResponse(response_doc, verb, pairs); 
    173         Element verb_elem = null; 
     173        //Element verb_elem = null; 
    174174         
    175175        // compose the request message to the receptionist 
     
    185185        if (xml_result == null) 
    186186        { 
    187             logger.info("xml_result is null"); 
    188             verb_elem = IIIFXML.createErrorElement(response_doc, "Internal error", ""); 
     187            logger.error("xml_result is null"); 
     188            //verb_elem = IIIFXML.createErrorElement(response_doc, "Internal error", ""); 
    189189            //xml_response.appendChild(verb_elem); 
    190190        } 
     
    199199            if (res == null) 
    200200            { 
    201                 logger.info("response element in xml_result is null"); 
    202                 verb_elem = IIIFXML.createErrorElement(response_doc, "Internal error", ""); 
     201                logger.error("response element in xml_result is null"); 
     202                //verb_elem = IIIFXML.createErrorElement(response_doc, "Internal error", ""); 
    203203            } 
    204204            else { 
    205                 verb_elem = GSXML.getFirstElementChild(res); // GetRecord 
     205                Element verb_elem = GSXML.getFirstElementChild(res); // GetRecord 
    206206                Node record_node = GSXML.getFirstElementChild(verb_elem); // record 
    207207                Element metadata_list_elem = (Element)GSXML.getChildByTagName(record_node,"metadata"); // metadata 
    208208 
    209209                Element assocfilepath_metadata_elem = (Element)GSXML.getChildByTagName(metadata_list_elem,"assocfilepath"); 
    210                 String assocfilepath_metadata_val = GSXML.getNodeText(assocfilepath_metadata_elem); 
    211  
    212                 Element image_metadata_elem = (Element)GSXML.getChildByTagName(metadata_list_elem,"Image"); 
    213                 String image_metadata_val = GSXML.getNodeText(image_metadata_elem); 
    214  
    215                 result = assocfilepath_metadata_val + "/" + image_metadata_val; 
     210 
     211                if (assocfilepath_metadata_elem == null) { 
     212                logger.error("Failed to find metadata 'assocfilepath' for Document " + identifier); 
     213                //verb_elem = IIIFXML.createErrorElement(response_doc, "Internal error", ""); 
     214                } 
     215                else { 
     216                String assocfilepath_metadata_val = GSXML.getNodeText(assocfilepath_metadata_elem); 
     217 
     218                Element image_metadata_elem = (Element)GSXML.getChildByTagName(metadata_list_elem,"Image"); 
     219                if (assocfilepath_metadata_elem == null) { 
     220                    logger.error("Failed to find metadata 'Image' for Document " + identifier); 
     221                } 
     222                else { 
     223                    String image_metadata_val = GSXML.getNodeText(image_metadata_elem); 
     224 
     225                    result = assocfilepath_metadata_val + "/" + image_metadata_val; 
     226                } 
     227                } 
    216228            } 
    217229 
  • gs3-extensions/iiif-servlet/trunk/src/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v2/GSInformationResource.java

    r32886 r32891  
    9191    final Identifier identifier_image = IdentifierToGSAssocfile.createIdentifierImage(identifier); 
    9292    final Source source = new SourceFactory().newSource(identifier_image, getDelegateProxy()); 
    93     /* 
    94     String identifier_str = identifier.toString(); 
    95     String[] strs = identifier_str.split(":", 3); 
    96     if(strs == null || strs.length < 3) { 
    97         System.err.println("identifier is not in the form site:coll:id" + identifier_str); 
    98         return null; 
    99     }     
    100     String site_name = strs[0]; 
    101     String coll_name = strs[1]; 
    102     String doc_id = strs[2]; 
    103  
    104     // Move into Constructor, ,and keep hashmap ??? 
    105     IIIFServerBridge gs_iiif_bridge = new IIIFServerBridge(); 
    106     gs_iiif_bridge.init(site_name); 
    107     String collect_image_filename = gs_iiif_bridge.doGetDocumentMessage(coll_name + ":" + doc_id); 
    108     String site_image_filename = site_name + "/collect/" + coll_name + "/index/assoc/" + collect_image_filename; 
    109      
    110     //System.err.println("**** gs_message = " + XMLConverter.getPrettyString(gs_message_elem)); 
    111     System.err.println("**** Greenstone site image filename = " + site_image_filename); 
    112  
    113     final Identifier identifier_image = new Identifier(site_image_filename); 
    114  
    115         //final Source source = new SourceFactory().newSource(identifier, getDelegateProxy()); 
    116     final Source source = new SourceFactory().newSource(identifier_image, getDelegateProxy()); 
    117          
    118     System.err.println("***** identifier_image = " + identifier_image); 
    119     System.err.println("***** source path = " + ((edu.illinois.library.cantaloupe.source.FileSource)source).getPath()); 
    120     */ 
    12193     
    12294        // If we are resolving first, or if the source image is not present in 
  • gs3-extensions/iiif-servlet/trunk/src/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v2/IdentifierToGSAssocfile.java

    r32886 r32891  
    4343    public static Identifier createIdentifierImage(Identifier identifier) throws Exception 
    4444    { 
     45    Identifier identifier_image = null; 
     46 
    4547    String identifier_str = identifier.toString(); 
    4648    String[] strs = identifier_str.split(":", 3); 
     
    5961     
    6062    String collect_image_filename = gs_iiif_bridge.doGetDocumentMessage(coll_name + ":" + doc_id); 
    61     String site_image_filename = site_name + "/collect/" + coll_name + "/index/assoc/" + collect_image_filename; 
    62      
    63     //System.err.println("**** Greenstone site image filename = " + site_image_filename); 
    6463 
    65     final Identifier identifier_image = new Identifier(site_image_filename); 
    66     //System.err.println("***** identifier_image = " + identifier_image); 
     64    if (collect_image_filename != null) { 
     65        String site_image_filename = site_name + "/collect/" + coll_name + "/index/assoc/" + collect_image_filename; 
     66 
     67        identifier_image = new Identifier(site_image_filename); 
     68    } 
    6769 
    6870