Ignore:
Timestamp:
2010-11-30T17:26:36+13:00 (13 years ago)
Author:
sjb48
Message:

Starting working on new format statement save architecture. This involves a new action, FormatAction, which will be responsible for the XSL transform and will pass the format string to the Collection object via the Message Router,

File:
1 edited

Legend:

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

    r23340 r23360  
    7272        system.setAttribute(GSXML.SYSTEM_SUBSET_ATT, info);
    7373    }
    74     else if(subaction.equals("s")) { // save format statement
    75          logger.error("Initiate save");
    76          String format_string = (String)params.get("data");
    77          logger.error("data="+format_string);
    78 
    79          //SamParser sam = new SamParser();
    80          //String format_statement = sam.parse(input);
    81          //logger.error("format string="+format_statement);
    82    
    83         Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
    84 
    85          Iterator it = params.keySet().iterator();
    86          while(it.hasNext())
    87          {
    88             logger.error("Param: "+it.next());
    89          } 
    90 
    91         //Node text = this.doc.createTextNode(format_string);
    92         //page_response.appendChild(text);
    93    
    94        
    95         try {
    96             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    97             DocumentBuilder builder = factory.newDocumentBuilder();
    98             //String input = "<html><head><title></title></head><body>" + format_string + "</body></html>";
    99             String input = format_string;
    100             InputSource is = new InputSource( new StringReader( input ) );
    101             Document d = builder.parse( is );
    102             Element e = d.getDocumentElement();
    103            
    104             page_response.appendChild(this.doc.importNode(e, true));
    105         }
    106         catch( Exception ex ) {
    107             logger.error("There was an exception "+ex);
    108            
    109             StringWriter sw = new StringWriter();
    110             PrintWriter pw = new PrintWriter(sw, true);
    111             ex.printStackTrace(pw);
    112             pw.flush();
    113             sw.flush();
    114             logger.error(sw.toString());
    115         }
    116        
    117    
    118         //Element child = this.doc.createElement("div"); //format_string);
    119         //Node text = this.doc.createTextNode(format_string); //"<h1>Hi there and greetings!</h1>");
    120         //child.innerHTML = "<h1>Hi there and greetings!</h1>";
    121         //child.setNodeValue(format_string);
    122         //child.appendChild(text);
    123         result.appendChild(page_response);
    124         return result;
    125     } else {
     74    else {
    12675        String name = (String)params.get(GSParams.SYSTEM_MODULE_NAME);
    12776        String type = (String)params.get(GSParams.SYSTEM_MODULE_TYPE);
     
    153102    }
    154103
    155     /*
    156     public void parse (String message) {
    157         //get a factory
    158         SAXParserFactory spf = SAXParserFactory.newInstance();
    159         try {
    160 
    161             //get a new instance of parser
    162             SAXParser sp = spf.newSAXParser();
    163             InputSource is = new InputSource( new StringReader( message ) );
    164             //parse the file and also register this class for call backs
    165             sp.parse(is, new SamParser());
    166 
    167         }catch(SAXException se) {
    168             se.printStackTrace();
    169         }catch(ParserConfigurationException pce) {
    170             pce.printStackTrace();
    171         }catch (IOException ie) {
    172             ie.printStackTrace();
    173         }
    174     }
    175     */
    176 
    177     //Event Handlers
    178 /*    public void startElement(String uri, String localName, String qName,
    179         Attributes attributes) throws SAXException {
    180         //reset
    181         logger.error("Start Element: "+qName);
    182         //if(qName.equalsIgnoreCase("Template")) {
    183             //create a new instance of employee
    184             //tempEmp = new Employee();
    185             //tempEmp.setType(attributes.getValue("type"));
    186            
    187         //}
    188     }
    189 
    190 
    191     public void characters(char[] ch, int start, int length) throws SAXException {
    192         tempVal = new String(ch,start,length);
    193     }
    194 
    195     public void endElement(String uri, String localName,
    196         String qName) throws SAXException {
    197 
    198         logger.error("Characters: "+tempVal);
    199         logger.error("End Element: "+qName);
    200         /*
    201         if(qName.equalsIgnoreCase("Employee")) {
    202             //add it to the list
    203             myEmpls.add(tempEmp);
    204 
    205         }else if (qName.equalsIgnoreCase("Name")) {
    206             tempEmp.setName(tempVal);
    207         }else if (qName.equalsIgnoreCase("Id")) {
    208             tempEmp.setId(Integer.parseInt(tempVal));
    209         }else if (qName.equalsIgnoreCase("Age")) {
    210             tempEmp.setAge(Integer.parseInt(tempVal));
    211         } */
    212 
    213     //}
    214 
    215104}
Note: See TracChangeset for help on using the changeset viewer.