jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r827966 [14/15] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security...
Date Wed, 21 Oct 2009 11:38:44 GMT
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java Wed Oct 21 11:38:31 2009
@@ -29,7 +29,7 @@
 import javax.jcr.RepositoryException;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.List;
 import java.util.Stack;
 
 /**
@@ -58,7 +58,7 @@
      * the same instance is popped from the stack in the endElement method
      * when the corresponding sv:node element is encountered.
      */
-    private final Stack stack = new Stack();
+    private final Stack<ImportState> stack = new Stack<ImportState>();
 
     /**
      * fields used temporarily while processing sv:property and sv:value elements
@@ -66,7 +66,7 @@
     private Name currentPropName;
     private int currentPropType = PropertyType.UNDEFINED;
     // list of AppendableValue objects
-    private ArrayList currentPropValues = new ArrayList();
+    private List<Importer.TextValue> currentPropValues = new ArrayList<Importer.TextValue>();
     private AppendableValue currentPropValue;
 
     /**
@@ -86,7 +86,7 @@
         }
         Name[] mixins = null;
         if (state.mixinNames != null) {
-            mixins = (Name[]) state.mixinNames.toArray(new Name[state.mixinNames.size()]);
+            mixins = state.mixinNames.toArray(new Name[state.mixinNames.size()]);
         }
         Importer.NodeInfo nodeInfo = new Importer.NodeInfo(state.nodeName, state.nodeTypeName, mixins, state.uuid);
 
@@ -98,8 +98,7 @@
             if (start) {
                 importer.startNode(nodeInfo, state.props, resolver);
                 // dispose temporary property values
-                for (Iterator iter = state.props.iterator(); iter.hasNext();) {
-                    Importer.PropInfo pi = (Importer.PropInfo) iter.next();
+                for (Importer.PropInfo pi : state.props) {
                     disposePropertyValues(pi);
                 }
             }
@@ -136,7 +135,7 @@
 
             if (!stack.isEmpty()) {
                 // process current node first
-                ImportState current = (ImportState) stack.peek();
+                ImportState current = stack.peek();
                 // need to start current node
                 if (!current.started) {
                     processNode(current, true, false);
@@ -232,7 +231,7 @@
     public void endElement(String namespaceURI, String localName, String qName)
             throws SAXException {
         // check element name
-        ImportState state = (ImportState) stack.peek();
+        ImportState state = stack.peek();
         if (NODE.equals(localName)) {
             // sv:node element
             if (!state.started) {
@@ -265,7 +264,7 @@
                 }
             } else if (currentPropName.equals(NameConstants.JCR_MIXINTYPES)) {
                 if (state.mixinNames == null) {
-                    state.mixinNames = new ArrayList(currentPropValues.size());
+                    state.mixinNames = new ArrayList<Name>(currentPropValues.size());
                 }
                 for (int i = 0; i < currentPropValues.size(); i++) {
                     AppendableValue val =
@@ -291,7 +290,7 @@
                     throw new SAXException("error while retrieving value", ioe);
                 }
             } else {
-                Importer.TextValue[] values = (Importer.TextValue[]) currentPropValues.toArray(new Importer.TextValue[currentPropValues.size()]);
+                Importer.TextValue[] values = currentPropValues.toArray(new Importer.TextValue[currentPropValues.size()]);
                 Importer.PropInfo prop = new Importer.PropInfo(currentPropName, currentPropType, values);
                 state.props.add(prop);
             }
@@ -320,7 +319,7 @@
         /**
          * list of mixin types of current node
          */
-        ArrayList mixinNames;
+        List<Name> mixinNames;
         /**
          * uuid of current node
          */
@@ -329,7 +328,7 @@
         /**
          * list of PropInfo instances representing properties of current node
          */
-        ArrayList props = new ArrayList();
+        List<Importer.PropInfo> props = new ArrayList<Importer.PropInfo>();
 
         /**
          * flag indicating whether startNode() has been called for current node

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java Wed Oct 21 11:38:31 2009
@@ -37,6 +37,7 @@
 
 import junit.framework.TestCase;
 
+import org.apache.jackrabbit.commons.cnd.ParseException;
 import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
 import org.apache.jackrabbit.spi.Batch;
 import org.apache.jackrabbit.spi.ChildInfo;
@@ -64,7 +65,6 @@
 import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.Subscription;
 import org.apache.jackrabbit.spi.commons.AbstractReadableRepositoryService;
-import org.apache.jackrabbit.spi.commons.nodetype.compact.ParseException;
 import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
 
 /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/HierarchyNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/HierarchyNodeTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/HierarchyNodeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/HierarchyNodeTest.java Wed Oct 21 11:38:31 2009
@@ -62,6 +62,7 @@
         resourceProps.add(jcrPrefix+":lastModifiedBy");
         resourceProps.add(jcrPrefix+":mimeType");
         resourceProps.add(jcrPrefix+":data");
+        resourceProps.add(jcrPrefix+":uuid");
 
         try {
             Node folder = testRootNode.addNode("folder", ntFolder);
@@ -116,4 +117,4 @@
             dump(nodes.nextNode());
         }
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java Wed Oct 21 11:38:31 2009
@@ -20,6 +20,7 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.jackrabbit.jcr2spi.observation.ObservationTest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -102,6 +103,9 @@
         // repository
         suite.addTestSuite(LoginTest.class);
 
+        // observation
+        suite.addTestSuite(ObservationTest.class);
+
         return suite;
     }
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryTest.java Wed Oct 21 11:38:31 2009
@@ -66,7 +66,7 @@
     }
 
     /**
-     * Test if a new registred namespace is immediately visible through another
+     * Test if a new registered namespace is immediately visible through another
      * session object.
      *
      * @throws RepositoryException
@@ -194,7 +194,7 @@
      * @return an unused namespace prefix.
      */
     private String getUnusedPrefix() throws RepositoryException {
-        Set prefixes = new HashSet(Arrays.asList(nsRegistry.getPrefixes()));
+        Set<String> prefixes = new HashSet<String>(Arrays.asList(nsRegistry.getPrefixes()));
         String prefix = TEST_PREFIX;
         int i = 0;
         while (prefixes.contains(prefix)) {
@@ -209,7 +209,7 @@
      * @return an unused namespace URI.
      */
     private String getUnusedURI() throws RepositoryException {
-        Set uris = new HashSet(Arrays.asList(nsRegistry.getURIs()));
+        Set<String> uris = new HashSet<String>(Arrays.asList(nsRegistry.getURIs()));
         String uri = TEST_URI;
         int i = 0;
         while (uris.contains(uri)) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java Wed Oct 21 11:38:31 2009
@@ -35,11 +35,11 @@
      * @throws NotExecutableException 
      */
     public void testQueryChildNodesOfRoot() throws RepositoryException, NotExecutableException {
-        List nodes = new ArrayList();
+        List<Node> nodes = new ArrayList<Node>();
         for (NodeIterator it = superuser.getRootNode().getNodes(); it.hasNext(); ) {
             nodes.add(it.nextNode());
         }
-        Node[] children = (Node[]) nodes.toArray(new Node[nodes.size()]);
+        Node[] children = nodes.toArray(new Node[nodes.size()]);
         executeXPathQuery(superuser, "/jcr:root/*", children);
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/xml/SessionImportTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/xml/SessionImportTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/xml/SessionImportTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/xml/SessionImportTest.java Wed Oct 21 11:38:31 2009
@@ -204,7 +204,7 @@
     private static String getUnknownURI(Session session, String uriHint) throws RepositoryException {
         String uri = uriHint;
         int index = 0;
-        List uris = Arrays.asList(session.getWorkspace().getNamespaceRegistry().getURIs());
+        List<String> uris = Arrays.asList(session.getWorkspace().getNamespaceRegistry().getURIs());
         while (uris.contains(uri)) {
             uri = uriHint + index;
             index++;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-parent/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-parent/pom.xml?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-parent/pom.xml (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-parent/pom.xml Wed Oct 21 11:38:31 2009
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.jackrabbit</groupId>
     <artifactId>parent</artifactId>
-    <version>3</version>
+    <version>4</version>
   </parent>
 
   <artifactId>jackrabbit-parent</artifactId>
@@ -45,6 +45,7 @@
   <properties>
     <slf4j.version>1.5.3</slf4j.version>
     <jetty.version>6.1.14</jetty.version>
+    <tika.version>0.4</tika.version>
   </properties>
 
   <build>
@@ -73,7 +74,6 @@
       <plugin>
         <!-- http://maven.apache.org/plugins/maven-idea-plugin/ -->
         <artifactId>maven-idea-plugin</artifactId>
-        <version>2.2</version>
         <configuration>
           <downloadSources>true</downloadSources>
           <jdkLevel>1.5</jdkLevel>
@@ -147,7 +147,7 @@
       <dependency>
         <groupId>javax.jcr</groupId>
         <artifactId>jcr</artifactId>
-        <version>2.0-b114</version>
+        <version>2.0</version>
         <scope>provided</scope>
       </dependency>
       <dependency>
@@ -233,6 +233,16 @@
         <version>2.4.1</version>
       </dependency>
       <dependency>
+        <groupId>org.apache.tika</groupId>
+        <artifactId>tika-core</artifactId>
+        <version>${tika.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.tika</groupId>
+        <artifactId>tika-parsers</artifactId>
+        <version>${tika.version}</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.derby</groupId>
         <artifactId>derby</artifactId>
         <version>10.2.1.6</version>

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/pom.xml?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/pom.xml (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/pom.xml Wed Oct 21 11:38:31 2009
@@ -34,6 +34,7 @@
   </parent>
   <artifactId>jackrabbit-spi-commons</artifactId>
   <name>Jackrabbit SPI Commons</name>
+  <packaging>bundle</packaging>
 
   <scm>
     <connection>
@@ -47,6 +48,19 @@
 
   <build>
     <plugins>
+        <plugin>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>maven-bundle-plugin</artifactId>
+          <extensions>true</extensions>
+          <configuration>
+            <instructions>
+              <Export-Package>
+                org.apache.jackrabbit.spi.commons;version=${pom.version},
+                org.apache.jackrabbit.spi.commons.*;version=${pom.version}
+              </Export-Package>
+            </instructions>
+          </configuration>
+        </plugin>
       <plugin>
         <artifactId>maven-antrun-plugin</artifactId>
         <executions>

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java Wed Oct 21 11:38:31 2009
@@ -32,13 +32,13 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
 
+import org.apache.jackrabbit.commons.cnd.ParseException;
 import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.ItemInfo;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.NodeInfo;
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.SessionInfo;
-import org.apache.jackrabbit.spi.commons.nodetype.compact.ParseException;
 
 /**
  * <code>AbstractReadableRepositoryService</code> provides an abstract base

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java Wed Oct 21 11:38:31 2009
@@ -48,6 +48,8 @@
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.version.VersionException;
 
+import org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader;
+import org.apache.jackrabbit.commons.cnd.ParseException;
 import org.apache.jackrabbit.spi.Batch;
 import org.apache.jackrabbit.spi.EventBundle;
 import org.apache.jackrabbit.spi.EventFilter;
@@ -75,8 +77,7 @@
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeStorage;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeStorageImpl;
-import org.apache.jackrabbit.spi.commons.nodetype.compact.CompactNodeTypeDefReader;
-import org.apache.jackrabbit.spi.commons.nodetype.compact.ParseException;
+import org.apache.jackrabbit.spi.commons.nodetype.QDefinitionBuilderFactory;
 import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
 
 /**
@@ -205,9 +206,11 @@
             this.namespaces.setMapping(entry.getKey(), entry.getValue());
         }
 
-        CompactNodeTypeDefReader reader;
+        CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping> reader;
         try {
-            reader = new CompactNodeTypeDefReader(cnd, "", this.namespaces);
+            reader = new CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping>(cnd, "",
+                    this.namespaces, new QDefinitionBuilderFactory());
+
             List<QNodeTypeDefinition> ntds = reader.getNodeTypeDefinitions();
             nodeTypeDefs.registerNodeTypes(ntds.toArray(new QNodeTypeDefinition[ntds.size()]), true);
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java Wed Oct 21 11:38:31 2009
@@ -20,7 +20,6 @@
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 
 import java.io.Serializable;
 
@@ -32,12 +31,6 @@
 public abstract class QItemDefinitionImpl implements QItemDefinition, Serializable {
 
     /**
-     * The special wildcard name used as the name of residual item definitions.
-     * TODO don't rely on specific factory impl
-     */
-    public static final Name ANY_NAME = NameFactoryImpl.getInstance().create("", "*");
-
-    /**
      * The name of the child item.
      */
     private final Name name;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java Wed Oct 21 11:38:31 2009
@@ -18,25 +18,34 @@
 
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.commons.conversion.NameException;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
 
 import java.util.Arrays;
 import java.util.TreeSet;
+import java.util.Set;
+import java.util.HashSet;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
 
 /**
  * <code>QNodeDefinitionImpl</code> implements a <code>QNodeDefinition</code>.
  */
 public class QNodeDefinitionImpl extends QItemDefinitionImpl implements QNodeDefinition {
 
+    private static final long serialVersionUID = -3671882394577685657L;
+
     /**
      * The name of the default primary type.
      */
     private final Name defaultPrimaryType;
-
     /**
      * The names of the required primary types.
      */
-    private final Name[] requiredPrimaryTypes;
-
+    private final Set<Name> requiredPrimaryTypes = new HashSet<Name>();
     /**
      * The 'allowsSameNameSiblings' flag.
      */
@@ -77,11 +86,36 @@
         super(name, declaringNodeType, isAutoCreated, isMandatory,
                 onParentVersion, isProtected);
         this.defaultPrimaryType = defaultPrimaryType;
-        this.requiredPrimaryTypes = requiredPrimaryTypes;
+        this.requiredPrimaryTypes.addAll(Arrays.asList(requiredPrimaryTypes));
         this.allowsSameNameSiblings = allowsSameNameSiblings;
     }
 
+    /**
+     * Creates a new node definition based on a JCR <code>NodeDefinition</code>.
+     *
+     * @param nodeDef  the node definition.
+     * @param resolver the name/path resolver of the session that provided the
+     *                 node definition
+     * @throws NameException      if <code>nodeDef</code> contains an illegal
+     *                            name.
+     * @throws NamespaceException if <code>nodeDef</code> contains a name with
+     *                            an namespace prefix that is unknown to
+     *                            <code>resolver</code>.
+     */
+    public QNodeDefinitionImpl(NodeDefinition nodeDef,
+                               NamePathResolver resolver)
+            throws NameException, NamespaceException {
+        this(nodeDef.getName().equals(NameConstants.ANY_NAME.getLocalName()) ? NameConstants.ANY_NAME : resolver.getQName(nodeDef.getName()),
+                nodeDef.getDeclaringNodeType() != null ? resolver.getQName(nodeDef.getDeclaringNodeType().getName()) : null,
+                nodeDef.isAutoCreated(), nodeDef.isMandatory(),
+                nodeDef.getOnParentVersion(), nodeDef.isProtected(),
+                nodeDef.getDefaultPrimaryType() != null ? resolver.getQName(nodeDef.getDefaultPrimaryType().getName()) : null,
+                getNodeTypeNames(nodeDef.getRequiredPrimaryTypes(), resolver),
+                nodeDef.allowsSameNameSiblings());
+    }
+
     //-------------------------------------------------------< QNodeDefinition >
+
     /**
      * {@inheritDoc}
      */
@@ -93,7 +127,7 @@
      * {@inheritDoc}
      */
     public Name[] getRequiredPrimaryTypes() {
-        return requiredPrimaryTypes;
+        return requiredPrimaryTypes.toArray(new Name[requiredPrimaryTypes.size()]);
     }
 
     /**
@@ -130,7 +164,8 @@
         if (obj instanceof QNodeDefinition) {
             QNodeDefinition other = (QNodeDefinition) obj;
             return super.equals(obj)
-                    && Arrays.equals(requiredPrimaryTypes, other.getRequiredPrimaryTypes())
+                    && requiredPrimaryTypes.equals(new HashSet<Name>(
+                            Arrays.asList(other.getRequiredPrimaryTypes())))
                     && (defaultPrimaryType == null
                             ? other.getDefaultPrimaryType() == null
                             : defaultPrimaryType.equals(other.getDefaultPrimaryType()))
@@ -169,4 +204,29 @@
         }
         return hashCode;
     }
+
+    //-----------------------------< internal >---------------------------------
+
+    /**
+     * Returns the names of the passed node types using the namespace resolver
+     * to parse the names.
+     *
+     * @param nt       the node types
+     * @param resolver the name/path resolver of the session that provided
+     *                 <code>nt</code>.
+     * @return the names of the node types.
+     * @throws NameException      if a node type returns an illegal name.
+     * @throws NamespaceException if the name of a node type contains a prefix
+     *                            that is not known to <code>resolver</code>.
+     */
+    private static Name[] getNodeTypeNames(NodeType[] nt,
+                                           NamePathResolver resolver)
+            throws NameException, NamespaceException {
+        Name[] names = new Name[nt.length];
+        for (int i = 0; i < nt.length; i++) {
+            Name ntName = resolver.getQName(nt[i].getName());
+            names[i] = ntName;
+        }
+        return names;
+    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java Wed Oct 21 11:38:31 2009
@@ -25,6 +25,7 @@
 import org.apache.jackrabbit.spi.QValueFactory;
 import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
@@ -40,6 +41,9 @@
 import java.util.HashSet;
 import java.util.Collections;
 import java.util.Arrays;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.Set;
 import java.io.Serializable;
 
 /**
@@ -48,6 +52,8 @@
  */
 public class QNodeTypeDefinitionImpl implements QNodeTypeDefinition, Serializable {
 
+    private static final long serialVersionUID = -4065300714874671511L;
+
     /**
      * The name of the node definition.
      */
@@ -89,20 +95,30 @@
     private final Name primaryItemName;
 
     /**
-     * The list of property definitions.
+     * The list of child node definitions.
      */
-    private final QPropertyDefinition[] propertyDefs;
+    private final Set<QPropertyDefinition> propertyDefs;
 
     /**
-     * The list of child node definitions.
+     * The list of property definitions.
      */
-    private final QNodeDefinition[] childNodeDefs;
+    private final Set<QNodeDefinition> childNodeDefs;
 
     /**
      * Unmodifiable collection of dependent node type <code>Name</code>s.
+     * Calculated on demand.
+     *
      * @see #getDependencies()
      */
-    private transient Collection<Name> dependencies;
+    private transient volatile Collection<Name> dependencies;
+
+    /**
+     * Default constructor.
+     */
+    public QNodeTypeDefinitionImpl() {
+        this(null, Name.EMPTY_ARRAY, null, false, false, true, false, null,
+                QPropertyDefinition.EMPTY_ARRAY, QNodeDefinition.EMPTY_ARRAY);
+    }
 
     /**
      * Copy constructor.
@@ -143,7 +159,6 @@
                                    QPropertyDefinition[] declaredPropDefs,
                                    QNodeDefinition[] declaredNodeDefs) {
         this.name = name;
-        this.supertypes = supertypes;
         this.supportedMixins = supportedMixins;
         this.isMixin = isMixin;
         this.isAbstract = isAbstract;
@@ -152,6 +167,10 @@
         this.primaryItemName = primaryItemName;
         this.propertyDefs = getSerializablePropertyDefs(declaredPropDefs);
         this.childNodeDefs = getSerializableNodeDefs(declaredNodeDefs);
+        // make sure supertypes are sorted
+        SortedSet<Name> types = new TreeSet<Name>();
+        types.addAll(Arrays.asList(supertypes));
+        this.supertypes = types.toArray(new Name[types.size()]);
     }
 
     /**
@@ -195,6 +214,7 @@
     }
 
     //------------------------------------------------< QNodeTypeDefinition >---
+
     /**
      * {@inheritDoc}
      */
@@ -206,9 +226,12 @@
      * {@inheritDoc}
      */
     public Name[] getSupertypes() {
-        Name[] sTypes = new Name[supertypes.length];
-        System.arraycopy(supertypes, 0, sTypes, 0, supertypes.length);
-        return sTypes;
+        if (supertypes.length > 0
+                || isMixin() || NameConstants.NT_BASE.equals(getName())) {
+            return supertypes;
+        } else {
+            return new Name[] { NameConstants.NT_BASE };
+        }
     }
 
     /**
@@ -250,24 +273,20 @@
      * {@inheritDoc}
      */
     public QPropertyDefinition[] getPropertyDefs() {
-        QPropertyDefinition[] pDefs = new QPropertyDefinition[propertyDefs.length];
-        System.arraycopy(propertyDefs, 0, pDefs, 0, propertyDefs.length);
-        return pDefs;
+        return propertyDefs.toArray(new QPropertyDefinition[propertyDefs.size()]);
     }
 
     /**
      * {@inheritDoc}
      */
     public QNodeDefinition[] getChildNodeDefs() {
-        QNodeDefinition[] cnDefs = new QNodeDefinition[childNodeDefs.length];
-        System.arraycopy(childNodeDefs, 0, cnDefs, 0, childNodeDefs.length);
-        return cnDefs;
+        return childNodeDefs.toArray(new QNodeDefinition[childNodeDefs.size()]);
     }
 
     /**
      * {@inheritDoc}
      */
-    public Collection getDependencies() {
+    public Collection<Name> getDependencies() {
         if (dependencies == null) {
             Collection<Name> deps = new HashSet<Name>();
             // supertypes
@@ -309,6 +328,9 @@
         return dependencies;
     }
     
+    /**
+     * {@inheritDoc}
+     */
     public Name[] getSupportedMixinTypes() {
         if (supportedMixins == null) {
             return null;
@@ -320,46 +342,78 @@
         }
     }
     
+    //-------------------------------------------< java.lang.Object overrides >
+
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof QNodeTypeDefinitionImpl) {
+            QNodeTypeDefinitionImpl other = (QNodeTypeDefinitionImpl) obj;
+            return (name == null ? other.name == null : name.equals(other.name))
+                    && (primaryItemName == null ? other.primaryItemName == null : primaryItemName.equals(other.primaryItemName))
+                    && Arrays.equals(getSupertypes(), other.getSupertypes())
+                    && isMixin == other.isMixin
+                    && hasOrderableChildNodes == other.hasOrderableChildNodes
+                    && isAbstract == other.isAbstract
+                    && isQueryable == other.isQueryable
+                    && propertyDefs.equals(other.propertyDefs)
+                    && childNodeDefs.equals(other.childNodeDefs);
+        }
+        return false;
+    }
+
+    /**
+     * Returns zero to satisfy the Object equals/hashCode contract.
+     * This class is mutable and not meant to be used as a hash key.
+     *
+     * @return always zero
+     * @see Object#hashCode()
+     */
+    public int hashCode() {
+        return 0;
+    }
+
     //-------------------------------< internal >-------------------------------
 
     /**
-     * Returns an array of serializable property definitions for
+     * Returns a set of serializable property definitions for
      * <code>propDefs</code>.
      *
      * @param propDefs the SPI property definitions.
-     * @return an array of serializable property definitions.
+     * @return a set of serializable property definitions.
      */
-    private static QPropertyDefinition[] getSerializablePropertyDefs(
+    private static Set<QPropertyDefinition> getSerializablePropertyDefs(
             QPropertyDefinition[] propDefs) {
-        QPropertyDefinition[] serDefs = new QPropertyDefinition[propDefs.length];
-        for (int i = 0; i < propDefs.length; i++) {
-            if (propDefs[i] instanceof Serializable) {
-                serDefs[i] = propDefs[i];
+        Set<QPropertyDefinition> defs = new HashSet<QPropertyDefinition>();
+        for (QPropertyDefinition pd : propDefs) {
+            if (pd instanceof Serializable) {
+                defs.add(pd);
             } else {
-                serDefs[i] = new QPropertyDefinitionImpl(propDefs[i]);
+                defs.add(pd);
             }
         }
-        return serDefs;
+        return defs;
     }
 
     /**
-     * Returns an array of serializable node definitions for
+     * Returns a set of serializable node definitions for
      * <code>nodeDefs</code>.
      *
      * @param nodeDefs the node definitions.
-     * @return an array of serializable node definitions.
+     * @return a set of serializable node definitions.
      */
-    private static QNodeDefinition[] getSerializableNodeDefs(
+    private static Set<QNodeDefinition> getSerializableNodeDefs(
             QNodeDefinition[] nodeDefs) {
-        QNodeDefinition[] serDefs = new QNodeDefinition[nodeDefs.length];
-        for (int i = 0; i < nodeDefs.length; i++) {
-            if (nodeDefs[i] instanceof Serializable) {
-                serDefs[i] = nodeDefs[i];
+        Set<QNodeDefinition> defs = new HashSet<QNodeDefinition>();
+        for (QNodeDefinition nd : nodeDefs) {
+            if (nd instanceof Serializable) {
+                defs.add(nd);
             } else {
-                serDefs[i] = new QNodeDefinitionImpl(nodeDefs[i]);
+                defs.add(new QNodeDefinitionImpl(nd));
             }
         }
-        return serDefs;
+        return defs;
     }
 
     private static Name[] getNames(String[] jcrNames, NamePathResolver resolver) throws NamespaceException, IllegalNameException {
@@ -381,8 +435,8 @@
         QPropertyDefinition[] declaredPropDefs = new QPropertyDefinition[pds.length];
         for (int i = 0; i < pds.length; i++) {
             PropertyDefinition propDef = pds[i];
-            Name name = propDef.getName().equals(QItemDefinitionImpl.ANY_NAME.getLocalName())
-                    ? QItemDefinitionImpl.ANY_NAME
+            Name name = propDef.getName().equals(NameConstants.ANY_NAME.getLocalName())
+                    ? NameConstants.ANY_NAME
                     : resolver.getQName(propDef.getName());
             // check if propDef provides declaring node type and if it matches 'this' one.
             if (propDef.getDeclaringNodeType() != null) {
@@ -429,8 +483,8 @@
         QNodeDefinition[] declaredNodeDefs = new QNodeDefinition[nds.length];
         for (int i = 0; i < nds.length; i++) {
             NodeDefinition nodeDef = nds[i];
-            Name name = nodeDef.getName().equals(QItemDefinitionImpl.ANY_NAME.getLocalName())
-                    ? QItemDefinitionImpl.ANY_NAME
+            Name name = nodeDef.getName().equals(NameConstants.ANY_NAME.getLocalName())
+                    ? NameConstants.ANY_NAME
                     : resolver.getQName(nodeDef.getName());
             // check if propDef provides declaring node type and if it matches 'this' one.
             if (nodeDef.getDeclaringNodeType() != null) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java Wed Oct 21 11:38:31 2009
@@ -20,11 +20,20 @@
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
+import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.nodetype.PropertyDefinition;
+
 /**
  * <code>QPropertyDefinitionImpl</code> implements SPI property
  * definition interface.
@@ -32,6 +41,8 @@
 public class QPropertyDefinitionImpl extends QItemDefinitionImpl
         implements QPropertyDefinition {
 
+    private static final long serialVersionUID = 1064686456661663541L;
+
     /**
      * The required type.
      */
@@ -61,7 +72,6 @@
      * The 'fullTextSearcheable' flag
      */
     private final boolean fullTextSearchable;
-
     /**
      * The 'queryOrderable' flag
      */
@@ -101,7 +111,8 @@
      * @param availableQueryOperators the available query operators
      * @param isFullTextSearchable if this is fulltext searchable
      * @param isQueryOrderable   if this is queryable
-     * @throws NullPointerException if <code>valueConstraints</code> is
+     * @throws NullPointerException if <code>valueConstraints</code> or
+     *                              <code>availableQueryOperators</code> is
      *                              <code>null</code>.
      * @since JCR 2.0
      */
@@ -119,6 +130,9 @@
         if (valueConstraints == null) {
             throw new NullPointerException("valueConstraints");
         }
+        if (availableQueryOperators == null) {
+            throw new NullPointerException("availableQueryOperators");
+        }
         this.defaultValues = defaultValues;
         this.multiple = isMultiple;
         this.requiredType = requiredType;
@@ -128,6 +142,31 @@
         this.queryOrderable = isQueryOrderable;
     }
 
+    /**
+     * Creates a new property definition based on <code>propDef</code>.
+     *
+     * @param propDef       the JCR property definition.
+     * @param resolver      the name/path resolver of the session that provided
+     *                      the property definition.
+     * @param qValueFactory the QValue factory.
+     * @throws RepositoryException if an error occurs while reading from
+     *                             <code>propDef</code>.
+     */
+    public QPropertyDefinitionImpl(PropertyDefinition propDef,
+                                   NamePathResolver resolver,
+                                   QValueFactory qValueFactory)
+            throws RepositoryException {
+        this(propDef.getName().equals(NameConstants.ANY_NAME.getLocalName()) ? NameConstants.ANY_NAME : resolver.getQName(propDef.getName()),
+                resolver.getQName(propDef.getDeclaringNodeType().getName()),
+                propDef.isAutoCreated(), propDef.isMandatory(),
+                propDef.getOnParentVersion(), propDef.isProtected(),
+                convertValues(propDef.getDefaultValues(), resolver, qValueFactory),
+                propDef.isMultiple(), propDef.getRequiredType(),
+                ValueConstraint.create(propDef.getRequiredType(), propDef.getValueConstraints(), resolver),
+                propDef.getAvailableQueryOperators(),
+                propDef.isFullTextSearchable(), propDef.isQueryOrderable());
+    }
+
     //------------------------------------------------< QPropertyDefinition >---
     /**
      * {@inheritDoc}
@@ -251,4 +290,31 @@
         }
         return hashCode;
     }
+
+    //-------------------------------< internal >-------------------------------
+
+    /**
+     * Convers JCR {@link Value}s to {@link QValue}s.
+     *
+     * @param values   the JCR values.
+     * @param resolver the name/path resolver of the session that provided the
+     *                 values.
+     * @param factory  the QValue factory.
+     * @return the converted values.
+     * @throws RepositoryException if an error occurs while converting the
+     *                             values.
+     */
+    private static QValue[] convertValues(Value[] values,
+                                          NamePathResolver resolver,
+                                          QValueFactory factory)
+            throws RepositoryException {
+        QValue[] defaultValues = null;
+        if (values != null) {
+            defaultValues = new QValue[values.length];
+            for (int i = 0; i < values.length; i++) {
+                defaultValues[i] = ValueFormat.getQValue(values[i], resolver, factory);
+            }
+        }
+        return defaultValues;
+    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/NameParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/NameParser.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/NameParser.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/NameParser.java Wed Oct 21 11:38:31 2009
@@ -119,24 +119,29 @@
             } else if (c == '}') {
                 if (state == STATE_URI_START || state == STATE_URI) {
                     String tmp = jcrName.substring(1, i);
-                    try {
-                        // make sure the uri is a known namespace uri
-                        // TODO: since namespace registration does not validate
-                        //       the URI format validation is omitted here
-                        if (!checkFormat) {
-                            resolver.getPrefix(tmp);
-                        }
+                    if (tmp.length() == 0 || tmp.indexOf(':') != -1) {
+                        // The leading "{...}" part is empty or contains
+                        // a colon, so we treat it as a valid namespace URI.
+                        // More detailed validity checks (is it well formed,
+                        // registered, etc.) are not needed here.
                         uri = tmp;
                         state = STATE_NAME_START;
-                    } catch (NamespaceException e) {
-                        // unknown uri -> apparently a localname starting with {
-                        // -> make sure there are no invalid characters
-                        if (tmp.indexOf(':') == -1 && tmp.indexOf('/') == -1) {
-                            state = STATE_NAME;
-                            nameStart = 0;
-                        } else {
-                            throw new IllegalNameException("Unknown uri " + tmp + ". But ':' and '/' are not allowed in a local name.");
-                        }
+                    } else if (tmp.equals("internal")) {
+                        // As a special Jackrabbit backwards compatibility
+                        // feature, support {internal} as a valid URI prefix
+                        uri = tmp;
+                        state = STATE_NAME_START;
+                    } else if (tmp.indexOf('/') == -1) {
+                        // The leading "{...}" contains neither a colon nor
+                        // a slash, so we can interpret it as a a part of a
+                        // normal local name.
+                        state = STATE_NAME;
+                        nameStart = 0;
+                    } else {
+                        throw new IllegalNameException(
+                                "The URI prefix of the name " + jcrName
+                                + " is neither a valid URI nor a valid part"
+                                + " of a local name.");
                     }
                 } else if (state == STATE_PREFIX_START) {
                     state = STATE_PREFIX; // prefix start -> validation later on will fail.

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java Wed Oct 21 11:38:31 2009
@@ -19,10 +19,21 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.NameException;
 
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.RepositoryException;
+import javax.jcr.NamespaceException;
+
 import java.util.ArrayList;
 
 /**
@@ -38,18 +49,109 @@
      */
     private static final Logger log = LoggerFactory.getLogger(AbstractNodeType.class);
 
-    private final AbstractNodeTypeManager ntMgr;
+    protected final AbstractNodeTypeManager ntMgr;
+
+    protected final QNodeTypeDefinition ntd;
+
+    protected final NamePathResolver resolver;
 
     /**
      * Create a new <code>AbstractNodeType</code>.
      *
-     * @param ntMgr
+     * @param ntd      the underlying node type definition.
+     * @param ntMgr    the node type manager.
+     * @param resolver the name/path resolver of the session that created this
+     *                 node type instance.
      */
-    public AbstractNodeType(AbstractNodeTypeManager ntMgr) {
+    public AbstractNodeType(QNodeTypeDefinition ntd,
+                            AbstractNodeTypeManager ntMgr,
+                            NamePathResolver resolver) {
+        this.ntd = ntd;
         this.ntMgr = ntMgr;
+        this.resolver = resolver;
+    }
+
+    /**
+     * Returns the node type definition.
+     *
+     * @return the internal node type definition.
+     */
+    public QNodeTypeDefinition getDefinition() {
+        return ntd;
     }
 
     //-----------------------------------------------------------< NodeType >---
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getName() {
+        try {
+            return resolver.getJCRName(ntd.getName());
+        } catch (NamespaceException e) {
+            // should never get here
+            log.error("encountered unregistered namespace in node type name", e);
+            return ntd.getName().toString();
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isAbstract() {
+        return ntd.isAbstract();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isMixin() {
+        return ntd.isMixin();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isQueryable() {
+        return ntd.isQueryable();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getDeclaredSupertypeNames() {
+        Name[] ntNames = ntd.getSupertypes();
+        String[] supertypes = new String[ntNames.length];
+        for (int i = 0; i < ntNames.length; i++) {
+            try {
+                supertypes[i] = resolver.getJCRName(ntNames[i]);
+            } catch (NamespaceException e) {
+                // should never get here
+                log.error("encountered unregistered namespace in node type name", e);
+                supertypes[i] = ntNames[i].toString();
+            }
+        }
+        return supertypes;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeType[] getDeclaredSupertypes() {
+        Name[] ntNames = ntd.getSupertypes();
+        NodeType[] supertypes = new NodeType[ntNames.length];
+        for (int i = 0; i < ntNames.length; i++) {
+            try {
+                supertypes[i] = ntMgr.getNodeType(ntNames[i]);
+            } catch (NoSuchNodeTypeException e) {
+                // should never get here
+                log.error("undefined supertype", e);
+                return new NodeType[0];
+            }
+        }
+        return supertypes;
+    }
+
     /**
      * @see javax.jcr.nodetype.NodeType#getDeclaredSubtypes()
      */
@@ -64,7 +166,81 @@
         return getSubtypes(false);
     }        
 
+    /**
+     * {@inheritDoc}
+     */
+    public NodeDefinition[] getDeclaredChildNodeDefinitions() {
+        QNodeDefinition[] cnda = ntd.getChildNodeDefs();
+        NodeDefinition[] nodeDefs = new NodeDefinition[cnda.length];
+        for (int i = 0; i < cnda.length; i++) {
+            nodeDefs[i] = ntMgr.getNodeDefinition(cnda[i]);
+        }
+        return nodeDefs;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getPrimaryItemName() {
+        // TODO JCR-1947: JSR 283: Node Type Attribute Subtyping Rules
+        try {
+            Name piName = ntd.getPrimaryItemName();
+            if (piName != null) {
+                return resolver.getJCRName(piName);
+            } else {
+                return null;
+            }
+        } catch (NamespaceException e) {
+            // should never get here
+            log.error("encountered unregistered namespace in name of primary item", e);
+            return ntd.getName().toString();
+        }
+    }
+
+    /**
+     * @see javax.jcr.nodetype.NodeTypeDefinition#getDeclaredPropertyDefinitions()
+     */
+    public PropertyDefinition[] getDeclaredPropertyDefinitions() {
+        QPropertyDefinition[] pda = ntd.getPropertyDefs();
+        PropertyDefinition[] propDefs = new PropertyDefinition[pda.length];
+        for (int i = 0; i < pda.length; i++) {
+            propDefs[i] = ntMgr.getPropertyDefinition(pda[i]);
+        }
+        return propDefs;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isNodeType(String nodeTypeName) {
+        Name ntName;
+        try {
+            ntName = resolver.getQName(nodeTypeName);
+        } catch (NamespaceException e) {
+            log.warn("invalid node type name: " + nodeTypeName, e);
+            return false;
+        } catch (NameException e) {
+            log.warn("invalid node type name: " + nodeTypeName, e);
+            return false;
+        }
+        return isNodeType(ntName);
+    }
+
+    /**
+     * Test if this nodetype equals or is directly or indirectly derived from
+     * the node type with the specified <code>nodeTypeName</code>, without
+     * checking of a node type of that name really exists.
+     *
+     * @param nodeTypeName A node type name.
+     * @return true if this node type represents the type with the given
+     * <code>nodeTypeName</code> or if it is directly or indirectly derived
+     * from it; otherwise <code>false</code>. If no node type exists with the
+     * specified name this method will also return <code>false</code>.
+     */
+    public abstract boolean isNodeType(Name nodeTypeName);
+
     //--------------------------------------------------------------------------
+
     /**
      * Returns the node types derived from this node type.
      *

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeTypeManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeTypeManager.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeTypeManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeTypeManager.java Wed Oct 21 11:38:31 2009
@@ -16,9 +16,9 @@
  */
 package org.apache.jackrabbit.spi.commons.nodetype;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 
 import javax.jcr.nodetype.NodeTypeManager;
@@ -28,6 +28,8 @@
 import javax.jcr.nodetype.PropertyDefinitionTemplate;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.RepositoryException;
 
@@ -38,11 +40,6 @@
 public abstract class AbstractNodeTypeManager implements NodeTypeManager {
 
     /**
-     * logger instance
-     */
-    private static final Logger log = LoggerFactory.getLogger(AbstractNodeTypeManager.class);
-
-    /**
      * Return the node type with the specified <code>ntName</code>.
      *
      * @param ntName Name of the node type to be returned.
@@ -52,6 +49,24 @@
     public abstract NodeType getNodeType(Name ntName) throws NoSuchNodeTypeException;
 
     /**
+     * Retrieve the <code>NodeDefinition</code> for the given
+     * <code>QNodeDefinition</code>.
+     *
+     * @param nd the QNodeDefinition.
+     * @return the node definition.
+     */
+    public abstract NodeDefinition getNodeDefinition(QNodeDefinition nd);
+
+    /**
+     * Retrieve the <code>PropertyDefinition</code> for the given
+     * <code>QPropertyDefinition</code>.
+     *
+     * @param pd the QPropertyDefinition.
+     * @return the property definition.
+     */
+    public abstract PropertyDefinition getPropertyDefinition(QPropertyDefinition pd);
+
+    /**
      * Returns the NamePathResolver used to validate JCR names.
      *
      * @return the NamePathResolver used to convert JCR names/paths to internal

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeDefinitionImpl.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeDefinitionImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeDefinitionImpl.java Wed Oct 21 11:38:31 2009
@@ -63,7 +63,17 @@
         super(itemDef, ntMgr, resolver);
     }
 
+    /**
+     * Returns the wrapped node definition.
+     *
+     * @return the wrapped node definition.
+     */
+    public QNodeDefinition unwrap() {
+        return (QNodeDefinition) itemDef;
+    }
+
     //-------------------------------------------------------< NodeDefinition >
+
     /**
      * {@inheritDoc}
      */

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionImpl.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionImpl.java Wed Oct 21 11:38:31 2009
@@ -72,7 +72,17 @@
         this.valueFactory = valueFactory;
     }
 
+    /**
+     * Returns the wrapped property definition.
+     *
+     * @return the wrapped property definition.
+     */
+    public QPropertyDefinition unwrap() {
+        return (QPropertyDefinition) itemDef;
+    }
+
     //-------------------------------------------------< PropertyDefinition >---
+
     /**
      * {@inheritDoc}
      */

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionTemplateImpl.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionTemplateImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionTemplateImpl.java Wed Oct 21 11:38:31 2009
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.spi.commons.nodetype;
 
-import org.apache.jackrabbit.spi.commons.query.qom.Operator;
+import org.apache.jackrabbit.commons.query.qom.Operator;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 
 import javax.jcr.PropertyType;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java Wed Oct 21 11:38:31 2009
@@ -36,6 +36,8 @@
 import javax.jcr.query.qom.QueryObjectModelConstants;
 import javax.jcr.version.OnParentVersionAction;
 
+import org.apache.jackrabbit.commons.cnd.Lexer;
+import org.apache.jackrabbit.commons.query.qom.Operator;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
@@ -43,14 +45,13 @@
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
-import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.commons.namespace.SessionNamespaceResolver;
 import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
 import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
-import org.apache.jackrabbit.spi.commons.query.qom.Operator;
 import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 import org.apache.jackrabbit.util.ISO9075;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/ComparisonImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/ComparisonImpl.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/ComparisonImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/ComparisonImpl.java Wed Oct 21 11:38:31 2009
@@ -21,6 +21,7 @@
 import javax.jcr.query.qom.QueryObjectModelConstants;
 import javax.jcr.query.qom.StaticOperand;
 
+import org.apache.jackrabbit.commons.query.qom.Operator;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 
 /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/JoinImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/JoinImpl.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/JoinImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/JoinImpl.java Wed Oct 21 11:38:31 2009
@@ -20,6 +20,7 @@
 import javax.jcr.query.qom.JoinCondition;
 import javax.jcr.query.qom.Source;
 
+import org.apache.jackrabbit.commons.query.qom.JoinType;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 
 /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/OrderingImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/OrderingImpl.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/OrderingImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/OrderingImpl.java Wed Oct 21 11:38:31 2009
@@ -20,6 +20,7 @@
 import javax.jcr.query.qom.Ordering;
 import javax.jcr.query.qom.QueryObjectModelConstants;
 
+import org.apache.jackrabbit.commons.query.qom.Order;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 
 /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java Wed Oct 21 11:38:31 2009
@@ -16,11 +16,8 @@
  */
 package org.apache.jackrabbit.spi.commons.query.qom;
 
-import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
-import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.commons.conversion.NameException;
-import org.apache.jackrabbit.spi.Path;
-
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.qom.And;
 import javax.jcr.query.qom.BindVariableValue;
@@ -56,8 +53,13 @@
 import javax.jcr.query.qom.Source;
 import javax.jcr.query.qom.StaticOperand;
 import javax.jcr.query.qom.UpperCase;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
+
+import org.apache.jackrabbit.commons.query.qom.JoinType;
+import org.apache.jackrabbit.commons.query.qom.Operator;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.commons.conversion.NameException;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 
 /**
  * <code>QueryObjectModelFactoryImpl</code> implements the query object model



Mime
View raw message