You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by an...@apache.org on 2012/08/08 17:16:11 UTC
svn commit: r1370804 - in
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name:
NamespaceConstants.java NamespaceRegistryImpl.java Namespaces.java
Author: angela
Date: Wed Aug 8 15:16:10 2012
New Revision: 1370804
URL: http://svn.apache.org/viewvc?rev=1370804&view=rev
Log:
OAK-125 : Improved namespace registry
- resolve TODO regarding naming of system node storing the nsp registry.
-> replacing jcr-prefix by 'rep'
- move name and path to namespaces to a separate utility in order to make it available elsewhere in oak-core
Added:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceConstants.java
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceRegistryImpl.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java
Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceConstants.java?rev=1370804&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceConstants.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceConstants.java Wed Aug 8 15:16:10 2012
@@ -0,0 +1,29 @@
+/*
+ * 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.plugins.name;
+
+import org.apache.jackrabbit.JcrConstants;
+
+/**
+ * NamespaceConstants... TODO
+ */
+public interface NamespaceConstants {
+
+ String REP_NAMESPACES = "rep:namespaces";
+
+ String NAMESPACES_PATH = '/' + JcrConstants.JCR_SYSTEM + '/' + REP_NAMESPACES;
+}
\ No newline at end of file
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceRegistryImpl.java?rev=1370804&r1=1370803&r2=1370804&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceRegistryImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceRegistryImpl.java Wed Aug 8 15:16:10 2012
@@ -24,6 +24,7 @@ import javax.jcr.NamespaceException;
import javax.jcr.NamespaceRegistry;
import javax.jcr.RepositoryException;
+import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.ContentSession;
import org.apache.jackrabbit.oak.api.Root;
@@ -33,7 +34,7 @@ import org.apache.jackrabbit.oak.core.De
/**
* Implementation of {@link NamespaceRegistry}.
*/
-public class NamespaceRegistryImpl implements NamespaceRegistry {
+public class NamespaceRegistryImpl implements NamespaceRegistry, NamespaceConstants {
private final ContentSession session;
@@ -59,7 +60,7 @@ public class NamespaceRegistryImpl imple
throws RepositoryException {
try {
Root root = session.getCurrentRoot();
- Tree namespaces = getOrCreate(root, "jcr:system", Namespaces.NSMAPNODENAME);
+ Tree namespaces = getOrCreate(root, JcrConstants.JCR_SYSTEM, REP_NAMESPACES);
namespaces.setProperty(
prefix, session.getCoreValueFactory().createValue(uri));
root.commit(DefaultConflictHandler.OURS);
@@ -76,7 +77,7 @@ public class NamespaceRegistryImpl imple
@Override
public void unregisterNamespace(String prefix) throws RepositoryException {
Root root = session.getCurrentRoot();
- Tree namespaces = root.getTree("/jcr:system/jcr:namespaces");
+ Tree namespaces = root.getTree(NAMESPACES_PATH);
if (namespaces == null || !namespaces.hasProperty(prefix)) {
throw new NamespaceException(
"Namespace mapping from " + prefix + " to "
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java?rev=1370804&r1=1370803&r2=1370804&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java Wed Aug 8 15:16:10 2012
@@ -30,13 +30,10 @@ import org.apache.jackrabbit.oak.api.Tre
/**
* Internal static utility class for managing the persisted namespace registry.
*/
-class Namespaces {
+class Namespaces implements NamespaceConstants {
private static final Map<String, String> defaults = new HashMap<String, String>();
- // TODO: this should not use the "jcr" prefix
- public static final String NSMAPNODENAME = "jcr:namespaces";
-
private Namespaces() {
}
@@ -61,7 +58,7 @@ class Namespaces {
Tree system = root.getChild(JcrConstants.JCR_SYSTEM);
if (system != null) {
- Tree namespaces = system.getChild(NSMAPNODENAME);
+ Tree namespaces = system.getChild(REP_NAMESPACES);
if (namespaces != null) {
for (PropertyState property : namespaces.getProperties()) {
String prefix = property.getName();