jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1373280 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/api/ main/java/org/apache/jackrabbit/oak/core/ main/java/org/apache/jackrabbit/oak/plugins/identifier/ main/java/org/apache/jackrabbit/oak/query/ test/jav...
Date Wed, 15 Aug 2012 09:21:05 GMT
Author: thomasm
Date: Wed Aug 15 09:21:05 2012
New Revision: 1373280

URL: http://svn.apache.org/viewvc?rev=1373280&view=rev
Log:
OAK-241 QueryEngine.executeQuery needs a session parameter (partial)

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/SessionQueryEngine.java
      - copied, changed from r1372376, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SessionQueryEngineImpl.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ContentSession.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ContentSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ContentSession.java?rev=1373280&r1=1373279&r2=1373280&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ContentSession.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ContentSession.java
Wed Aug 15 09:21:05 2012
@@ -82,7 +82,7 @@ public interface ContentSession extends 
      * @return the query engine
      */
     @Nonnull
-    QueryEngine getQueryEngine();
+    SessionQueryEngine getQueryEngine();
 
     /**
      * Returns the internal value factory.

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/SessionQueryEngine.java
(from r1372376, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/SessionQueryEngine.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/SessionQueryEngine.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java&r1=1372376&r2=1373280&rev=1373280&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/SessionQueryEngine.java
Wed Aug 15 09:21:05 2012
@@ -26,7 +26,7 @@ import org.apache.jackrabbit.oak.namepat
  * <p>
  * What query languages are supported depends on the registered query parsers.
  */
-public interface QueryEngine {
+public interface SessionQueryEngine {
 
     /**
      * Get the list of supported query languages.
@@ -59,7 +59,7 @@ public interface QueryEngine {
      * @throws ParseException if the statement could not be parsed
      * @throws IllegalArgumentException if there was an error executing the query
      */
-    Result executeQuery(String statement, String language, ContentSession session,
+    Result executeQuery(String statement, String language,
             long limit, long offset, Map<String, CoreValue> bindings,
             NamePathMapper namePathMapper) throws ParseException;
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java?rev=1373280&r1=1373279&r2=1373280&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
Wed Aug 15 09:21:05 2012
@@ -29,7 +29,6 @@ import org.apache.jackrabbit.mk.core.Mic
 import org.apache.jackrabbit.mk.index.Indexer;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.ContentSession;
-import org.apache.jackrabbit.oak.api.QueryEngine;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
 import org.apache.jackrabbit.oak.query.QueryEngineImpl;
 import org.apache.jackrabbit.oak.security.authentication.LoginContextProviderImpl;
@@ -58,7 +57,7 @@ public class ContentRepositoryImpl imple
 
     private final LoginContextProvider loginContextProvider;
 
-    private final QueryEngine queryEngine;
+    private final QueryEngineImpl queryEngine;
     private final KernelNodeStore nodeStore;
 
     /**
@@ -75,10 +74,10 @@ public class ContentRepositoryImpl imple
 
     /**
      * Utility constructor, intended to be used within test cases only.
-     * 
+     *
      * Creates an Oak repository instance based on the given, already
      * initialized components.
-     * 
+     *
      * @param microKernel
      *            underlying kernel instance
      * @param indexProvider

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java?rev=1373280&r1=1373279&r2=1373280&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
Wed Aug 15 09:21:05 2012
@@ -18,16 +18,16 @@ package org.apache.jackrabbit.oak.core;
 
 import java.io.IOException;
 import java.util.Set;
-
 import javax.annotation.Nonnull;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
-
 import org.apache.jackrabbit.oak.api.AuthInfo;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
-import org.apache.jackrabbit.oak.api.QueryEngine;
+import org.apache.jackrabbit.oak.api.SessionQueryEngine;
 import org.apache.jackrabbit.oak.api.Root;
+import org.apache.jackrabbit.oak.query.QueryEngineImpl;
+import org.apache.jackrabbit.oak.query.SessionQueryEngineImpl;
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlContext;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.slf4j.Logger;
@@ -43,11 +43,11 @@ class ContentSessionImpl implements Cont
     private final LoginContext loginContext;
     private final String workspaceName;
     private final NodeStore store;
-    private final QueryEngine queryEngine;
+    private final SessionQueryEngine queryEngine;
     private final AccessControlContext accessControlContext;
 
     public ContentSessionImpl(LoginContext loginContext, String workspaceName,
-                              NodeStore store, QueryEngine queryEngine,
+                              NodeStore store, QueryEngineImpl queryEngine,
                               AccessControlContext accessControlContext) {
 
         assert queryEngine != null;
@@ -55,8 +55,7 @@ class ContentSessionImpl implements Cont
         this.loginContext = loginContext;
         this.workspaceName = workspaceName;
         this.store = store;
-        this.queryEngine = queryEngine;
-
+        this.queryEngine = new SessionQueryEngineImpl(this, queryEngine);
         this.accessControlContext = accessControlContext;
         this.accessControlContext.initialize(getAuthInfo().getPrincipals());
     }
@@ -94,7 +93,7 @@ class ContentSessionImpl implements Cont
 
     @Nonnull
     @Override
-    public QueryEngine getQueryEngine() {
+    public SessionQueryEngine getQueryEngine() {
         return queryEngine;
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java?rev=1373280&r1=1373279&r2=1373280&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
Wed Aug 15 09:21:05 2012
@@ -175,7 +175,7 @@ public class IdentifierManager {
             Map<String, CoreValue> bindings = Collections.singletonMap("id", contentSession.getCoreValueFactory().createValue(id));
 
             Result result = contentSession.getQueryEngine().executeQuery("SELECT * FROM [nt:base]
WHERE [jcr:uuid] = $id", Query.JCR_SQL2,
-                    contentSession, Long.MAX_VALUE, 0, bindings, NamePathMapper.DEFAULT);
+                    Long.MAX_VALUE, 0, bindings, new NamePathMapper.Default());
 
             String path = null;
             for (ResultRow rr : result.getRows()) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java?rev=1373280&r1=1373279&r2=1373280&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
Wed Aug 15 09:21:05 2012
@@ -25,7 +25,6 @@ import org.apache.jackrabbit.mk.api.Micr
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
-import org.apache.jackrabbit.oak.api.QueryEngine;
 import org.apache.jackrabbit.oak.kernel.KernelNodeState;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
@@ -37,7 +36,7 @@ import org.apache.jackrabbit.oak.spi.sta
 /**
  * The query engine implementation.
  */
-public class QueryEngineImpl implements QueryEngine {
+public class QueryEngineImpl {
 
     static final String SQL2 = "JCR-SQL2";
     static final String SQL = "sql";
@@ -54,7 +53,6 @@ public class QueryEngineImpl implements 
         this.indexProvider = indexProvider;
     }
 
-    @Override
     public List<String> getSupportedQueryLanguages() {
         return Arrays.asList(SQL2, SQL, XPATH, JQOM);
     }
@@ -67,7 +65,6 @@ public class QueryEngineImpl implements 
      * @return the list of bind variable names
      * @throws ParseException
      */
-    @Override
     public List<String> getBindVariableNames(String statement, String language) throws
ParseException {
         Query q = parseQuery(statement, language);
         return q.getBindVariableNames();
@@ -93,7 +90,6 @@ public class QueryEngineImpl implements 
         return q;
     }
 
-    @Override
     public ResultImpl executeQuery(String statement, String language, ContentSession session,
             long limit, long offset, Map<String, CoreValue> bindings,
             NamePathMapper namePathMapper) throws ParseException {

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SessionQueryEngineImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SessionQueryEngineImpl.java?rev=1373280&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SessionQueryEngineImpl.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SessionQueryEngineImpl.java
Wed Aug 15 09:21:05 2012
@@ -0,0 +1,60 @@
+/*
+ * 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.oak.query;
+
+import java.text.ParseException;
+import java.util.List;
+import java.util.Map;
+import org.apache.jackrabbit.oak.api.ContentSession;
+import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.api.SessionQueryEngine;
+import org.apache.jackrabbit.oak.api.Result;
+import org.apache.jackrabbit.oak.namepath.NamePathMapper;
+
+/**
+ * The query engine implementation bound to a session.
+ */
+public class SessionQueryEngineImpl implements SessionQueryEngine {
+
+    private final QueryEngineImpl queryEngine;
+    private final ContentSession session;
+
+    public SessionQueryEngineImpl(ContentSession session, QueryEngineImpl queryEngine) {
+        this.session = session;
+        this.queryEngine = queryEngine;
+    }
+
+    @Override
+    public List<String> getSupportedQueryLanguages() {
+        return queryEngine.getSupportedQueryLanguages();
+    }
+
+    @Override
+    public List<String> getBindVariableNames(String statement, String language)
+            throws ParseException {
+        return queryEngine.getBindVariableNames(statement, language);
+    }
+
+    @Override
+    public Result executeQuery(String statement, String language, long limit,
+            long offset, Map<String, CoreValue> bindings,
+            NamePathMapper namePathMapper) throws ParseException {
+        return queryEngine.executeQuery(statement, language, session, limit,
+                offset, bindings, namePathMapper);
+    }
+
+}

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java?rev=1373280&r1=1373279&r2=1373280&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
Wed Aug 15 09:21:05 2012
@@ -30,7 +30,7 @@ import org.apache.jackrabbit.mk.core.Mic
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
-import org.apache.jackrabbit.oak.api.QueryEngine;
+import org.apache.jackrabbit.oak.api.SessionQueryEngine;
 import org.apache.jackrabbit.oak.api.Result;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
@@ -53,14 +53,14 @@ import org.junit.Before;
  */
 public abstract class AbstractLuceneQueryTest {
 
-    private static String TEST_INDEX_NAME = DEFAULT_INDEX_NAME;
+    protected static final String SQL2 = "JCR-SQL2";
 
-    protected static String SQL2 = "JCR-SQL2";
+    private static final String TEST_INDEX_NAME = DEFAULT_INDEX_NAME;
 
     protected ContentRepository repository;
     protected ContentSession session;
     protected CoreValueFactory vf;
-    protected QueryEngine qe;
+    protected SessionQueryEngine qe;
     protected Root root;
 
     @Before
@@ -95,7 +95,7 @@ public abstract class AbstractLuceneQuer
 
     /**
      * Recreates an empty index node, ready to be used in tests
-     * 
+     *
      * @throws Exception
      */
     private void cleanupIndexNode() throws Exception {
@@ -112,7 +112,7 @@ public abstract class AbstractLuceneQuer
     }
 
     protected Result executeQuery(String statement) throws ParseException {
-        return qe.executeQuery(statement, SQL2, session, Long.MAX_VALUE, 0,
+        return qe.executeQuery(statement, SQL2, Long.MAX_VALUE, 0,
                 null, null);
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java?rev=1373280&r1=1373279&r2=1373280&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
Wed Aug 15 09:21:05 2012
@@ -20,10 +20,8 @@ import org.apache.jackrabbit.mk.core.Mic
 import org.apache.jackrabbit.mk.index.IndexWrapper;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
-import org.apache.jackrabbit.oak.api.QueryEngine;
+import org.apache.jackrabbit.oak.api.SessionQueryEngine;
 import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
-import org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexProvider;
-import org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 
 import javax.jcr.GuestCredentials;
@@ -36,7 +34,7 @@ public abstract class AbstractQueryTest 
     protected final IndexWrapper mk;
     protected final ContentRepositoryImpl rep;
     protected final CoreValueFactory vf;
-    protected final QueryEngine qe;
+    protected final SessionQueryEngine qe;
     protected final ContentSession session;
 
     {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java?rev=1373280&r1=1373279&r2=1373280&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java
Wed Aug 15 09:21:05 2012
@@ -196,7 +196,7 @@ public class QueryTest extends AbstractQ
     }
 
     private Result executeQuery(String statement, String language, HashMap<String, CoreValue>
sv) throws ParseException {
-        return qe.executeQuery(statement, language, session, Long.MAX_VALUE, 0, sv, null);
+        return qe.executeQuery(statement, language, Long.MAX_VALUE, 0, sv, null);
     }
 
 }



Mime
View raw message