Changeset 15437

Show
Ignore:
Timestamp:
14.05.2008 13:27:08 (12 years ago)
Author:
ak19
Message:

Introduced GSearchConnection member indexName set in its constructor by FedoraGS3Connection

Location:
other-projects/trunk/gs3-webservices-democlient/src/GS3Fedora/org/greenstone/fedora/services
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • other-projects/trunk/gs3-webservices-democlient/src/GS3Fedora/org/greenstone/fedora/services/FedoraGS3Connection.java

    r15331 r15437  
    2929import org.greenstone.fedora.services.FedoraGS3Exception.FedoraGS3RunException; 
    3030import org.greenstone.fedora.services.FedoraGS3Exception.NotAFedoraServerException; 
    31 import org.greenstone.fedora.services.FedoraToGS3Interface.Constants; 
    3231import org.greenstone.gsdl3.util.GSXML; 
    3332import org.w3c.dom.Document; 
     
    111110    protected String gSearchWSDLURL; 
    112111     
     112    /** The name of the index that FedoraGSearch will index the GS3 
     113     * documents into. If no name is specified in the properties file, 
     114     * this will default to FedoraIndex. */ 
     115    protected String gSearchIndexName; 
     116     
    113117    /** 5 argument constructor is the same as that of superclass FedoraConnection: 
    114118     * @param protocol can be either http or https 
     
    175179     * properties loaded from a propertiesFile. This method is overridden   
    176180     * here in order to instantiate the gSearchConnection based on the   
    177      * gSearchWSDLURL. (If one was not provided in the properties file,   
     181     * - gSearchWSDLURL (If one was not provided in the properties file,   
    178182     * gSearchWSDLURL defaults to something of the form 
    179183     * "http://localhost:8080/fedoragsearch/services/FgsOperations?wsdl" 
    180184     * where http://localhost:8080/fedora is the baseURL of fedora and 
    181185     * "gsearch/services/FgsOperations?wsdl" is the default gSearchWSDLSuffix.) 
     186     * - name of the index into which the GS3 documents have been indexed  
     187     * and which FedoraGenericSearch should use to perform searches. If none is 
     188     * given in the properties file, then the index name defaults "FedoraIndex". 
    182189     * @param properties is the Properties Map loaded from a properties file 
    183190     * (if there was any) which specifies such things as host and port of the 
    184191     * FedoraServer, but can also specify the property "gsearch.wsdlURL". 
    185192     * At the end of this method, properties' "gsearch.wsdlURL" will be set 
    186      * to whatever the final value of this.gSearchWSDLURL is. 
     193     * to whatever the final value of this.gSearchWSDLURL is, and  
     194     * "gsearch.indexName" will be set to to whatever the final value of 
     195     * this.gSearchIndexName is.  
    187196    */ 
    188197    protected void setInitialisationProperties(Properties properties) 
     
    200209        // so that it will be written out to the properties file again 
    201210        properties.setProperty("gsearch.wsdlURL", this.gSearchWSDLURL); 
     211         
     212        // Similarly for the name of the index FedoraGenericSearch should use 
     213        // when performing searches for GS3 docs stored in Fedora's repository. 
     214        this.gSearchIndexName = properties.getProperty( 
     215                "gsearch.indexName", "FedoraIndex"); // default to FedoraIndex 
     216        properties.setProperty("gsearch.indexName", this.gSearchIndexName); 
    202217        // Create a connection to FedoraGSearch's web services: 
    203218        initSearchFunctionality(); 
     
    212227    { 
    213228        try { 
    214             this.fedoraGSearch = new GSearchConnection(gSearchWSDLURL); 
     229            this.fedoraGSearch = null; 
     230            this.fedoraGSearch = new GSearchConnection( 
     231                    gSearchWSDLURL, gSearchIndexName); 
    215232            this.serviceNames = SERVICES; 
    216233        } catch(Exception e){ 
     
    251268     * @param url is the new url of the GSearch web services WSDL file */ 
    252269    public void setGSearchWSDLURL(String url) {  
    253         gSearchWSDLURL = url; 
     270        this.gSearchWSDLURL = url; 
     271        initSearchFunctionality(); 
     272    } 
     273     
     274    /** @return the gSearchIndexName, the name of the index Fedora Generic 
     275     * Search will search in (where GS3 docs have been indexed into). */ 
     276    public String getGSearchIndexName() { return gSearchIndexName; } 
     277     
     278    /** Sets the member variable gSearchIndexName that specifies the name 
     279     * of the index containing indexed GS3 documents. Then it attempts  
     280     * to instantiate a connection to the Fedora GSearch web services using 
     281     * this changed value for indexName.  
     282     * @param indexName is the new name of the index containing indexed GS3  
     283     * docs that GSearch should search in. */ 
     284    public void setGSearchIndexName(String indexName) {  
     285        this.gSearchIndexName = indexName; 
    254286        initSearchFunctionality(); 
    255287    } 
  • other-projects/trunk/gs3-webservices-democlient/src/GS3Fedora/org/greenstone/fedora/services/FedoraToGS3Interface.java

    r15222 r15437  
    2323import java.util.Map; 
    2424 
    25  
    2625/** 
    27  * The following methods return the same data as FedoraGS3DL, but formatted as  
    28  * Greenstone Response-Message XML. This way our java-client can parse    
    29  * the returned XML in the same way and store them in the same datastructures.  
     26 * Most of the following methods return the same data as FedoraGS3DL, but  
     27 * formatted as Greenstone Response-Message XML. This way our java-client can  
     28 * parse the returned XML in the same way and store them in the same data 
     29 * structures.  
    3030 * @author ak19 
    3131*/ 
     
    5454        public static final String COMMA = ","; 
    5555    } 
     56     
     57        /* FEDORA GENERIC SEARCH RELATED */ 
     58    /** @return the gSearchWSDLURL, the url of the WSDL for the 
     59     * FedoraGSearch web services */ 
     60    public String getGSearchWSDLURL(); 
     61     
     62    /** Sets the member variable gSearchWSDLURL that specify the location of 
     63     * the WSDL file of FedoraGSearch's web services. Then it attempts  
     64     * to instantiate a connection to those web services.  
     65     * @param url is the new url of the GSearch web services WSDL file */ 
     66    public void setGSearchWSDLURL(String url); 
     67     
     68    /** @return the gSearchIndexName, the name of the index Fedora Generic 
     69     * Search will search in (where GS3 docs have been indexed into). */ 
     70    public String getGSearchIndexName(); 
     71     
     72    /** Sets the member variable gSearchIndexName that specifies the name 
     73     * of the index containing indexed GS3 documents. Then it attempts  
     74     * to instantiate a connection to the Fedora GSearch web services using 
     75     * this changed value for indexName.  
     76     * @param indexName is the new name of the index containing indexed GS3  
     77     * docs that GSearch should search in. */ 
     78    public void setGSearchIndexName(String indexName); 
    5679     
    5780    /* DESCRIBE SERVICES */ 
  • other-projects/trunk/gs3-webservices-democlient/src/GS3Fedora/org/greenstone/fedora/services/GSearchConnection.java

    r15222 r15437  
    6060    protected static String NAMESPACE_URI = "http://server.fedoragsearch.defxws.dk"; 
    6161    protected static String SERVICE_NAME = "OperationsService";  
    62     protected static final String INDEX_NAME = "FedoraIndex";  
    6362 
    6463    /** The names of the methods we use of Fedora Generic Search's web services 
     
    7877    /** separator used internally to separate values of a search field */  
    7978    protected static final String SPACE = " "; 
     79 
     80        /** The name of the Index wherein FedoraGSearch has indexed all the GS3 docs. 
     81     * This final member is public here so that others may read the indexName   
     82     * that this GSearchConnection works with. */ 
     83    public final String indexName;  
    8084     
    8185    /** The Service object used to connect to the FedoraGSearch web services */ 
     
    8993    protected final DocumentBuilder builder; 
    9094     
     95 
     96     
    9197    /** Constructor that takes a String representing the url of the WSDL 
    9298     * file for FedoraGSearch's web services, and tries to establish a  
    9399     * connection to those web services.  
    94100     * @param wsdlFileLocation is a String representing the url of the WSDL file 
     101     * @param indexName is the name of the index that Fedora Generic Search 
     102     * should work with (the index wherein the indexed GS3 documents have been 
     103     * placed).  
    95104    */ 
    96     public GSearchConnection(String wsdlFileLocation)  
     105    public GSearchConnection(String wsdlFileLocation, String indexName)  
    97106        throws MalformedURLException, ServiceException,  
    98107            ParserConfigurationException 
    99108    {  
     109        this.indexName = indexName; 
     110         
    100111        URL wsdlURL = new URL(wsdlFileLocation); 
    101112        service = new Service(wsdlURL, new QName(NAMESPACE_URI, SERVICE_NAME)); 
     
    218229        return gFindObjects(fullSearchTerm, sort,  
    219230            hitPageStart, hitPageSize, snippetsMax,  
    220             fieldMaxLength, INDEX_NAME, resultPageXslt); 
     231            fieldMaxLength, indexName, resultPageXslt); 
    221232    } 
    222233     
     
    364375        return gFindObjects(fieldedSearchTerms, sort,  
    365376                hitPageStart, hitPageSize, snippetsMax,  
    366                 fieldMaxLength, INDEX_NAME, resultPageXslt); 
     377                fieldMaxLength, indexName, resultPageXslt); 
    367378    } 
    368379     
     
    460471        try {  
    461472            GSearchConnection searcher = new GSearchConnection( 
    462                 "http://localhost:8080/fedoragsearch/services/FgsOperations?wsdl"); 
     473                "http://localhost:8080/fedoragsearch/services/FgsOperations?wsdl", "FedoraIndex"); 
    463474             
    464475