Changeset 5112


Ignore:
Timestamp:
2003-08-07T16:55:18+12:00 (21 years ago)
Author:
kjdon
Message:

added in functionality to use a different type of collection. the file etc/collectionInit.xml so far has <collectionInit class=MyCollection/> - use this to specify a different collection class if needed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/MessageRouter.java

    r4859 r5112  
    194194    public Element process(Element message) {
    195195
    196     ///ystem.out.println("MR received request");
    197     ///ystem.out.println(this.converter.getString(message));
     196    System.out.println("MR received request");
     197    System.out.println(this.converter.getString(message));
    198198               
    199199    // check that its a correct message tag
     
    247247    } // for each request
    248248   
    249     ///ystem.out.println("MR returned response");
    250     ///ystem.out.println(this.converter.getString(mainResult));
     249    System.out.println("MR returned response");
     250    System.out.println(this.converter.getString(mainResult));
    251251
    252252    return mainResult;
     
    674674
    675675    System.out.println("MessageRouter:Activating collection: "+col_name+".");
    676              
    677     Collection c = new Collection();
     676       
     677    // now we need to look for the etc/collectionInit.xml file, and see what sort of Collection to load
     678    Collection c = null;
     679    File init_file = new File(GSFile.collectionInitFile(this.site_home, col_name));
     680    if (init_file.exists()) {
     681        Element init_elem = this.converter.getDOM(init_file).getDocumentElement();
     682        String coll_class_name = init_elem.getAttribute("class");
     683        if (coll_class_name.equals("")) {
     684        c = new Collection();
     685        } else {
     686        try {
     687            c = (Collection)Class.forName("org.greenstone.gsdl3.collection."+coll_class_name).newInstance();
     688        } catch (Exception e) {
     689            System.out.println("couldn't create a new collection, type "+coll_class_name+", defaulting to class Collection");
     690            c = new Collection();
     691        }
     692        }
     693    } else {
     694        // use the defualt collection
     695        c = new Collection();
     696    }
    678697    c.setCollectionName(col_name);
    679698    c.setSiteHome(this.site_home);
Note: See TracChangeset for help on using the changeset viewer.