jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1359696 - in /jackrabbit/oak/trunk/oak-jcr/src/main: java/org/apache/jackrabbit/oak/jcr/nodetype/ resources/org/apache/jackrabbit/oak/jcr/nodetype/
Date Tue, 10 Jul 2012 14:17:56 GMT
Author: reschke
Date: Tue Jul 10 14:17:55 2012
New Revision: 1359696

URL: http://svn.apache.org/viewvc?rev=1359696&view=rev
Log:
OAK-66: decouple CND based NodeTypeManagerDelegate from NamespaceRegistry by restricting it
to well known Oak prefixes

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/resources/org/apache/jackrabbit/oak/jcr/nodetype/builtin_nodetypes.cnd

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerDelegate.java?rev=1359696&r1=1359695&r2=1359696&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerDelegate.java
Tue Jul 10 14:17:55 2012
@@ -21,11 +21,11 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.jcr.NamespaceRegistry;
 import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader;
@@ -34,20 +34,27 @@ import org.apache.jackrabbit.commons.cnd
 import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory.AbstractNodeTypeDefinitionBuilder;
 import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory.AbstractPropertyDefinitionBuilder;
 import org.apache.jackrabbit.commons.cnd.ParseException;
-import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
-import org.apache.jackrabbit.oak.plugins.name.NamespaceRegistryImpl;
 
 public class NodeTypeManagerDelegate {
 
     private final CoreValueFactory cvf;
-    private final NamespaceRegistry nsregistry;
     private final List<NodeTypeDelegate> typeDelegates;
 
-    public NodeTypeManagerDelegate(ContentSession session, CoreValueFactory cvf) throws RepositoryException
{
+    private static final Map<String, String> nsdefaults;
+    static {
+        Map<String, String> tmp = new HashMap<String,String>();
+        tmp.put("rep", "internal"); // TODO: https://issues.apache.org/jira/browse/OAK-74
+        tmp.put("jcr", "http://www.jcp.org/jcr/1.0");
+        tmp.put("nt",  "http://www.jcp.org/jcr/nt/1.0");
+        tmp.put("mix", "http://www.jcp.org/jcr/mix/1.0");
+        tmp.put("xml", "http://www.w3.org/XML/1998/namespace");
+        nsdefaults = Collections.unmodifiableMap(tmp);
+    }
+
+    public NodeTypeManagerDelegate(CoreValueFactory cvf) throws RepositoryException {
         this.cvf = cvf;
-        this.nsregistry = new NamespaceRegistryImpl(session);
 
         try {
             InputStream stream = NodeTypeManagerImpl.class.getResourceAsStream("builtin_nodetypes.cnd");
@@ -88,6 +95,15 @@ public class NodeTypeManagerDelegate {
 
         @Override
         public void setNamespace(String prefix, String uri) throws RepositoryException {
+
+            String t = nsdefaults.get(prefix);
+            if (t == null) {
+                throw new RepositoryException("Unsupported namespace prefix for initial CND
load: " + prefix);
+            }
+            else if (!t.equals(uri)) {
+                throw new RepositoryException("Can't remap namespace prefix for initial CND
laod: " + prefix);
+            }
+
             nsmap.put(prefix, uri);
         }
 
@@ -97,26 +113,7 @@ public class NodeTypeManagerDelegate {
         }
 
         public String convertNameToOak(String cndName) throws RepositoryException {
-            if (cndName == null) {
-                return null;
-            } else {
-                int pos = cndName.indexOf(":");
-                if (pos < 0) {
-                    // no colon
-                    return cndName;
-                } else {
-                    String pref = cndName.substring(0, pos);
-                    String name = cndName.substring(pos + 1);
-                    String ns = nsmap.get(pref);
-
-                    if (ns == null) {
-                        throw new RepositoryException("no namespace defined for prefix "
+ pref);
-                    } else {
-                        String oakprefix = nsregistry.getPrefix(ns);
-                        return oakprefix + ":" + name;
-                    }
-                }
-            }
+            return cndName; // is assumed to be the Oak name for now
         }
 
         public List<String> convertNamesToOak(List<String> cndNames) throws RepositoryException
{

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java?rev=1359696&r1=1359695&r2=1359696&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
Tue Jul 10 14:17:55 2012
@@ -49,7 +49,7 @@ public class NodeTypeManagerImpl impleme
     public NodeTypeManagerImpl(SessionDelegate sd) throws RepositoryException {
         this.vf = sd.getValueFactory();
         this.mapper = sd.getNamePathMapper();
-        this.ntmd = new NodeTypeManagerDelegate(sd.getContentSession(), sd.getValueFactory().getCoreValueFactory());
+        this.ntmd = new NodeTypeManagerDelegate(sd.getValueFactory().getCoreValueFactory());
     }
 
     private void init() {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/resources/org/apache/jackrabbit/oak/jcr/nodetype/builtin_nodetypes.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/resources/org/apache/jackrabbit/oak/jcr/nodetype/builtin_nodetypes.cnd?rev=1359696&r1=1359695&r2=1359696&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/resources/org/apache/jackrabbit/oak/jcr/nodetype/builtin_nodetypes.cnd
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/resources/org/apache/jackrabbit/oak/jcr/nodetype/builtin_nodetypes.cnd
Tue Jul 10 14:17:55 2012
@@ -18,7 +18,7 @@
 <rep='internal'>
 <jcr='http://www.jcp.org/jcr/1.0'>
 <nt='http://www.jcp.org/jcr/nt/1.0'>
-<mixin='http://www.jcp.org/jcr/mix/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
 
 //------------------------------------------------------------------------------
 // B A S E  T Y P E
@@ -43,7 +43,7 @@
  * This abstract node type serves as the supertype of nt:file and nt:folder.
  * @since 1.0
  */
-[nt:hierarchyNode] > mixin:created
+[nt:hierarchyNode] > mix:created
   abstract
 
 /**
@@ -92,7 +92,7 @@
  *
  * @since 1.0
  */
-[nt:resource] > mixin:mimeType, mixin:lastModified, mixin:referenceable
+[nt:resource] > mix:mimeType, mix:lastModified, mix:referenceable
   primaryitem jcr:data
   - jcr:data (BINARY) mandatory
 
@@ -103,7 +103,7 @@
  * Note that the protected attributes suggested by JSR283 are omitted in this variant.
  * @since 2.0
  */
-[mixin:title]
+[mix:title]
   mixin
   - jcr:title (STRING)
   - jcr:description (STRING)
@@ -120,7 +120,7 @@
  *
  * @since 2.0
  */
-[mixin:created]
+[mix:created]
   mixin
   - jcr:created (DATE) autocreated protected
   - jcr:createdBy (STRING) autocreated protected
@@ -142,7 +142,7 @@
  * Note that the protected attributes suggested by JSR283 are omitted in this variant.
  * @since 2.0
  */
-[mixin:lastModified]
+[mix:lastModified]
   mixin
   - jcr:lastModified (DATE) autocreated
   - jcr:lastModifiedBy (STRING) autocreated
@@ -157,7 +157,7 @@
  * Note that the protected attributes suggested by JSR283 are omitted in this variant.
  * @since 2.0
  */
-[mixin:language]
+[mix:language]
   mixin
   - jcr:language (STRING)
 
@@ -174,7 +174,7 @@
  * Note that the protected attributes suggested by JSR283 are omitted in this variant.
  * @since 2.0
  */
-[mixin:mimeType]
+[mix:mimeType]
   mixin
   - jcr:mimeType (STRING)
   - jcr:encoding (STRING)
@@ -221,14 +221,14 @@
   - jcr:id (WEAKREFERENCE)
 
 /**
- * The mixin:etag mixin type defines a standardized identity validator for BINARY 
+ * The mix:etag mixin type defines a standardized identity validator for BINARY 
  * properties similar to the entity tags used in HTTP/1.1
  *
  * A jcr:etag property is an opaque string whose syntax is identical to that
  * defined for entity tags in HTTP/1.1. Semantically, the jcr:etag is comparable
  * to the HTTP/1.1 strong entity tag.
  *
- * On creation of a mixin:etag node N, or assignment of mixin:etag to N, the
+ * On creation of a mix:etag node N, or assignment of mix:etag to N, the
  * repository must create a jcr:etag property with an implementation determined
  * value.
  *
@@ -240,7 +240,7 @@
  *
  * @since 2.0
  */
-[mixin:etag]
+[mix:etag]
   mixin
   - jcr:etag (STRING) protected autocreated
 
@@ -281,7 +281,7 @@
  *
  * @since 1.0
  */
-[mixin:referenceable]
+[mix:referenceable]
   mixin
   - jcr:uuid (STRING) mandatory autocreated protected INITIALIZE 
 
@@ -292,7 +292,7 @@
 /**
  * @since 1.0
  */
-[mixin:lockable]
+[mix:lockable]
   mixin
   - jcr:lockOwner (STRING) protected IGNORE
   - jcr:lockIsDeep (BOOLEAN) protected IGNORE
@@ -304,7 +304,7 @@
 /**
  * @since 2.0
  */
-[mixin:shareable] > mixin:referenceable
+[mix:shareable] > mix:referenceable
   mixin
 
 //------------------------------------------------------------------------------
@@ -314,14 +314,14 @@
 /**
  * @since 2.0
  */
-[mixin:simpleVersionable]
+[mix:simpleVersionable]
   mixin
   - jcr:isCheckedOut (BOOLEAN) = 'true' mandatory autocreated protected IGNORE
 
 /**
  * @since 1.0
  */
-[mixin:versionable] > mixin:simpleVersionable, mixin:referenceable
+[mix:versionable] > mix:simpleVersionable, mix:referenceable
   mixin
   - jcr:versionHistory (REFERENCE) mandatory protected IGNORE < 'nt:versionHistory'
   - jcr:baseVersion (REFERENCE) mandatory protected IGNORE < 'nt:version'
@@ -335,7 +335,7 @@
 /**
  * @since 1.0
  */
-[nt:versionHistory] > mixin:referenceable
+[nt:versionHistory] > mix:referenceable
   - jcr:versionableUuid (STRING) mandatory autocreated protected ABORT
     /** @since 2.0 */
   - jcr:copiedFrom (WEAKREFERENCE) protected ABORT < 'nt:version'
@@ -352,7 +352,7 @@
 /**
  * @since 1.0
  */
-[nt:version] > mixin:referenceable
+[nt:version] > mix:referenceable
   - jcr:created (DATE) mandatory autocreated protected ABORT
   - jcr:predecessors (REFERENCE) protected multiple ABORT < 'nt:version'
   - jcr:successors (REFERENCE) protected multiple ABORT < 'nt:version'
@@ -363,7 +363,7 @@
 /**
  * @since 1.0
  */
-[nt:frozenNode] > mixin:referenceable
+[nt:frozenNode] > mix:referenceable
   orderable
   - jcr:frozenPrimaryType (NAME) mandatory autocreated protected ABORT
   - jcr:frozenMixinTypes (NAME) protected multiple ABORT
@@ -381,13 +381,13 @@
 /**
  * @since 2.0
  */
-[nt:activity] > mixin:referenceable
+[nt:activity] > mix:referenceable
   - jcr:activityTitle (STRING) mandatory autocreated protected
 
 /**
  * @since 2.0
  */
-[nt:configuration] > mixin:versionable
+[nt:configuration] > mix:versionable
   - jcr:root (REFERENCE) mandatory autocreated protected
 
 //------------------------------------------------------------------------------
@@ -469,7 +469,7 @@
 //------------------------------------------------------------------------------
 
 /**
- * Only nodes with mixin node type mixin:lifecycle may participate in a lifecycle.
+ * Only nodes with mixin node type mix:lifecycle may participate in a lifecycle.
  *
  * @peop jcr:lifecyclePolicy
  *              This property is a reference to another node that contains
@@ -481,7 +481,7 @@
  *
  * @since 2.0
  */
-[mixin:lifecycle]
+[mix:lifecycle]
   mixin
   - jcr:lifecyclePolicy (REFERENCE) protected INITIALIZE
   - jcr:currentLifecycleState (STRING) protected INITIALIZE
@@ -591,7 +591,7 @@
 // User Management 
 // -----------------------------------------------------------------------------
 
-[rep:Authorizable] > mixin:referenceable, nt:hierarchyNode
+[rep:Authorizable] > mix:referenceable, nt:hierarchyNode
   abstract
   + * (nt:base) = nt:unstructured VERSION
   - rep:principalName (STRING) protected mandatory



Mime
View raw message