jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r815805 [2/2] - in /jackrabbit/sandbox/JCR-2170: ./ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/ jackrabbit-core/ jackrabbit-core/src/main/java/org/apache/jackrab...
Date Wed, 16 Sep 2009 14:33:25 GMT
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/NameParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/NameParser.java?rev=815805&r1=815804&r2=815805&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/NameParser.java
(original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/NameParser.java
Wed Sep 16 14:33:23 2009
@@ -119,24 +119,29 @@
             } else if (c == '}') {
                 if (state == STATE_URI_START || state == STATE_URI) {
                     String tmp = jcrName.substring(1, i);
-                    try {
-                        // make sure the uri is a known namespace uri
-                        // TODO: since namespace registration does not validate
-                        //       the URI format validation is omitted here
-                        if (!checkFormat) {
-                            resolver.getPrefix(tmp);
-                        }
+                    if (tmp.length() == 0 || tmp.indexOf(':') != -1) {
+                        // The leading "{...}" part is empty or contains
+                        // a colon, so we treat it as a valid namespace URI.
+                        // More detailed validity checks (is it well formed,
+                        // registered, etc.) are not needed here.
                         uri = tmp;
                         state = STATE_NAME_START;
-                    } catch (NamespaceException e) {
-                        // unknown uri -> apparently a localname starting with {
-                        // -> make sure there are no invalid characters
-                        if (tmp.indexOf(':') == -1 && tmp.indexOf('/') == -1) {
-                            state = STATE_NAME;
-                            nameStart = 0;
-                        } else {
-                            throw new IllegalNameException("Unknown uri " + tmp + ". But
':' and '/' are not allowed in a local name.");
-                        }
+                    } else if (tmp.equals("internal")) {
+                        // As a special Jackrabbit backwards compatibility
+                        // feature, support {internal} as a valid URI prefix
+                        uri = tmp;
+                        state = STATE_NAME_START;
+                    } else if (tmp.indexOf('/') == -1) {
+                        // The leading "{...}" contains neither a colon nor
+                        // a slash, so we can interpret it as a a part of a
+                        // normal local name.
+                        state = STATE_NAME;
+                        nameStart = 0;
+                    } else {
+                        throw new IllegalNameException(
+                                "The URI prefix of the name " + jcrName
+                                + " is neither a valid URI nor a valid part"
+                                + " of a local name.");
                     }
                 } else if (state == STATE_PREFIX_START) {
                     state = STATE_PREFIX; // prefix start -> validation later on will
fail.

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/NameParserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/NameParserTest.java?rev=815805&r1=815804&r2=815805&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/NameParserTest.java
(original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/NameParserTest.java
Wed Sep 16 14:33:23 2009
@@ -123,8 +123,7 @@
         valid.add(new String[] {"{http://jackrabbit.apache.org:80}abc", "http://jackrabbit.apache.org:80",
"abc"});
         valid.add(new String[] {"{http://jackrabbit.apache.org/info}abc", "http://jackrabbit.apache.org/info",
"abc"});
         valid.add(new String[] {"{jcr:jackrabbit}abc", "jcr:jackrabbit", "abc"});
-        valid.add(new String[] {"{/jackrabbit/a/b/c}abc", "/jackrabbit/a/b/c", "abc"});
-        valid.add(new String[] {"{abc}def", "abc", "def"});
+        valid.add(new String[] {"{abc:}def", "abc:", "def"});
         valid.add(new String[] {"{}abc", "", "abc"});
 
         for (Iterator it = valid.iterator(); it.hasNext();) {
@@ -146,7 +145,7 @@
         invalid.add("a{b:c");
         invalid.add("a}b:c");
         // unknown uri -> but invalid local name with ':' and or '/'
-        invalid.add("{http//:test.apache.org}abc");
+        invalid.add("{http//test.apache.org}abc");
         invalid.add("{test/test/test}abc");
         // invalid local name containing '/'
         invalid.add("{http://jackrabbit.apache.org}abc/dfg");
@@ -157,7 +156,6 @@
         // invalid local name containing '/'
         invalid.add("/a/b/c");
         // known uri but local name missing -> must fail.
-        invalid.add("{abc}");
         invalid.add("{http://jackrabbit.apache.org}");
         invalid.add("{}");
 
@@ -202,7 +200,6 @@
         valid.add(new String[] {"{http://jackrabbit.apache.org:80}abc", "http://jackrabbit.apache.org:80",
"abc"});
         valid.add(new String[] {"{http://jackrabbit.apache.org/info}abc", "http://jackrabbit.apache.org/info",
"abc"});
         valid.add(new String[] {"{jcr:jackrabbit}abc", "jcr:jackrabbit", "abc"});
-        valid.add(new String[] {"{/jackrabbit/a/b/c}abc", "/jackrabbit/a/b/c", "abc"});
         valid.add(new String[] {"{abc}def", "abc", "def"});
         valid.add(new String[] {"{}abc", "", "abc"});
 
@@ -231,9 +228,11 @@
         // invalid local name containing '/'
         invalid.add("/a/b/c");
         // known uri but local name missing -> must fail.
-        invalid.add("{abc}");
         invalid.add("{http://jackrabbit.apache.org}");
         invalid.add("{}");
+        // invalid URI part
+        invalid.add("{/jackrabbit/a/b/c}abc");
+
 
         for (Iterator it = invalid.iterator(); it.hasNext();) {
             String jcrName = (String) it.next();

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrName.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrName.java?rev=815805&r1=815804&r2=815805&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrName.java
(original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrName.java
Wed Sep 16 14:33:23 2009
@@ -54,8 +54,10 @@
         list.add(new JcrName("{}a", "", "a"));
         list.add(new JcrName("{}name", "", "name"));
         list.add(new JcrName("{}na me", "", "na me"));
-        list.add(new JcrName("{prefix}name", "prefix", "name"));
-        list.add(new JcrName("{prefix}na me", "prefix", "na me"));        
+        list.add(new JcrName("{uri:}name", "uri:", "name"));
+        list.add(new JcrName("{uri:}na me", "uri:", "na me"));
+        list.add(new JcrName("{nouri}name", "", "{nouri}name"));
+        list.add(new JcrName("{nouri}na me", "", "{nouri}na me"));
         list.add(new JcrName("{}...", "", "..."));
         list.add(new JcrName("{}.a.", "", ".a."));
 

Modified: jackrabbit/sandbox/JCR-2170/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/pom.xml?rev=815805&r1=815804&r2=815805&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/pom.xml (original)
+++ jackrabbit/sandbox/JCR-2170/pom.xml Wed Sep 16 14:33:23 2009
@@ -44,7 +44,6 @@
     <module>jackrabbit-jcr-commons</module>
     <module>jackrabbit-jcr-tests</module>
     <module>jackrabbit-core</module>
-    <module>jackrabbit-text-extractors</module>
     <module>jackrabbit-webdav</module>
     <module>jackrabbit-jcr-server</module>
     <module>jackrabbit-webapp</module>



Mime
View raw message