jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r572348 - in /jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm: exception/InvalidQueryException.java manager/ObjectContentManager.java manager/impl/ObjectContentManagerImpl.java
Date Mon, 03 Sep 2007 14:24:39 GMT
Author: fmeschbe
Date: Mon Sep  3 07:24:39 2007
New Revision: 572348

URL: http://svn.apache.org/viewvc?rev=572348&view=rev
Log:
JCR-1106 Add simple query method to ObjectContentManager and adapt to new ObjectIterator constructor

Added:
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/exception/InvalidQueryException.java
Modified:
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/ObjectContentManager.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java

Added: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/exception/InvalidQueryException.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/exception/InvalidQueryException.java?rev=572348&view=auto
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/exception/InvalidQueryException.java
(added)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/exception/InvalidQueryException.java
Mon Sep  3 07:24:39 2007
@@ -0,0 +1,37 @@
+/*
+ * $Url: $
+ * $Id: $
+ *
+ * Copyright 1997-2005 Day Management AG
+ * Barfuesserplatz 6, 4001 Basel, Switzerland
+ * All Rights Reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * Day Management AG, ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with Day.
+ */
+package org.apache.jackrabbit.ocm.exception;
+
+/**
+ * The <code>InvalidQuerySyntaxException</code> is an
+ * <code>ObjectContentManagerException</code> thrown if the query of the
+ * {@link org.apache.jackrabbit.ocm.manager.ObjectContentManager#getObjectIterator(String,
String)}
+ * is invalid. This exception actually wraps a standard JCR
+ * <code>javax.jcr.InvalidQueryException</code> to make it an unchecked
+ * exception. The cause of this exception will always be the original
+ * <code>InvalidQueryException</code> and the message will always be the
+ * original exception's message.
+ */
+public class InvalidQueryException extends ObjectContentManagerException {
+
+    /**
+     * Create an exception wrapping the given checked JCR exception
+     * 
+     * @param cause The wrapped JCR <code>InvalidQueryException</code>
+     */
+    public InvalidQueryException(javax.jcr.query.InvalidQueryException cause) {
+        super(cause.getMessage(), cause);
+    }
+}

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/ObjectContentManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/ObjectContentManager.java?rev=572348&r1=572347&r2=572348&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/ObjectContentManager.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/ObjectContentManager.java
Mon Sep  3 07:24:39 2007
@@ -187,7 +187,7 @@
      * 
      */
     public Collection getObjects(Query query) throws ObjectContentManagerException;
-    
+
     
     /**
      * Retrieve some objects matching to a query. 
@@ -198,6 +198,37 @@
      */
     public Iterator getObjectIterator (Query query) throws ObjectContentManagerException;
      
+    
+    /**
+     * Retrieve an objects matching a query specified in a specific query language.
+     * This method is expected to call create a <code>Query</code> using the
+     * session's <code>QueryManager</code> with the given query exception and
+     * language parameters.
+     * <p>
+     * If the query <code>statement</code> is syntactically invalid, given the
+     * language specified, an <code>InvalidQueryException</code> is thrown. The
+     * <code>language</code> must be a string from among those returned by
+     * <code>javax.jcr.QueryManager.getSupportedQueryLanguages()</code>;
+     * if it is not, then an <code>InvalidQueryException</code> is thrown.
+     * 
+     * @param query The query to execute to find the objects.
+     * @param language The language in which the query is  written
+     * 
+     * @return An iterator of objects instances. Each entry in the iterator
+     *      represents the mapping of a node returned by the query. If the
+     *      query returns a node, which may not be mapped, the respective node
+     *      is ignored.
+     * 
+     * @throws org.apache.jackrabbit.ocm.exception.InvalidQueryException If the
+     *      query is not a valid JCR Query according to the specified language 
+     * @throws ObjectContentManagerException If an error occurrs querying for
+     *      the objects.
+     *      
+     * @see javax.jcr.query.QueryManager#createQuery(String, String)
+     * @see javax.jcr.query.QueryManager#getSupportedQueryLanguages()
+     */
+    public Iterator getObjectIterator(String query, String language);
+
     
     /**
      * Checkout - Create a new version

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java?rev=572348&r1=572347&r2=572348&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java
Mon Sep  3 07:24:39 2007
@@ -627,7 +627,6 @@
             NodeIterator nodeIterator = queryResult.getNodes();
 
             return new ObjectIterator(nodeIterator,
-                                      query.getFilter().getFilterClass(),
                                       this.objectConverter,
                                       this.session);
 
@@ -641,6 +640,29 @@
         }
     }
 
+    /**
+    *
+    * @see org.apache.jackrabbit.ocm.manager.ObjectContentManager#getObjectIterator(String,
String)
+    */
+    public Iterator getObjectIterator(String query, String language) {
+        try {
+            log.debug("Get Object with expression : " + query);
+
+            javax.jcr.query.Query jcrQuery = session.getWorkspace().getQueryManager().createQuery(query,
language);
+            QueryResult queryResult = jcrQuery.execute();
+            NodeIterator nodeIterator = queryResult.getNodes();
+
+            return new ObjectIterator(nodeIterator,
+                                      this.objectConverter,
+                                      this.session);
+
+        } catch (InvalidQueryException iqe) {
+            throw new org.apache.jackrabbit.ocm.exception.InvalidQueryException(iqe);
+        } catch (RepositoryException re) {
+            throw new ObjectContentManagerException(re.getMessage(), re);
+        }
+    }
+    
     /**
      *
      * @see org.apache.jackrabbit.ocm.manager.ObjectContentManager#checkin(java.lang.String)



Mime
View raw message