Changeset 25975

Show
Ignore:
Timestamp:
19.07.2012 14:21:53 (7 years ago)
Author:
sjm84
Message:

Service racks now store the global format and return it whenever the format is requested

Files:
1 modified

Legend:

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

    r25635 r25975  
    2020 
    2121// greenstone classes 
    22 import org.greenstone.gsdl3.util.*; 
    23 import org.greenstone.gsdl3.core.*; 
    24  
    25 // xml classes 
     22import java.lang.reflect.Method; 
     23import java.util.HashMap; 
     24 
     25import org.apache.log4j.Logger; 
     26import org.greenstone.gsdl3.core.MessageRouter; 
     27import org.greenstone.gsdl3.core.ModuleInterface; 
     28import org.greenstone.gsdl3.util.CollectionClassLoader; 
     29import org.greenstone.gsdl3.util.Dictionary; 
     30import org.greenstone.gsdl3.util.GSPath; 
     31import org.greenstone.gsdl3.util.GSXML; 
     32import org.greenstone.gsdl3.util.XMLConverter; 
     33import org.w3c.dom.Document; 
     34import org.w3c.dom.Element; 
    2635import org.w3c.dom.Node; 
    2736import org.w3c.dom.NodeList; 
    28 import org.w3c.dom.Element; 
    29 import org.w3c.dom.Document; 
    30 import org.xml.sax.InputSource; 
    31 import javax.xml.parsers.*; 
    32 import org.apache.xpath.XPathAPI; 
    33  
    34 // general java classes 
    35 import java.io.Reader; 
    36 import java.io.StringReader; 
    37 import java.io.File; 
    38 import java.util.HashMap; 
    39 import java.util.ResourceBundle; 
    40 import java.util.Locale; 
    41 import java.lang.reflect.Method; 
    42  
    43 import org.apache.log4j.*; 
    4437 
    4538/** 
     
    9487    protected HashMap<String, Node> format_info_map = null; 
    9588 
     89    protected Element _globalFormat = null; 
     90 
    9691    /** 
    9792     * A class loader that knows about the collection resources directory can 
     
    114109    public void cleanUp() 
    115110    { 
     111    } 
     112 
     113    public void setGlobalFormat(Element globalFormat) 
     114    { 
     115        _globalFormat = globalFormat; 
    116116    } 
    117117 
     
    210210    public Node process(Node message_node) 
    211211    { 
    212  
    213212        Element message = this.converter.nodeToElement(message_node); 
    214213 
     
    395394        if (this.format_info_map.containsKey(to)) 
    396395        { 
    397             response.appendChild(getServiceFormat(to)); 
     396            response.appendChild(response.getOwnerDocument().importNode(getServiceFormat(to), true)); 
     397            if (_globalFormat != null) 
     398            { 
     399                response.appendChild(response.getOwnerDocument().importNode(GSXML.duplicateWithNewName(response.getOwnerDocument(), _globalFormat, GSXML.GLOBAL_FORMAT_ELEM, false), true)); 
     400            } 
     401            System.err.println("RESPONSE = " + GSXML.xmlNodeToString(response)); 
    398402            response.setAttribute(GSXML.FROM_ATT, to); 
    399403            return response;