Changeset 24135


Ignore:
Timestamp:
2011-06-09T15:42:41+12:00 (13 years ago)
Author:
sjb48
Message:

Saving of the format statement to the collectionConfig is now possible. The bug with select boxes where the selected item was not saved has now been fixed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/Collection.java

    r23968 r24135  
    3333import java.io.File;
    3434import java.util.HashMap;
     35import java.util.*;
    3536
    3637import javax.xml.parsers.DocumentBuilder;
     
    471472                int index;
    472473                Element elem;
     474                // Try importing entire tree to this.doc so we can add and remove children at ease
     475                //Node current_node = this.doc.importNode(GSXML.getChildByTagName(config, "CollectionConfig"),true);
    473476                Node current_node = GSXML.getChildByTagName(config, "CollectionConfig");
    474477                NodeList current_node_list;
    475    
     478   
     479                logger.error("Service is "+service);
     480
    476481                if(service.equals("ClassifierBrowse"))
    477482                {
     
    480485                    // default is <browse><format>
    481486
     487                    logger.error("Looking for browse");
    482488                    current_node = GSXML.getChildByTagName(current_node, "browse");
    483489
     
    485491                    if(classifier != null)
    486492                    {
     493                        logger.error("Classifier is not null");
     494                        logger.error("Classifier is "+classifier);
    487495                        current_node_list = GSXML.getChildrenByTagName(current_node, "classifier");
    488496                        index = Integer.parseInt(classifier.substring(2)) - 1;
     497                        logger.error("classifier index is "+index);
    489498                        // index should be given by X-1
    490499                        current_node = current_node_list.item(index);
    491                         current_node = GSXML.getChildByTagName(current_node, "format");
     500                        // what if classifier does not have a format tag?
     501                        if(GSXML.getChildByTagName(current_node, "format") == null)
     502                        {
     503                            logger.error("ERROR: classifier does not have a format child");
     504                            // well then create a format tag
     505                            Element format_tag = config.createElement("format");
     506                            current_node = (Node) current_node.appendChild(format_tag);
     507                            //current_node = (Node) format_tag;
     508                        }
     509                       
     510                        else{
     511                            current_node = GSXML.getChildByTagName(current_node, "format");
     512                        }
    492513                    }
    493514                    else{
     515                        logger.error("Classifier is null");
    494516                        current_node = GSXML.getChildByTagName(current_node, "format");
    495517                    }
     
    498520                {
    499521                    // look in <format> with no attributes
     522                    logger.error("I presume this is search");
    500523           
    501524                    current_node_list = GSXML.getChildrenByTagName(current_node, "search");
     
    532555                {
    533556                    //if(transformed.getNodeType() == Node.DOCUMENT_NODE)
    534                 //transformed = ((Document)transformed).getDocumentElement();
    535                     logger.error("Node type: "+current_node_list.item(k).getNodeType());
     557                    //transformed = ((Document)transformed).getDocumentElement();
     558                    //logger.error("Node type: "+current_node_list.item(k).getNodeType());
    536559                    if(current_node_list.item(k).getNodeType() != Node.PROCESSING_INSTRUCTION_NODE)
    537                         current_node = elem.appendChild(this.doc.importNode(current_node_list.item(k),true));
     560                        elem.appendChild(config.importNode(current_node_list.item(k),true));
    538561                }
    539562
     
    546569                // Now convert config document to string for writing to file
    547570                String new_config = this.converter.getString(config);
     571
     572                new_config = StringUtils.replace(new_config, "&lt;", "<");
     573                new_config = StringUtils.replace(new_config, "&gt;", ">");
     574                new_config = StringUtils.replace(new_config, "&quot;", "\"");
    548575   
    549576                // Write to file (not original! for now)
Note: See TracChangeset for help on using the changeset viewer.