com.indexdata.masterkey.pazpar2.client
Class AbstractPazpar2Client

java.lang.Object
  extended by com.indexdata.masterkey.pazpar2.client.AbstractPazpar2Client
All Implemented Interfaces:
Pazpar2Client
Direct Known Subclasses:
Pazpar2ClientGeneric, Pazpar2ClientTorus

public abstract class AbstractPazpar2Client
extends Object
implements Pazpar2Client

Author:
jakub, nielserik

Nested Class Summary
 class AbstractPazpar2Client.HttpResponse
           
 
Field Summary
protected  Pazpar2ClientConfiguration cfg
           
protected  Pazpar2Session pazpar2Session
           
protected  Pazpar2ServiceDefinition serviceDefinition
           
 String XML_CT
           
 
Constructor Summary
protected AbstractPazpar2Client(Pazpar2ClientConfiguration proxyCfg)
           
 
Method Summary
 Pazpar2HttpResponse executeCommand(ClientCommand command, OutputStream os)
          Forwards any Pazpar2 command and stores the results in the OutputStream
protected  AbstractPazpar2Client.HttpResponse executeSearch(OutputStream os)
          Performs a Pazpar2 search command process
 Document getHit(String recid)
          Returns a 'hit' by recid from the latest 'show' document.
 Document getResults(String command)
          Returns the results of the latest command of the kind processed by this proxy client
 ClientCommand getSearchCommand()
          Returns the latest search command executed through this proxy client
 int getSearchCount()
          Returns the number of searches so far on this pazpar2 client object
 String getSessionId()
          Returns current Pazpar2 session ID
 long getTimeStamp(String command, int searchNumber)
          Returns the number of times this command has be executed with a result since the current search was initiated.
protected  void pipeStream(InputStream is, OutputStream os)
          Pipes the last response input stream to a specified output stream.
 Document recordRequest(String recid)
          Makes a non-managed/transient pazpar2 record request.
 Document recordRequest(String recid, int offset)
          Makes a non-managed/transient pazpar2 record offset request.
protected  AbstractPazpar2Client.HttpResponse request(String queryString)
          Send pazpar2 protocol request.
protected abstract  boolean requiresForcedInit()
           
 Document searchRequest(String queryString)
          Makes a non-managed pazpar2 search request on a cloned pazpar2 client This is for 'embedded' pazpar2 requests by other plug-ins than Relay and independently of the main pazpar2 session.
protected  void sendInit(boolean clear)
          Initializes a Pazpar2 session and stores the Pazpar2 session ID with the proxy client
protected  void sendInit(Document service)
           
protected  AbstractPazpar2Client.HttpResponse sendRequest(String encodedParams)
          Sends a Pazpar2 request off to the configured Pazpar2 URL and with the provided parameters
protected  boolean sessionIsAlive()
          Sends a Pazpar2 ping command for the current Pazpar2 session ID (if any exists) Returns true if the Pazpar2 session ID exists and Pazpar2 says the session is alive
 void setSearchCommand(ClientCommand command)
          Stores the current search command on the proxy client
 Document showRequest()
          Makes a non-managed/transient pazpar2 show request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.indexdata.masterkey.pazpar2.client.Pazpar2Client
cloneMe, getSettings, init
 

Field Detail

cfg

protected Pazpar2ClientConfiguration cfg

serviceDefinition

protected Pazpar2ServiceDefinition serviceDefinition

pazpar2Session

protected Pazpar2Session pazpar2Session

XML_CT

public final String XML_CT
See Also:
Constant Field Values
Constructor Detail

AbstractPazpar2Client

protected AbstractPazpar2Client(Pazpar2ClientConfiguration proxyCfg)
                         throws ProxyErrorException
Throws:
ProxyErrorException
Method Detail

requiresForcedInit

protected abstract boolean requiresForcedInit()

getSessionId

public String getSessionId()
Returns current Pazpar2 session ID

Specified by:
getSessionId in interface Pazpar2Client
Returns:
pazpar2 session id

setSearchCommand

public void setSearchCommand(ClientCommand command)
Stores the current search command on the proxy client

Specified by:
setSearchCommand in interface Pazpar2Client

getSearchCount

public int getSearchCount()
Description copied from interface: Pazpar2Client
Returns the number of searches so far on this pazpar2 client object

Specified by:
getSearchCount in interface Pazpar2Client

getSearchCommand

public ClientCommand getSearchCommand()
Returns the latest search command executed through this proxy client

Specified by:
getSearchCommand in interface Pazpar2Client
Returns:

executeSearch

protected AbstractPazpar2Client.HttpResponse executeSearch(OutputStream os)
                                                    throws IOException,
                                                           Pazpar2ErrorException
Performs a Pazpar2 search command process

Parameters:
os - OutputStream to pipe results to
Returns:
200 if successful
Throws:
IOException
Pazpar2ErrorException

executeCommand

public final Pazpar2HttpResponse executeCommand(ClientCommand command,
                                                OutputStream os)
                                         throws IOException,
                                                Pazpar2ErrorException
Description copied from interface: Pazpar2Client
Forwards any Pazpar2 command and stores the results in the OutputStream

Specified by:
executeCommand in interface Pazpar2Client
Returns:
HTTP status of pazpar2 request
Throws:
IOException
Pazpar2ErrorException

getTimeStamp

public long getTimeStamp(String command,
                         int searchNumber)
Returns the number of times this command has be executed with a result since the current search was initiated.

Specified by:
getTimeStamp in interface Pazpar2Client

getResults

public Document getResults(String command)
Description copied from interface: Pazpar2Client
Returns the results of the latest command of the kind processed by this proxy client

Specified by:
getResults in interface Pazpar2Client
Returns:

request

protected AbstractPazpar2Client.HttpResponse request(String queryString)
                                              throws Pazpar2IOException,
                                                     Pazpar2ErrorException
Send pazpar2 protocol request.

Parameters:
queryString - url encoded query string
Returns:
response
Throws:
com.indexdata.masterkey.pazpar2.exceptions.Pazpar2IOException
com.indexdata.masterkey.pazpar2.exceptions.Pazpar2ErrorException
com.indexdata.masterkey.pazpar2.exceptions.Pazpar2MalformedOutputException
Pazpar2IOException
Pazpar2ErrorException

pipeStream

protected void pipeStream(InputStream is,
                          OutputStream os)
                   throws IOException
Pipes the last response input stream to a specified output stream.

Parameters:
os - output stream to pipe to
Throws:
IOException

sendInit

protected void sendInit(boolean clear)
                 throws Pazpar2IOException,
                        Pazpar2ErrorException
Initializes a Pazpar2 session and stores the Pazpar2 session ID with the proxy client

Parameters:
clear -
Throws:
Pazpar2IOException
Pazpar2ErrorException

sendInit

protected void sendInit(Document service)
                 throws Pazpar2IOException,
                        Pazpar2ErrorException
Throws:
Pazpar2IOException
Pazpar2ErrorException

sessionIsAlive

protected boolean sessionIsAlive()
Sends a Pazpar2 ping command for the current Pazpar2 session ID (if any exists) Returns true if the Pazpar2 session ID exists and Pazpar2 says the session is alive


sendRequest

protected AbstractPazpar2Client.HttpResponse sendRequest(String encodedParams)
                                                  throws Pazpar2IOException,
                                                         Pazpar2ErrorException
Sends a Pazpar2 request off to the configured Pazpar2 URL and with the provided parameters

Parameters:
encodedParams -
Returns:
Throws:
Pazpar2IOException
Pazpar2ErrorException

getHit

public Document getHit(String recid)
Returns a 'hit' by recid from the latest 'show' document.

Specified by:
getHit in interface Pazpar2Client
Returns:
A Record Document based on a hit in search results

recordRequest

public Document recordRequest(String recid,
                              int offset)
                       throws Pazpar2ErrorException,
                              Pazpar2IOException
Description copied from interface: Pazpar2Client
Makes a non-managed/transient pazpar2 record offset request. This is for 'embedded' pazpar2 requests by other plug-ins than Relay and independently of the main pazpar2 session. It will not update the state of the pazpar2 client object.

Specified by:
recordRequest in interface Pazpar2Client
Returns:
pazpar2's response as a Document
Throws:
Pazpar2ErrorException
Pazpar2IOException

recordRequest

public Document recordRequest(String recid)
                       throws Pazpar2ErrorException,
                              Pazpar2IOException
Description copied from interface: Pazpar2Client
Makes a non-managed/transient pazpar2 record request. This is for 'embedded' pazpar2 requests by other plug-ins than Relay and independently of the main pazpar2 session. It will not update the state of the pazpar2 client object.

Specified by:
recordRequest in interface Pazpar2Client
Returns:
pazpar2's response as a Document
Throws:
Pazpar2ErrorException
Pazpar2IOException

showRequest

public Document showRequest()
                     throws Pazpar2ErrorException,
                            Pazpar2IOException
Description copied from interface: Pazpar2Client
Makes a non-managed/transient pazpar2 show request. This is for 'embedded' pazpar2 requests by other plug-ins than Relay and independently of the main pazpar2 session. It will not update the state of the pazpar2 client object.

Specified by:
showRequest in interface Pazpar2Client
Returns:
pazpar2's response as a Document
Throws:
Pazpar2ErrorException
Pazpar2IOException

searchRequest

public Document searchRequest(String queryString)
                       throws Pazpar2ErrorException,
                              Pazpar2IOException
Description copied from interface: Pazpar2Client
Makes a non-managed pazpar2 search request on a cloned pazpar2 client This is for 'embedded' pazpar2 requests by other plug-ins than Relay and independently of the main pazpar2 session. It will not update the state of the pazpar2 client object. The method should only be invoked on a cloned pazpar2 client object, using it on a main pazpar2 session would compromise the state of the session.

Specified by:
searchRequest in interface Pazpar2Client
Returns:
pazpar2's response as a Document
Throws:
Pazpar2ErrorException
Pazpar2IOException


Copyright © 2012. All Rights Reserved.