Changeset 29728

Show
Ignore:
Timestamp:
10.02.2015 18:07:10 (5 years ago)
Author:
ak19
Message:

Adjusting gs3-server code to work with changes made to 29686 where web.xml was split into web.xml and servlets.xml, with the first including the second.

Location:
main/trunk/greenstone3/src/java/org/greenstone
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSEntityResolver.java

    r16869 r29728  
    3333 
    3434    ClassLoader class_loader = null; 
     35    File baseFilepath = null; 
    3536     
    3637     static Logger logger = Logger.getLogger(org.greenstone.gsdl3.util.GSEntityResolver.class.getName()); 
     38 
     39    public GSEntityResolver() {} 
     40 
     41    public GSEntityResolver(File baseFilepath) { 
     42    this.baseFilepath = baseFilepath; 
     43    } 
     44 
     45    /* Methods with the ClassLoader parameter are unused at present */ 
     46    public GSEntityResolver(ClassLoader loader) { 
     47    this.class_loader = loader; 
     48    } 
    3749 
    3850    public void setClassLoader(ClassLoader loader) { 
     
    5668        } 
    5769    } 
     70     
     71    // use the baseFilepath, if one was provided 
     72    if(this.baseFilepath != null) { 
     73        return new InputSource("file://" + this.baseFilepath + File.separator + temp_id); 
     74    } 
     75 
    5876    // try using a class loader 
    5977    if (this.class_loader==null) { 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XMLConverter.java

    r28978 r29728  
    159159    return null; 
    160160    } 
     161 
     162  public static Document getDOM(File in, EntityResolver er) { 
     163     
     164    try {       
     165      InputSource xml_source = new InputSource(new FileInputStream(in)); 
     166      Document doc = getDOM(xml_source, er);       
     167      return doc;       
     168    } 
     169    catch (Exception e) 
     170      { 
     171    logger.error(e.getMessage()); 
     172      } 
     173    return null; 
     174  } 
    161175 
    162176  public static Document getDOM(InputSource source, EntityResolver er) { 
  • main/trunk/greenstone3/src/java/org/greenstone/server/Server3Settings.java

    r25951 r29728  
    44import java.awt.event.*; 
    55import java.io.File; 
     6import java.io.FileInputStream; 
    67import java.util.ArrayList; 
    78import java.util.HashMap; 
     
    910 
    1011import org.w3c.dom.*; 
     12import org.xml.sax.InputSource; 
    1113 
    1214import org.greenstone.util.ScriptReadWrite; 
    1315 
    1416import org.greenstone.util.GlobalProperties; 
     17import org.greenstone.gsdl3.util.GSEntityResolver; 
    1518import org.greenstone.gsdl3.util.GSXML; 
    1619import org.greenstone.gsdl3.util.XMLConverter; 
     
    4144    File web_xml = new File(GlobalProperties.getGSDL3Home() + File.separator + "WEB-INF" + File.separator + "web.xml"); 
    4245    XMLConverter converter = new XMLConverter(); 
    43     Document web_config = converter.getDOM(web_xml); 
     46    // web.xml now includes the new file servlets.xml which defines entities used therein 
     47    // So when loading web.xml's DOM, need to resolve entities in web.xml. And for this,  
     48    // need to instruct the entity resolver to load included files relative to web.xml's location 
     49    Document web_config = converter.getDOM(web_xml, new GSEntityResolver(web_xml.getParentFile()));  
    4450    if (web_config == null) { 
    4551        logger.error("web.xml is null! "+web_xml.getAbsolutePath());