jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1415968 - in /jackrabbit/trunk: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/query/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/
Date Sat, 01 Dec 2012 10:05:46 GMT
Author: jukka
Date: Sat Dec  1 10:05:45 2012
New Revision: 1415968

URL: http://svn.apache.org/viewvc?rev=1415968&view=rev
Log:
JCR-3474: Add JackrabbitQueryResult.getTotalSize()

Added:
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/query/
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/query/JackrabbitQueryResult.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java

Added: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/query/JackrabbitQueryResult.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/query/JackrabbitQueryResult.java?rev=1415968&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/query/JackrabbitQueryResult.java
(added)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/query/JackrabbitQueryResult.java
Sat Dec  1 10:05:45 2012
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.api.query;
+
+import javax.jcr.query.QueryResult;
+
+/**
+ * The Jackrabbit query result interface. This interface contains the
+ * Jackrabbit-specific extensions to the JCR {@link QueryResult} interface.
+ *
+ * @since Jackrabbit 2.6
+ */
+public interface JackrabbitQueryResult extends QueryResult {
+
+    /**
+     * Returns the total number of hits. This is the number of results you
+     * would get without any limit or offset settings. This method may return
+     * <code>-1</code> if the total size is unknown.
+     *
+     * @return the total number of hits, or <code>-1</code>
+     */
+    int getTotalSize();
+
+}

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java?rev=1415968&r1=1415967&r2=1415968&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
Sat Dec  1 10:05:45 2012
@@ -26,9 +26,9 @@ import java.util.NoSuchElementException;
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
-import javax.jcr.query.QueryResult;
 import javax.jcr.query.RowIterator;
 
+import org.apache.jackrabbit.api.query.JackrabbitQueryResult;
 import org.apache.jackrabbit.core.session.SessionContext;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.query.qom.ColumnImpl;
@@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Implements the <code>QueryResult</code> interface.
  */
-public abstract class QueryResultImpl implements QueryResult {
+public abstract class QueryResultImpl implements JackrabbitQueryResult {
 
     /**
      * The logger instance for this class
@@ -364,10 +364,12 @@ public abstract class QueryResultImpl im
 
     /**
      * Returns the total number of hits. This is the number of results you
-     * will get get if you don't set any limit or offset. Keep in mind that this
-     * number may get smaller if nodes are found in the result set which the
-     * current session has no permission to access. This method may return
+     * will get get if you don't set any limit or offset. This method may return
      * <code>-1</code> if the total size is unknown.
+     * <p>
+     * Keep in mind that this number may get smaller if nodes are found in
+     * the result set which the current session has no permission to access.
+     * FIXME: This might be a security problem.
      *
      * @return the total number of hits.
      */

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java?rev=1415968&r1=1415967&r2=1415968&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
Sat Dec  1 10:05:45 2012
@@ -49,17 +49,8 @@ public class AbstractQueryTest extends A
 
     protected QueryObjectModelFactory qomFactory;
 
-    /**
-     * true if this is a Jackrabbit JCR implementation
-     */
-    boolean isJackrabbitImpl = true;
-    private static final String DESCRIPTOR_NAME = "jcr.repository.name";
-    private static final String DESCRIPTOR_VALUE = "Jackrabbit";
-
     protected void setUp() throws Exception {
         super.setUp();
-        isJackrabbitImpl = DESCRIPTOR_VALUE.equals(getHelper().getRepository()
-                .getDescriptor(DESCRIPTOR_NAME));
         qm = superuser.getWorkspace().getQueryManager();
         qomFactory = qm.getQOMFactory();
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java?rev=1415968&r1=1415967&r2=1415968&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
Sat Dec  1 10:05:45 2012
@@ -22,7 +22,7 @@ import javax.jcr.RepositoryException;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryResult;
 
-import org.apache.jackrabbit.core.query.lucene.QueryResultImpl;
+import org.apache.jackrabbit.api.query.JackrabbitQueryResult;
 
 public class LimitAndOffsetTest extends AbstractQueryTest {
 
@@ -129,8 +129,8 @@ public class LimitAndOffsetTest extends 
         QueryResult result = query.execute();
         NodeIterator nodes = result.getNodes();
         assertEquals(2, nodes.getSize());
-        if (isJackrabbitImpl) {
-            assertEquals(3, ((QueryResultImpl) result).getTotalSize());
+        if (result instanceof JackrabbitQueryResult) {
+            assertEquals(3, ((JackrabbitQueryResult) result).getTotalSize());
         }
 
         // JCR-2684: offset higher than total result => size == 0
@@ -139,8 +139,8 @@ public class LimitAndOffsetTest extends 
         nodes = result.getNodes();
         assertFalse(nodes.hasNext());
         assertEquals(0, nodes.getSize());
-        if (isJackrabbitImpl) {
-            assertEquals(3, ((QueryResultImpl) result).getTotalSize());
+        if (result instanceof JackrabbitQueryResult) {
+            assertEquals(3, ((JackrabbitQueryResult) result).getTotalSize());
         }
 
         query.setOffset(1);
@@ -148,8 +148,8 @@ public class LimitAndOffsetTest extends 
         result = query.execute();
         nodes = result.getNodes();
         assertEquals(1, nodes.getSize());
-        if (isJackrabbitImpl) {
-            assertEquals(3, ((QueryResultImpl) result).getTotalSize());
+        if (result instanceof JackrabbitQueryResult) {
+            assertEquals(3, ((JackrabbitQueryResult) result).getTotalSize());
         }
     }
 



Mime
View raw message