jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1157142 - /jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Date Fri, 12 Aug 2011 14:59:14 GMT
Author: mduerig
Date: Fri Aug 12 14:59:14 2011
New Revision: 1157142

URL: http://svn.apache.org/viewvc?rev=1157142&view=rev
Log:
spi2microkernel (WIP)
- don't allow reserved namespace modifications

Modified:
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java?rev=1157142&r1=1157141&r2=1157142&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Fri Aug 12 14:59:14 2011
@@ -61,6 +61,7 @@ import org.slf4j.LoggerFactory;
 
 import javax.jcr.Credentials;
 import javax.jcr.GuestCredentials;
+import javax.jcr.NamespaceException;
 import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
@@ -419,8 +420,26 @@ public class RepositoryServiceImpl exten
 
     //------------------------------------------< Name space management >---
 
+    private static final Set<String> RESERVED_NS = new HashSet<String>() {{
+        add("");
+        add("internal");
+        add("http://www.jcp.org/jcr/1.0");
+        add("http://www.w3.org/2001/XMLSchema");
+        add("http://www.jcp.org/jcr/nt/1.0");
+        add("http://www.jcp.org/jcr/mix/1.0");
+        add("http://www.jcp.org/jcr/sv/1.0");
+        add("http://www.w3.org/XML/1998/namespace");
+    }};
+
     @Override
     public void registerNamespace(SessionInfo sessionInfo, String prefix, String uri) throws
RepositoryException {
+        if (namespaces.hasPrefix(prefix)) {
+            String existingUri = namespaces.getURI(prefix);
+            if (RESERVED_NS.contains(existingUri)) {
+                throw new NamespaceException("Cannot register reserved namespace: " + prefix);
+            }
+        }
+
         Paths.addKnownNamespace(prefix, uri);
         namespaces.setMapping(prefix, uri);
         nodeTypeStore.write(namespaces, nodeTypeDefs);
@@ -428,6 +447,10 @@ public class RepositoryServiceImpl exten
 
     @Override
     public void unregisterNamespace(SessionInfo sessionInfo, String uri) throws RepositoryException
{
+        if (RESERVED_NS.contains(uri)) {
+            throw new NamespaceException("Cannot register reserved namespace: " + uri);
+        }
+        
         namespaces.removeMapping(uri);
         nodeTypeStore.write(namespaces, nodeTypeDefs);
     }



Mime
View raw message