jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1333055 - in /jackrabbit/oak/trunk: oak-it/jcr/pom.xml oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/namespace/NamespaceRegistryImpl.java
Date Wed, 02 May 2012 14:16:28 GMT
Author: reschke
Date: Wed May  2 14:16:27 2012
New Revision: 1333055

URL: http://svn.apache.org/viewvc?rev=1333055&view=rev
Log:
OAK-6: minor NamespaceRegistry fixes, update test exclusions

Modified:
    jackrabbit/oak/trunk/oak-it/jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/namespace/NamespaceRegistryImpl.java

Modified: jackrabbit/oak/trunk/oak-it/jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/jcr/pom.xml?rev=1333055&r1=1333054&r2=1333055&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-it/jcr/pom.xml Wed May  2 14:16:27 2012
@@ -48,7 +48,6 @@ org.apache.jackrabbit.test.api.NodeDisco
 org.apache.jackrabbit.test.api.SessionReadMethodsTest#testGetNodeByUUIDFailure
 org.apache.jackrabbit.test.api.PathTest
 org.apache.jackrabbit.test.api.AddNodeTest
-org.apache.jackrabbit.test.api.NamespaceRegistryTest
 org.apache.jackrabbit.test.api.ReferencesTest
 org.apache.jackrabbit.test.api.SessionTest
 org.apache.jackrabbit.test.api.SessionUUIDTest

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/namespace/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/namespace/NamespaceRegistryImpl.java?rev=1333055&r1=1333054&r2=1333055&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/namespace/NamespaceRegistryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/namespace/NamespaceRegistryImpl.java
Wed May  2 14:16:27 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.jcr.namespace;
 
+import java.util.Locale;
+
 import javax.jcr.NamespaceException;
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.RepositoryException;
@@ -39,6 +41,8 @@ public class NamespaceRegistryImpl imple
     @Override
     public void registerNamespace(String prefix, String uri)
             throws RepositoryException {
+        checkMutablePrefix(prefix);
+        checkMutableURI(uri);
         try {
             nsMappings.registerNamespace(prefix, uri);
         } catch (CommitFailedException e) {
@@ -50,7 +54,11 @@ public class NamespaceRegistryImpl imple
 
     @Override
     public void unregisterNamespace(String prefix) throws RepositoryException {
+        checkMutablePrefix(prefix);
         try {
+            if (nsMappings.getURI(prefix) == null) {
+                throw new NamespaceException("prefix '" + prefix + "' is unused");
+            }
             nsMappings.unregisterNamespace(prefix);
         } catch (CommitFailedException e) {
             throw new RepositoryException(
@@ -110,4 +118,18 @@ public class NamespaceRegistryImpl imple
                     + uri, e);
         }
     }
+
+    private void checkMutablePrefix(String prefix) throws NamespaceException {
+        if ("jcr".equals(prefix) || "nt".equals(prefix) || "mix".equals(prefix) || "sv".equals(prefix)
+                || prefix.toLowerCase(Locale.ENGLISH).startsWith("xml")) {
+            throw new NamespaceException("Can not map or remap prefix '" + prefix + "'");
+        }
+    }
+
+    private void checkMutableURI(String uri) throws NamespaceException {
+        if ("http://www.jcp.org/jcr/1.0".equals(uri) || "http://www.jcp.org/jcr/nt/1.0".equals(uri)
+                || "http://www.jcp.org/jcr/mix/1.0".equals(uri) || "http://www.jcp.org/jcr/sv/1.0".equals(uri))
{
+            throw new NamespaceException("Can not map or remap uri '" + uri + "'");
+        }
+    }
 }



Mime
View raw message