jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1325775 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: NamespaceRegistryImpl.java WorkspaceImpl.java
Date Fri, 13 Apr 2012 14:01:07 GMT
Author: reschke
Date: Fri Apr 13 14:01:06 2012
New Revision: 1325775

URL: http://svn.apache.org/viewvc?rev=1325775&view=rev
Log:
add a dummy NamespaceRegsitry

Added:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NamespaceRegistryImpl.java
Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NamespaceRegistryImpl.java?rev=1325775&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NamespaceRegistryImpl.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NamespaceRegistryImpl.java
Fri Apr 13 14:01:06 2012
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.oak.jcr;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+/**
+ * A naive implementation of {@link NamespaceRegistry}, hard-wiring the
+ * predefined namespaces for now.
+ */
+public class NamespaceRegistryImpl implements NamespaceRegistry {
+
+    private Map<String, String> map;
+
+    public NamespaceRegistryImpl() {
+        map = new HashMap<String, String>();
+        map.put(PREFIX_EMPTY, NAMESPACE_EMPTY);
+        map.put(PREFIX_JCR, NAMESPACE_JCR);
+        map.put(PREFIX_MIX, NAMESPACE_MIX);
+        map.put(PREFIX_NT, NAMESPACE_NT);
+        map.put(PREFIX_XML, NAMESPACE_XML);
+    }
+
+    @Override
+    public void registerNamespace(String prefix, String uri) throws NamespaceException,
+            UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException
{
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void unregisterNamespace(String prefix) throws NamespaceException, UnsupportedRepositoryOperationException,
+            AccessDeniedException, RepositoryException {
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public String[] getPrefixes() throws RepositoryException {
+        return map.keySet().toArray(new String[map.size()]);
+    }
+
+    @Override
+    public String[] getURIs() throws RepositoryException {
+        return map.values().toArray(new String[map.size()]);
+    }
+
+    @Override
+    public String getURI(String prefix) throws NamespaceException, RepositoryException {
+        String result = map.get(prefix);
+        if (result == null) {
+            throw new NamespaceException();
+        }
+        return result;
+    }
+
+    @Override
+    public String getPrefix(String uri) throws NamespaceException, RepositoryException {
+        for (Map.Entry<String, String> entry : map.entrySet()) {
+            if (entry.getValue().equals(uri)) {
+                return entry.getKey();
+            }
+        }
+        throw new NamespaceException();
+    }
+}

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java?rev=1325775&r1=1325774&r2=1325775&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
Fri Apr 13 14:01:06 2012
@@ -51,6 +51,7 @@ public class WorkspaceImpl implements Wo
 
     private final SessionContext<SessionImpl> sessionContext;
     private QueryManagerImpl queryManager;
+    private NamespaceRegistry nsRegistry;
 
     public WorkspaceImpl(SessionContext<SessionImpl> sessionContext) {
         this.sessionContext = sessionContext;
@@ -154,9 +155,10 @@ public class WorkspaceImpl implements Wo
     @Override
     public NamespaceRegistry getNamespaceRegistry() throws RepositoryException {
         ensureIsAlive();
-
-        // TODO
-        return null;
+        if (nsRegistry == null) {
+            nsRegistry = new NamespaceRegistryImpl();
+        }
+        return nsRegistry;
     }
 
     @Override



Mime
View raw message