jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1330843 - in /jackrabbit/oak/trunk/oak-jcr/src: main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Date Thu, 26 Apr 2012 13:30:27 GMT
Author: angela
Date: Thu Apr 26 13:30:26 2012
New Revision: 1330843

URL: http://svn.apache.org/viewvc?rev=1330843&view=rev
Log:
OAK-72 - Implement JCR API

- forward Node#addNode(String) to #addNode(String, String)
- dummy impl in case nt-name is null (TODO)
- dummy impl for PropertyDelegate#getDefinition()

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1330843&r1=1330842&r2=1330843&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Thu Apr 26 13:30:26 2012
@@ -145,16 +145,21 @@ public class NodeImpl extends ItemImpl i
      * @see Node#addNode(String)
      */
     @Override
-    public Node addNode(String relJcrPath) throws RepositoryException {
-        checkStatus();
-        NodeDelegate added = dlg.addNode(toOakPath(relJcrPath));
-        return new NodeImpl(added);
+    public Node addNode(String relPath) throws RepositoryException {
+        return addNode(relPath, null);
     }
 
     @Override
     public Node addNode(String relPath, String primaryNodeTypeName) throws RepositoryException
{
         checkStatus();
-        Node childNode = addNode(relPath);
+
+        if (primaryNodeTypeName == null) {
+            // TODO retrieve matching nt from effective definition based on name-matching.
+            primaryNodeTypeName = JcrConstants.NT_UNSTRUCTURED;
+        }
+
+        NodeDelegate added = dlg.addNode(toOakPath(relPath));
+        Node childNode = new NodeImpl(added);
         childNode.setPrimaryType(primaryNodeTypeName);
         return childNode;
     }
@@ -549,8 +554,7 @@ public class NodeImpl extends ItemImpl i
         checkStatus();
 
         // TODO: check if transient changes to mixin-types are reflected here
-        NodeTypeManager ntMgr =
-                getSession().getWorkspace().getNodeTypeManager();
+        NodeTypeManager ntMgr = getSession().getWorkspace().getNodeTypeManager();
         String primaryNtName = getProperty(JcrConstants.JCR_PRIMARYTYPE).getString();
         return ntMgr.getNodeType(primaryNtName);
     }
@@ -564,8 +568,7 @@ public class NodeImpl extends ItemImpl i
 
         // TODO: check if transient changes to mixin-types are reflected here
         if (hasProperty(JcrConstants.JCR_MIXINTYPES)) {
-            NodeTypeManager ntMgr =
-                    getSession().getWorkspace().getNodeTypeManager();
+            NodeTypeManager ntMgr = getSession().getWorkspace().getNodeTypeManager();
             Value[] mixinNames = getProperty(JcrConstants.JCR_MIXINTYPES).getValues();
             NodeType[] mixinTypes = new NodeType[mixinNames.length];
             for (int i = 0; i < mixinNames.length; i++) {
@@ -628,7 +631,8 @@ public class NodeImpl extends ItemImpl i
     @Override
     public NodeDefinition getDefinition() throws RepositoryException {
         checkStatus();
-        
+
+
         // TODO
         return new NodeDefinition() {
  

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java?rev=1330843&r1=1330842&r2=1330843&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
Thu Apr 26 13:30:26 2012
@@ -19,6 +19,8 @@ package org.apache.jackrabbit.oak.jcr;
 import java.util.List;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.PropertyDefinition;
 
 import org.apache.jackrabbit.oak.api.CoreValue;
@@ -42,7 +44,85 @@ public class PropertyDelegate extends It
 
     PropertyDefinition getDefinition() throws RepositoryException {
         // TODO
-        return null;
+        return new PropertyDefinition() {
+
+            @Override
+            public int getRequiredType() {
+                return 0;
+            }
+
+            @Override
+            public String[] getValueConstraints() {
+                // TODO
+                return new String[0];
+            }
+
+            @Override
+            public Value[] getDefaultValues() {
+                // TODO
+                return new Value[0];
+            }
+
+            @Override
+            public boolean isMultiple() {
+                // TODO
+                return propertyState.isArray();
+            }
+
+            @Override
+            public String[] getAvailableQueryOperators() {
+                // TODO
+                return new String[0];
+            }
+
+            @Override
+            public boolean isFullTextSearchable() {
+                // TODO
+                return false;
+            }
+
+            @Override
+            public boolean isQueryOrderable() {
+                // TODO
+                return false;
+            }
+
+            @Override
+            public NodeType getDeclaringNodeType() {
+                // TODO
+                return null;
+            }
+
+            @Override
+            public String getName() {
+                // TODO
+                return propertyState.getName();
+            }
+
+            @Override
+            public boolean isAutoCreated() {
+                // TODO
+                return false;
+            }
+
+            @Override
+            public boolean isMandatory() {
+                // TODO
+                return false;
+            }
+
+            @Override
+            public int getOnParentVersion() {
+                // TODO
+                return 0;
+            }
+
+            @Override
+            public boolean isProtected() {
+                // TODO
+                return false;
+            }
+        };
     }
     
     void remove() throws RepositoryException {
@@ -95,8 +175,7 @@ public class PropertyDelegate extends It
 
         if (parent == null) {
             propertyState = null;
-        }
-        else {
+        } else {
             propertyState = parent.getProperty(Paths.getName(path));
         }
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java?rev=1330843&r1=1330842&r2=1330843&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Thu Apr 26 13:30:26 2012
@@ -18,6 +18,7 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
+import org.apache.jackrabbit.JcrConstants;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -248,6 +249,9 @@ public class RepositoryTest extends Abst
         PropertyIterator properties = node.getProperties();
         while (properties.hasNext()) {
             Property p = properties.nextProperty();
+            if (JcrConstants.JCR_PRIMARYTYPE.equals(p.getName())) {
+                continue;
+            }
             assertTrue(propertyNames.remove(p.getName()));
             if (p.isMultiple()) {
                 for (Value v : p.getValues()) {



Mime
View raw message