Changeset 3471 for trunk/gsdl3


Ignore:
Timestamp:
2002-10-16T09:38:16+13:00 (22 years ago)
Author:
kjdon
Message:

service modules now belong to a serviceCluster or colleciton - collection_name has been changed to the more general cluster_name. service module cant configure itself from a file - we no longer know where the appropriate file is. so must be configured by passing the xml node to the configure method

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3/service
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GSDL2ClassifierService.java

    r3453 r3471  
    5353    // the response element
    5454    Element result = doc_.createElement("response");
    55     String from = GSPath.appendLink(collection_name_, "ClassifierBrowse");
     55    String from = GSPath.appendLink(cluster_name_, "ClassifierBrowse");
    5656    result.setAttribute("from", from);
    5757    result.setAttribute("type", "query");
     
    183183    }
    184184   
    185     System.out.println("classifier result:");
    186     System.out.println(converter_.getString(result));
    187185    return result;
    188186   
     
    215213    service_info_map_.put("ClassifierBrowse", e);
    216214   
    217     if (gdbm_src_.openDatabase(GSFile.GDBMDatabaseFile(site_home_, collection_name_), GDBMWrapper.READER)) {
     215    if (gdbm_src_.openDatabase(GSFile.GDBMDatabaseFile(site_home_, cluster_name_), GDBMWrapper.READER)) {
    218216        return true;
    219217    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/MGPPGDBMService.java

    r3442 r3471  
    189189    service_info_map_.put("MetadataRetrieve", e);
    190190
    191     if (gdbm_src_.openDatabase(GSFile.GDBMDatabaseFile(site_home_, collection_name_), GDBMWrapper.READER)) {
     191    if (gdbm_src_.openDatabase(GSFile.GDBMDatabaseFile(site_home_, cluster_name_), GDBMWrapper.READER)) {
    192192        return true;
    193193    }
     
    223223
    224224    Element result = doc_.createElement("response");
    225     String from = GSPath.appendLink(collection_name_, "TextQuery");
     225    String from = GSPath.appendLink(cluster_name_, "TextQuery");
    226226    result.setAttribute("from", from);
    227227    result.setAttribute("type", "query");
     
    261261    // now set up the mgpp stuff
    262262    String basedir = GSFile.collectionBaseDir(site_home_,
    263                           collection_name_);
    264     String indexdir = GSFile.collectionIndexPath(collection_name_, index);
     263                          cluster_name_);
     264    String indexdir = GSFile.collectionIndexPath(cluster_name_, index);
    265265
    266266    mgpp_src_.loadIndexData(basedir, indexdir);
     
    294294    protected Element processFieldQuery(Element request) {
    295295    Element result = doc_.createElement("response");
    296     String from = GSPath.appendLink(collection_name_, "FieldQuery");
     296    String from = GSPath.appendLink(cluster_name_, "FieldQuery");
    297297    result.setAttribute("from", from);
    298298    result.setAttribute("type", "query");
     
    311311    // where the mgpp text files are
    312312    String basedir = GSFile.collectionBaseDir(site_home_,
    313                           collection_name_);
    314     String textdir = GSFile.collectionTextPath(collection_name_);
     313                          cluster_name_);
     314    String textdir = GSFile.collectionTextPath(cluster_name_);
    315315
    316316    // an empty result
    317317    Element result = doc_.createElement("response");
    318     String from = GSPath.appendLink(collection_name_, "ResourceRetrieve");
     318    String from = GSPath.appendLink(cluster_name_, "ResourceRetrieve");
    319319    result.setAttribute("from", from);
    320320    result.setAttribute("type", "query");
     
    409409    protected Element processMetadataRetrieve(Element request) {
    410410    Element result = doc_.createElement("response");
    411     String from = GSPath.appendLink(collection_name_, "MetadataRetrieve");
     411    String from = GSPath.appendLink(cluster_name_, "MetadataRetrieve");
    412412    result.setAttribute("from", from);
    413413    result.setAttribute("type", "query");
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/PhindService.java

    r3443 r3471  
    7777    String app_info = "<applet CODEBASE='lib/java' CODE='org.greenstone.applet.phind.Phind.class' ARCHIVE='phind.jar, xercesImpl.jar, gsdl3.jar, jaxp.jar, xml-apis.jar' WIDTH='500' HEIGHT='400'><PARAM NAME='library' VALUE=''/> <PARAM NAME='phindcgi' VALUE='?a=a&amp;sa=r&amp;sn=Phind'/>";
    7878    app_info +="<PARAM NAME='collection'   VALUE='";
    79     app_info += collection_name_;
     79    app_info += cluster_name_;
    8080    app_info += "'/> <PARAM NAME='classifier' VALUE='1'/>  <PARAM NAME='orientation'  VALUE='vertical'/> <PARAM NAME='depth' VALUE='2'/> <PARAM NAME='resultorder' VALUE='L,l,E,e,D,d'/> <PARAM NAME='backdrop' VALUE='interfaces/default/images/phindbg1.jpg'/><PARAM NAME='fontsize' VALUE='10'/> <PARAM NAME='blocksize'    VALUE='10'/>The Phind java applet.</applet>";
    8181   
     
    115115    String phind_index = (String)params.get("pc");
    116116    // the location of the mgpp database files
    117     basepath_ = GSFile.phindBaseDir(site_home_, collection_name_, phind_index);
     117    basepath_ = GSFile.phindBaseDir(site_home_, cluster_name_, phind_index);
    118118
    119119    // the result element
    120120    Element result = doc_.createElement("response");
    121     String from = GSPath.appendLink(collection_name_, "PhindApplet");
     121    String from = GSPath.appendLink(cluster_name_, "PhindApplet");
    122122    result.setAttribute("from", from);
    123123    result.setAttribute("type", "query");
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/ServiceModule.java

    r3441 r3471  
    4040 * ServiceModule - abstract base class
    4141 *
    42  * A ServiceModule provides Services to a collection/system.
     42 * A ServiceModule provides Services to a collection/cluster/site.
    4343 * It may provide more than one Service. for eg
    4444 * MGGDBMServiceModule may support "DocRetrieve", "TextQuery", "MetadataRetrieve" services
     
    5050    implements ModuleInterface
    5151{
     52
     53
    5254    /** the absolute address of the site home */
    5355    protected String site_home_ =null;
    54     /** the name of the collection directory that this service belongs to -
     56    /** the name of the cluster that this service belongs to -
    5557    if any */
    56     protected String collection_name_ = null;
     58    protected String cluster_name_ = null;
    5759
    5860    /** some services can talk back to the message router */
     
    7274    protected HashMap service_info_map_ = null;
    7375
     76    /** sets the cluster name */
     77    public void setClusterName(String cluster_name) {
     78    cluster_name_ = cluster_name;
     79    }
    7480    /** sets the collect name */
    7581    public void setCollectionName(String coll_name) {
    76     collection_name_ = coll_name;
     82    setClusterName(coll_name);
    7783    }
    7884   
     
    95101    }
    96102   
    97     /**
    98      * Configure the object. - default method for service modules
    99      *
    100      * reads either collection (if a collection name has been set), or system
    101      * configuration file, and configures itself
    102      * this calls configure(Element) with the XML element node from the config
    103      * file.
    104      * configure(Element) should be used if the config file has already been
    105      * parsed.  This method will work with any subclass.
    106      *
    107      * @return true if configure successful, false otherwise.
    108      */
    109     public boolean configure(){
    110    
    111     if (site_home_==null) {
    112         System.err.println("setSiteHome() must be called before configure()");
    113         return false;
    114     }
    115 
    116     File config_file=null;
    117     if (collection_name_ !=null) {
    118        
    119         config_file = new File(GSFile.collectionBuildConfigFile(site_home_, collection_name_));
    120     }
    121     else {
    122         config_file = new File(GSFile.siteConfigFile(site_home_));
    123     }
    124 
    125     if (config_file.exists() ) {
    126        
    127         Document doc = converter_.getDOM(config_file);
    128        
    129         try {
    130         // get the service list and look for own service
    131         // Note: XPathAPI is slow apparently
    132         String xpath = "//ServiceModule[@name='"+this.getClass().getName()+"']";
    133         System.out.println("xpath="+xpath);
    134         Node n = XPathAPI.selectSingleNode(doc, xpath);
    135         if (n !=null) {
    136             return this.configure((Element)n);
    137         }
    138         } catch (Exception e) {
    139         System.err.println("ServiceModule configure exception: "+e.getMessage());
    140         return false;
    141         }
    142     }
    143     System.err.println("ServiceModule error: unable to configure ServiceModule " + this.getClass().getName() );
    144     return false;
    145    
    146    
    147     }
    148 
    149     /** The configure method that does the real work
     103
     104    /** configure the service module
    150105     *
    151106     * @param info the XML node <serviceModule name="XXX"/> with name equal
Note: See TracChangeset for help on using the changeset viewer.