jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r786680 - in /jackrabbit/trunk/jackrabbit-spi-commons/src: main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefReader.java test/resources/cnd-reader-test-input.cnd
Date Fri, 19 Jun 2009 21:53:42 GMT
Author: tripod
Date: Fri Jun 19 21:53:42 2009
New Revision: 786680

URL: http://svn.apache.org/viewvc?rev=786680&view=rev
Log:
JCR-2167 CompactNodeTypeDefReader could auto-provide default namespace mappings if omitted

Modified:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefReader.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/cnd-reader-test-input.cnd

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefReader.java?rev=786680&r1=786679&r2=786680&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefReader.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefReader.java
Fri Jun 19 21:53:42 2009
@@ -124,6 +124,23 @@
 public class CompactNodeTypeDefReader {
 
     /**
+     * Default namespace mappings
+     */
+    public static final NamespaceMapping NS_DEFAULTS;
+    static {
+        try {
+            NS_DEFAULTS = new NamespaceMapping();
+            NS_DEFAULTS.setMapping(Name.NS_EMPTY_PREFIX, Name.NS_DEFAULT_URI);
+            NS_DEFAULTS.setMapping(Name.NS_JCR_PREFIX, Name.NS_JCR_URI);
+            NS_DEFAULTS.setMapping(Name.NS_MIX_PREFIX, Name.NS_MIX_URI);
+            NS_DEFAULTS.setMapping(Name.NS_NT_PREFIX, Name.NS_NT_URI);
+            NS_DEFAULTS.setMapping(Name.NS_REP_PREFIX, Name.NS_REP_URI);
+        } catch (NamespaceException e) {
+            throw new InternalError(e.toString());
+        }
+    }
+    
+    /**
      * the list of parsed QNodeTypeDefinition
      */
     private final List<QNodeTypeDefinition> nodeTypeDefs
@@ -199,7 +216,7 @@
      */
     public CompactNodeTypeDefReader(Reader r, String systemId)
             throws ParseException {
-        this(r, systemId, new NamespaceMapping(), null);
+        this(r, systemId, null, null);
     }
 
     /**
@@ -215,7 +232,7 @@
     public CompactNodeTypeDefReader(Reader r, String systemId,
                                     QNodeTypeDefinitionsBuilder builder)
             throws ParseException {
-        this(r, systemId, new NamespaceMapping(), builder);
+        this(r, systemId, null, builder);
     }
 
     /**
@@ -249,7 +266,9 @@
                 ? new QNodeTypeDefinitionsBuilderImpl()
                 : builder;
         lexer = new Lexer(r, systemId);
-        this.nsMapping = mapping;
+        this.nsMapping = mapping == null
+                ? new NamespaceMapping(NS_DEFAULTS)
+                : mapping;
         this.resolver = new DefaultNamePathResolver(nsMapping);
         nextToken();
         parse();

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/cnd-reader-test-input.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/cnd-reader-test-input.cnd?rev=786680&r1=786679&r2=786680&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/cnd-reader-test-input.cnd (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/cnd-reader-test-input.cnd Fri
Jun 19 21:53:42 2009
@@ -15,10 +15,14 @@
  * limitations under the License.
  */
 <ex = "http://example.org/jackrabbit/example">
-<rep='internal'>
 <jcr='http://www.jcp.org/jcr/1.0'>
 <nt='http://www.jcp.org/jcr/nt/1.0'>
-<mix='http://www.jcp.org/jcr/mix/1.0'>
+
+// test remapping
+<REP='internal'>
+
+// omit this namespace to test auto-registering
+// <mix='http://www.jcp.org/jcr/mix/1.0'>
 
 //------------------------------------------------------------------------------
 // E X A M P L E  T Y P E S
@@ -35,6 +39,8 @@
   
 [ex:Empty]
 
+[NoPrefix]
+
 [ex:Reference]
   - ex:ref (reference) mandatory protected < 'ex:ref'
   
@@ -206,19 +212,19 @@
 // J A C K R A B B I T   I N T E R N A L S
 //------------------------------------------------------------------------------
 
-[rep:nodeTypes]
+[REP:nodeTypes]
   + * (nt:nodeType) = nt:nodeType protected abort
 
-[rep:root] > nt:unstructured
+[REP:root] > nt:unstructured
   orderable
-  + jcr:system (rep:system) = rep:system mandatory ignore
+  + jcr:system (REP:system) = REP:system mandatory ignore
 
-[rep:system]
+[REP:system]
   orderable
-  + jcr:versionStorage (rep:versionStorage) = rep:versionStorage mandatory protected abort
-  + jcr:nodeTypes (rep:nodeTypes) = rep:nodeTypes mandatory protected abort
+  + jcr:versionStorage (REP:versionStorage) = REP:versionStorage mandatory protected abort
+  + jcr:nodeTypes (REP:nodeTypes) = REP:nodeTypes mandatory protected abort
   + * (nt:base) = nt:unstructured multiple ignore
 
-[rep:versionStorage]
+[REP:versionStorage]
   + * (nt:versionHistory) = nt:versionHistory protected multiple abort
-  + * (rep:versionStorage) = rep:versionStorage protected multiple abort
+  + * (REP:versionStorage) = REP:versionStorage protected multiple abort



Mime
View raw message