jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r655556 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: WorkspaceImpl.java query/QueryImpl.java query/QueryManagerImpl.java
Date Mon, 12 May 2008 16:51:39 GMT
Author: jukka
Date: Mon May 12 09:51:39 2008
New Revision: 655556

URL: http://svn.apache.org/viewvc?rev=655556&view=rev
Log:
JCR-1564: JSR 283 namespace handling
    - Removed the query -> LocalNamespaceMappings dependency in jcr2spi
    - Now it works, thanks to revision 655554

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java?rev=655556&r1=655555&r2=655556&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
Mon May 12 09:51:39 2008
@@ -261,7 +261,7 @@
     public QueryManager getQueryManager() throws RepositoryException {
         session.checkIsAlive();
         if (qManager == null) {
-            qManager = new QueryManagerImpl(session, session.getLocalNamespaceMappings(),
+            qManager = new QueryManagerImpl(session,
                     session.getNamePathResolver(), session.getItemManager(),
                     session.getHierarchyManager(), wspManager);
         }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryImpl.java?rev=655556&r1=655555&r2=655556&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryImpl.java
Mon May 12 09:51:39 2008
@@ -16,10 +16,12 @@
  */
 package org.apache.jackrabbit.jcr2spi.query;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.jackrabbit.jcr2spi.ItemManager;
 import org.apache.jackrabbit.jcr2spi.WorkspaceManager;
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager;
-import org.apache.jackrabbit.jcr2spi.name.LocalNamespaceMappings;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.QueryInfo;
@@ -50,11 +52,6 @@
     private final Session session;
 
     /**
-     * The namespace mappings of the session that executes this query.
-     */
-    private final LocalNamespaceMappings nsResolver;
-
-    /**
      * Name and Path resolver
      */
     private final NamePathResolver resolver;
@@ -94,7 +91,6 @@
      * Creates a new query.
      *
      * @param session          the session that created this query.
-     * @param nsResolver       the namespace resolver to be used.
      * @param resolver
      * @param itemMgr          the item manager of that session.
      * @param hierarchyManager the HierarchyManager of that session.
@@ -104,27 +100,26 @@
      * @param language         the language of the query statement.
      * @throws InvalidQueryException if the query is invalid.
      */
-    public QueryImpl(Session session, LocalNamespaceMappings nsResolver, NamePathResolver
resolver,
+    public QueryImpl(Session session, NamePathResolver resolver,
                      ItemManager itemMgr, HierarchyManager hierarchyManager,
                      WorkspaceManager wspManager,
                      String statement, String language)
             throws InvalidQueryException, RepositoryException {
         this.session = session;
         this.resolver = resolver;
-        this.nsResolver = nsResolver;
         this.itemManager = itemMgr;
         this.hierarchyManager = hierarchyManager;
         this.statement = statement;
         this.language = language;
         this.wspManager = wspManager;
-        this.wspManager.checkQueryStatement(statement, language, nsResolver.getLocalNamespaceMappings());
+        this.wspManager.checkQueryStatement(
+                statement, language, getNamespaceMappings());
     }
 
     /**
      * Creates a query from a node.
      *
      * @param session    the session that created this query.
-     * @param nsResolver the namespace resolver to be used.
      * @param resolver
      * @param itemMgr    the item manager of that session.
      * @param hierarchyManager
@@ -134,14 +129,13 @@
      * @throws RepositoryException   if another error occurs while reading from
      *                               the node.
      */
-    public QueryImpl(Session session, LocalNamespaceMappings nsResolver, NamePathResolver
resolver,
+    public QueryImpl(Session session, NamePathResolver resolver,
                      ItemManager itemMgr, HierarchyManager hierarchyManager,
                      WorkspaceManager wspManager, Node node)
         throws InvalidQueryException, RepositoryException {
 
         this.session = session;
         this.resolver = resolver;
-        this.nsResolver = nsResolver;
         this.itemManager = itemMgr;
         this.hierarchyManager = hierarchyManager;
         this.node = node;
@@ -155,20 +149,36 @@
         }
         statement = node.getProperty(resolver.getJCRName(NameConstants.JCR_STATEMENT)).getString();
         language = node.getProperty(resolver.getJCRName(NameConstants.JCR_LANGUAGE)).getString();
-        this.wspManager.checkQueryStatement(statement, language,
-                    nsResolver.getLocalNamespaceMappings());
+        this.wspManager.checkQueryStatement(
+                statement, language, getNamespaceMappings());
     }
 
     /**
      * @see Query#execute()
      */
     public QueryResult execute() throws RepositoryException {
-        QueryInfo qI = wspManager.executeQuery(statement, language,
-                nsResolver.getLocalNamespaceMappings());
+        QueryInfo qI = wspManager.executeQuery(
+                statement, language, getNamespaceMappings());
         return new QueryResultImpl(itemManager, hierarchyManager,
                 qI, resolver, session.getValueFactory());
     }
 
+    /***
+     * Utility method that returns the namespace mappings of the current
+     * session.
+     *
+     * @return namespace mappings (prefix -> uri)
+     * @throws RepositoryException if a repository error occurs
+     */
+    private Map getNamespaceMappings() throws RepositoryException {
+        Map mappings = new HashMap();
+        String[] prefixes = session.getNamespacePrefixes();
+        for (int i = 0; i < prefixes.length; i++) {
+            mappings.put(prefixes[i], session.getNamespaceURI(prefixes[i]));
+        }
+        return mappings;
+    }
+
     /**
      * @see Query#getStatement()
      */

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java?rev=655556&r1=655555&r2=655556&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java
Mon May 12 09:51:39 2008
@@ -19,7 +19,6 @@
 import org.apache.jackrabbit.jcr2spi.ItemManager;
 import org.apache.jackrabbit.jcr2spi.WorkspaceManager;
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager;
-import org.apache.jackrabbit.jcr2spi.name.LocalNamespaceMappings;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 
 import javax.jcr.Node;
@@ -40,11 +39,6 @@
     private final Session session;
 
     /**
-     * The local namespace mappings for this query manager.
-     */
-    private final LocalNamespaceMappings nsResolver;
-
-    /**
      * Name and Path resolver
      */
     private final NamePathResolver resolver;
@@ -69,19 +63,16 @@
      * <code>Session</code>.
      *
      * @param session
-     * @param nsResolver
      * @param itemMgr
      * @param hierarchyManager
      * @param wspManager
      */
     public QueryManagerImpl(Session session,
-                            LocalNamespaceMappings nsResolver,
                             NamePathResolver resolver,
                             ItemManager itemMgr,
                             HierarchyManager hierarchyManager,
                             WorkspaceManager wspManager) {
         this.session = session;
-        this.nsResolver = nsResolver;
         this.resolver = resolver;
         this.itemMgr = itemMgr;
         this.hierarchyManager = hierarchyManager;
@@ -94,7 +85,7 @@
     public Query createQuery(String statement, String language)
             throws InvalidQueryException, RepositoryException {
         checkIsAlive();
-        QueryImpl query = new QueryImpl(session, nsResolver, resolver, itemMgr, hierarchyManager,
wspManager, statement, language);
+        QueryImpl query = new QueryImpl(session, resolver, itemMgr, hierarchyManager, wspManager,
statement, language);
         return query;
     }
 
@@ -104,7 +95,7 @@
     public Query getQuery(Node node)
             throws InvalidQueryException, RepositoryException {
         checkIsAlive();
-        QueryImpl query = new QueryImpl(session, nsResolver, resolver, itemMgr, hierarchyManager,
wspManager, node);
+        QueryImpl query = new QueryImpl(session, resolver, itemMgr, hierarchyManager, wspManager,
node);
         return query;
     }
 



Mime
View raw message