jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r556151 - in /jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src: main/java/org/apache/jackrabbit/ocm/nodemanagement/ main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/ main/java/org/apache/jackrabbit/ocm/nodemanag...
Date Fri, 13 Jul 2007 21:22:18 GMT
Author: clombart
Date: Fri Jul 13 14:22:17 2007
New Revision: 556151

URL: http://svn.apache.org/viewvc?view=rev&rev=556151
Log:
1/ Solve issue JCR-1025 (default namespace should be empty).
2/ Add more methods for removing node types. Unfortunatly Jackrabbit doesn't support it yet.


Modified:
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/NodeTypeManager.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/BaseNamespaceHelper.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jeceira/NodeTypeManagerImpl.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/test/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/NodeTypeManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/NodeTypeManager.java?view=diff&rev=556151&r1=556150&r2=556151
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/NodeTypeManager.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/NodeTypeManager.java
Fri Jul 13 14:22:17 2007
@@ -131,7 +131,7 @@
             String jcrNodeType, boolean reflectSuperClasses)
             throws NodeTypeCreationException;
     
-    /** This method created JCR node types from a JCR vendor specific
+    /** This method creates JCR node types from a JCR vendor specific
      * configuration file.
      *
      * @param session Repository session
@@ -150,8 +150,17 @@
      * @param mappingXmlFiles InputStreams to jcr-mapping xml file
      * @throws NodeTypeRemovalException NodeTypeRemovalException
      */
-    void removeNodeTypes(Session session, InputStream[] mappingXmlFiles)
+    void removeNodeTypesFromMappingFile(Session session, InputStream[] mappingXmlFiles)
     throws NodeTypeRemovalException;
+    
+    /**
+     * This method removes JCR node types from a JCR vendor specific configuration file
+     * @param session Repository session
+     * @param jcrRepositoryConfigurationFile the file that contains the node type definition
+     * @throws NodeTypeRemovalException
+     */
+    void removeNodeTypesFromConfiguration(Session session, InputStream jcrRepositoryConfigurationFile)
+    throws NodeTypeRemovalException;    
     
     /** This method removes a single JCR node type identified by its jcrNodeType
      * name.

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/BaseNamespaceHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/BaseNamespaceHelper.java?view=diff&rev=556151&r1=556150&r2=556151
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/BaseNamespaceHelper.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/BaseNamespaceHelper.java
Fri Jul 13 14:22:17 2007
@@ -24,11 +24,11 @@
     
     /** Default namespace if none is specified.
      */
-    public static final String DEFAULT_NAMESPACE = "ocm";
+//    public static final String DEFAULT_NAMESPACE = "";
     
     /** Default namespace URI if none is specified.
      */
-    public static final String DEFAULT_NAMESPACE_URI = "http://jackrabbit.apache.org/ocm";
   
+    public static final String DEFAULT_NAMESPACE_URI = "";    
     
     /** Creates a new instance of BaseNamespaceHelper. */
     public BaseNamespaceHelper() {

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java?view=diff&rev=556151&r1=556150&r2=556151
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java
Fri Jul 13 14:22:17 2007
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.ocm.nodemanagement.impl.jackrabbit;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -459,7 +460,7 @@
      * @throws org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException 
      * @throws javax.jcr.RepositoryException 
      */
-    public void createNodeTypesFromList(Session session, List nodeTypes)
+    private void createNodeTypesFromList(Session session, List nodeTypes)
     throws InvalidNodeTypeDefException, RepositoryException
     {
         getNodeTypeRegistry(session).registerNodeTypes(nodeTypes);
@@ -468,9 +469,60 @@
     /**
      * @see org.apache.jackrabbit.ocm.nodemanagement.NodeTypeManager#removeNodeTypes
      */     
-    public void removeNodeTypes(Session session, InputStream[] mappingXmlFiles)
+    public void removeNodeTypesFromConfiguration(Session session, InputStream jcrRepositoryConfigurationFile)
     throws NodeTypeRemovalException
     {
+    	try
+        {
+            NodeTypeDef[] types = NodeTypeReader.read(jcrRepositoryConfigurationFile);
+
+            ArrayList list = new ArrayList();
+            for (int i = 0; i < types.length; i++)
+            {
+                list.add(types[i]);
+            }
+            
+            removeNodeTypesFromList(session, list);
+            log.info("Registered " + list.size() + " nodetypes from xml configuration file.");
+        }
+        catch (Exception e)
+        {
+            log.error("Could not create node types from configuration file.", e);
+            throw new NodeTypeRemovalException(e);
+        }
+    }
+    
+    private void removeNodeTypesFromList(Session session, List nodeTypes)
+    throws NodeTypeRemovalException
+    {
+        for (Iterator nodeTypeIterator = nodeTypes.iterator(); nodeTypeIterator.hasNext();)

+        {
+			NodeTypeDef nodeTypeDef = (NodeTypeDef) nodeTypeIterator.next();
+			this.removeSingleNodeType(session, nodeTypeDef.getName());
+			
+		}
+    	
+    }
+
+    /**
+     * @see org.apache.jackrabbit.ocm.nodemanagement.NodeTypeManager#createSingleNodeTypeFromMappingFile
+     */     
+    public void removeNodeTypesFromMappingFile(Session session, InputStream[] mappingXmlFile)
+            throws NodeTypeRemovalException
+    {
+    }
+    
+    public void removeSingleNodeType(Session session, QName qName)
+    throws NodeTypeRemovalException
+    {
+        try
+        {
+            getNodeTypeRegistry(session).unregisterNodeType(qName);
+        }
+        catch (Exception e)
+        {
+            throw new NodeTypeRemovalException(e);
+        }      
     }
     
     /**

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jeceira/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jeceira/NodeTypeManagerImpl.java?view=diff&rev=556151&r1=556150&r2=556151
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jeceira/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jeceira/NodeTypeManagerImpl.java
Fri Jul 13 14:22:17 2007
@@ -116,5 +116,12 @@
     public List getAllPrimaryNodeTypeNames(Session session)
     {
         return null;
-    }    
+    }
+
+	public void removeNodeTypesFromConfiguration(Session session, InputStream jcrRepositoryConfigurationFile)
throws NodeTypeRemovalException {
+	}
+
+	public void removeNodeTypesFromMappingFile(Session session, InputStream[] mappingXmlFiles)
throws NodeTypeRemovalException {
+	}   
+    
 }

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/test/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/test/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java?view=diff&rev=556151&r1=556150&r2=556151
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/test/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/test/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java
Fri Jul 13 14:22:17 2007
@@ -159,10 +159,10 @@
 
         getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
         
-        NodeType test3 = session.getWorkspace().getNodeTypeManager().getNodeType("ocm:test3");
+        NodeType test3 = session.getWorkspace().getNodeTypeManager().getNodeType("test3");
         assertNotNull(test3);
         assertFalse(test3.isMixin());
-        assertEquals(test3.getName(), "ocm:test3");
+        assertEquals(test3.getName(), "test3");
         assertEquals(test3.getSupertypes().length, 1);
         assertEquals(test3.getSupertypes()[0].getName(), "nt:base");        
     }
@@ -181,10 +181,10 @@
 
         getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
         
-        NodeType test4 = session.getWorkspace().getNodeTypeManager().getNodeType("ocm:test.Test4Class");
+        NodeType test4 = session.getWorkspace().getNodeTypeManager().getNodeType("test.Test4Class");
         assertNotNull(test4);
         assertFalse(test4.isMixin());
-        assertEquals(test4.getName(), "ocm:test.Test4Class");
+        assertEquals(test4.getName(), "test.Test4Class");
         assertEquals(test4.getSupertypes().length, 1);
         assertEquals(test4.getSupertypes()[0].getName(), "nt:base");        
     }
@@ -210,7 +210,7 @@
         assertEquals(test5.getSupertypes().length, 2);
         assertTrue(containsSuperType("ocm:test2", test5.getSupertypes()));
         assertTrue(containsSuperType("nt:base", test5.getSupertypes()));
-        assertTrue(containsProperty("ocm:abc", test5.getPropertyDefinitions()));
+        assertTrue(containsProperty("abc", test5.getPropertyDefinitions()));
     }
     
     public void testCreateSingleNodeTypeNtNamespace() throws Exception
@@ -261,7 +261,7 @@
         // not check node type definition, assuming other tests have done that
         
         // assert property definition a
-        PropertyDefinition propDef = getPropertyDefinition(test9.getPropertyDefinitions(),
"ocm:a");
+        PropertyDefinition propDef = getPropertyDefinition(test9.getPropertyDefinitions(),
"a");
         assertNotNull(propDef);
         assertEquals(propDef.getRequiredType(), PropertyType.STRING);
     }
@@ -286,7 +286,7 @@
         // not check node type definition, assuming other tests have done that
         
         // assert property definition a
-        PropertyDefinition propDef = getPropertyDefinition(test10.getPropertyDefinitions(),
"ocm:a");
+        PropertyDefinition propDef = getPropertyDefinition(test10.getPropertyDefinitions(),
"a");
         assertNotNull(propDef);
         assertEquals(propDef.getRequiredType(), PropertyType.STRING);
         
@@ -313,7 +313,7 @@
         // not check node type definition, assuming other tests have done that
         
         // assert property definition a
-        PropertyDefinition propDef = getPropertyDefinition(test13.getPropertyDefinitions(),
"ocm:a");
+        PropertyDefinition propDef = getPropertyDefinition(test13.getPropertyDefinitions(),
"a");
         assertNotNull(propDef);
         assertEquals(propDef.getRequiredType(), PropertyType.STRING);
     }
@@ -339,7 +339,7 @@
         // not check node type definition, assuming other tests have done that
         
         // assert property definition a
-        PropertyDefinition propDef = getPropertyDefinition(test14.getPropertyDefinitions(),
"ocm:a");
+        PropertyDefinition propDef = getPropertyDefinition(test14.getPropertyDefinitions(),
"a");
         assertNotNull(propDef);
         assertEquals(propDef.getRequiredType(), PropertyType.STRING);
 
@@ -365,7 +365,7 @@
         // not check node type definition, assuming other tests have done that
         
         // assert child node definition a
-        NodeDefinition nodeDef = getChildNodeDefinition(test11.getChildNodeDefinitions(),
"ocm:b");
+        NodeDefinition nodeDef = getChildNodeDefinition(test11.getChildNodeDefinitions(),
"b");
         assertNotNull(nodeDef);
         assertNotNull(nodeDef.getRequiredPrimaryTypes());
         assertEquals(nodeDef.getRequiredPrimaryTypes().length, 1);
@@ -392,7 +392,7 @@
         // not check node type definition, assuming other tests have done that
         
         // assert property definition a
-        NodeDefinition nodeDef = getChildNodeDefinition(test12.getChildNodeDefinitions(),
"ocm:b");
+        NodeDefinition nodeDef = getChildNodeDefinition(test12.getChildNodeDefinitions(),
"b");
         assertNotNull(nodeDef);
         assertNotNull(nodeDef);
         assertNotNull(nodeDef.getRequiredPrimaryTypes());



Mime
View raw message