Changeset 22370


Ignore:
Timestamp:
2010-07-09T15:00:11+12:00 (14 years ago)
Author:
ak19
Message:
  1. Bugfix: Dr Bainbridge discovered that the reason the fedora pages off the GS3 tomcat server stopped functioning after visiting the GS3 pages off the same server, was that XMLTransformer was fixing the TransformerFactory property for the entire system. Unfortunately it set this to one (xalan) that is not included in the libraries that fedora ships with. The solution is to now let Java work out, which it already does correctly, that GS3 is using the one that's part of its included jar files (xalan.jar), instead of fixing this with System.setProperty. Now the Fedora pages run off the GS3 tomcat server at all times. 2. FedoraServiceProxy will use any fedora connection specifics in the info element coming from buildConfig.xml (for protocol, host, port, authentication), otherwise it will use defaults.
Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/FedoraServiceProxy.java

    r22366 r22370  
    108108    // Try to instantiate a Fedora dl handle
    109109    try {
    110         // The properties file containing the initial digital library connection
    111         // settings which get displayed in the connection dialog fields
    112         //final File propertiesFile = new File("gs3fedora.properties");
    113         //fedoraServicesAPIA = new FedoraServicesAPIA(propertiesFile);
    114        
    115         // Defaults. Read host and port from global.properties
     110        // Fedora connection settings defaults.
     111        // Read host and port from global.properties, since by default, we expect the Greenstone server to be used
    116112        Properties globalProperties = new Properties();
    117113        globalProperties.load(Class.forName("org.greenstone.util.GlobalProperties").getClassLoader().getResourceAsStream("global.properties"));
     
    120116        String protocol = "http";
    121117        String username = "fedoraIntCallUser"; //"fedoraAdmin"
    122         String password = "changeme"; //"pounamu"
    123 
    124         fedoraServicesAPIA = new FedoraServicesAPIA(protocol, host, Integer.parseInt(port), username, password); //"fedoraAdmin", "pounamu"
     118        String password = "changeme"; //"<user password>"
     119
     120        // See if buildConfig.xml overrides any of the defaults
     121        // info is the <serviceRack> Element from buildConfig.xml (extra_info are the Elements of collectionConfig.xml)
     122
     123        NodeList nodes = info.getElementsByTagName("fedoraConnection");
     124        if(nodes != null && nodes.getLength() > 0) {
     125
     126        Element fedoraElement = (Element)nodes.item(0);
     127        if(fedoraElement.hasAttribute("protocol")) {
     128            protocol = fedoraElement.getAttribute("protocol");
     129        }       
     130        if(fedoraElement.hasAttribute("host")) {
     131            host = fedoraElement.getAttribute("host");
     132        }
     133        if(fedoraElement.hasAttribute("port")) {
     134            port = fedoraElement.getAttribute("port");
     135        }
     136        if(fedoraElement.hasAttribute("username")) {
     137            username = fedoraElement.getAttribute("username");
     138        }
     139        if(fedoraElement.hasAttribute("password")) {
     140            password = fedoraElement.getAttribute("password");
     141        }       
     142        }   
     143
     144        fedoraServicesAPIA = new FedoraServicesAPIA(protocol, host, Integer.parseInt(port), username, password);
     145
    125146    } catch(org.greenstone.fedora.services.FedoraGS3Exception.CancelledException e) {
    126         // The user pressed cancel in the fedora services instantiation dlg
     147        // The user pressed cancel in the fedora services instantiation dialog
    127148        return false;
    128149    } catch(Exception e) {
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XMLTransformer.java

    r18452 r22370  
    7474   */
    7575    public XMLTransformer() {
    76 
    7776    // make sure we are using the xalan transformer
    78     System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");
     77
     78    // http://download.oracle.com/docs/cd/E17476_01/javase/1.5.0/docs/api/index.html?javax/xml/transform/TransformerFactory.html states that
     79    // TransformerFactory.newInstance() looks in jar files for a Factory specified in META-INF/services/javax.xml.transform.TransformerFactory,
     80    // else it will use the "platform default"
     81    // In this case: xalan.jar's META-INF/services/javax.xml.transform.TransformerFactory contains org.apache.xalan.processor.TransformerFactoryImpl
     82    // as required.
     83
     84    // This means we no longer have to do a System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");
     85    // followed by a this.t_factory = org.apache.xalan.processor.TransformerFactoryImpl.newInstance();
     86    // The System.setProperty step to force the TransformerFactory implementation that gets used conflicts with
     87    // Fedora (visiting the Greenstone server pages breaks the Greenstone-tomcat hosted Fedora pages) as Fedora
     88    // does not include the xalan.jar and therefore can't then find the xalan TransformerFactory explicitly set.
     89
    7990    try {
    80         this.t_factory = org.apache.xalan.processor.TransformerFactoryImpl.newInstance();
    81 
     91        this.t_factory = TransformerFactory.newInstance();
    8292    } catch (Exception e) {
    8393        logger.error("exception "+e.getMessage());
Note: See TracChangeset for help on using the changeset viewer.