jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppieg...@apache.org
Subject svn commit: r358028 [1/2] - in /incubator/jackrabbit/trunk/contrib/nt-ns-util: ./ applications/ applications/test/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/...
Date Tue, 20 Dec 2005 16:20:35 GMT
Author: ppiegaze
Date: Tue Dec 20 08:20:16 2005
New Revision: 358028

URL: http://svn.apache.org/viewcvs?rev=358028&view=rev
Log:
added getNamespaceMapping to compact NT importer, added new XSD2NT converter, renamed contrib dir appropriately

Added:
    incubator/jackrabbit/trunk/contrib/nt-ns-util/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/cnd-reader-test-input.cnd
    incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/log4j.properties   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/xsd-converter-model-output.cnd
    incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/xsd-converter-test-input.xsd   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/maven.xml   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/project.properties   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/project.xml   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefWriter.java   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/Lexer.java   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/ParseException.java   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceAdder.java   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceExtractor.java   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceMapping.java   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/nodetype/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/nodetype/SchemaConversionException.java   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/nodetype/SchemaConverter.java   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/test/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/test/java/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/test/java/org/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/test/java/org/apache/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/test/java/org/apache/jackrabbit/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/test/java/org/apache/jackrabbit/core/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/test/java/org/apache/jackrabbit/core/nodetype/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/test/java/org/apache/jackrabbit/core/nodetype/compact/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/test/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefTest.java   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/test/java/org/apache/jackrabbit/core/nodetype/compact/TestAll.java   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/test/java/org/apache/jackrabbit/util/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/test/java/org/apache/jackrabbit/util/nodetype/
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/test/java/org/apache/jackrabbit/util/nodetype/SchemaConverterTest.java   (with props)
    incubator/jackrabbit/trunk/contrib/nt-ns-util/src/test/java/org/apache/jackrabbit/util/nodetype/TestAll.java   (with props)

Added: incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/cnd-reader-test-input.cnd
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/cnd-reader-test-input.cnd?rev=358028&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/cnd-reader-test-input.cnd (added)
+++ incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/cnd-reader-test-input.cnd Tue Dec 20 08:20:16 2005
@@ -0,0 +1,5 @@
+<ex = "http://apache.org/incubator/jackrabbit/example">
+[ex:NodeType] > ex:ParentNodeType1, ex:ParentNodeType2
+  orderable mixin
+  - ex:property (long) = '1', '2' primary mandatory autocreated protected multiple version < '[1,10]'
+  + ex:node (ex:RequiredNodeType1, ex:RequiredNodeType2) = ex:RequiredNodeType1 mandatory autocreated protected multiple version
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/log4j.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/log4j.properties?rev=358028&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/log4j.properties (added)
+++ incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/log4j.properties Tue Dec 20 08:20:16 2005
@@ -0,0 +1,22 @@
+# Set root logger level to DEBUG and its only appender to A1.
+log4j.rootLogger=INFO, file
+#log4j.rootLogger=DEBUG, stdout, file
+#log4j.rootLogger=ERROR, stdout, file
+
+log4j.logger.org.apache.jackrabbit.test=DEBUG
+log4j.logger.org.apache.jackrabbit.core.state.bdb=DEBUG
+
+# 'stdout' is set to be a ConsoleAppender.
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+
+# 'stdout' uses PatternLayout
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L)\n
+
+# 'file' is set to be a FileAppender.
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.File=jcr.log
+
+# 'file' uses PatternLayout.
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L)\n

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/xsd-converter-model-output.cnd
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/xsd-converter-model-output.cnd?rev=358028&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/xsd-converter-model-output.cnd (added)
+++ incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/xsd-converter-model-output.cnd Tue Dec 20 08:20:16 2005
@@ -0,0 +1,45 @@
+[bookType]
+  - id
+  - available (Boolean)
+  - isbn mandatory
+  + title (titleType) = titleType mandatory
+  + authors (authorsType) = authorsType mandatory
+  + characters (charactersType) = charactersType mandatory
+
+[authorType]
+  - id
+  - name mandatory
+  - born (Date) mandatory
+  - dead (Date)
+
+[xs:anyType]
+  orderable
+  - * (undefined)
+  + *
+  + jcr:xmltext (jcr:Xmltext) = jcr:Xmltext multiple
+
+[authorsType]
+  orderable
+  + author (authorType) = authorType multiple
+
+[characterType]
+  - id
+  - name mandatory
+  - born (Date) mandatory
+  - qualification mandatory
+
+[jcr:Xmltext]
+  - jcr:xmlcharacters
+
+[titleType]
+  - lang
+  - jcr:xmlContent
+
+[libraryType]
+  orderable
+  + book (bookType) = bookType mandatory multiple
+
+[charactersType]
+  orderable
+  + character (characterType) = characterType multiple
+

Added: incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/xsd-converter-test-input.xsd
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/xsd-converter-test-input.xsd?rev=358028&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/xsd-converter-test-input.xsd (added)
+++ incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/xsd-converter-test-input.xsd Tue Dec 20 08:20:16 2005
@@ -0,0 +1,73 @@
+<?xml version="1.0"?> 
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+  <xs:element name="name" type="xs:token"/>
+  <xs:element name="qualification" type="xs:token"/>
+  <xs:element name="born" type="xs:date"/>
+  <xs:element name="dead" type="xs:date"/>
+  <xs:element name="isbn" type="xs:NMTOKEN"/>
+  <xs:attribute name="id" type="xs:ID"/>
+  <xs:attribute name="available" type="xs:boolean"/>
+  <xs:attribute name="lang" type="xs:language"/>
+  <xs:element name="title">
+    <xs:complexType>
+      <xs:simpleContent>
+        <xs:extension base="xs:token">
+          <xs:attribute ref="lang"/>
+        </xs:extension>
+      </xs:simpleContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="library">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element ref="book" maxOccurs="unbounded"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="authors">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element ref="author" minOccurs="0" maxOccurs="unbounded"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="author">
+    <xs:complexType>
+      <xs:all>
+        <xs:element ref="name"/>
+        <xs:element ref="born"/>
+        <xs:element ref="dead" minOccurs="0"/>
+      </xs:all>
+      <xs:attribute ref="id"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="book">
+    <xs:complexType>
+      <xs:all>
+        <xs:element ref="isbn"/>
+        <xs:element ref="title"/>
+        <xs:element ref="authors"/>
+        <xs:element ref="characters"/>
+      </xs:all>
+      <xs:attribute ref="id"/>
+      <xs:attribute ref="available"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="characters">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element ref="character" minOccurs="0" maxOccurs="unbounded"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="character">
+    <xs:complexType>
+      <xs:all>
+        <xs:element ref="name"/>
+        <xs:element ref="born"/>
+        <xs:element ref="qualification"/>
+      </xs:all>
+      <xs:attribute ref="id"/>
+    </xs:complexType>
+  </xs:element>
+</xs:schema>
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/applications/test/xsd-converter-test-input.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/nt-ns-util/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/nt-ns-util/maven.xml?rev=358028&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/nt-ns-util/maven.xml (added)
+++ incubator/jackrabbit/trunk/contrib/nt-ns-util/maven.xml Tue Dec 20 08:20:16 2005
@@ -0,0 +1,23 @@
+<!--
+   Copyright 2004-2005 The Apache Software Foundation or its licensors,
+                       as applicable.
+
+   Licensed 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.
+-->
+<project
+    default="jar:jar"
+    xmlns:deploy="deploy"
+    xmlns:j="jelly:core"
+    xmlns:ant="jelly:ant"
+    xmlns:maven="jelly:maven">
+</project>
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/maven.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/nt-ns-util/project.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/nt-ns-util/project.properties?rev=358028&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/nt-ns-util/project.properties (added)
+++ incubator/jackrabbit/trunk/contrib/nt-ns-util/project.properties Tue Dec 20 08:20:16 2005
@@ -0,0 +1,106 @@
+#  Copyright 2003-2005 The Apache Software Foundation or its licensors,
+#                      as applicable
+#
+#  Licensed 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.
+
+######################################################################
+# Apache Central Repository
+######################################################################
+maven.repo.central=www.apache.org
+maven.repo.central.directory=/www/www.apache.org/dist/java-repository
+maven.remote.group=apcvs
+maven.changelog.factory = org.apache.maven.svnlib.SvnChangeLogFactory
+
+######################################################################
+# JUnit Testing
+######################################################################
+maven.test.failure = false
+maven.junit.fork=true
+#maven.junit.sysproperties=org.xml.sax.driver java.security.auth.login.config
+maven.junit.sysproperties=org.xml.sax.driver
+org.xml.sax.driver=org.apache.xerces.parsers.SAXParser
+#java.security.auth.login.config=applications/test/jaas.config
+
+
+#If you wish to skip tests when doing builds, uncomment
+#maven.test.skip = true
+
+######################################################################
+# Checkstyle
+######################################################################
+maven.checkstyle.properties= checkstyle.xml
+maven.linkcheck.enable=false 
+
+######################################################################
+# JavaDoc
+#
+# javadoc urls can be added here, multiple urls are appended using a comma
+#
+# maven.javadoc.links = http://foo/bar/api,\
+#                       http://flim/flam/api/
+######################################################################
+maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/,http://www.day.com/maven/jsr170/javadocs/jcr-0.16.4.1/
+maven.javadoc.author=false
+maven.javadoc.version=false
+
+######################################################################
+# Other opts
+######################################################################
+# uncomment the next line to work in offline mode (no jar download & no linkcheck)
+#maven.mode.online=
+
+maven.compile.debug=on
+maven.compile.deprecation=off
+maven.compile.optimize=off
+maven.compile.source=1.4
+maven.compile.target=1.4
+
+maven.jarResources.basedir=src/java
+maven.jar.excludes=**/package.html
+
+# Location of the generated query language parsers. Needed for
+# the Maven Eclipse plugin to automatically locate the generated
+# source files. Note that this value matches the hardcoded path
+# in the Maven JavaCC plugin. Therefore, do not change this value!
+maven.gen.src=${maven.build.dir}/generated-src/main
+
+# specifying additional remote repository for downloading dependencies 
+# not available at www.ibiblio.org/maven/
+maven.repo.remote = http://www.ibiblio.org/maven/,http://www.day.com/maven/
+
+######################################################################
+# Site L&F
+######################################################################
+# maven.xdoc.jsl=
+maven.xdoc.date=
+maven.xdoc.poweredby.image=maven-feather.png
+maven.xdoc.version=${pom.currentVersion}
+maven.xdoc.developmentProcessUrl=http://incubator.apache.org/projects/jackrabbit.html
+maven.changelog.range=60
+maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory
+maven.multiproject.overviewPage.title=Jackrabbit components
+
+# ------------------------------------------------------------------------
+# M A V E N  J A R  O V E R R I D E
+# ------------------------------------------------------------------------
+#maven.jar.override = on
+#maven.jar.jcr = ${basedir}/lib/jcr.jar
+
+######################################################################
+# Site Deploy (into ../jackrabbit-site for checkout on incubator.apache.org)
+######################################################################
+maven.site.deploy.method=fs
+
+# IDE settings
+maven.eclipse.resources.addtoclasspath=true
+

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/project.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/nt-ns-util/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/nt-ns-util/project.xml?rev=358028&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/nt-ns-util/project.xml (added)
+++ incubator/jackrabbit/trunk/contrib/nt-ns-util/project.xml Tue Dec 20 08:20:16 2005
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+    <pomVersion>3</pomVersion>
+    <groupId>org.apache.jackrabbit</groupId>
+    <artifactId>nt-ns-util</artifactId>
+    <name>JCR Node Type and Namespace Utilities</name>
+    <currentVersion>1.0-SNAPSHOT</currentVersion>
+    <organization>
+        <name>The Apache Software Foundation</name>
+        <url>http://incubator.apache.org/projects/jackrabbit.html</url>
+        <logo>http://incubator.apache.org/images/apache-incubator-logo.png</logo>
+    </organization>
+    <inceptionYear>2005</inceptionYear>
+    <package>org.apache.jackrabbit.core.nodetype.compact</package>
+    <package>org.apache.jackrabbit.util.nodetype</package>
+    <package>org.apache.jackrabbit.util.name</package>
+    <description>JCR Node Type and Namespace Utilities</description>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-commons</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>concurrent</groupId>
+            <artifactId>concurrent</artifactId>
+            <version>1.3.4</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <properties>
+                <scope>test</scope>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-jta</artifactId>
+            <version>1.0-M1</version>
+        </dependency>
+        <dependency>
+            <groupId>jsr170</groupId>
+            <artifactId>jcr</artifactId>
+            <version>1.0</version>
+            <url>http://jcp.org/en/jsr/detail?id=170</url>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.8</version>
+        </dependency>
+        <dependency>
+            <groupId>lucene</groupId>
+            <artifactId>lucene</artifactId>
+            <version>1.4.3</version>
+        </dependency>
+        <dependency>
+            <groupId>xerces</groupId>
+            <artifactId>xercesImpl</artifactId>
+            <version>2.6.2</version>
+        </dependency>
+        <dependency>
+            <groupId>xerces</groupId>
+            <artifactId>xmlParserAPIs</artifactId>
+            <version>2.0.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>10.1.1.0</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <sourceDirectory>src/main/java</sourceDirectory>
+        <unitTestSourceDirectory>src/test/java</unitTestSourceDirectory>
+        <unitTest>
+            <includes>
+                <include>**/*TestAll.java</include>
+            </includes>
+            <excludes>
+                <exclude>**/init/*</exclude>
+            </excludes>
+            <resources>
+                <resource>
+                    <directory>applications/test</directory>
+                    <includes>
+                        <include>*.properties</include>
+                        <include>*.xml</include>
+                        <include>*.cnd</include>
+                        <include>*.xsd</include>
+                    </includes>
+                </resource>
+                <resource>
+                    <directory>src/test/java</directory>
+                    <includes>
+                        <include>**/*.xml</include>
+                        <include>**/*.txt</include>
+                    </includes>
+                </resource>
+            </resources>
+        </unitTest>
+    </build>
+</project>
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/project.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java?rev=358028&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java (added)
+++ incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java Tue Dec 20 08:20:16 2005
@@ -0,0 +1,694 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.core.nodetype.compact;
+
+import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
+import org.apache.jackrabbit.core.nodetype.PropDefImpl;
+import org.apache.jackrabbit.core.nodetype.NodeDefImpl;
+import org.apache.jackrabbit.core.nodetype.ItemDef;
+import org.apache.jackrabbit.core.nodetype.NodeDef;
+import org.apache.jackrabbit.core.nodetype.PropDef;
+import org.apache.jackrabbit.core.nodetype.ValueConstraint;
+import org.apache.jackrabbit.core.nodetype.InvalidConstraintException;
+import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.NoPrefixDeclaredException;
+import org.apache.jackrabbit.name.IllegalNameException;
+import org.apache.jackrabbit.name.UnknownPrefixException;
+import org.apache.jackrabbit.util.name.NamespaceMapping;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+import javax.jcr.version.OnParentVersionAction;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.HashSet;
+import java.util.Arrays;
+
+/**
+ * CompactNodeTypeDefReader. Parses node type definitions written in the compact
+ * node type definition format and returns a list of NodeTypeDef objects that
+ * can then be used to register node types.
+ * <p/>
+ * The BNF grammar of the compact node type definition:<br>
+ * <pre>
+ * cnd ::= {ns_mapping | node_type_def}
+ *
+ * ns_mapping ::= "&lt;" prefix "=" namespace "&gt;"
+ *
+ * prefix ::= string
+ *
+ * namespace ::= string
+ *
+ * node_type_def ::= node_type_name [super_types] [options] {property_def | node_def}
+ *
+ * node_type_name ::= "[" string "]"
+ *
+ * super_types ::= "&gt;" string_list
+ *
+ * options ::= orderable_opt | mixin_opt | orderable_opt mixin_opt | mixin_opt orderable_opt
+ *
+ * orderable_opt ::= "orderable" | "ord" | "o"
+ *
+ * mixin_opt ::= "mixin" | "mix" | "m"
+ *
+ * property_def ::= "-" property_name [property_type_decl] [default_values] [attributes] [value_constraints]
+ *
+ * property_name ::= string
+ *
+ * property_type_decl ::= "(" property_type ")"
+ *
+ * property_type ::= "STRING" | "String |"string" |
+ *                   "BINARY" | "Binary" | "binary" |
+ *                   "LONG" | "Long" | "long" |
+ *                   "DOUBLE" | "Double" | "double" |
+ *                   "BOOLEAN" | "Boolean" | "boolean" |
+ *                   "DATE" | "Date" | "date" |
+ *                   "NAME | "Name | "name |
+ *                   "PATH" | "Path" | "path" |
+ *                   "REFERENCE" | "Reference" | "reference" |
+ *                   "UNDEFINED" | "Undefined" | "undefined" | "*"
+ *
+ *
+ * default_values ::= "=" string_list
+ *
+ * value_constraints ::= "&lt;" string_list
+ *
+ * node_def ::= "+" node_name [required_types] [default_type] [attributes]
+ *
+ * node_name ::= string
+ *
+ * required_types ::= "(" string_list ")"
+ *
+ * default_type ::= "=" string
+ *
+ * attributes ::= "primary" | "pri" | "!" |
+ *                "autocreated" | "aut" | "a" |
+ *                "mandatory" | "man" | "m" |
+ *                "protected" | "pro" | "p" |
+ *                "multiple" | "mul" | "*" |
+ *                "COPY" | "Copy" | "copy" |
+ *                "VERSION" | "Version" | "version" |
+ *                "INITIALIZE" | "Initialize" | "initialize" |
+ *                "COMPUTE" | "Compute" | "compute" |
+ *                "IGNORE" | "Ignore" | "ignore" |
+ *                "ABORT" | "Abort" | "abort"
+ *
+ * string_list ::= string {"," string}
+ *
+ * string ::= quoted_string | unquoted_string
+ *
+ * quoted_string :: = "'" unquoted_string "'"
+ *
+ * unquoted_string ::= ...a string...
+ * </pre>
+ */
+public class CompactNodeTypeDefReader {
+
+    /**
+     * the list of parsed nodetype defs
+     */
+    private List nodeTypeDefs = new LinkedList();
+
+    /**
+     * the current namespace mapping
+     */
+    private NamespaceMapping nsMapping;
+
+    /**
+     * the underlying lexer
+     */
+    private Lexer lexer;
+
+    /**
+     * the current token
+     */
+    private String currentToken;
+
+    /**
+     * Creates a new CND reader.
+     *
+     * @param r
+     * @throws ParseException
+     */
+    public CompactNodeTypeDefReader(Reader r, String systemId) throws ParseException {
+        this(r, systemId, new NamespaceMapping());
+    }
+
+
+    /**
+     * Creates a new CND reader.
+     *
+     * @param r
+     * @throws ParseException
+     */
+    public CompactNodeTypeDefReader(Reader r, String systemId, NamespaceMapping mapping)
+            throws ParseException {
+        lexer = new Lexer(r, systemId);
+        this.nsMapping = mapping;
+        nextToken();
+        parse();
+    }
+
+    /**
+     * Returns the list of parsed nodetype definitions.
+     *
+     * @return a List of NodeTypeDef objects
+     */
+    public List getNodeTypeDefs() {
+        return nodeTypeDefs;
+    }
+
+    /**
+     * Returns the namespace mapping.
+     *
+     * @return a NamespaceMapping object.
+     */
+    public NamespaceMapping getNamespaceMapping() {
+        return nsMapping;
+    }
+
+    /**
+     * Parses the definition
+     *
+     * @throws ParseException
+     */
+    private void parse() throws ParseException {
+        while (!currentTokenEquals(Lexer.EOF)) {
+            if (doNameSpace()) {
+                continue;
+            }
+            NodeTypeDef ntd = new NodeTypeDef();
+            ntd.setOrderableChildNodes(false);
+            ntd.setMixin(false);
+            ntd.setPrimaryItemName(null);
+            doNodeTypeName(ntd);
+            doSuperClasses(ntd);
+            doOptions(ntd);
+            // add nt:base to superclasses if not mixin
+            if (!ntd.isMixin()) {
+                HashSet superTypes = new HashSet(Arrays.asList(ntd.getSupertypes()));
+                if (!superTypes.contains(QName.NT_BASE)) {
+                    superTypes.add(QName.NT_BASE);
+                    ntd.setSupertypes((QName[]) superTypes.toArray(new QName[superTypes.size()]));
+                }
+            }
+            doItemDefs(ntd);
+            nodeTypeDefs.add(ntd);
+        }
+    }
+
+    /**
+     * processes the namespace declaration
+     *
+     * @return
+     * @throws ParseException
+     */
+    private boolean doNameSpace() throws ParseException {
+        if (!currentTokenEquals('<')) {
+            return false;
+        }
+        nextToken();
+        String prefix = currentToken;
+        nextToken();
+        if (!currentTokenEquals('=')) {
+            lexer.fail("Missing = in namespace decl.");
+        }
+        nextToken();
+        String uri = currentToken;
+        nextToken();
+        if (!currentTokenEquals('>')) {
+            lexer.fail("Missing > in namespace decl.");
+        }
+        try {
+            nsMapping.setMapping(prefix, uri);
+        } catch (NamespaceException e) {
+            // ignore
+        }
+        nextToken();
+        return true;
+    }
+
+    /**
+     * processes the nodetype name
+     *
+     * @param ntd
+     * @throws ParseException
+     */
+    private void doNodeTypeName(NodeTypeDef ntd) throws ParseException {
+        if (!currentTokenEquals(Lexer.BEGIN_NODE_TYPE_NAME)) {
+            lexer.fail("Missing '" + Lexer.BEGIN_NODE_TYPE_NAME + "' delimiter for beginning of node type name");
+        }
+        nextToken();
+        ntd.setName(toQName(currentToken));
+
+        nextToken();
+        if (!currentTokenEquals(Lexer.END_NODE_TYPE_NAME)) {
+            lexer.fail("Missing '" + Lexer.END_NODE_TYPE_NAME + "' delimiter for end of node type name");
+        }
+        nextToken();
+    }
+
+    /**
+     * processes the superclasses
+     *
+     * @param ntd
+     * @throws ParseException
+     */
+    private void doSuperClasses(NodeTypeDef ntd) throws ParseException {
+        List supertypes = new ArrayList();
+        if (!currentTokenEquals(Lexer.EXTENDS)) {
+            return;
+        }
+        do {
+            nextToken();
+            supertypes.add(toQName(currentToken));
+            nextToken();
+        } while (currentTokenEquals(Lexer.LIST_DELIMITER));
+        ntd.setSupertypes((QName[]) supertypes.toArray(new QName[0]));
+    }
+
+    /**
+     * processes the options
+     *
+     * @param ntd
+     * @throws ParseException
+     */
+    private void doOptions(NodeTypeDef ntd) throws ParseException {
+        if (currentTokenEquals(Lexer.ORDERABLE)) {
+            ntd.setOrderableChildNodes(true);
+            nextToken();
+            if (currentTokenEquals(Lexer.MIXIN)) {
+                ntd.setMixin(true);
+                nextToken();
+            }
+        } else if (currentTokenEquals(Lexer.MIXIN)) {
+            ntd.setMixin(true);
+            nextToken();
+            if (currentTokenEquals(Lexer.ORDERABLE)) {
+                ntd.setMixin(true);
+                nextToken();
+            }
+        }
+    }
+
+    /**
+     * processes the item definitions
+     *
+     * @param ntd
+     * @throws ParseException
+     */
+    private void doItemDefs(NodeTypeDef ntd) throws ParseException {
+        List propertyDefinitions = new ArrayList();
+        List nodeDefinitions = new ArrayList();
+        while (currentTokenEquals(Lexer.PROPERTY_DEFINITION) || currentTokenEquals(Lexer.CHILD_NODE_DEFINITION)) {
+            if (currentTokenEquals(Lexer.PROPERTY_DEFINITION)) {
+                PropDefImpl pdi = new PropDefImpl();
+
+                pdi.setAutoCreated(false);
+                pdi.setDeclaringNodeType(ntd.getName());
+                pdi.setDefaultValues(null);
+                pdi.setMandatory(false);
+                pdi.setMultiple(false);
+                pdi.setOnParentVersion(OnParentVersionAction.COPY);
+                pdi.setProtected(false);
+                pdi.setRequiredType(PropertyType.STRING);
+                pdi.setValueConstraints(null);
+
+                nextToken();
+                doPropertyDefinition(pdi, ntd);
+                propertyDefinitions.add(pdi);
+
+            } else if (currentTokenEquals(Lexer.CHILD_NODE_DEFINITION)) {
+                NodeDefImpl ndi = new NodeDefImpl();
+
+                ndi.setAllowsSameNameSiblings(false);
+                ndi.setAutoCreated(false);
+                ndi.setDeclaringNodeType(ntd.getName());
+                ndi.setMandatory(false);
+                ndi.setOnParentVersion(OnParentVersionAction.COPY);
+                ndi.setProtected(false);
+                ndi.setDefaultPrimaryType(null);
+                ndi.setRequiredPrimaryTypes(new QName[]{QName.NT_BASE});
+
+                nextToken();
+                doChildNodeDefinition(ndi, ntd);
+                nodeDefinitions.add(ndi);
+            }
+        }
+
+        if (propertyDefinitions.size() > 0) {
+            ntd.setPropertyDefs((PropDef[]) propertyDefinitions.toArray(new PropDef[0]));
+        }
+
+        if (nodeDefinitions.size() > 0) {
+            ntd.setChildNodeDefs((NodeDef[]) nodeDefinitions.toArray(new NodeDef[0]));
+        }
+    }
+
+    /**
+     * processes the property definition
+     *
+     * @param pdi
+     * @param ntd
+     * @throws ParseException
+     */
+    private void doPropertyDefinition(PropDefImpl pdi, NodeTypeDef ntd)
+            throws ParseException {
+        if (currentToken.equals("*")) {
+            pdi.setName(ItemDef.ANY_NAME);
+        } else {
+            pdi.setName(toQName(currentToken));
+        }
+        nextToken();
+        doPropertyType(pdi);
+        doPropertyDefaultValue(pdi);
+        doPropertyAttributes(pdi, ntd);
+        doPropertyValueConstraints(pdi);
+    }
+
+    /**
+     * processes the property type
+     *
+     * @param pdi
+     * @throws ParseException
+     */
+    private void doPropertyType(PropDefImpl pdi) throws ParseException {
+        if (!currentTokenEquals(Lexer.BEGIN_TYPE)) {
+            return;
+        }
+        nextToken();
+        if (currentTokenEquals(Lexer.STRING)) {
+            pdi.setRequiredType(PropertyType.STRING);
+        } else if (currentTokenEquals(Lexer.BINARY)) {
+            pdi.setRequiredType(PropertyType.BINARY);
+        } else if (currentTokenEquals(Lexer.LONG)) {
+            pdi.setRequiredType(PropertyType.LONG);
+        } else if (currentTokenEquals(Lexer.DOUBLE)) {
+            pdi.setRequiredType(PropertyType.DOUBLE);
+        } else if (currentTokenEquals(Lexer.BOOLEAN)) {
+            pdi.setRequiredType(PropertyType.BOOLEAN);
+        } else if (currentTokenEquals(Lexer.DATE)) {
+            pdi.setRequiredType(PropertyType.DATE);
+        } else if (currentTokenEquals(Lexer.NAME)) {
+            pdi.setRequiredType(PropertyType.NAME);
+        } else if (currentTokenEquals(Lexer.PATH)) {
+            pdi.setRequiredType(PropertyType.PATH);
+        } else if (currentTokenEquals(Lexer.REFERENCE)) {
+            pdi.setRequiredType(PropertyType.REFERENCE);
+        } else if (currentTokenEquals(Lexer.UNDEFINED)) {
+            pdi.setRequiredType(PropertyType.UNDEFINED);
+        } else {
+            lexer.fail("Unkown property type '" + currentToken + "' specified");
+        }
+        nextToken();
+        if (!currentTokenEquals(Lexer.END_TYPE)) {
+            lexer.fail("Missing '" + Lexer.END_TYPE + "' delimiter for end of property type");
+        }
+        nextToken();
+    }
+
+    /**
+     * processes the property attributes
+     *
+     * @param pdi
+     * @param ntd
+     * @throws ParseException
+     */
+    private void doPropertyAttributes(PropDefImpl pdi, NodeTypeDef ntd) throws ParseException {
+        while (currentTokenEquals(Lexer.ATTRIBUTE)) {
+            if (currentTokenEquals(Lexer.PRIMARY)) {
+                if (ntd.getPrimaryItemName() != null) {
+                    String name = null;
+                    try {
+                        name = nsMapping.getJCRName(ntd.getName());
+                    } catch (NoPrefixDeclaredException e) {
+                        // Should never happen, checked earlier
+                    }
+                    lexer.fail("More than one primary item specified in node type '" + name + "'");
+                }
+                ntd.setPrimaryItemName(pdi.getName());
+            } else if (currentTokenEquals(Lexer.AUTOCREATED)) {
+                pdi.setAutoCreated(true);
+            } else if (currentTokenEquals(Lexer.MANDATORY)) {
+                pdi.setMandatory(true);
+            } else if (currentTokenEquals(Lexer.PROTECTED)) {
+                pdi.setProtected(true);
+            } else if (currentTokenEquals(Lexer.MULTIPLE)) {
+                pdi.setMultiple(true);
+            } else if (currentTokenEquals(Lexer.COPY)) {
+                pdi.setOnParentVersion(OnParentVersionAction.COPY);
+            } else if (currentTokenEquals(Lexer.VERSION)) {
+                pdi.setOnParentVersion(OnParentVersionAction.VERSION);
+            } else if (currentTokenEquals(Lexer.INITIALIZE)) {
+                pdi.setOnParentVersion(OnParentVersionAction.INITIALIZE);
+            } else if (currentTokenEquals(Lexer.COMPUTE)) {
+                pdi.setOnParentVersion(OnParentVersionAction.COMPUTE);
+            } else if (currentTokenEquals(Lexer.IGNORE)) {
+                pdi.setOnParentVersion(OnParentVersionAction.IGNORE);
+            } else if (currentTokenEquals(Lexer.ABORT)) {
+                pdi.setOnParentVersion(OnParentVersionAction.ABORT);
+            }
+            nextToken();
+        }
+    }
+
+    /**
+     * processes the property default values
+     *
+     * @param pdi
+     * @throws ParseException
+     */
+    private void doPropertyDefaultValue(PropDefImpl pdi) throws ParseException {
+        if (!currentTokenEquals(Lexer.DEFAULT)) {
+            return;
+        }
+        List defaultValues = new ArrayList();
+        do {
+            nextToken();
+            InternalValue value = null;
+            try {
+                value = InternalValue.create(currentToken, pdi.getRequiredType(), nsMapping);
+            } catch (ValueFormatException e) {
+                lexer.fail("'" + currentToken + "' is not a valid string representation of a value of type " + pdi.getRequiredType());
+            } catch (RepositoryException e) {
+                lexer.fail("An error occured during value conversion of '" + currentToken + "'");
+            }
+            defaultValues.add(value);
+            nextToken();
+        } while (currentTokenEquals(Lexer.LIST_DELIMITER));
+        pdi.setDefaultValues((InternalValue[]) defaultValues.toArray(new InternalValue[0]));
+    }
+
+    /**
+     * processes the property value constraints
+     *
+     * @param pdi
+     * @throws ParseException
+     */
+    private void doPropertyValueConstraints(PropDefImpl pdi) throws ParseException {
+        if (!currentTokenEquals(Lexer.CONSTRAINT)) {
+            return;
+        }
+        List constraints = new ArrayList();
+        do {
+            nextToken();
+            ValueConstraint constraint = null;
+            try {
+                constraint = ValueConstraint.create(pdi.getRequiredType(), currentToken, nsMapping);
+            } catch (InvalidConstraintException e) {
+                lexer.fail("'" + currentToken + "' is not a valid constraint expression for a value of type " + pdi.getRequiredType());
+            }
+            constraints.add(constraint);
+            nextToken();
+        } while (currentTokenEquals(Lexer.LIST_DELIMITER));
+        pdi.setValueConstraints((ValueConstraint[]) constraints.toArray(new ValueConstraint[0]));
+    }
+
+    /**
+     * processes the childnode definition
+     *
+     * @param ndi
+     * @param ntd
+     * @throws ParseException
+     */
+    private void doChildNodeDefinition(NodeDefImpl ndi, NodeTypeDef ntd)
+            throws ParseException {
+        if (currentTokenEquals('*')) {
+            ndi.setName(ItemDef.ANY_NAME);
+        } else {
+            ndi.setName(toQName(currentToken));
+        }
+        nextToken();
+        doChildNodeRequiredTypes(ndi);
+        doChildNodeDefaultType(ndi);
+        doChildNodeAttributes(ndi, ntd);
+    }
+
+    /**
+     * processes the childnode required types
+     *
+     * @param ndi
+     * @throws ParseException
+     */
+    private void doChildNodeRequiredTypes(NodeDefImpl ndi) throws ParseException {
+        if (!currentTokenEquals(Lexer.BEGIN_TYPE)) {
+            return;
+        }
+        List types = new ArrayList();
+        do {
+            nextToken();
+            types.add(toQName(currentToken));
+            nextToken();
+        } while (currentTokenEquals(Lexer.LIST_DELIMITER));
+        ndi.setRequiredPrimaryTypes((QName[]) types.toArray(new QName[0]));
+        nextToken();
+    }
+
+    /**
+     * processes the childnode default types
+     *
+     * @param ndi
+     * @throws ParseException
+     */
+    private void doChildNodeDefaultType(NodeDefImpl ndi) throws ParseException {
+        if (!currentTokenEquals(Lexer.DEFAULT)) {
+            return;
+        }
+        nextToken();
+        ndi.setDefaultPrimaryType(toQName(currentToken));
+        nextToken();
+    }
+
+    /**
+     * processes the childnode attributes
+     *
+     * @param ndi
+     * @param ntd
+     * @throws ParseException
+     */
+    private void doChildNodeAttributes(NodeDefImpl ndi, NodeTypeDef ntd) throws ParseException {
+        while (currentTokenEquals(Lexer.ATTRIBUTE)) {
+            if (currentTokenEquals(Lexer.PRIMARY)) {
+                if (ntd.getPrimaryItemName() != null) {
+                    String name = null;
+                    try {
+                        name = nsMapping.getJCRName(ntd.getName());
+                    } catch (NoPrefixDeclaredException e) {
+                        // Should never happen, checked earlier
+                    }
+                    lexer.fail("More than one primary item specified in node type '" + name + "'");
+                }
+                ntd.setPrimaryItemName(ndi.getName());
+            } else if (currentTokenEquals(Lexer.AUTOCREATED)) {
+                ndi.setAutoCreated(true);
+            } else if (currentTokenEquals(Lexer.MANDATORY)) {
+                ndi.setMandatory(true);
+            } else if (currentTokenEquals(Lexer.PROTECTED)) {
+                ndi.setProtected(true);
+            } else if (currentTokenEquals(Lexer.MULTIPLE)) {
+                ndi.setAllowsSameNameSiblings(true);
+            } else if (currentTokenEquals(Lexer.COPY)) {
+                ndi.setOnParentVersion(OnParentVersionAction.COPY);
+            } else if (currentTokenEquals(Lexer.VERSION)) {
+                ndi.setOnParentVersion(OnParentVersionAction.VERSION);
+            } else if (currentTokenEquals(Lexer.INITIALIZE)) {
+                ndi.setOnParentVersion(OnParentVersionAction.INITIALIZE);
+            } else if (currentTokenEquals(Lexer.COMPUTE)) {
+                ndi.setOnParentVersion(OnParentVersionAction.COMPUTE);
+            } else if (currentTokenEquals(Lexer.IGNORE)) {
+                ndi.setOnParentVersion(OnParentVersionAction.IGNORE);
+            } else if (currentTokenEquals(Lexer.ABORT)) {
+                ndi.setOnParentVersion(OnParentVersionAction.ABORT);
+            }
+            nextToken();
+        }
+    }
+
+    /**
+     * Converts the given string into a qualified name using the current
+     * namespace mapping.
+     *
+     * @param stringName
+     * @return the qualified name
+     * @throws ParseException if the conversion fails
+     */
+    private QName toQName(String stringName) throws ParseException {
+        try {
+            return QName.fromJCRName(stringName, nsMapping);
+        } catch (IllegalNameException e) {
+            lexer.fail("Error while parsing '" + stringName + "'", e);
+            return null;
+        } catch (UnknownPrefixException e) {
+            lexer.fail("Error while parsing '" + stringName + "'", e);
+            return null;
+        }
+    }
+
+    /**
+     * Gets the next token from the underlying lexer.
+     *
+     * @see Lexer#getNextToken()
+     * @throws ParseException if the lexer fails to get the next token.
+     */
+    private void nextToken() throws ParseException {
+        currentToken = lexer.getNextToken();
+    }
+
+    /**
+     * Checks if the {@link #currentToken} is semantically equal to the given
+     * argument.
+     *
+     * @param s the tokens to compare with
+     * @return <code>true</code> if equals; <code>false</code> otherwise.
+     */
+    private boolean currentTokenEquals(String[] s) {
+        for (int i = 0; i < s.length; i++) {
+            if (currentToken.equals(s[i])) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Checks if the {@link #currentToken} is semantically equal to the given
+     * argument.
+     *
+     * @param c the tokens to compare with
+     * @return <code>true</code> if equals; <code>false</code> otherwise.
+     */
+    private boolean currentTokenEquals(char c) {
+        return currentToken.length() == 1 && currentToken.charAt(0) == c;
+    }
+
+    /**
+     * Checks if the {@link #currentToken} is semantically equal to the given
+     * argument.
+     *
+     * @param s the tokens to compare with
+     * @return <code>true</code> if equals; <code>false</code> otherwise.
+     */
+    private boolean currentTokenEquals(String s) {
+        return currentToken.equals(s);
+    }
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefWriter.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefWriter.java?rev=358028&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefWriter.java (added)
+++ incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefWriter.java Tue Dec 20 08:20:16 2005
@@ -0,0 +1,389 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.core.nodetype.compact;
+
+import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
+import org.apache.jackrabbit.core.nodetype.PropDef;
+import org.apache.jackrabbit.core.nodetype.NodeDef;
+import org.apache.jackrabbit.core.nodetype.ValueConstraint;
+import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.name.QName;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.version.OnParentVersionAction;
+import java.io.Writer;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * Prints node type defs in a compact notation
+ * Print Format:
+ * <ex = "http://apache.org/jackrabbit/example">
+ * [ex:NodeType] > ex:ParentType1, ex:ParentType2
+ * orderable mixin
+ *   - ex:property (STRING) = 'default1', 'default2'
+ *     primary mandatory autocreated protected multiple VERSION
+ *     < 'constraint1', 'constraint2'
+ *   + ex:node (ex:reqType1, ex:reqType2) = ex:defaultType
+ *     mandatory autocreated protected multiple VERSION
+ */
+public class CompactNodeTypeDefWriter {
+
+    /**
+     * the indention string
+     */
+    private final static String INDENT = "  ";
+
+    /**
+     * The list of NodeTypeDefs to write
+     */
+    private final List nodeTypeDefList;
+
+    /**
+     * the current namespace resolver
+     */
+    private final NamespaceResolver resolver;
+
+    /**
+     * the underlying writer
+     */
+    private final Writer out;
+
+    /**
+     * The namespaces to be written out.
+     */
+    private final Map namespaceMap = new HashMap();
+
+    /**
+     *
+     * @param l
+     * @param r
+     * @param w
+     */
+    public CompactNodeTypeDefWriter(List l, NamespaceResolver r, Writer w) throws NamespaceException {
+        nodeTypeDefList = l;
+        out = w;
+        resolver = r;
+        buildNamespaceMap();
+    }
+
+    /**
+     *
+     * @throws IOException
+     */
+    public void write() throws IOException, NamespaceException {
+        for (Iterator i = namespaceMap.entrySet().iterator(); i.hasNext();){
+            Map.Entry e = (Map.Entry)i.next();
+            String prefix = (String)e.getKey();
+            String uri = (String)e.getValue();
+            out.write("<");
+            out.write(prefix);
+            out.write(" = \"");
+            out.write(uri);
+            out.write("\">\n");
+        }
+        for (Iterator i = nodeTypeDefList.iterator(); i.hasNext();){
+            NodeTypeDef ntd = (NodeTypeDef)i.next();
+            writeName(ntd);
+            writeSupertypes(ntd);
+            writeOptions(ntd);
+            writePropDefs(ntd);
+            writeChildNodeDefs(ntd);
+        }
+    }
+
+    /**
+     * closes this writer but not the underlying stream
+     *
+     * @throws IOException
+     */
+    public void close() throws IOException {
+        out.flush();
+    }
+
+    /**
+     * buildNamespaceMap
+     */
+    private void buildNamespaceMap() throws NamespaceException {
+        for (Iterator i = nodeTypeDefList.iterator(); i.hasNext();){
+            NodeTypeDef ntd = (NodeTypeDef)i.next();
+            addNamespace(ntd.getName());
+            addNamespace(ntd.getSupertypes());
+            PropDef[] pda = ntd.getPropertyDefs();
+            for (int j = 0; j < pda.length; j++){
+                PropDef pd = pda[j];
+                addNamespace(pd.getName());
+            }
+
+            NodeDef[] nda = ntd.getChildNodeDefs();
+            for (int j = 0; j < nda.length; j++){
+                NodeDef nd = nda[j];
+                addNamespace(nd.getName());
+                addNamespace(nd.getRequiredPrimaryTypes());
+                addNamespace(nd.getDefaultPrimaryType());
+            }
+        }
+    }
+
+    private void addNamespace(QName qn) throws NamespaceException {
+        String uri = qn.getNamespaceURI();
+        String prefix = resolver.getPrefix(uri);
+        namespaceMap.put(prefix, uri);
+    }
+
+    private void addNamespace(QName[] qna) throws NamespaceException {
+        for(int i = 0; i < qna.length; i++){
+            QName qn = qna[i];
+            addNamespace(qn);
+        }
+    }
+
+    /**
+     * writeName
+     */
+    private void writeName(NodeTypeDef ntd) throws IOException, NamespaceException {
+        out.write("[");
+        out.write(resolve(ntd.getName()));
+        out.write("]");
+    }
+
+    /**
+     * writeSupertypes
+     */
+    private void writeSupertypes(NodeTypeDef ntd) throws IOException, NamespaceException {
+        QName[] sta = ntd.getSupertypes();
+        if (sta == null) return;
+        String delim=" > ";
+        for (int i=0; i<sta.length; i++) {
+            if (!sta[i].equals(QName.NT_BASE)) {
+                out.write(delim);
+                out.write(resolve(sta[i]));
+                delim = ", ";
+            }
+        }
+    }
+
+    /**
+     * writeOptions
+     */
+    private void writeOptions(NodeTypeDef ntd) throws IOException {
+        if (ntd.hasOrderableChildNodes()) {
+            out.write("\n" + INDENT);
+            out.write("orderable");
+            if (ntd.isMixin()) {
+                out.write(" mixin");
+            }
+        } else if (ntd.isMixin()) {
+            out.write("\n" + INDENT);
+            out.write("mixin");
+        }
+    }
+
+    /**
+     * writePropDefs
+     */
+    private void writePropDefs(NodeTypeDef ntd) throws IOException, NamespaceException {
+        PropDef[] pda = ntd.getPropertyDefs();
+        for (int i = 0; i < pda.length; i++) {
+            PropDef pd = pda[i];
+            writePropDef(ntd, pd);
+        }
+    }
+
+    /**
+     * writeNodeDefs
+     */
+    private void writeChildNodeDefs(NodeTypeDef ntd) throws IOException, NamespaceException {
+        NodeDef[] nda = ntd.getChildNodeDefs();
+        for (int i = 0; i < nda.length; i++) {
+            NodeDef nd = nda[i];
+            writeNodeDef(ntd, nd);
+        }
+    }
+
+    /**
+     * writePropDef
+     * @param pd
+     */
+    private void writePropDef(NodeTypeDef ntd, PropDef pd) throws IOException, NamespaceException {
+        out.write("\n" + INDENT + "- ");
+        writeItemDefName(pd.getName());
+        out.write(" (");
+        out.write(PropertyType.nameFromValue(pd.getRequiredType()).toLowerCase());
+        out.write(")");
+        writeDefaultValues(pd.getDefaultValues());
+        out.write(ntd.getPrimaryItemName() != null && ntd.getPrimaryItemName().equals(pd.getName()) ? " primary" : "");
+        if (pd.isMandatory()) {
+            out.write(" mandatory");
+        }
+        if (pd.isAutoCreated()) {
+            out.write(" autocreated");
+        }
+        if (pd.isProtected()) {
+            out.write(" protected");
+        }
+        if (pd.isMultiple()) {
+            out.write(" multiple");
+        }
+        if (pd.getOnParentVersion() != OnParentVersionAction.COPY) {
+            out.write(" ");
+            out.write(OnParentVersionAction.nameFromValue(pd.getOnParentVersion()).toLowerCase());
+        }
+        writeValueConstraints(pd.getValueConstraints());
+    }
+
+    /**
+     * writeDefaultValues
+     * @param dva
+     */
+    private void writeDefaultValues(InternalValue[] dva) throws IOException {
+        if (dva == null || dva.length == 0) return;
+        String delim=" = '";
+        for (int i = 0; i < dva.length; i++) {
+            out.write(delim);
+            try {
+                out.write(escape(dva[i].toJCRValue(resolver).getString()));
+            } catch (RepositoryException e) {
+                out.write(escape(dva[i].toString()));
+            }
+            out.write("'");
+            delim=", '";
+        }
+    }
+
+    /**
+     * writeValueConstraints
+     * @param vca
+     */
+    private void writeValueConstraints(ValueConstraint[] vca) throws IOException {
+        if (vca == null || vca.length == 0) return;
+        String vc = vca[0].getDefinition(resolver);
+        out.write(" < '");
+        out.write(escape(vc));
+        out.write("'");
+        for (int i = 1; i < vca.length; i++) {
+            vc = vca[i].getDefinition(resolver);
+            out.write(", '");
+            out.write(escape(vc));
+            out.write("'");
+        }
+    }
+
+    /**
+     * writeNodeDef
+     * @param nd
+     */
+    private void writeNodeDef(NodeTypeDef ntd, NodeDef nd) throws IOException, NamespaceException {
+        out.write("\n" + INDENT + "+ ");
+        writeItemDefName(nd.getName());
+        writeRequiredTypes(nd.getRequiredPrimaryTypes());
+        writeDefaultType(nd.getDefaultPrimaryType());
+        out.write(ntd.getPrimaryItemName() != null && ntd.getPrimaryItemName().equals(nd.getName()) ? " primary" : "");
+        if (nd.isMandatory()) {
+            out.write(" mandatory");
+        }
+        if (nd.isAutoCreated()) {
+            out.write(" autocreated");
+        }
+        if (nd.isProtected()) {
+            out.write(" protected");
+        }
+        if (nd.allowsSameNameSiblings()) {
+            out.write(" multiple");
+        }
+        if (nd.getOnParentVersion() != OnParentVersionAction.COPY) {
+            out.write(" ");
+            out.write(OnParentVersionAction.nameFromValue(nd.getOnParentVersion()).toLowerCase());
+        }
+    }
+
+    private void writeItemDefName(QName name) throws IOException, NamespaceException {
+        String s = resolve(name);
+        // check for '-' and '+'
+        if (s.indexOf('-') >= 0 || s.indexOf('+') >= 0) {
+            out.write('\'');
+            out.write(s);
+            out.write('\'');
+        } else {
+            out.write(s);
+        }
+    }
+    /**
+     * putRequiredTypes
+     * @param reqTypes
+     */
+    private void writeRequiredTypes(QName[] reqTypes) throws IOException, NamespaceException {
+        if (reqTypes != null && reqTypes.length > 0) {
+            String delim = " (";
+            for (int i = 0; i < reqTypes.length; i++) {
+                out.write(delim);
+                out.write(resolve(reqTypes[i]));
+                delim=", ";
+            }
+            out.write(")");
+        }
+    }
+
+    /**
+     * putDefaultType
+     * @param defType
+     */
+    private void writeDefaultType(QName defType) throws IOException, NamespaceException {
+        if (defType != null && !defType.getLocalName().equals("*")) {
+            out.write(" = ");
+            out.write(resolve(defType));
+        }
+    }
+
+    /**
+     * resolve
+     * @param qname
+     * @return the resolved name
+     */
+    private String resolve(QName qname) throws NamespaceException {
+        if (qname == null) {
+            return "";
+        }
+        String prefix = resolver.getPrefix(qname.getNamespaceURI());
+        if (prefix != null && !prefix.equals(QName.NS_EMPTY_PREFIX)) {
+            prefix += ":";
+        }
+        return prefix + qname.getLocalName();
+    }
+
+    /**
+     * escape
+     * @param s
+     * @return the escaped string
+     */
+    private String escape(String s) {
+        StringBuffer sb = new StringBuffer(s);
+        for (int i = 0; i < sb.length(); i++) {
+            if (sb.charAt(i) == '\\') {
+                sb.insert(i, '\\');
+                i++;
+            } else if (sb.charAt(i) == '\'') {
+                sb.insert(i, '\'');
+                i++;
+            }
+        }
+        return sb.toString();
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefWriter.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/Lexer.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/Lexer.java?rev=358028&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/Lexer.java (added)
+++ incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/Lexer.java Tue Dec 20 08:20:16 2005
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.core.nodetype.compact;
+
+import java.io.StreamTokenizer;
+import java.io.Reader;
+import java.io.IOException;
+
+/**
+ * Lexer
+ */
+public class Lexer {
+    public final static char SINGLE_QUOTE = '\'';
+    public final static char DOUBLE_QUOTE = '\"';
+    public final static char BEGIN_NODE_TYPE_NAME = '[';
+    public final static char END_NODE_TYPE_NAME = ']';
+    public final static char EXTENDS = '>';
+    public final static char LIST_DELIMITER = ',';
+    public final static char PROPERTY_DEFINITION = '-';
+    public final static char CHILD_NODE_DEFINITION = '+';
+    public final static char BEGIN_TYPE = '(';
+    public final static char END_TYPE = ')';
+    public final static char DEFAULT = '=';
+    public final static char CONSTRAINT = '<';
+
+    public final static String[] ORDERABLE = new String[] {"orderable", "ord", "o"};
+    public final static String[] MIXIN = new String[]{"mixin", "mix", "m"};
+
+    public final static String[] PRIMARY = new String[]{"primary", "pri", "!"};
+    public final static String[] AUTOCREATED = new String[]{"autocreated", "aut", "a"};
+    public final static String[] MANDATORY = new String[]{"mandatory", "man", "m"};
+    public final static String[] PROTECTED = new String[]{"protected", "pro", "p"};
+    public final static String[] MULTIPLE = new String[]{"multiple", "mul", "*"};
+
+    public final static String[] COPY = new String[]{"copy", "Copy", "COPY"};
+    public final static String[] VERSION = new String[]{"version", "Version", "VERSION"};
+    public final static String[] INITIALIZE = new String[]{"initialize", "Initialize", "INITIALIZE"};
+    public final static String[] COMPUTE = new String[]{"compute", "Compute", "COMPUTE"};
+    public final static String[] IGNORE = new String[]{"ignore", "Ignore", "IGNORE"};
+    public final static String[] ABORT = new String[]{"abort", "Abort", "ABORT"};
+
+    public final static String[] ATTRIBUTE = new String[]{"primary", "pri", "!",
+                                                          "autocreated", "aut", "a",
+                                                          "mandatory", "man", "m",
+                                                          "protected", "pro", "p",
+                                                          "multiple", "mul", "*",
+                                                          "copy", "Copy", "COPY",
+                                                          "version", "Version", "VERSION",
+                                                          "initialize", "Initialize", "INITIALIZE",
+                                                          "compute", "Compute", "COMPUTE",
+                                                          "ignore", "Ignore", "IGNORE",
+                                                          "abort", "Abort", "ABORT"};
+
+    public final static String[] STRING = {"string", "String", "STRING"};
+    public final static String[] BINARY = {"binary", "Binary", "BINARY"};
+    public final static String[] LONG = {"long", "Long", "LONG"};
+    public final static String[] DOUBLE = {"double", "Double", "DOUBLE"};
+    public final static String[] BOOLEAN = {"boolean", "Boolean", "BOOLEAN"};
+    public final static String[] DATE = {"date", "Date", "DATE"};
+    public final static String[] NAME = {"name", "Name", "NAME"};
+    public final static String[] PATH = {"path", "Path", "PATH"};
+    public final static String[] REFERENCE = {"reference", "Reference", "REFERENCE"};
+
+    public final static String[] UNDEFINED = new String[]{"undefined", "Undefined", "UNDEFINED", "*"};
+
+    public final static String EOF = "eof";
+
+    private final StreamTokenizer st;
+
+    private final String systemId;
+
+    /**
+     * Constructor
+     * @param r
+     */
+    public Lexer(Reader r, String systemId){
+        this.systemId = systemId;
+        st = new StreamTokenizer(r);
+
+        st.eolIsSignificant(false);
+
+        st.lowerCaseMode(false);
+
+        st.slashSlashComments(true);
+        st.slashStarComments(true);
+
+        st.wordChars('a','z');
+        st.wordChars('A','Z');
+        st.wordChars(':',':');
+
+        st.quoteChar(SINGLE_QUOTE);
+        st.quoteChar(DOUBLE_QUOTE);
+
+        st.ordinaryChar(BEGIN_NODE_TYPE_NAME);
+        st.ordinaryChar(END_NODE_TYPE_NAME);
+        st.ordinaryChar(EXTENDS);
+        st.ordinaryChar(LIST_DELIMITER);
+        st.ordinaryChar(PROPERTY_DEFINITION);
+        st.ordinaryChar(CHILD_NODE_DEFINITION);
+        st.ordinaryChar(BEGIN_TYPE);
+        st.ordinaryChar(END_TYPE);
+        st.ordinaryChar(DEFAULT);
+        st.ordinaryChar(CONSTRAINT);
+    }
+
+    /**
+     * getNextToken
+     *
+     * @return
+     * @throws ParseException
+     */
+    public String getNextToken() throws ParseException {
+        try {
+            int tokenType = st.nextToken();
+            if (tokenType == StreamTokenizer.TT_EOF){
+                return EOF;
+            } else if(tokenType == StreamTokenizer.TT_WORD || tokenType == SINGLE_QUOTE || tokenType == DOUBLE_QUOTE){
+                return st.sval;
+            } else {
+                return new String(new char[]{(char)tokenType});
+            }
+        } catch (IOException e){
+            fail("IOException while attempting to read input stream", e);
+            return null;
+        }
+    }
+
+    public void fail(String message) throws ParseException {
+        throw new ParseException(message, st.lineno(), -1, systemId);
+    }
+
+    public void fail(String message, Throwable e) throws ParseException {
+        throw new ParseException(message, e, st.lineno(), -1, systemId);
+    }
+
+    public void fail(Throwable e) throws ParseException {
+        throw new ParseException(e, st.lineno(), -1, systemId);
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/Lexer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/Lexer.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/ParseException.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/ParseException.java?rev=358028&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/ParseException.java (added)
+++ incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/ParseException.java Tue Dec 20 08:20:16 2005
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.core.nodetype.compact;
+
+/**
+ * ParseException
+ */
+public class ParseException extends Exception {
+
+    /**
+     * the line number where the error occurred
+     */
+    private final int lineNumber;
+
+    /**
+     * the column number where the error occurred
+     */
+    private final int colNumber;
+
+    /**
+     * the systemid of the source that produced the error
+     */
+    private final String systemId;
+
+
+    /**
+     * Constructs a new instance of this class with <code>null</code> as its
+     * detail message.
+     */
+    public ParseException(int lineNumber, int colNumber, String systemId) {
+        super();
+        this.lineNumber = lineNumber;
+        this.colNumber = colNumber;
+        this.systemId = systemId;
+    }
+
+    /**
+     * Constructs a new instance of this class with the specified detail
+     * message.
+     *
+     * @param message the detail message. The detail message is saved for
+     *                later retrieval by the {@link #getMessage()} method.
+     */
+    public ParseException(String message, int lineNumber, int colNumber, String systemId) {
+        super(message);
+        this.lineNumber = lineNumber;
+        this.colNumber = colNumber;
+        this.systemId = systemId;
+    }
+
+    /**
+     * Constructs a new instance of this class with the specified detail
+     * message and root cause.
+     *
+     * @param message   the detail message. The detail message is saved for
+     *                  later retrieval by the {@link #getMessage()} method.
+     * @param rootCause root failure cause
+     */
+    public ParseException(String message, Throwable rootCause, int lineNumber, int colNumber, String systemId) {
+        super(message, rootCause);
+        this.lineNumber = lineNumber;
+        this.colNumber = colNumber;
+        this.systemId = systemId;
+    }
+
+    /**
+     * Constructs a new instance of this class with the specified root cause.
+     *
+     * @param rootCause root failure cause
+     */
+    public ParseException(Throwable rootCause, int lineNumber, int colNumber, String systemId) {
+        super(rootCause);
+        this.lineNumber = lineNumber;
+        this.colNumber = colNumber;
+        this.systemId = systemId;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getMessage() {
+        StringBuffer b = new StringBuffer(super.getMessage());
+        String delim =" (";
+        if (systemId != null && !systemId.equals("")) {
+            b.append(delim);
+            b.append(systemId);
+            delim = ", ";
+        }
+        if (lineNumber>=0) {
+            b.append(delim);
+            b.append("line ");
+            b.append(lineNumber);
+            delim = ", ";
+        }
+        if (colNumber>=0) {
+            b.append(delim);
+            b.append("col ");
+            b.append(colNumber);
+            delim = ", ";
+        }
+        if (delim.equals(", ")) {
+            b.append(")");
+        }
+        return b.toString();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString() {
+        return super.toString();// + " (" + systemId + ", line " + lineNumber +", col " + colNumber +")";
+    }
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/ParseException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/ParseException.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceAdder.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceAdder.java?rev=358028&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceAdder.java (added)
+++ incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceAdder.java Tue Dec 20 08:20:16 2005
@@ -0,0 +1,32 @@
+package org.apache.jackrabbit.util.name;
+
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.NamespaceException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.RepositoryException;
+import java.util.Map;
+import java.util.Iterator;
+
+public class NamespaceAdder {
+    NamespaceRegistry registry;
+
+    public NamespaceAdder(NamespaceRegistry nsr) {
+        registry = nsr;
+    }
+
+    public void addNamespaces(NamespaceMapping nsm)
+            throws NamespaceException, UnsupportedRepositoryOperationException, RepositoryException {
+        Map m = nsm.getPrefixToURIMapping();
+        for(Iterator i = m.values().iterator(); i.hasNext();){
+            Map.Entry e = (Map.Entry)i.next();
+            String prefix = (String)e.getKey();
+            String uri =(String)e.getKey();
+            registry.registerNamespace(prefix, uri);
+        }
+    }
+
+    public void addNamespace(String prefix, String uri)
+        throws NamespaceException, UnsupportedRepositoryOperationException, RepositoryException {
+        registry.registerNamespace(prefix, uri);
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceAdder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceAdder.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceExtractor.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceExtractor.java?rev=358028&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceExtractor.java (added)
+++ incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceExtractor.java Tue Dec 20 08:20:16 2005
@@ -0,0 +1,115 @@
+/*
+ * $Id:$
+ *
+ * Copyright 2002-2004 Day Management AG, Switzerland.
+ *
+ * Licensed under the Day RI License, Version 2.0 (the "License"),
+ * as a reference implementation of the following specification:
+ *
+ *   Content Repository API for Java Technology, revision 0.13
+ *        <http://www.jcp.org/en/jsr/detail?id=170>
+ *
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License files at
+ *
+ *     http://www.day.com/content/en/licenses/day-ri-license-2.0
+ *     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.util.name;
+
+import org.xml.sax.XMLReader;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.helpers.XMLReaderFactory;
+import org.xml.sax.helpers.DefaultHandler;
+import org.apache.log4j.Logger;
+
+import javax.jcr.NamespaceException;
+import java.io.FileInputStream;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Extracts namespace mapping information from an XML file.
+ * XML file is parsed and all startPrefixMapping events
+ * are intercepted. Scoping of prefix mapping within the XML file
+ * may result in multiple namespace using the same prefix. This
+ * is handled by mangling the prefix when required.
+ *
+ * The resulting NamespaceMapping implements NamespaceResolver
+ * and can be used by tools (such as o.a.j.tools.nodetype.CompactNodeTypeDefWriter)
+ * to resolve namespaces.
+ */
+public class NamespaceExtractor {
+    private static Logger log = Logger.getLogger(NamespaceExtractor.class);
+    private final NamespaceMapping mapping = new NamespaceMapping();
+    private final Map basePrefixes = new HashMap();
+    private String defaultBasePrefix;
+
+    /**
+     * Constructor
+     * @param fileName
+     * @param dpb
+     * @throws NamespaceException
+     */
+    public NamespaceExtractor(String fileName, String dpb) throws NamespaceException {
+        defaultBasePrefix = dpb;
+        try{
+            ContentHandler handler = new NamespaceHandler();
+            XMLReader parser = XMLReaderFactory.createXMLReader();
+            parser.setContentHandler(handler);
+            parser.parse(new InputSource(new FileInputStream(fileName)));
+        } catch(Exception e){
+            throw new NamespaceException();
+        }
+    }
+
+    /**
+     * getNamespaceMapping
+     * @return a NamespaceMapping
+     */
+    public NamespaceMapping getNamespaceMapping(){
+        return mapping;
+    }
+
+    /**
+     * SAX ContentHandler that reacts to namespace mappings in incoming XML.
+     */
+    private class NamespaceHandler extends DefaultHandler{
+        public void startPrefixMapping(String prefix, String uri) throws SAXException {
+            if (uri == null) uri = "";
+
+            //Replace the empty prefix with the defaultBasePrefix
+            if (prefix == null || prefix.equals("")){
+                prefix = defaultBasePrefix;
+            }
+
+            try{
+                // if prefix already used
+                if (mapping.getURI(prefix) != null){
+                    int c;
+                    Integer co = (Integer) basePrefixes.get(prefix);
+                    if (co == null) {
+                        basePrefixes.put(prefix, new Integer(1));
+                        c = 1;
+                    } else {
+                        c = co.intValue() + 1;
+                        basePrefixes.put(prefix, new Integer(c));
+                    }
+                    prefix = prefix + "_" + c;
+                }
+                mapping.setMapping(prefix, uri);
+            } catch(NamespaceException e){
+                String msg = e.getMessage();
+                log.debug(msg);
+            }
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceExtractor.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceMapping.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceMapping.java?rev=358028&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceMapping.java (added)
+++ incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceMapping.java Tue Dec 20 08:20:16 2005
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.util.name;
+
+import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.name.AbstractNamespaceResolver;
+
+import javax.jcr.NamespaceException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * A Simple Namespace Mapping table. Mappings can be added
+ * and then the object can be used as a NamespaceResolver. Additionally, it can
+ * be based on a underlying NamespaceResolver
+ */
+public class NamespaceMapping extends AbstractNamespaceResolver {
+
+    /** local uris */
+    private final Properties prefixToURI = new Properties();
+
+    /** local prefix */
+    private final Properties URIToPrefix = new Properties();
+
+    /** base */
+    private final NamespaceResolver base;
+
+    public NamespaceMapping() {
+        this.base = null;
+    }
+
+    /**
+     * Constructor
+     */
+    public NamespaceMapping(NamespaceResolver base) {
+        this.base = base;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getPrefix(String uri) throws NamespaceException {
+        if (URIToPrefix.containsKey(uri)) {
+            return URIToPrefix.getProperty(uri);
+        } else if (base == null) {
+            throw new NamespaceException("No prefix for URI '" + uri + "' declared.");
+        } else {
+            return base.getPrefix(uri);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getURI(String prefix) throws NamespaceException {
+        if (prefixToURI.containsKey(prefix)) {
+            return prefixToURI.getProperty(prefix);
+        } else if (base == null) {
+            throw new NamespaceException("No URI for pefix '" + prefix + "' declared.");
+        } else {
+            return base.getURI(prefix);
+        }
+    }
+
+    /**
+     * Set a prefix == URI one-to-one mapping
+     *
+     * @param prefix
+     * @param uri
+     * @throws NamespaceException
+     */
+    public void setMapping(String prefix, String uri) throws NamespaceException{
+        if (prefix == null) {
+            throw new NamespaceException("Prefix must not be null");
+        }
+        if (uri == null) {
+            throw new NamespaceException("URI must not be null");
+        }
+        if (URIToPrefix.containsKey(uri)) {
+            // remove mapping
+            prefixToURI.remove(URIToPrefix.remove(uri));
+        }
+        if (prefixToURI.containsKey(prefix)) {
+            // remove mapping
+            URIToPrefix.remove(prefixToURI.remove(prefix));
+        }
+        prefixToURI.put(prefix, uri);
+        URIToPrefix.put(uri, prefix);
+    }
+
+    /**
+     * Return a Map of prefix to URI mappings currently registered.
+     * The returned Map is a copy of the internal Map.
+     * @return Map
+     */
+    public Map getPrefixToURIMapping(){
+        return new HashMap(prefixToURI);
+    }
+
+    /**
+     * Return a Map of URI to prefix mappings currently registered.
+     * The returned Map is a copy of the internal Map.
+     * @return Map
+     */
+    public Map getURIToPrefixMapping(){
+        return new HashMap(URIToPrefix);
+    }
+
+     /**
+     * Override equals()
+      *
+     * @param obj
+     * @return boolean
+     */
+    public boolean equals(Object obj){
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof NamespaceMapping) {
+            NamespaceMapping other = (NamespaceMapping) obj;
+            return this.getPrefixToURIMapping().equals(other.getPrefixToURIMapping())
+                   && this.getURIToPrefixMapping().equals(other.getURIToPrefixMapping());
+        }
+        return false;
+    }
+
+    /**
+     * Override toString()
+     *
+     * @return String
+     */
+    public String toString(){
+        String s= "";
+        Set mapping = prefixToURI.entrySet();
+        for(Iterator i = mapping.iterator(); i.hasNext();){
+            Map.Entry entry = (Map.Entry)i.next();
+            String prefix = (String)entry.getKey();
+            String uri = (String)entry.getValue();
+            s += "'" + prefix + "' == '" + uri + "'\n";
+        }
+        return s;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceMapping.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/jackrabbit/trunk/contrib/nt-ns-util/src/main/java/org/apache/jackrabbit/util/name/NamespaceMapping.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url



Mime
View raw message