com.endeca.navigation
Class HttpENEConnection

java.lang.Object
  extended by com.endeca.navigation.HttpENEConnection
All Implemented Interfaces:
ENEConnection, Serializable
Direct Known Subclasses:
AuthHttpENEConnection

public class HttpENEConnection
extends Object
implements ENEConnection, Serializable

Provides a connection to an Endeca MDEX Engine over HTTP. Also provides a mechanism for issuing queries to the MDEX Engine. The HttpENEConnection is currently the only implementation of the ENEConnection interface.

This connection is a repository for hostname and port configuration parameters for HTTP connections to an MDEX Engine. The connection does not open a persistant connection to the MDEX Engine. The instantiation of this connection does not initiate an HTTP socket connection. Instead each issuance of the query method opens a HTTP socket connection(s), makes the requests, and closes the connection(s).

An example usage of the HttpENEConnection in JSP:

 <%
        ENEConnection nec = new HttpENEConnection("engine.endeca.com",
                                                "5001");
        ENEQuery usq = new UrlENEQuery(request.getQueryString());
        ENEQueryResults qr = nec.query(usq);
 %>
 
Another example usage of the HttpENEConnection in JSP using the useBean syntax:
 <jsp:useBean id="nec" scope="request"
             class="com.endeca.navigation.HttpENEConnection"
             type="com.endeca.navigation.ENEConnection">
        <jsp:setProperty name="nec" property="hostname"
                         value="moose.dev.endeca.com"/>
        <jsp:setProperty name="nec" property="port"
                         value="5001"/>
 </jsp:useBean>
 <%
        ENEQuery usq = new UrlENEQuery(request.getQueryString());
        ENEQueryResults qr = nec.query(neq);
 %>
 

See Also:
Serialized Form

Nested Class Summary
static class HttpENEConnection.HttpHeader
           
 
Constructor Summary
HttpENEConnection()
          Default empty constructor.
HttpENEConnection(String hostname, int port)
          Constructor for connection to an Endeca MDEX Engine over HTTP.
HttpENEConnection(String hostname, String port)
          Constructor for connection to an Endeca MDEX Engine over HTTP.
 
Method Summary
 void addHttpHeader(String name, String value)
          Add an HTTP header to the query request.
 void enableSSL()
          Enabling SSL specifies that a secure connection must be made between the API and the dgraph.
 void enableSSL(KeyStore clientKs, String clientPassphrase, KeyStore caKs)
          Enabling SSL specifies that a secure connection must be made between the API and the dgraph.
 String getHostname()
          Gets the specified hostname of the MDEX Engine.
 int getMaxUrl()
          Gets the value of maxUrl.
 int getPort()
          Gets the specified port of the MDEX Engine.
 ENEQueryResults query(ENEQuery neq)
          Issues a query against the MDEX Engine.
 void setHostname(String hostname)
          Sets the hostname of the MDEX Engine.
 void setHostnameVerifier(HostnameVerifier newHv)
          Sets the hostname verifier that will be used to check the server certificate's CN for an SSL connection.
 void setMaxUrl(int maxUrl)
          Sets the value of maxUrl.
 void setPort(int port)
          Sets the port of the MDEX Engine.
 void setPort(String port)
          Sets the port of the MDEX Engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpENEConnection

public HttpENEConnection()
Default empty constructor. Hostname and port need to be set before query is called, else a ENEQueryException will be thrown.


HttpENEConnection

public HttpENEConnection(String hostname,
                         String port)
Constructor for connection to an Endeca MDEX Engine over HTTP.

Parameters:
hostname - hostname or IP address of the MDEX Engine. Example: 127.0.0.1 or engine.endeca.com.
port - port of the MDEX Engine. Example: 5001.

HttpENEConnection

public HttpENEConnection(String hostname,
                         int port)
Constructor for connection to an Endeca MDEX Engine over HTTP.

Parameters:
hostname - hostname or IP address of the MDEX Engine. Example: 127.0.0.1 or engine.endeca.com.
port - port of the MDEX Engine. Example: 5001.
Method Detail

query

public ENEQueryResults query(ENEQuery neq)
                      throws ENEQueryException
Issues a query against the MDEX Engine. The query method returns a ENEQueryResults object which contains the resultant objects returned by the MDEX Engine in response to the query neq.

Specified by:
query in interface ENEConnection
Parameters:
neq - the query object containing the navigation, record etc. type requests to the MDEX Engine
Throws:
ENEQueryException - if there is a problem making the query. Possible subclasses of ENEQueryException that could be thrown are ENEConnectionException, EmptyENEQueryException, PartialENEQueryException, ENEException, VersionMismatchException, and so on.

setHostnameVerifier

public void setHostnameVerifier(HostnameVerifier newHv)
Sets the hostname verifier that will be used to check the server certificate's CN for an SSL connection.

Parameters:
newHv - verifier object to be used

setHostname

public void setHostname(String hostname)
Sets the hostname of the MDEX Engine.

Parameters:
hostname - hostname of the MDEX Engine.

setPort

public void setPort(String port)
Sets the port of the MDEX Engine.

Parameters:
port - port of the MDEX Engine.

setPort

public void setPort(int port)
Sets the port of the MDEX Engine.

Parameters:
port - port of the MDEX Engine.

enableSSL

public void enableSSL()
Enabling SSL specifies that a secure connection must be made between the API and the dgraph. If enableSSL is called without any arguments, then the JVM's default KeyStore will be used to supply any certificates required to establish the connection.


enableSSL

public void enableSSL(KeyStore clientKs,
                      String clientPassphrase,
                      KeyStore caKs)
               throws IllegalArgumentException
Enabling SSL specifies that a secure connection must be made between the API and the dgraph. Keys and certificates can for the front-end's connection to the dgraph can be explicitly with this method. If a null clientKs or caKs is passed into this method, the Java VM's default keystore and truststore will be used, as appropriate.

Parameters:
clientKs - KeyStore containing the front-end's certificate.
clientPassphrase - Passphrase for recovering keys from the KeyStore holding the client's certificate.
caKs - KeyStore containing additional CA certs that are trusted to sign server certificates.
Throws:
IllegalArgumentException

setMaxUrl

public void setMaxUrl(int maxUrl)
Sets the value of maxUrl.

Parameters:
maxUrl - The maximum URL length for which use of an HTTP GET operation is allowed. If a longer URL is needed, an HTTP POST operation will be used instead. If set to 0, POST will always be used. If set to -1, either GET or POST may be used at the discretion of the API. The default is -1.

getMaxUrl

public int getMaxUrl()
Gets the value of maxUrl.

Returns:
The maximum URL length for which use of an HTTP GET operation is allowed. Longer URLs will be sent with an HTTP POST operation.

addHttpHeader

public void addHttpHeader(String name,
                          String value)
Add an HTTP header to the query request. If a header is specified that has already been added, its value will be replaced with that from the most recent invocation.

Parameters:
name - The name of the HTTP header to add.
value - The value of the HTTP header to add.

getHostname

public String getHostname()
Gets the specified hostname of the MDEX Engine.

Returns:
the hostname of the MDEX Engine. null if hostname has not been set.

getPort

public int getPort()
Gets the specified port of the MDEX Engine.

Returns:
the port of the MDEX Engine. 0 if port has not been set.


2010 Endeca Technologies, Inc.
Endeca Confidential