jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1375489 - in /jackrabbit/oak/trunk/oak-jcr/src: main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Date Tue, 21 Aug 2012 12:10:49 GMT
Author: mduerig
Date: Tue Aug 21 12:10:49 2012
New Revision: 1375489

URL: http://svn.apache.org/viewvc?rev=1375489&view=rev
Log:
OAK-101: implement identifier handling (byUUID, byIdentifier, etc)
test cases

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.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=1375489&r1=1375488&r2=1375489&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
Tue Aug 21 12:10:49 2012
@@ -57,6 +57,7 @@ import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Iterators;
 import com.google.common.collect.Lists;
+import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.commons.ItemNameMatcher;
 import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
 import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter;
@@ -932,30 +933,27 @@ public class NodeImpl extends ItemImpl<N
                 NodeType nt = ntm.getNodeType(mixinName); // throws on not found
                 // TODO: END
 
-                String jcrMixinTypes = sessionDelegate.getOakPathOrThrow(Property.JCR_MIXIN_TYPES);
-                PropertyDelegate mixins = dlg.getProperty(jcrMixinTypes);
-
+                PropertyDelegate mixins = dlg.getProperty(JcrConstants.JCR_MIXINTYPES);
                 CoreValue cv = ValueConverter.toCoreValue(mixinName, PropertyType.NAME, sessionDelegate);
 
                 boolean nodeModified = false;
-
                 if (mixins == null) {
                     nodeModified = true;
-                    dlg.setProperty(jcrMixinTypes, Collections.singletonList(cv));
+                    dlg.setProperty(JcrConstants.JCR_MIXINTYPES, Collections.singletonList(cv));
                 } else {
                     List<CoreValue> values = Lists.newArrayList(mixins.getValues());
                     if (!values.contains(cv)) {
                         values.add(cv);
                         nodeModified = true;
-                        dlg.setProperty(jcrMixinTypes, values);
+                        dlg.setProperty(JcrConstants.JCR_MIXINTYPES, values);
                     }
                 }
 
                 // TODO: hack -- make sure we assign a UUID
-                if (nodeModified && nt.isNodeType(NodeType.MIX_REFERENCEABLE)) {
-                    String jcrUuid = sessionDelegate.getOakPathOrThrow(Property.JCR_UUID);
-                    String uuid = IdentifierManager.generateUUID();
-                    dlg.setProperty(jcrUuid, ValueConverter.toCoreValue(uuid, PropertyType.STRING,
sessionDelegate));
+                if (nodeModified && nt.isNodeType(JcrConstants.MIX_REFERENCEABLE))
{
+                    CoreValue value = ValueConverter.toCoreValue(IdentifierManager.generateUUID(),
+                            PropertyType.STRING, sessionDelegate);
+                    dlg.setProperty(JcrConstants.JCR_UUID, value);
                 }
                 return null;
             }

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=1375489&r1=1375488&r2=1375489&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
Tue Aug 21 12:10:49 2012
@@ -984,6 +984,74 @@ public class RepositoryTest extends Abst
     }
 
     @Test
+    @Ignore("OAK-261")  //  TODO OAK-261: Support querying on property types
+    public void getReferences() throws RepositoryException {
+        Session session = getAdminSession();
+        Node referee = getNode("/foo");
+        referee.addMixin("mix:referenceable");
+        getNode(TEST_PATH).setProperty("reference", session.getValueFactory().createValue(referee));
+        session.save();
+
+        PropertyIterator refs = referee.getReferences();
+        assertTrue(refs.hasNext());
+        Property p = refs.nextProperty();
+        assertEquals("reference", p.getName());
+        assertFalse(refs.hasNext());
+    }
+
+    @Test
+    @Ignore("OAK-261")  //  TODO OAK-261: Support querying on property types
+    public void getNamedReferences() throws RepositoryException {
+        Session session = getAdminSession();
+        Node referee = getNode("/foo");
+        referee.addMixin("mix:referenceable");
+        Value value = session.getValueFactory().createValue(referee);
+        getNode(TEST_PATH).setProperty("reference", value);
+        getNode("/bar").setProperty("reference", value);
+        session.save();
+
+        PropertyIterator refs = referee.getReferences("bar");
+        assertTrue(refs.hasNext());
+        Property p = refs.nextProperty();
+        assertEquals("reference", p.getName());
+        assertFalse(refs.hasNext());
+    }
+
+    @Test
+    @Ignore("OAK-261")  //  TODO OAK-261: Support querying on property types
+    public void getWeakReferences() throws RepositoryException {
+        Session session = getAdminSession();
+        Node referee = getNode("/foo");
+        referee.addMixin("mix:referenceable");
+        getNode(TEST_PATH).setProperty("weak-reference", session.getValueFactory().createValue(referee,
true));
+        session.save();
+
+        PropertyIterator refs = referee.getWeakReferences();
+        assertTrue(refs.hasNext());
+        Property p = refs.nextProperty();
+        assertEquals("weak-reference", p.getName());
+        assertFalse(refs.hasNext());
+    }
+
+    @Test
+    @Ignore("OAK-261")  //  TODO OAK-261: Support querying on property types
+    public void getNamedWeakReferences() throws RepositoryException {
+        Session session = getAdminSession();
+        Node referee = getNode("/foo");
+        referee.addMixin("mix:referenceable");
+        Value value = session.getValueFactory().createValue(referee, true);
+        getNode(TEST_PATH).setProperty("reference", value);
+        getNode("/bar").setProperty("reference", value);
+        session.save();
+
+        PropertyIterator refs = referee.getWeakReferences("bar");
+        assertTrue(refs.hasNext());
+        Property p = refs.nextProperty();
+        assertEquals("reference", p.getName());
+        assertFalse(refs.hasNext());
+    }
+
+    @Test
     public void sessionSave() throws RepositoryException {
         Session session1 = createAdminSession();
         Session session2 = createAdminSession();



Mime
View raw message