net.kwfgrid.gwes.xmldbclient
Class RemoteQuery

java.lang.Object
  extended by net.kwfgrid.gwes.xmldbclient.RemoteQuery
All Implemented Interfaces:
Remote, QueryInterface

public class RemoteQuery
extends Object
implements QueryInterface

Encapsulates Axis2 Java stubs for eXist-DB.

Version:
$Id: RemoteQuery.java 1446 2010-12-09 09:41:27Z hoheisel $
Author:
Andreas Hoheisel (www.andreas-hoheisel.de)

Constructor Summary
RemoteQuery(String serviceUrl)
           
 
Method Summary
 String connect(String userId, String password)
          Create a new user session.
 void disconnect(String sessionId)
          Release a user session.
 String getResource(String sessionId, String path, boolean indent, boolean xinclude)
          Retrieve a document from the database.
 javax.activation.DataHandler getResourceData(String sessionId, String path, boolean indent, boolean xinclude, boolean processXSLPI)
          Retrieve a document from the database.
 QueryServiceStub.Collection listCollection(String sessionId, String path)
          Get information on the specified collection.
 QueryServiceStub.QueryResponse query(String sessionId, String xquery)
          Execute a simple XPath query passed as string.
 String[] retrieve(String sessionId, int start, int howmany, boolean indent, boolean xinclude, String highlight)
          Retrieve a set of query results from the last query executed within the current session.
 String[] retrieveByDocument(String sessionId, int start, int howmany, String path, boolean indent, boolean xinclude, String highlight)
          For the specified document, retrieve a set of query results from the last query executed within the current session.
 QueryServiceStub.Base64BinaryArray retrieveData(String sessionId, int start, int howmany, boolean indent, boolean xinclude, String highlight)
          Retrieve a set of query results from the last query executed within the current session.
 QueryServiceStub.QueryResponse xquery(String sessionId, javax.activation.DataHandler xquery)
          Execute an XQuery.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteQuery

public RemoteQuery(String serviceUrl)
            throws RemoteException
Throws:
RemoteException
Method Detail

connect

public String connect(String userId,
                      String password)
               throws RemoteException
Description copied from interface: QueryInterface
Create a new user session. Authenticates the user against the database. The user has to be a valid database user. If the provided user information is valid, a new session will be registered on the server and a session id will be returned. The session will be valid for at least 60 minutes. Please call disconnect() to release the session. Sessions are shared between the Query and Admin services. A session created through the Query service can be used with the Admin service and vice versa.

Specified by:
connect in interface QueryInterface
Returns:
session-id a unique id for the created session
Throws:
RemoteException - if the user cannot log in

retrieve

public String[] retrieve(String sessionId,
                         int start,
                         int howmany,
                         boolean indent,
                         boolean xinclude,
                         String highlight)
                  throws RemoteException
Description copied from interface: QueryInterface
Retrieve a set of query results from the last query executed within the current session. The first result to be retrieved from the result set is defined by the start-parameter. Results are counted from 1.

Specified by:
retrieve in interface QueryInterface
Parameters:
sessionId - a valid session id as returned by connect().
start - the first result to retrieve.
howmany - number of results to be returned.
indent - should the XML be pretty-printed?
xinclude - should xinclude tags be expanded?
highlight - highlight matching search terms within elements or attributes. Possible values are: "elements" for elements only, "attributes" for attributes only, "both" for elements and attributes, "none" to disable highlighting. For elements, matching terms are surrounded by <exist:match> tags. For attributes, terms are marked with the char sequence "||".
Throws:
RemoteException

disconnect

public void disconnect(String sessionId)
                throws RemoteException
Description copied from interface: QueryInterface
Release a user session. This will free all resources (including result sets).

Specified by:
disconnect in interface QueryInterface
Parameters:
sessionId - a valid session id as returned by connect().
Throws:
RemoteException

getResourceData

public javax.activation.DataHandler getResourceData(String sessionId,
                                                    String path,
                                                    boolean indent,
                                                    boolean xinclude,
                                                    boolean processXSLPI)
                                             throws RemoteException
Description copied from interface: QueryInterface
Retrieve a document from the database. This method returns the document data in binary form to avoid possible conflicts.

Specified by:
getResourceData in interface QueryInterface
Parameters:
sessionId - a valid session id as returned by connect().
path - the full path to the document.
indent - should the document be pretty-printed (indented)?
xinclude - should xinclude tags be expanded?
processXSLPI - should XSL processing instructions be processed?
Returns:
the resource in base64 binary encoding
Throws:
RemoteException

xquery

public QueryServiceStub.QueryResponse xquery(String sessionId,
                                             javax.activation.DataHandler xquery)
                                      throws RemoteException
Description copied from interface: QueryInterface
Execute an XQuery.

Specified by:
xquery in interface QueryInterface
Parameters:
sessionId - a valid session id as returned by connect().
xquery - the XQuery script in binary encoding.
Returns:
query response
Throws:
RemoteException

retrieveData

public QueryServiceStub.Base64BinaryArray retrieveData(String sessionId,
                                                       int start,
                                                       int howmany,
                                                       boolean indent,
                                                       boolean xinclude,
                                                       String highlight)
                                                throws RemoteException
Description copied from interface: QueryInterface
Retrieve a set of query results from the last query executed within the current session. This method returns the data as an array of base64 encoded data. The first result to be retrieved from the result set is defined by the start-parameter. Results are counted from 1.

Specified by:
retrieveData in interface QueryInterface
Parameters:
sessionId - a valid session id as returned by connect().
start - the first result to retrieve.
howmany - number of results to be returned.
indent - should the XML be pretty-printed?
xinclude - should xinclude tags be expanded?
highlight - highlight matching search terms within elements or attributes. Possible values are: "elements" for elements only, "attributes" for attributes only, "both" for elements and attributes, "none" to disable highlighting. For elements, matching terms are surrounded by <exist:match> tags. For attributes, terms are marked with the char sequence "||".
Throws:
RemoteException

retrieveByDocument

public String[] retrieveByDocument(String sessionId,
                                   int start,
                                   int howmany,
                                   String path,
                                   boolean indent,
                                   boolean xinclude,
                                   String highlight)
                            throws RemoteException
Description copied from interface: QueryInterface
For the specified document, retrieve a set of query results from the last query executed within the current session. Only hits in the given document (identified by its path) are returned. The first result to be retrieved from the result set is defined by the start-parameter. Results are counted from 1.

Specified by:
retrieveByDocument in interface QueryInterface
Parameters:
sessionId - a valid session id as returned by connect().
start - the first result to retrieve.
howmany - number of results to be returned.
path - the full path to the document.
indent - should the XML be pretty-printed?
xinclude - should xinclude tags be expanded?
highlight - highlight matching search terms within elements or attributes. Possible values are: "elements" for elements only, "attributes" for attributes only, "both" for elements and attributes, "none" to disable highlighting. For elements, matching terms are surrounded by <exist:match> tags. For attributes, terms are marked with the char sequence "||".
Throws:
RemoteException

listCollection

public QueryServiceStub.Collection listCollection(String sessionId,
                                                  String path)
                                           throws RemoteException
Description copied from interface: QueryInterface
Get information on the specified collection.

Specified by:
listCollection in interface QueryInterface
Parameters:
sessionId - a valid session id as returned by connect().
path - the full path to the collection.
Throws:
RemoteException

getResource

public String getResource(String sessionId,
                          String path,
                          boolean indent,
                          boolean xinclude)
                   throws RemoteException
Description copied from interface: QueryInterface
Retrieve a document from the database.

Specified by:
getResource in interface QueryInterface
Parameters:
sessionId - a valid session id as returned by connect().
path - the full path to the document.
indent - should the document be pretty-printed (indented)?
xinclude - should xinclude tags be expanded?
Returns:
the resource as string
Throws:
RemoteException

query

public QueryServiceStub.QueryResponse query(String sessionId,
                                            String xquery)
                                     throws RemoteException
Description copied from interface: QueryInterface
Execute a simple XPath query passed as string.

Specified by:
query in interface QueryInterface
Parameters:
sessionId - a valid session id as returned by connect().
xquery - XPath query string.
Returns:
QueryResponse describing the query results.
Throws:
RemoteException


Copyright © 2005-2011 Fraunhofer FIRST. All Rights Reserved.