jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1419342 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: namepath/IdentityNameMapper.java namepath/NameMapperImpl.java plugins/nodetype/DefBuilderFactory.java plugins/nodetype/TypeValidatorProvider.java
Date Mon, 10 Dec 2012 11:08:42 GMT
Author: jukka
Date: Mon Dec 10 11:08:41 2012
New Revision: 1419342

URL: http://svn.apache.org/viewvc?rev=1419342&view=rev
Log:
OAK-189: Swallowed exceptions

Simplify the name mapper for cases where no local mappings are present

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/IdentityNameMapper.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NameMapperImpl.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefBuilderFactory.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeValidatorProvider.java

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/IdentityNameMapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/IdentityNameMapper.java?rev=1419342&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/IdentityNameMapper.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/IdentityNameMapper.java
Mon Dec 10 11:08:41 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 java.util.Map;
+
+import javax.annotation.CheckForNull;
+
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.plugins.name.Namespaces;
+
+/**
+ * Name mapper with no local prefix remappings. URI to prefix mappings
+ * are read from the repository when needed.
+ */
+public class IdentityNameMapper implements NameMapper {
+
+    private final Tree root;
+
+    public IdentityNameMapper(Tree root) {
+        this.root = root;
+    }
+
+    @Override @CheckForNull
+    public String getJcrName(String oakName) {
+        assert !oakName.startsWith(":"); // hidden name
+        return oakName;
+    }
+
+    @Override @CheckForNull
+    public String getOakName(String jcrName) {
+        if (jcrName.startsWith("{")) { // Could it be an expanded name?
+            int colon = jcrName.indexOf(':');
+            int brace = jcrName.indexOf('}');
+            if (0 < colon && colon < brace) { // Yes, it looks like one
+                String uri = jcrName.substring(1, brace);
+                String name = jcrName.substring(brace + 1);
+                for (Map.Entry<String, String> entry
+                        : Namespaces.getNamespaceMap(root).entrySet()) {
+                    if (uri.equals(entry.getValue())) {
+                        return entry.getKey() + ':' + name;
+                    }
+                }
+                return null;
+            }
+        }
+
+        return jcrName;
+    }
+
+    @Override
+    public boolean hasSessionLocalMappings() {
+        return false;
+    }
+
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefBuilderFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefBuilderFactory.java?rev=1419342&r1=1419341&r2=1419342&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefBuilderFactory.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefBuilderFactory.java
Mon Dec 10 11:08:41 2012
@@ -23,7 +23,7 @@ import javax.jcr.nodetype.NodeTypeTempla
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory;
 import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.namepath.NameMapperImpl;
+import org.apache.jackrabbit.oak.namepath.IdentityNameMapper;
 import org.apache.jackrabbit.oak.plugins.name.NamespaceConstants;
 import org.apache.jackrabbit.oak.plugins.name.Namespaces;
 
@@ -38,7 +38,7 @@ class DefBuilderFactory extends
 
     @Override
     public NodeTypeTemplateImpl newNodeTypeDefinitionBuilder() {
-        return new NodeTypeTemplateImpl(new NameMapperImpl(root));
+        return new NodeTypeTemplateImpl(new IdentityNameMapper(root));
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeValidatorProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeValidatorProvider.java?rev=1419342&r1=1419341&r2=1419342&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeValidatorProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeValidatorProvider.java
Mon Dec 10 11:08:41 2012
@@ -19,7 +19,7 @@ package org.apache.jackrabbit.oak.plugin
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.jackrabbit.oak.core.ReadOnlyTree;
-import org.apache.jackrabbit.oak.namepath.NameMapperImpl;
+import org.apache.jackrabbit.oak.namepath.IdentityNameMapper;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
@@ -34,7 +34,7 @@ public class TypeValidatorProvider imple
     public Validator getRootValidator(NodeState before, final NodeState after) {
         ReadOnlyNodeTypeManager ntm = new ValidatingNodeTypeManager(after);
         ReadOnlyTree root = new ReadOnlyTree(after);
-        final NamePathMapper mapper = new NamePathMapperImpl(new NameMapperImpl(root));
+        final NamePathMapper mapper = new NamePathMapperImpl(new IdentityNameMapper(root));
         return new TypeValidator(ntm, root, mapper);
     }
 



Mime
View raw message