Changeset 12165


Ignore:
Timestamp:
2006-07-12T11:20:03+12:00 (18 years ago)
Author:
kjdon
Message:

added a hack to cope with pre 2.71 collections which don't specify a build type. if no build type specified, use mg unless searchtypes were specified, in which case use mgpp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionConfiguration.java

    r12131 r12165  
    4747import org.w3c.dom.*;
    4848
    49 /** This class provides either access to a pseudo-G3 document, or parses a collect.cfg file in such a way as to provide an xml-type view of its content. This later version is useful as it allows the manipulation and free form editing of a legacy collect.cfg file while still allowing the various CDM data managers to base themselves directly on this model (whereas they used to be independant ListModels which clobbered the ordering of unparsed commands).
     49/** This class provides access to an xml-type view of the collect.cfg file. This is useful as it allows the manipulation and free form editing of a collect.cfg file while still allowing the various CDM data managers to base themselves directly on this model (whereas they used to be independant ListModels which clobbered the ordering of unparsed commands).
    5050 * @author John Thompson, Greenstone Digital Library, University of Waikato
    5151 * @version 2.3d
     
    731731    static private String levelsToString(Element command_element) {
    732732    StringBuffer text = new StringBuffer("");
    733     if(!command_element.getAttribute(ASSIGNED_ATTRIBUTE).equals(TRUE_STR)) {
     733    if(command_element.getAttribute(ASSIGNED_ATTRIBUTE).equals(FALSE_STR)) {
    734734        text.append("#");
    735735    }
     
    829829     * note we are ignoring 2.39 compatibility now. */
    830830    private void parse(File collect_cfg_file) {
     831    // hack for pre 2.71 compatibility - we need to add in a
     832    // build type if there is not one there
     833    boolean search_types_parsed = false;
     834    boolean build_types_parsed = false;
    831835    try {
    832836
     
    904908            if(command_element == null && (command_type.equals(COLLECTIONMETADATA_PUBLIC_STR) || command_type.equals(COLLECTIONMETADATA_CREATOR_STR) || command_type.equals(COLLECTIONMETADATA_MAINTAINER_STR) || command_type.equals(BUILDTYPE_STR))) {
    905909            command_element = parseMetadataSpecial(command_str);
     910            // pre 2.71 hack
     911            if (command_type.equals(BUILDTYPE_STR)) {
     912                build_types_parsed = true;
     913            }
    906914            }
    907915            if(command_element == null && command_type.equals(PLUGIN_STR)) {
     
    911919            if(command_element == null && command_type.equals(SEARCHTYPE_STR)) {
    912920            command_element = parseSearchType(command_str);
     921            // pre 2.71 hack
     922            search_types_parsed = true;
     923           
    913924            }
    914925            if(command_element == null && command_type.equals(SUBCOLLECTION_STR)) {
     
    941952            //}
    942953        }
    943 
     954        if (!build_types_parsed) {
     955        String buildtype_type = BuildTypeManager.BUILD_TYPE_MG;
     956        if (search_types_parsed) {
     957            buildtype_type = BuildTypeManager.BUILD_TYPE_MGPP;
     958        }
     959        Element command_element = parseMetadataSpecial(BUILDTYPE_STR+"  "+buildtype_type);
     960        Node target_node = findInsertionPoint(command_element);
     961        if(target_node != null) {
     962            collect_cfg_element.insertBefore(command_element, target_node);
     963        }
     964        else {
     965            collect_cfg_element.appendChild(command_element);
     966        }
     967
     968        }
    944969    }
    945970    catch(Exception exception) {
     
    949974    }
    950975   
     976 
    951977    private Element parseClassify(String command_str) {
    952978    Element command_element = null;
     
    13821408        }
    13831409        value = Codec.transform(value, Codec.GREENSTONE_TO_DOM);
    1384         XMLTools.setValue(command_element, value);
    1385        
     1410        XMLTools.setValue(command_element, value);     
    13861411        }
    13871412    }
Note: See TracChangeset for help on using the changeset viewer.