jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1390548 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/
Date Wed, 26 Sep 2012 15:07:05 GMT
Author: mduerig
Date: Wed Sep 26 15:07:04 2012
New Revision: 1390548

URL: http://svn.apache.org/viewvc?rev=1390548&view=rev
Log:
OAK-345: Split NameMapper into session aware and session less parts

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NameMapperImpl.java
  (with props)
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionNameMapper.java
  (with props)
Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NameMapperImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NameMapperImpl.java?rev=1390548&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NameMapperImpl.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NameMapperImpl.java
Wed Sep 26 15:07:04 2012
@@ -0,0 +1,70 @@
+/*
+ * 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.namepath;
+
+import javax.annotation.CheckForNull;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.plugins.name.ReadOnlyNamespaceRegistry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NameMapperImpl extends AbstractNameMapper {
+    private static final Logger log = LoggerFactory.getLogger(NameMapperImpl.class);
+
+    private final Tree root;
+    private final NamespaceRegistry nsReg = new ReadOnlyNamespaceRegistry() {
+        @Override
+        protected Tree getReadTree() {
+            return root;
+        }
+    };
+
+    public NameMapperImpl(Tree root) {
+        this.root = root;
+    }
+
+    @Override
+    @CheckForNull
+    protected String getJcrPrefix(String oakPrefix) {
+        return oakPrefix;
+    }
+
+    @Override
+    @CheckForNull
+    protected String getOakPrefix(String jcrPrefix) {
+        return jcrPrefix;
+    }
+
+    @Override
+    @CheckForNull
+    protected String getOakPrefixFromURI(String uri) {
+        try {
+            return nsReg.getPrefix(uri);
+        } catch (RepositoryException e) {
+            log.debug("Could not get OAK prefix for URI " + uri);
+            return null;
+        }
+    }
+
+    @Override
+    public boolean hasSessionLocalMappings() {
+        return false;
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NameMapperImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NameMapperImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java?rev=1390548&r1=1390547&r2=1390548&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
Wed Sep 26 15:07:04 2012
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.jcr;
 
 import java.io.IOException;
 import java.util.concurrent.ScheduledExecutorService;
+
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.jcr.ItemExistsException;
@@ -48,7 +49,6 @@ import org.apache.jackrabbit.oak.jcr.obs
 import org.apache.jackrabbit.oak.jcr.security.principal.PrincipalManagerImpl;
 import org.apache.jackrabbit.oak.jcr.security.user.UserManagerImpl;
 import org.apache.jackrabbit.oak.jcr.value.ValueFactoryImpl;
-import org.apache.jackrabbit.oak.namepath.AbstractNameMapper;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl;
 import org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager;
@@ -93,7 +93,7 @@ public class SessionDelegate {
         this.root = contentSession.getLatestRoot();
         this.autoRefresh = autoRefresh;
         this.idManager = new IdentifierManager(contentSession.getQueryEngine(), root);
-        this.namePathMapper = new NamePathMapperImpl(new SessionNameMapper(), idManager);
+        this.namePathMapper = new NamePathMapperImpl(new SessionNameMapper(this), idManager);
         this.valueFactory = new ValueFactoryImpl(contentSession.getCoreValueFactory(), namePathMapper);
     }
 
@@ -489,54 +489,4 @@ public class SessionDelegate {
         return TODO.unimplemented().returnValue(new UserManagerImpl(getSession(), getNamePathMapper(),
ctx.getUserProvider(contentSession, root), ctx.getMembershipProvider(contentSession, root),
ctx.getConfig()));
     }
 
-    //--------------------------------------------------< SessionNameMapper >---
-
-    private class SessionNameMapper extends AbstractNameMapper {
-
-        //-----------------------------------------------------< NameMapper >---
-        @Override
-        @CheckForNull
-        protected String getJcrPrefix(String oakPrefix) {
-            try {
-                String ns = getWorkspace().getNamespaceRegistry().getURI(oakPrefix);
-                return session.getNamespacePrefix(ns);
-            } catch (RepositoryException e) {
-                log.debug("Could not get JCR prefix for OAK prefix " + oakPrefix);
-                return null;
-            }
-        }
-
-        @Override
-        @CheckForNull
-        protected String getOakPrefix(String jcrPrefix) {
-            try {
-                String ns = getSession().getNamespaceURI(jcrPrefix);
-                return getWorkspace().getNamespaceRegistry().getPrefix(ns);
-            } catch (RepositoryException e) {
-                log.debug("Could not get OAK prefix for JCR prefix " + jcrPrefix);
-                return null;
-            }
-        }
-
-        @Override
-        @CheckForNull
-        protected String getOakPrefixFromURI(String uri) {
-            try {
-                return getWorkspace().getNamespaceRegistry().getPrefix(uri);
-            } catch (RepositoryException e) {
-                log.debug("Could not get OAK prefix for URI " + uri);
-                return null;
-            }
-        }
-
-        @Override
-        public boolean hasSessionLocalMappings() {
-            if (session instanceof SessionImpl) {
-                return ((SessionImpl) session).hasSessionLocalMappings();
-            } else {
-                // we don't know
-                return true;
-            }
-        }
-    }
 }

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionNameMapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionNameMapper.java?rev=1390548&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionNameMapper.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionNameMapper.java
Wed Sep 26 15:07:04 2012
@@ -0,0 +1,60 @@
+package org.apache.jackrabbit.oak.jcr;
+
+import javax.annotation.CheckForNull;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.oak.namepath.AbstractNameMapper;
+
+public class SessionNameMapper extends AbstractNameMapper {
+    private final SessionDelegate sessionDelegate;
+
+    public SessionNameMapper(SessionDelegate sessionDelegate) {
+        this.sessionDelegate = sessionDelegate;
+    }
+
+    @Override
+    @CheckForNull
+    protected String getJcrPrefix(String oakPrefix) {
+        try {
+            String ns = sessionDelegate.getWorkspace().getNamespaceRegistry().getURI(oakPrefix);
+            return sessionDelegate.getSession().getNamespacePrefix(ns);
+        } catch (RepositoryException e) {
+            SessionDelegate.log.debug("Could not get JCR prefix for OAK prefix " + oakPrefix);
+            return null;
+        }
+    }
+
+    @Override
+    @CheckForNull
+    protected String getOakPrefix(String jcrPrefix) {
+        try {
+            String ns = sessionDelegate.getSession().getNamespaceURI(jcrPrefix);
+            return sessionDelegate.getWorkspace().getNamespaceRegistry().getPrefix(ns);
+        } catch (RepositoryException e) {
+            SessionDelegate.log.debug("Could not get OAK prefix for JCR prefix " + jcrPrefix);
+            return null;
+        }
+    }
+
+    @Override
+    @CheckForNull
+    protected String getOakPrefixFromURI(String uri) {
+        try {
+            return sessionDelegate.getWorkspace().getNamespaceRegistry().getPrefix(uri);
+        } catch (RepositoryException e) {
+            SessionDelegate.log.debug("Could not get OAK prefix for URI " + uri);
+            return null;
+        }
+    }
+
+    @Override
+    public boolean hasSessionLocalMappings() {
+        if (sessionDelegate.getSession() instanceof SessionImpl) {
+            return ((SessionImpl) sessionDelegate.getSession()).hasSessionLocalMappings();
+        }
+        else {
+            // we don't know
+            return true;
+        }
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionNameMapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionNameMapper.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message