jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1243638 - in /jackrabbit/sandbox/jackrabbit-microkernel/src: main/java/org/apache/jackrabbit/state/ChangeTree.java main/java/org/apache/jackrabbit/state/NodeState.java test/java/org/apache/jackrabbit/RepositoryTest.java
Date Mon, 13 Feb 2012 18:28:02 GMT
Author: mduerig
Date: Mon Feb 13 18:28:02 2012
New Revision: 1243638

URL: http://svn.apache.org/viewvc?rev=1243638&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- correctly overlay persisted properties with transiently modified properties  

Modified:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java?rev=1243638&r1=1243637&r2=1243638&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
Mon Feb 13 18:28:02 2012
@@ -263,10 +263,15 @@ public class ChangeTree {
         }
 
         /**
-         * @return  an iterator of all added, removed and modified properties.
+         * @return  an iterator of all added and modified properties.
          */
         public Iterator<Entry<String, JsonValue>> getProperties() {
-            return properties.entrySet().iterator();
+            return Iterators.filterIterator(properties.entrySet().iterator(), new Predicate<Entry<String,
JsonValue>>() {
+                @Override
+                public boolean evaluate(Entry<String, JsonValue> e) {
+                    return e.getValue() != JsonAtom.NULL;
+                }
+            });
         }
 
         /**

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java?rev=1243638&r1=1243637&r2=1243638&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java
Mon Feb 13 18:28:02 2012
@@ -135,8 +135,19 @@ public class NodeState {
     }
 
     public Iterator<Entry<String, JsonValue>> getProperties() {
-        // fixme: correctly overlay modified properties and removed properties
-        return Iterators.iteratorChain(getPersistedProperties(), nodeDelta.getProperties());
+        Map<String, JsonValue> childEntries = getJsonObject().value();
+
+        Iterator<Entry<String, JsonValue>> propertyEntries =
+            Iterators.filterIterator(childEntries.entrySet().iterator(),
+                new Predicate<Entry<String, JsonValue>>() {
+                    @Override
+                    public boolean evaluate(Entry<String, JsonValue> entry) {
+                        return !entry.getKey().startsWith(":") && !isNode(entry.getValue())
+                            && !nodeDelta.hasProperty(entry.getKey());
+                    }
+                });
+
+        return Iterators.iteratorChain(propertyEntries, nodeDelta.getProperties());
     }
 
     public Iterator<Entry<String, JsonValue>> getProperties(Predicate<Entry<String,
JsonValue>> condition) {
@@ -213,18 +224,6 @@ public class NodeState {
         return value.isObject();
     }
 
-    private Iterator<Entry<String, JsonValue>> getPersistedProperties() {
-        Map<String, JsonValue> childEntries = getJsonObject().value();
-
-        return Iterators.filterIterator(childEntries.entrySet().iterator(),
-            new Predicate<Entry<String, JsonValue>>() {
-                @Override
-                public boolean evaluate(Entry<String, JsonValue> entry) {
-                    return !entry.getKey().startsWith(":") && !isNode(entry.getValue());
-                }
-        });
-    }
-
     private JsonValue getPropertyValueOrNull(String name) {
         JsonValue value = nodeDelta.getProperty(name);
         if (value == null) {

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java?rev=1243638&r1=1243637&r2=1243638&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java
Mon Feb 13 18:28:02 2012
@@ -246,13 +246,13 @@ public class RepositoryTest {
     @Test
     public void getProperties() throws RepositoryException {
         Set<String> propertyNames = new HashSet<String>() {{
-            add("stringProp");
             add("intProp");
             add("mvProp");
+            add("added");
         }};
         
         Set<String> values = new HashSet<String>() {{
-            add("stringVal");
+            add("added");
             add("1");
             add("2");
             add("3");
@@ -260,9 +260,14 @@ public class RepositoryTest {
         }};
 
         Node node = getNode("/foo");
+        node.setProperty("added", "added");        // transiently added
+        node.getProperty("stringProp").remove();   // transiently removed
+        node.getProperty("intProp").remove();      // transiently removed...
+        node.setProperty("intProp", 42);           // ...and added again
         PropertyIterator properties = node.getProperties();
         while (properties.hasNext()) {
             Property p = properties.nextProperty();
+            System.out.println(p.getName() + ":" + p.toString());
             assertTrue(propertyNames.remove(p.getName()));
             if (p.isMultiple()) {
                 for (Value v : p.getValues()) {



Mime
View raw message