Changeset 8249


Ignore:
Timestamp:
2004-10-08T14:25:37+13:00 (20 years ago)
Author:
mdewsnip
Message:

Moved the XMLStringToDOM() function from Utility into CollectionDesignManager, as it depends on the Gatherer class.

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
4 edited

Legend:

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

    r8243 r8249  
    351351
    352352        StringBuffer xml = Utility.readXMLStream(input_stream);
    353         document = Utility.XMLStringToDOM(xml,classifier);
     353        document = CollectionDesignManager.XMLStringToDOM(xml,classifier);
    354354    }
    355355    catch (Exception error) {
     
    436436    {
    437437    StringBuffer xml  = Utility.readXMLStream(input_stream);
    438     Document document = Utility.XMLStringToDOM(xml, "-listall");
     438    Document document = CollectionDesignManager.XMLStringToDOM(xml, "-listall");
    439439
    440440    // Parse XML to build up list of classifier names
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java

    r8243 r8249  
    3232import javax.swing.*;
    3333import javax.swing.event.*;
     34import org.apache.xerces.parsers.*;
    3435import org.greenstone.gatherer.Configuration;
    3536import org.greenstone.gatherer.DebugStream;
     37import org.greenstone.gatherer.Dictionary;
    3638import org.greenstone.gatherer.Gatherer;
    3739import org.greenstone.gatherer.util.GSDLSiteConfig;
    3840import org.greenstone.gatherer.util.Utility;
     41import org.w3c.dom.*;
     42import org.xml.sax.*;
    3943
    4044/** This manager provides access to submanagers, which in turn provide tools for the designing of Greenstone collections via the information stored in etc/collect.cfg. This class acts as a hub for the managers that handle specific parts of the configuration such as classifiers, format strings and language settings.
     
    242246
    243247
     248    static public Document XMLStringToDOM(StringBuffer xml, String form)
     249    {
     250    Document document = null;
     251
     252    // If something has gone horribly wrong then xml will be empty.
     253    if(xml.length() > 0) {
     254        try {
     255        // Then read the xml from the piped input stream.
     256        StringReader xml_sr = new StringReader(xml.toString());
     257        InputSource source = new InputSource(xml_sr);
     258        DOMParser parser = new DOMParser();
     259        parser.parse(source);
     260        document = parser.getDocument();
     261        }
     262        catch (Exception error) {
     263        System.err.println("Failed when trying to parse XML stream ");
     264        error.printStackTrace();
     265        }
     266    }
     267    else {
     268        //DebugStream.println("Zero length argument xml detected for: " + form);
     269        String[] margs = new String[1];
     270        margs[0] = form;
     271        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.PlugInManager.PlugIn_XML_Parse_Failed", margs), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     272    }
     273
     274    return document;
     275    }
     276
     277
    244278    private class CDMChangeListener
    245279    implements ActionListener, DocumentListener {
  • trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java

    r8243 r8249  
    403403
    404404        StringBuffer xml = Utility.readXMLStream(input_stream);
    405         document = Utility.XMLStringToDOM(xml,plugin);
     405        document = CollectionDesignManager.XMLStringToDOM(xml,plugin);
    406406    }
    407407    catch (Exception error) {
     
    470470    {
    471471    StringBuffer xml  = Utility.readXMLStream(input_stream);
    472     Document document = Utility.XMLStringToDOM(xml, "-listall");
     472    Document document = CollectionDesignManager.XMLStringToDOM(xml, "-listall");
    473473
    474474    // Parse XML to build up list of plugin names
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r8248 r8249  
    14101410
    14111411
    1412     static public Document XMLStringToDOM(StringBuffer xml, String form)
    1413     {
    1414     Document document = null;
    1415 
    1416     // If something has gone horribly wrong then xml will be empty.
    1417     if(xml.length() > 0) {
    1418         try {
    1419         // Then read the xml from the piped input stream.
    1420         StringReader xml_sr = new StringReader(xml.toString());
    1421         InputSource source = new InputSource(xml_sr);
    1422         DOMParser parser = new DOMParser();
    1423         parser.parse(source);
    1424         document = parser.getDocument();
    1425         }
    1426         catch (Exception error) {
    1427         System.err.println("Failed when trying to parse XML stream ");
    1428         error.printStackTrace();
    1429         }
    1430     }
    1431     else {
    1432         //DebugStream.println("Zero length argument xml detected for: " + form);
    1433         String[] margs = new String[1];
    1434         margs[0] = form;
    1435         JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.PlugInManager.PlugIn_XML_Parse_Failed", margs), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
    1436     }
    1437 
    1438     return document;
    1439     }
    1440 
    1441 
    1442 
    14431412    /** Method to spread out a line of text so that is is justified to the given width, by attempting to widen white-spacing in a balanced way.
    14441413     * @param original The <strong>String</strong> to justify.
Note: See TracChangeset for help on using the changeset viewer.