Changeset 14049


Ignore:
Timestamp:
2007-05-03T09:33:03+12:00 (17 years ago)
Author:
xiao
Message:

Add implementation of reading collectionConfig.xml for openning a collection when the mode is gs3.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/collection/BasicCollectionConfiguration.java

    r10345 r14049  
    4343import org.greenstone.gatherer.util.Codec;
    4444import org.greenstone.gatherer.util.StaticStrings;
     45import org.greenstone.gatherer.util.XMLTools;
    4546import org.w3c.dom.*;
    4647
     
    5455    private String maintainer = "";
    5556    private String name = "";
     57    private String is_public = "";
    5658   
    5759    private String site = null; // used for gs3 colls
     
    145147        ///ystem.err.println("maintainer  = " + maintainer);
    146148        ///ystem.err.println("description = " + description);
     149
     150        if(filename.endsWith(".xml")) {
     151       
     152        Document xml_file_doc = XMLTools.parseXMLFile(file);
     153        Element root = xml_file_doc.getDocumentElement();
     154
     155        Node metadataListNode = XMLTools.getChildByTagNameIndexed(root, StaticStrings.METADATALIST_STR, 0);
     156        Node displayItemListNode = XMLTools.getChildByTagNameIndexed(root, StaticStrings.DISPLAYITEMLIST_STR, 0);
     157        String []strings = {creator,
     158                    maintainer,
     159                    is_public,
     160                    name,
     161                    description};
     162        String []att_names = {StaticStrings.COLLECTIONMETADATA_CREATOR_STR,
     163                      StaticStrings.COLLECTIONMETADATA_MAINTAINER_STR,
     164                      StaticStrings.COLLECTIONMETADATA_PUBLIC_STR,
     165                      StaticStrings.NAME_STR,
     166                      StaticStrings.DESCRIPTION_STR};
     167        for (int i=0; i<strings.length; i++) { 
     168            Element e = XMLTools.getNamedElement((Element)metadataListNode,
     169                StaticStrings.METADATA_STR, StaticStrings.NAME_ATTRIBUTE, att_names[i]);
     170            if (i >=3) {
     171            e = XMLTools.getNamedElement((Element)displayItemListNode,
     172                  StaticStrings.DISPLAYITEM_STR, StaticStrings.NAME_ATTRIBUTE, att_names[i]);
     173            }
     174            if (e == null) {
     175            continue;
     176            }
     177            strings[i] = XMLTools.getNodeText(e);
     178        }
     179
     180        }
    147181    }
    148182    catch(Exception error) {
     
    150184        DebugStream.printStackTrace(error);
    151185    }
     186
    152187    }
    153188
     
    189224    return name;
    190225    }
     226
     227    public String getIsPublic() {
     228    return is_public;
     229    }
    191230   
    192231    /** Retrieve the short name for this collection which, given this current file is in <col_name>/etc/collect.cfg, is the name of this file's parent file's parent.
Note: See TracChangeset for help on using the changeset viewer.