Changeset 11046


Ignore:
Timestamp:
2006-01-17T10:31:10+13:00 (18 years ago)
Author:
mdewsnip
Message:

Tidied up plugin and classifier parsing and error output.

Location:
trunk/gli/src/org/greenstone/gatherer/cdm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/ClassifierManager.java

    r11039 r11046  
    349349        }
    350350
    351         document = CollectionDesignManager.XMLStringToDOM(xml,classifier);
    352     }
    353     catch (Exception error) {
    354         error.printStackTrace();
    355         ///ystem.err.println("Error: Cannot parse " + getClassifierName(classifier));
    356     }
    357     if(document != null) {
     351        if (xml.length() > 0) {
     352        document = CollectionDesignManager.XMLStringToDOM(xml, classifier);
     353        }
     354        else {
     355        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.PlugInManager.Classifier_XML_Parse_Failed", classifier), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     356        }
     357    }
     358    catch (Exception exception) {
     359        DebugStream.println("Failed when trying to parse: " + classifier);
     360        DebugStream.printStackTrace(exception);
     361    }
     362
     363    if (document != null) {
    358364        parseXML(document.getDocumentElement());
    359365    }
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java

    r10556 r11046  
    258258    Document document = null;
    259259
    260     // If something has gone horribly wrong then xml will be empty.
    261     if(xml.length() > 0) {
    262         try {
    263         // Then read the xml from the piped input stream.
    264         StringReader xml_sr = new StringReader(xml.toString());
    265         InputSource source = new InputSource(xml_sr);
    266         DOMParser parser = new DOMParser();
    267         parser.parse(source);
    268         document = parser.getDocument();
    269         }
    270         catch (Exception error) {
    271         System.err.println("Failed when trying to parse XML stream ");
    272         error.printStackTrace();
    273         }
    274     }
    275     else {
    276         //DebugStream.println("Zero length argument xml detected for: " + form);
    277         String[] margs = new String[1];
    278         margs[0] = form;
    279         JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.PlugInManager.PlugIn_XML_Parse_Failed", margs), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);  // !! TO DO: This is bad -- this function is used for more than just plugins
     260    try {
     261        // Read the xml from the piped input stream.
     262        StringReader xml_sr = new StringReader(xml.toString());
     263        InputSource source = new InputSource(xml_sr);
     264        DOMParser parser = new DOMParser();
     265        parser.parse(source);
     266        document = parser.getDocument();
     267    }
     268    catch (Exception error) {
     269        System.err.println("Failed when trying to parse XML stream ");
     270        error.printStackTrace();
    280271    }
    281272
  • trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java

    r11038 r11046  
    481481        }
    482482
    483         document = CollectionDesignManager.XMLStringToDOM(xml,plugin);
    484     }
    485     catch (Exception error) {
    486         System.err.println("Failed when trying to parse: " + plugin);
    487         error.printStackTrace();
    488     }
    489     if(document != null) {
     483        if (xml.length() > 0) {
     484        document = CollectionDesignManager.XMLStringToDOM(xml, plugin);
     485        }
     486        else {
     487        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.PlugInManager.PlugIn_XML_Parse_Failed", plugin), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     488        }
     489    }
     490    catch (Exception exception) {
     491        DebugStream.println("Failed when trying to parse: " + plugin);
     492        DebugStream.printStackTrace(exception);
     493    }
     494
     495    if (document != null) {
    490496        parseXML(document.getDocumentElement());
    491497    }
     
    522528    }
    523529    }
    524 
    525530
    526531
Note: See TracChangeset for help on using the changeset viewer.