com.endeca.portal.mdex
Class MDEXUtil

java.lang.Object
  extended by com.endeca.portal.mdex.MDEXUtil

public class MDEXUtil
extends java.lang.Object

Helper class containing useful methods to execute on an ENEQuery

Author:
dan

Constructor Summary
MDEXUtil()
           
 
Method Summary
static com.endeca.navigation.ENEQuery addQueryTracking(com.endeca.navigation.ENEQuery query, RequestTracker requestTracker)
          instruments a MDEX 6 query by setting an ENEQueryInfo object on the query
static boolean checkAPICompatibility(MDEXState state)
           
static com.endeca.navigation.ENEQuery copyQuery(com.endeca.navigation.ENEQuery previousQuery)
          This method takes an ENEQuery object and makes a copy of it.
static com.endeca.navigation.ENEQueryResults execute(MDEXState mdexState, com.endeca.navigation.ENEQuery query, RequestTracker requestTracker)
           
static com.endeca.navigation.ENEQuery fromJSONObject(org.json.JSONObject j)
          Creates a new ENEQuery object based on the contents of this JSON object.
static com.endeca.navigation.ENEQuery fromJSONString(java.lang.String s)
          Creates a new ENEQuery object based on the contents of this JSON packet.
static int hashCode(com.endeca.navigation.ENEQuery query)
          Returns a hashcode of the query, used to tersely identify the contents of the query.
static int hashCode(java.lang.String jsonString)
          Currently this is just a wrapper of String.hashCode() - this method exists solely so we can override the hashcode implementation if we want to, and to allow calling ENEQueryUtils.hashCode() on a pre-existing jsonString.
static void main(java.lang.String[] args)
           
static java.net.URLConnection ping(java.lang.String server, java.lang.String port, SSLConfig sslConfig)
           
static java.net.URLConnection stats(java.lang.String server, java.lang.String port, SSLConfig sslConfig)
           
static com.endeca.navigation.ENEQuery tidyNavQuery(com.endeca.navigation.ENEQuery query)
          Cleans up and sanitizes a nav query; right now all it does is rewrite the query to include the root if there are otherwise no nav descriptors
static org.json.JSONObject toJSONObject(com.endeca.navigation.ENEQuery query)
          Returns a JSONObject containing all pertinent query info
static java.lang.String toJSONString(com.endeca.navigation.ENEQuery query)
          Returns a JSON string containing all pertinent query info
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MDEXUtil

public MDEXUtil()
Method Detail

hashCode

public static int hashCode(com.endeca.navigation.ENEQuery query)
                    throws org.json.JSONException
Returns a hashcode of the query, used to tersely identify the contents of the query. The hashcode will be the same for two separate instances of a query as long as those queries have the same parameters.

Parameters:
query - the query to hash
Returns:
the hashcode
Throws:
org.json.JSONException

hashCode

public static int hashCode(java.lang.String jsonString)
Currently this is just a wrapper of String.hashCode() - this method exists solely so we can override the hashcode implementation if we want to, and to allow calling ENEQueryUtils.hashCode() on a pre-existing jsonString. This is useful in cases where a calling class wants to calculate the jsonString for a query and also calculate the hashcode, without having to re-calc the jsonString just to get the hashcode

Parameters:
jsonString - the (json) string to hash
Returns:
the hashcode

toJSONString

public static java.lang.String toJSONString(com.endeca.navigation.ENEQuery query)
                                     throws org.json.JSONException
Returns a JSON string containing all pertinent query info

Parameters:
query - the query to turn into a JSON string
Returns:
the JSON string representing the query
Throws:
org.json.JSONException

toJSONObject

public static org.json.JSONObject toJSONObject(com.endeca.navigation.ENEQuery query)
                                        throws org.json.JSONException
Returns a JSONObject containing all pertinent query info

Parameters:
query - the query to turn into a JSON object
Returns:
the JSON object representing the query
Throws:
org.json.JSONException

fromJSONString

public static com.endeca.navigation.ENEQuery fromJSONString(java.lang.String s)
Creates a new ENEQuery object based on the contents of this JSON packet.

Parameters:
s - the JSON packet to parse
Returns:
the ENEQuery

fromJSONObject

public static com.endeca.navigation.ENEQuery fromJSONObject(org.json.JSONObject j)
Creates a new ENEQuery object based on the contents of this JSON object. Returns null if it cannot parse the JSON Object.

Parameters:
j - the JSON object to parse
Returns:
the ENEQuery

tidyNavQuery

public static com.endeca.navigation.ENEQuery tidyNavQuery(com.endeca.navigation.ENEQuery query)
Cleans up and sanitizes a nav query; right now all it does is rewrite the query to include the root if there are otherwise no nav descriptors

Parameters:
query - the query to tidy up
Returns:
the cleaned query

copyQuery

public static com.endeca.navigation.ENEQuery copyQuery(com.endeca.navigation.ENEQuery previousQuery)
This method takes an ENEQuery object and makes a copy of it. It does this indirectly, by copying all properties of the query one by one to the new query object, since the ENEQuery presentationAPI object does not expose a copy method. TODO: review this code and make sure it is correct

Parameters:
previousQuery -
Returns:
ENEQuery newQuery

main

public static void main(java.lang.String[] args)
                 throws org.json.JSONException
Throws:
org.json.JSONException

execute

public static com.endeca.navigation.ENEQueryResults execute(MDEXState mdexState,
                                                            com.endeca.navigation.ENEQuery query,
                                                            RequestTracker requestTracker)
                                                     throws com.endeca.navigation.ENEQueryException
Throws:
com.endeca.navigation.ENEQueryException

addQueryTracking

public static com.endeca.navigation.ENEQuery addQueryTracking(com.endeca.navigation.ENEQuery query,
                                                              RequestTracker requestTracker)
instruments a MDEX 6 query by setting an ENEQueryInfo object on the query

Parameters:
query - the ENEQuery
requestTracker - the tracker containing the session, request, etc. tokens
Returns:
the modified ENEQuery

ping

public static java.net.URLConnection ping(java.lang.String server,
                                          java.lang.String port,
                                          SSLConfig sslConfig)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

stats

public static java.net.URLConnection stats(java.lang.String server,
                                           java.lang.String port,
                                           SSLConfig sslConfig)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

checkAPICompatibility

public static boolean checkAPICompatibility(MDEXState state)