jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r653751 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: WorkspaceImpl.java query/QueryImpl.java query/QueryManagerImpl.java
Date Tue, 06 May 2008 11:53:43 GMT
Author: jukka
Date: Tue May  6 04:53:42 2008
New Revision: 653751

URL: http://svn.apache.org/viewvc?rev=653751&view=rev
Log:
JCR-1564: JSR 283 namespace handling
    - Reduced exposure of the LocalNamespaceMappings class
    - Makes refactoring easier

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=653751&r1=653750&r2=653751&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
Tue May  6 04:53:42 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=653751&r1=653750&r2=653751&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
Tue May  6 04:53:42 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;
@@ -104,20 +101,29 @@
      * @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());
+    }
+
+    private Map getNamespaceMappings() throws RepositoryException {
+        Map map = new HashMap();
+        String[] prefixes = session.getNamespacePrefixes();
+        for (int i = 0; i < prefixes.length; i++) {
+            map.put(prefixes[i], session.getNamespaceURI(prefixes[i]));
+        }
+        return map;
     }
 
     /**
@@ -134,14 +140,12 @@
      * @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 {
-
+            throws InvalidQueryException, RepositoryException {
         this.session = session;
         this.resolver = resolver;
-        this.nsResolver = nsResolver;
         this.itemManager = itemMgr;
         this.hierarchyManager = hierarchyManager;
         this.node = node;
@@ -155,16 +159,16 @@
         }
         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());
     }

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=653751&r1=653750&r2=653751&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
Tue May  6 04:53:42 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;
@@ -75,13 +69,11 @@
      * @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 +86,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 +96,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