jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r582276 - /jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java
Date Fri, 05 Oct 2007 14:06:52 GMT
Author: angela
Date: Fri Oct  5 07:06:50 2007
New Revision: 582276

URL: http://svn.apache.org/viewvc?rev=582276&view=rev
Log:
JCR-1157 : Expose namespace registry via workspace instead via session in spi2jcr. (Apply
patch provided by michael duerig)

Modified:
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java

Modified: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java?rev=582276&r1=582275&r2=582276&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java
Fri Oct  5 07:06:50 2007
@@ -17,9 +17,11 @@
 package org.apache.jackrabbit.spi2jcr;
 
 import org.apache.jackrabbit.spi.SessionInfo;
-import org.apache.jackrabbit.name.SessionNamespaceResolver;
+import org.apache.jackrabbit.name.AbstractNamespaceResolver;
 import org.apache.jackrabbit.name.NamespaceResolver;
 
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
 import javax.jcr.Session;
 import javax.jcr.RepositoryException;
 import javax.jcr.Credentials;
@@ -55,11 +57,36 @@
      * @param session     the JCR session.
      * @param credentials a copy of the credentials that were used to obtain the
      *                    JCR session.
+     * @throws RepositoryException 
      */
-    SessionInfoImpl(Session session, Credentials credentials) {
+    SessionInfoImpl(Session session, Credentials credentials) throws RepositoryException
{
         this.session = session;
-        this.resolver = new SessionNamespaceResolver(session);
         this.credentials = credentials;
+        
+        final NamespaceRegistry nsReg = session.getWorkspace().getNamespaceRegistry();
+       
+        this.resolver = new AbstractNamespaceResolver() {
+            public String getPrefix(String uri) throws NamespaceException {
+                try {
+                    return nsReg.getPrefix(uri);
+                }
+                catch (RepositoryException e) {
+                    // should never get here...
+                    throw new NamespaceException("internal error: failed to resolve namespace
uri", e);
+                }
+            }
+
+            public String getURI(String prefix) throws NamespaceException {
+                try {
+                    return nsReg.getURI(prefix);
+                }
+                catch (RepositoryException e) {
+                    // should never get here...
+                    throw new NamespaceException("internal error: failed to resolve namespace
prefix", e);
+                }
+            }
+        };
+        
     }
 
     /**



Mime
View raw message