jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1136504 - in /jackrabbit/sandbox/spi2microkernel/src: main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Date Thu, 16 Jun 2011 15:59:22 GMT
Author: mduerig
Date: Thu Jun 16 15:59:22 2011
New Revision: 1136504

URL: http://svn.apache.org/viewvc?rev=1136504&view=rev
Log:
spi2microkernel prototype (WIP)
name space registry

Modified:
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
    jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.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=1136504&r1=1136503&r2=1136504&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
Thu Jun 16 15:59:22 2011
@@ -47,7 +47,9 @@ import org.apache.jackrabbit.spi2microke
 import org.json.simple.parser.JSONParser;
 import org.json.simple.parser.ParseException;
 
+import javax.jcr.AccessDeniedException;
 import javax.jcr.Credentials;
+import javax.jcr.NamespaceException;
 import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
@@ -318,6 +320,18 @@ public class RepositoryServiceImpl exten
         nodeTypeDefs.unregisterNodeTypes(nodeTypeNames);
     }
 
+    //------------------------------------------< Name space management >---
+
+    @Override
+    public void registerNamespace(SessionInfo sessionInfo, String prefix, String uri) throws
NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException
{
+        namespaces.setMapping(prefix, uri);
+    }
+
+    @Override
+    public void unregisterNamespace(SessionInfo sessionInfo, String uri) throws NamespaceException,
UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
+        namespaces.removeMapping(uri);
+    }
+
     //------------------------------------------< private >---
 
     private static ChangeLog changeLog(Batch batch) throws RepositoryException {

Modified: jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java?rev=1136504&r1=1136503&r2=1136504&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Thu Jun 16 15:59:22 2011
@@ -30,6 +30,7 @@ import org.junit.Test;
 
 import javax.imageio.spi.ServiceRegistry;
 import javax.jcr.Binary;
+import javax.jcr.NamespaceRegistry;
 import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.Node;
 import javax.jcr.PathNotFoundException;
@@ -53,6 +54,7 @@ import java.util.Iterator;
 import java.util.Set;
 
 import static java.util.Arrays.asList;
+import static org.apache.jackrabbit.spi2microkernel.util.Arrays.contains;
 import static org.junit.Assert.*;
 
 public class RepositoryTest {
@@ -848,6 +850,21 @@ public class RepositoryTest {
     }
 
     @Test
+    public void nameSpaceRegistry() throws RepositoryException {
+        NamespaceRegistry nsReg = getSession().getWorkspace().getNamespaceRegistry();
+        assertFalse(contains(nsReg.getPrefixes(), "foo"));
+        assertFalse(contains(nsReg.getURIs(), "file:///foo"));
+
+        nsReg.registerNamespace("foo", "file:///foo");
+        assertTrue(contains(nsReg.getPrefixes(), "foo"));
+        assertTrue(contains(nsReg.getURIs(), "file:///foo"));
+
+        nsReg.unregisterNamespace("foo");
+        assertFalse(contains(nsReg.getPrefixes(), "foo"));
+        assertFalse(contains(nsReg.getURIs(), "file:///foo"));
+    }
+
+    @Test
     public void mixin() throws RepositoryException {
         NodeTypeManager ntMgr = getSession().getWorkspace().getNodeTypeManager();
         NodeTypeTemplate mixTest = ntMgr.createNodeTypeTemplate();



Mime
View raw message