jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r807714 - in /jackrabbit/trunk: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/...
Date Tue, 25 Aug 2009 16:56:36 GMT
Author: mduerig
Date: Tue Aug 25 16:56:36 2009
New Revision: 807714

URL: http://svn.apache.org/viewvc?rev=807714&view=rev
Log:
JCR-2278: Move NodeTypeStorage to spi-commons and provide default implementation

Added:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeStorage.java
      - copied, changed from r807517, jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeStorageImpl.java
  (with props)
Removed:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java
Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=807714&r1=807713&r2=807714&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Tue Aug 25 16:56:36 2009
@@ -18,7 +18,6 @@
 
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistryImpl;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeStorage;
 import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider;
 import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProviderImpl;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeTypeProvider;
@@ -86,6 +85,7 @@
 import org.apache.jackrabbit.spi.NameFactory;
 import org.apache.jackrabbit.spi.PathFactory;
 import org.apache.jackrabbit.spi.Subscription;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeStorage;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java?rev=807714&r1=807713&r2=807714&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java
Tue Aug 25 16:56:36 2009
@@ -20,6 +20,7 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeStorage;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java?rev=807714&r1=807713&r2=807714&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
Tue Aug 25 16:56:36 2009
@@ -26,6 +26,7 @@
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.QItemDefinition;
 import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeStorage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Copied: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeStorage.java
(from r807517, jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeStorage.java?p2=jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeStorage.java&p1=jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java&r1=807517&r2=807714&rev=807714&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeStorage.java
Tue Aug 25 16:56:36 2009
@@ -14,17 +14,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.jcr2spi.nodetype;
+package org.apache.jackrabbit.spi.commons.nodetype;
 
-import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import java.util.Iterator;
 
-import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.RepositoryException;
-import java.util.Iterator;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeTypeExistsException;
+
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 
 /**
- * <code>NodeTypeStorage</code>...
+ * <code>NodeTypeStorage</code> provides means for storing {@link QNodeTypeDefinition}s.
  */
 public interface NodeTypeStorage {
 
@@ -34,7 +36,7 @@
      * @return
      * @throws RepositoryException
      */
-    public Iterator getAllDefinitions() throws RepositoryException;
+    public Iterator<QNodeTypeDefinition> getAllDefinitions() throws RepositoryException;
 
     /**
      * Returns the <code>QNodeTypeDefinition</code>s for the given node type
@@ -46,9 +48,26 @@
      * @throws NoSuchNodeTypeException
      * @throws RepositoryException
      */
-    public Iterator getDefinitions(Name[] nodeTypeNames) throws NoSuchNodeTypeException,
RepositoryException;
+    public Iterator<QNodeTypeDefinition> getDefinitions(Name[] nodeTypeNames) throws
NoSuchNodeTypeException, RepositoryException;
+
+    /**
+     * Add all {@link QNodeTypeDefinition}s provided to the store. If <code>allowUpdate</code>
is <code>true</code>
+     * previously registered node QNodeTypeDefinitions will be overwritten.
+     * @param nodeTypeDefs  QNodeTypeDefinitions to add to the store
+     * @param allowUpdate   Whether to overwrite existing QNodeTypeDefinitions
+     * @throws RepositoryException
+     * @throws NodeTypeExistsException  If <code>allowUpdate</code> is <code>true</code>
and a QNodeTypeDefinitions
+     *   of that name already exists. In this case, none of the provided QNodeTypeDefinitions
is registered.
+     */
+    public void registerNodeTypes(QNodeTypeDefinition[] nodeTypeDefs, boolean allowUpdate)
+            throws RepositoryException, NodeTypeExistsException;
 
-    public void registerNodeTypes(QNodeTypeDefinition[] nodeTypeDefs, boolean allowUpdate)
throws RepositoryException;
-    
+    /**
+     * Remove all {@link QNodeTypeDefinition}s provided from the store.
+     * @param nodeTypeNames   QNodeTypeDefinitions to remove from the store
+     * @throws RepositoryException
+     * @throws NoSuchNodeTypeException  If any of the QNodeTypeDefinitions does not exist.
In this case
+     * none of the provided is unregistered.
+     */
     public void unregisterNodeTypes(Name[] nodeTypeNames) throws NoSuchNodeTypeException,
RepositoryException;
 }
\ No newline at end of file

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeStorageImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeStorageImpl.java?rev=807714&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeStorageImpl.java
(added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeStorageImpl.java
Tue Aug 25 16:56:36 2009
@@ -0,0 +1,94 @@
+/*
+ * 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.spi.commons.nodetype;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeTypeExistsException;
+
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+
+public class NodeTypeStorageImpl implements NodeTypeStorage {
+
+    private final Map<Name, QNodeTypeDefinition> definitions = new HashMap<Name,
QNodeTypeDefinition>();
+
+    public Iterator<QNodeTypeDefinition> getAllDefinitions() throws RepositoryException
{
+        return definitions.values().iterator();
+    }
+
+    public Iterator<QNodeTypeDefinition> getDefinitions(Name[] nodeTypeNames) throws
NoSuchNodeTypeException,
+            RepositoryException {
+
+        if (nodeTypeNames == null) {
+            return definitions.values().iterator();
+        }
+
+        Collection<QNodeTypeDefinition> defs = new ArrayList<QNodeTypeDefinition>(nodeTypeNames.length);
+
+        for (Name name : nodeTypeNames) {
+            if (definitions.containsKey(name)) {
+                defs.add(definitions.get(name));
+            }
+            else {
+                throw new NoSuchNodeTypeException("{" + name.getNamespaceURI() + "}" + name.getLocalName());
+            }
+        }
+
+        return defs.iterator();
+    }
+
+    public void registerNodeTypes(QNodeTypeDefinition[] nodeTypeDefs, boolean allowUpdate)
+            throws RepositoryException {
+
+        if (nodeTypeDefs == null) {
+            throw new IllegalArgumentException("nodeTypeDefs must not be null");
+        }
+
+        if (allowUpdate) {
+            for (QNodeTypeDefinition ntd : nodeTypeDefs) {
+                Name name = ntd.getName();
+                if (definitions.containsKey(name)) {
+                    throw new NodeTypeExistsException("{" + name.getNamespaceURI() + "}"
+ name.getLocalName());
+                }
+            }
+        }
+
+        for (QNodeTypeDefinition ntd : nodeTypeDefs) {
+            definitions.put(ntd.getName(), ntd);
+        }
+    }
+
+    public void unregisterNodeTypes(Name[] nodeTypeNames) throws NoSuchNodeTypeException,
RepositoryException {
+        for (Name name : nodeTypeNames) {
+            if (!definitions.containsKey(name)) {
+                throw new NoSuchNodeTypeException("{" + name.getNamespaceURI() + "}" + name.getLocalName());
+            }
+        }
+
+        for (Name name : nodeTypeNames) {
+            definitions.remove(name);
+        }
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeStorageImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message