Changeset 23405


Ignore:
Timestamp:
12/07/10 17:05:38 (11 years ago)
Author:
sjb48
Message:

FormatAction constructs message containing format string that is sent to the collection. The message knows the service, and if it is the browse service, then it also knows the classifer list number.

Location:
main/trunk/greenstone3
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/FormatAction.java

    r23361 r23405  
    33import org.greenstone.gsdl3.core.ModuleInterface;
    44import org.greenstone.gsdl3.util.*;
     5import org.greenstone.util.GlobalProperties;
    56
    67// XML classes
     
    5455   
    5556    String coll = (String)params.get(GSParams.COLLECTION); //SYSTEM_CLUSTER);
     57    String service = (String)params.get(GSParams.SERVICE);
     58    String classifier = (String)params.get("cl");
     59
     60
     61    logger.error("Collection="+coll);
     62    logger.error("Service="+service);
     63    logger.error("Classifier="+classifier);
     64
    5665
    5766    String to = "";
     
    6271    Element mr_request_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    6372    Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT_STRING, to, lang, uid);
     73
     74    request.setAttribute("service", service);
     75    if(classifier != null)
     76        request.setAttribute("classifier", classifier);
     77
    6478    mr_request_message.appendChild(mr_request);
    6579   
    66     Element format = this.doc.createElement(GSXML.FORMAT_STRING_ELEM);
    67     mr_request.appendChild(format);
     80    //Element format = this.doc.createElement(GSXML.FORMAT_STRING_ELEM);
     81    //mr_request.appendChild(format);
    6882
    6983    String format_string = (String)params.get("data");
     
    7286
    7387    Iterator it = params.keySet().iterator();
    74     while(it.hasNext())
    75     {
    76         logger.error("Param: "+it.next());
    77     }     
     88    //while(it.hasNext())
     89    //{
     90    //    logger.error("Param: "+it.next());
     91    //}     
    7892
    7993    try {
     
    8397            String input = format_string;
    8498            InputSource is = new InputSource( new StringReader( input ) );
    85             Document d = builder.parse( is );
    86             Element e = d.getDocumentElement();
    87            
    88             page_response.appendChild(this.doc.importNode(e, true));
     99            Document d = (Document) builder.parse( is );
     100            //Element e = d.getDocumentElement();
     101            //Node d2 = this.doc.importNode(e,true);
     102
     103            //Document format_doc = this.converter.newDOM();
     104            //doc.appendChild(d2);
     105
     106            //File interface_config_file = new File(GSFile.interfaceConfigFile(GSFile.interfaceHome(GlobalProperties.getGSDL3Home(), (String)this.config_params.get(GSConstants.INTERFACE_NAME))));
     107            //if (!interface_config_file.exists()) {
     108            //  logger.error(" interface config file: "+interface_config_file.getPath()+" not found!");
     109            //}
     110            //Document config_doc = this.converter.getDOM(interface_config_file, "utf-8");
     111            //if (config_doc == null) {
     112            //  logger.error(" could not parse interface config file: "+interface_config_file.getPath());
     113            //}
     114       
     115            //Element config_elem = config_doc.getDocumentElement();
     116            //String base_interface = config_elem.getAttribute("baseInterface");
     117
     118
     119            // Call XSLT to transform document to xml format string
     120            XMLTransformer transformer = new XMLTransformer();
     121            //String stylesheet = GSFile.stylesheetFile(GlobalProperties.getGSDL3Home(), (String)this.config_params.get(GSConstants.SITE_NAME), coll, (String)this.config_params.get(GSConstants.INTERFACE_NAME), "oran", "FormatAction");
     122            //logger.error(stylesheet);
     123            Document style_doc = this.converter.getDOM(new File("/home/sam/greenstone3/web/interfaces/oran/transform/formatString.xsl"), "UTF-8");
     124
     125            if(style_doc == null)
     126                logger.error("style_doc is null");
     127
     128            // not sure what to do here - some code from Transforming Receptionist
     129            String transformed = transformer.transformToString(style_doc, d);
     130            //Node transformed = transformer.transform(style_doc, d);
     131           
     132            Element format = this.doc.createElement(GSXML.FORMAT_STRING_ELEM);
     133            GSXML.setNodeText(format, transformed);
     134            //format.appendChild(this.doc.createTextNode(transformed));
     135            //format.setNodeValue(transformed);
     136            mr_request.appendChild(format);
     137            logger.error("Transformed: "+transformed);
     138
     139
     140            //page_response.appendChild(this.doc.importNode(e, true));
    89141    } catch( Exception ex ) {
    90142            logger.error("There was an exception "+ex);
     
    100152
    101153    // Call XSLT to transform document to xml format string
    102     this.transformer = new XMLTransformer();
     154    //XMLTransformer transformer = new XMLTransformer();
    103155
    104156    // not sure what to do here - some code from Transforming Receptionist
     157    //transformer.transformToString(Document stylesheet, Document source);
    105158
    106159    // create a mesage to send to the collection object via the message router
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java

    r21770 r23405  
    509509        return response;
    510510    }
    511    
     511
     512    if (type.equals(GSXML.REQUEST_TYPE_FORMAT_STRING)) {
     513        logger.error("Received format string request");
     514        String service = request.getAttribute("service");
     515        logger.error("Service is " + service);
     516        String classifier = null;
     517        if(service.equals("ClassifierBrowse"))
     518        {
     519            classifier = request.getAttribute("classifier");
     520            logger.error("Classifier is " + classifier);
     521        }
     522        Element format_element = (Element) GSXML.getChildByTagName(request, GSXML.FORMAT_STRING_ELEM);
     523        String format_string = GSXML.getNodeText(format_element);
     524        logger.error("Format string: " + format_string);
     525        logger.error("Config file location = " + GSFile.collectionConfigFile(this.site_home, this.cluster_name));
     526    }
    512527    if (type.equals(GSXML.REQUEST_TYPE_SYSTEM)) {
    513528        response = processSystemRequest(request);
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/Receptionist.java

    r23360 r23405  
    234234
    235235    logger.debug("receptionist returned response");
    236     logger.error("receptionist returned response");
     236    //logger.error("receptionist returned response");
    237237    logger.debug(this.converter.getString(resulting_page));
    238     logger.error(this.converter.getString(resulting_page));
     238    //logger.error(this.converter.getString(resulting_page));
    239239//    logger.info("receptionist returned response");
    240240//    logger.info(this.converter.getString(resulting_page));
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java

    r23336 r23405  
    659659      logger.info(" cant find stylesheet for "+name);
    660660    }
     661    logger.error("stylesheet:"+stylesheet);
    661662    return stylesheet;
    662663  }
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XMLTransformer.java

    r22390 r23405  
    9898        //this.t_factory = TransformerFactory.newInstance();
    9999    } catch (Exception e) {
    100         logger.error("exception "+e.getMessage());
     100        logger.error("exception creating t_factory "+e.getMessage());
    101101    }
    102102    }
  • main/trunk/greenstone3/web/interfaces/oran/interfaceConfig.xml

    r23360 r23405  
    2222    <action name='s' class='SystemAction' xslt='system.xsl'/>
    2323
    24     <action name='f' class='FormatAction' xslt='formatString.xsl'/>
     24    <action name='f' class='FormatAction'/> <!-- xslt='formatString.xsl'/> -->
    2525
    2626    <action name='g' class='GeneralAction'>
  • main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js

    r23360 r23405  
    1111    //console.log(formatStatement);
    1212
     13    // find collection name
     14
     15    var myurl = document.URL;
     16    console.log(myurl);
     17    var first = myurl.indexOf("&c")+3;
     18    var last = myurl.indexOf("&", first);
     19   
     20    var collection_name = myurl.substring(first,last); ///&c=(.*)&/.exec(myurl);
     21    console.log(collection_name);
     22
     23    first = myurl.indexOf("&s")+3;
     24    last = myurl.indexOf("&", first);
     25
     26    var service_name = myurl.substring(first,last);
     27    console.log(service_name);
     28
     29    var classifier_name = null;
     30
     31    if(service_name == "ClassifierBrowse")
     32    {
     33        first = myurl.indexOf("&cl")+4;
     34        last = myurl.indexOf("&", first);
     35
     36        classifier_name = myurl.substring(first,last);
     37        console.log(classifier_name);
     38    }
    1339
    1440    //var myurl = 'http://localhost:8080/greenstone3/format?a=s&sa=s&t='+formatStatement;
     
    1743
    1844    // How do I find out my collection name?
    19 
    20     $.post("http://localhost:8080/greenstone3/format?a=f", {data: formatStatement}, function(data) {
     45    var post_url = "http://localhost:8080/greenstone3/format?a=f&c=" + collection_name +"&s=" + service_name;
     46
     47    if(classifier_name != null)
     48        post_url = post_url + "&cl=" + classifier_name;
     49
     50    $.post(post_url, {data: formatStatement}, function(data) {
    2151        //$('.result').innerHTML = data; //html(data);
    2252        console.log("Success, we have received data");
  • main/trunk/greenstone3/web/interfaces/oran/transform/formatString.xsl

    r23360 r23405  
    1 <?xml version="1.0" encoding="ISO-8859-1"?>
     1<?xml version="1.0" encoding="UTF-8"?>
    22<xsl:stylesheet version="1.0"
    33  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    4   xmlns:java="http://xml.apache.org/xslt/java"
    5   extension-element-prefixes="java">
     4  xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
     5  xmlns:gslib="http://www.greenstone.org/XSL/Library"
     6  xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
     7  xmlns:util="http://org.greenstone.gsdl3.util.XSLTUtil"
     8  exclude-result-prefixes="util gslib gsf xslt">
     9
     10  <!-- extension-element-prefixes="java"> -->
    611
    712  <xsl:strip-space elements="*"/>
     
    241246  <!-- Main page generation -->
    242247
    243   <xsl:template match="page">
    244     <html>
     248  <xsl:template match="/">
     249    <!-- <html>
    245250      <head>
    246251    <title>
     
    249254      </head>
    250255      <body>
    251         <h2> This should be the format string (unmodified and html version) </h2>
     256        <h2> This should be the format string (unmodified and html version) </h2> -->
    252257        <!-- <xsl:value-of select="/page/pageResponse" disable-output-escaping="yes"/> -->
    253258        <xsl:call-template name="xml">
    254             <xsl:with-param name="fmt" select="/page/pageResponse"/>
     259            <xsl:with-param name="fmt" select="."/>
    255260        </xsl:call-template><xsl:text> </xsl:text>
    256261        <!-- <xsl:apply-templates select="/page/pageResponse" mode="xml"/> -->
    257       </body>
    258     </html>
    259   </xsl:template>
    260  
     262      <!-- </body>
     263    </html> -->
     264  </xsl:template>
     265 
     266  <!--
    261267  <xsl:template name="pageTitle">
    262268    <xsl:value-of select="java:org.greenstone.gsdl3.util.XSLTUtil.getInterfaceText($interface_name, /page/@lang, 'gsdl')"/>
    263   </xsl:template>
     269  </xsl:template> -->
    264270 
    265271</xsl:stylesheet>
Note: See TracChangeset for help on using the changeset viewer.