You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2009/09/22 11:00:59 UTC
svn commit: r817554 - in /sling/trunk/bundles/jcr/resource/src:
main/java/org/apache/sling/jcr/resource/internal/
test/java/org/apache/sling/jcr/resource/internal/
Author: cziegeler
Date: Tue Sep 22 09:00:58 2009
New Revision: 817554
URL: http://svn.apache.org/viewvc?rev=817554&view=rev
Log:
SLING-1112 : ValueMap doesn't allow "deep property fetching" anymore
Modified:
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrModifiablePropertyMap.java
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrPropertyMap.java
sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrPropertyMapTest.java
Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrModifiablePropertyMap.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrModifiablePropertyMap.java?rev=817554&r1=817553&r2=817554&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrModifiablePropertyMap.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrModifiablePropertyMap.java Tue Sep 22 09:00:58 2009
@@ -46,19 +46,6 @@
}
// ---------- Map
-
- /**
- * @see java.util.Map#get(java.lang.Object)
- */
- public Object get(Object key) {
- CacheEntry entry = cache.get(key);
- if (entry == null && !this.fullyRead ) {
- entry = read((String) key);
- }
-
- return entry == null ? null : entry.defaultValue;
- }
-
/**
* @see java.util.Map#clear()
*/
@@ -77,6 +64,9 @@
* @see java.util.Map#put(java.lang.Object, java.lang.Object)
*/
public Object put(String key, Object value) {
+ if ( key == null || key.indexOf('/') != -1 ) {
+ throw new IllegalArgumentException("Invalud key: " + key);
+ }
readFully();
final Object oldValue = this.get(key);
try {
@@ -144,7 +134,7 @@
try {
final Node node = getNode();
for(final String key : this.changedProperties) {
- final String name = ISO9075.encode(key);
+ final String name = ISO9075.encodePath(key);
if ( cache.containsKey(key) ) {
final CacheEntry entry = cache.get(key);
if ( entry.isMulti ) {
Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrPropertyMap.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrPropertyMap.java?rev=817554&r1=817553&r2=817554&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrPropertyMap.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrPropertyMap.java Tue Sep 22 09:00:58 2009
@@ -212,12 +212,13 @@
CacheEntry read(final String key) {
// if the node has been completely read, we need not check
- // again, as we certainly will not find the key
- if (fullyRead) {
+ // again if the key does not point to a sub node
+ if (fullyRead && key.indexOf('/') == -1 ) {
+ // except if the key contains
return null;
}
- final String name = ISO9075.encode(key);
+ final String name = ISO9075.encodePath(key);
try {
if (node.hasProperty(name)) {
final Property prop = node.getProperty(name);
Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrPropertyMapTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrPropertyMapTest.java?rev=817554&r1=817553&r2=817554&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrPropertyMapTest.java (original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrPropertyMapTest.java Tue Sep 22 09:00:58 2009
@@ -234,17 +234,19 @@
return createPropertyMap(node);
}
+ private static final String TEST_PATH = "a<a";
+
public void testNames() throws Exception {
- this.rootNode.setProperty(ISO9075.encode("a/a"), "value");
+ this.rootNode.setProperty(ISO9075.encodePath(TEST_PATH), "value");
final ValueMap vm = this.createPropertyMap(this.rootNode);
- assertEquals("value", vm.get("a/a"));
+ assertEquals("value", vm.get(TEST_PATH));
}
public void testIerators() throws Exception {
- this.rootNode.setProperty(ISO9075.encode("a/a"), "value");
+ this.rootNode.setProperty(ISO9075.encodePath(TEST_PATH), "value");
final ValueMap vm = this.createPropertyMap(this.rootNode);
- assertTrue(vm.containsKey("a/a"));
- search(vm.keySet().iterator(), "a/a");
+ assertTrue(vm.containsKey(TEST_PATH));
+ search(vm.keySet().iterator(), TEST_PATH);
search(vm.values().iterator(), "value");
}