Ignore:
Timestamp:
2012-10-04T18:33:06+13:00 (12 years ago)
Author:
ak19
Message:

GSearch works again with the latest version of Fedora and FedoraGSearch (3.6.1 and 2.5 respectively).

Location:
other-projects/gs3-webservices-java-client/trunk
Files:
4 edited

Legend:

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

    r26270 r26286  
    9595        protected static final String SUPPORTED_VERSION = "3.3"; //"2.2.1";
    9696                                     // 3.3 works with genericSearch version 2.2
     97                                     // 3.6.1 works with genericSearch version 2.5
    9798
    9899    /* Some fixed strings of known literals */
     
    545546                "default", isUserSpecifiedPortAddressSuffix);
    546547        }
    547        
    548548    }
    549549   
  • other-projects/gs3-webservices-java-client/trunk/src/GS3Fedora/org/greenstone/fedora/services/FedoraGS3Connection.java

    r26270 r26286  
    5050import java.io.IOException;
    5151import javax.net.ssl.SSLHandshakeException;
     52import java.net.Authenticator;
    5253import java.net.ConnectException;
    5354import java.net.MalformedURLException;
     55import java.net.PasswordAuthentication;
    5456import java.rmi.RemoteException;
    5557import javax.xml.parsers.ParserConfigurationException;
     
    7375   
    7476    /** Default name of Fedora index */
    75     private static final String DEFAULT_FEDORA_INDEX = "BasicIndex";
    76    
    77     /** Complete list of services that are supported our FedoraGS3 would 
    78      * support if everything goes well. If a connection to FedoraGSearch
     77    private static final String DEFAULT_FEDORA_INDEX = "FgsIndex"; //"BasicIndex" for older versions of GSearch
     78   
     79    /** Complete list of services that our FedoraGS3 would support
     80     * if everything goes well. If a connection to FedoraGSearch
    7981     * cannot be established, the query services will no longer be
    8082     * available. The actual services supported are given by member
     
    182184     * - name of the index into which the GS3 documents have been indexed
    183185     * and which FedoraGenericSearch should use to perform searches. If none is
    184      * given in the properties file, then the index name defaults to "FedoraIndex".
     186     * given in the properties file, then the index name defaults to "FgsIndex"
     187     * (no longer BasicIndex  or FedoraIndex).
    185188     * @param properties is the Properties Map loaded from a properties file
    186189     * (if there was any) which specifies such things as host and port of the
     
    220223    */
    221224    protected void init(String protocol, String host, String port,
    222             String fedoraServerUsername, String fedoraServerPassword)
     225            final String fedoraServerUsername, final String fedoraServerPassword)
    223226        throws ParserConfigurationException, MalformedURLException,
    224227            AuthenticationFailedException, RemoteException, Exception
     
    228231        this.gSearchWSDLURL = this.baseURL + this.gSearchWSDLSuffix;
    229232        this.gSearchIndexName = DEFAULT_FEDORA_INDEX;
     233       
     234        // Now need to set username and password for accessing WSDL (after GSearch 2.2)
     235        // http://stackoverflow.com/questions/3037221/401-error-when-consuming-a-web-service-with-http-basic-authentication-using-cxf
     236       
     237        // The java.net.Authenticator can be used to send user credentials when needed.
     238        Authenticator.setDefault(new Authenticator() {
     239            @Override
     240            protected PasswordAuthentication getPasswordAuthentication() {
     241            return new PasswordAuthentication(
     242                              fedoraServerUsername,
     243                              fedoraServerPassword.toCharArray());
     244            }
     245        });
     246       
    230247        initSearchFunctionality();
    231248    }   
     
    246263        } catch(Exception e){
    247264            LOG.error("Cannot connect to FedoraGSearch's web services at "
    248                 + gSearchWSDLURL + "\nQuery services will not be available.");
     265                  + gSearchWSDLURL + "\nQuery services will not be available.", e);
     266            // Exception, e, as parameter prints the stacktrace of the exception to the log
     267
    249268            // If an exception occurs, something has gone wrong when
    250269            // trying to connect to FedoraGSearch's web services. This
  • other-projects/gs3-webservices-java-client/trunk/src/GS3Fedora/org/greenstone/fedora/services/GSearchConnection.java

    r21573 r26286  
    9292    /** A DocumentBuilder object used to construct and parse XML */
    9393    protected final DocumentBuilder builder;
    94    
    9594
    9695   
     
    138137        builder = factory.newDocumentBuilder(); // to create XML docs
    139138    }
    140        
    141    
     139
    142140    /**
    143141     * Method to invoke gfindObjects operation of Fedora Generic Search
     
    210208        // for debugging
    211209        //javax.swing.JOptionPane.showMessageDialog(null, "GSearchConnection.gFindObjects:" + valueFound);
    212            
     210       
    213211        return valueFound;
    214212    }
     
    292290        // and put quotes around phrases, then combine all the terms
    293291        // together again with spaces to separate them.
    294         allfields = formatSearchTermsInField(allfields, ALL_FIELDS);
     292        allfields = formatSearchTermsInField(allfields, ALL_FIELDS); // search foxml.all.text
    295293            // ALL_FIELDS has no field name
    296294        titles = formatSearchTermsInField(titles, DC_TITLE_FIELD);
Note: See TracChangeset for help on using the changeset viewer.