Note that there are some explanatory texts on larger screens.

plurals
  1. POPerforming remote query on a Jackrabbit Server
    primarykey
    data
    text
    <p>We are using Jackrabbit 2.2.6 ( webapp) deployed on a Glassfish Application server. We are also building a client to upload files to the server using the rmi interface exposed by the server. We are able to login and upload files using the standard JCR API from the client to the remote server. However, we are having hard time querying the remote server ( we are using JCR-SQL2). Here is the snippet of the code that we are using to query the remote server: </p> <pre><code>public static List&lt;Node&gt; getNode(Session session, String q) { try { QueryManager qman = session.getWorkspace().getQueryManager(); Query query = qman.createQuery(q, Query.JCR_SQL2); QueryResult result = query.execute(); RowIterator rowIt = result.getRows(); System.err.println("Found results " + rowIt.hasNext()); List&lt;Node&gt; nList = new LinkedList&lt;Node&gt;(); while (rowIt.hasNext()) { Row row = rowIt.nextRow(); nList.add(row.getNode()); } return nList; } catch (RepositoryException ex) { Logger.getLogger(BasicArtifacts.class.getName()).log(Level.SEVERE, null, ex); } return null; } </code></pre> <p>This is what we got when executing the code:</p> <pre><code>javax.jcr.UnsupportedRepositoryOperationException: TODO: JCRRMI-26 at org.apache.jackrabbit.rmi.client.ClientRow.getNode(ClientRow.java:70) </code></pre> <p>It seems like <em>nList.add(row.getNode());</em> is the culprit. Looks like this is not the best way to do remote query on a Jackrabbit server. </p> <p>We confirmed that it works on the local transient repository.</p> <p>While looking through the Jackrabbit code base, we encountered the RemoteQuery and related classes. I tried to write some code - but could not quite make it work. Here is the snippet </p> <pre><code>public static List&lt;Node&gt; getNode(Session session, String q) throws RemoteException { try { QueryManager qman = session.getWorkspace().getQueryManager(); ServerAdapterFactory factory = new ServerAdapterFactory(); RemoteQueryManager rqman = factory.getRemoteQueryManager(session, qman); RemoteQuery rquery = rqman.createQuery(q, Query.JCR_SQL2); //this is a basic query - not yet sure how to implement the constraints as yet. RemoteQueryResult rresult = rquery.execute(); RemoteIterator rit = rresult.getRows(); Object[] objs = rit.nextObjects(); System.err.println("Found results " + rit.getSize() ); List&lt;Node&gt; nList = new LinkedList&lt;Node&gt;(); for(Object obj:objs){ //System.err.println(row.getPath()); ServerRow row = (ServerRow)obj; for(Value val:row.getValues()){ System.err.println("Value:"+ val.getString()); } //How to get the Node out of the ServerRow? //nList.add(row.); } return nList; } catch (RepositoryException ex) { Logger.getLogger(UploadContentToRemote.class.getName()).log(Level.SEVERE, null, ex); } return null; </code></pre> <p>}</p> <p>Any help, pointers will be appreciated. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload