You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/10/18 23:25:11 UTC

[sling-org-apache-sling-mongodb] 23/36: SLING-3451 : Support for deep reads from a value map

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-mongodb.git

commit 4964922cd85d349f2be31ef7b8298054d6132e05
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Mar 14 13:49:01 2014 +0000

    SLING-3451 : Support for deep reads from a value map
    
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1577529 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                                             | 2 +-
 .../org/apache/sling/mongodb/impl/MongoDBCollectionResource.java    | 6 +-----
 src/main/java/org/apache/sling/mongodb/impl/MongoDBResource.java    | 5 +++--
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/pom.xml b/pom.xml
index 07bb13d..4886c18 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,7 +64,7 @@
         <dependency>
     	    <groupId>org.apache.sling</groupId>
     	    <artifactId>org.apache.sling.api</artifactId>
-    	    <version>2.4.0</version>
+    	    <version>2.6.1-SNAPSHOT</version>
     	    <scope>provided</scope>
         </dependency>
         <dependency>
diff --git a/src/main/java/org/apache/sling/mongodb/impl/MongoDBCollectionResource.java b/src/main/java/org/apache/sling/mongodb/impl/MongoDBCollectionResource.java
index 6cccb4a..6b2ae0b 100644
--- a/src/main/java/org/apache/sling/mongodb/impl/MongoDBCollectionResource.java
+++ b/src/main/java/org/apache/sling/mongodb/impl/MongoDBCollectionResource.java
@@ -22,8 +22,6 @@ import java.util.Map;
 import org.apache.sling.api.resource.AbstractResource;
 import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.resource.ValueMap;
-import org.apache.sling.api.wrappers.ValueMapDecorator;
 
 public class MongoDBCollectionResource extends AbstractResource {
 
@@ -80,9 +78,7 @@ public class MongoDBCollectionResource extends AbstractResource {
     @SuppressWarnings("unchecked")
     @Override
     public <AdapterType> AdapterType adaptTo(final Class<AdapterType> type) {
-        if ( type == ValueMap.class ) {
-            return (AdapterType) new ValueMapDecorator(Collections.EMPTY_MAP);
-        } else if ( type == Map.class ) {
+        if ( type == Map.class ) {
             return (AdapterType) Collections.EMPTY_MAP;
         }
         return super.adaptTo(type);
diff --git a/src/main/java/org/apache/sling/mongodb/impl/MongoDBResource.java b/src/main/java/org/apache/sling/mongodb/impl/MongoDBResource.java
index 93c51e4..5bae7fa 100644
--- a/src/main/java/org/apache/sling/mongodb/impl/MongoDBResource.java
+++ b/src/main/java/org/apache/sling/mongodb/impl/MongoDBResource.java
@@ -23,6 +23,7 @@ import org.apache.sling.api.resource.ModifiableValueMap;
 import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.api.wrappers.DeepReadValueMapDecorator;
 
 import com.mongodb.DBObject;
 
@@ -118,10 +119,10 @@ public class MongoDBResource extends AbstractResource {
     public <AdapterType> AdapterType adaptTo(final Class<AdapterType> type) {
         if ( type == ValueMap.class || type == Map.class ) {
             this.dbObject = this.provider.getUpdatedDBObject(this.resourcePath, this.dbObject);
-            return (AdapterType) new ReadableValueMap(this.dbObject);
+            return (AdapterType) new DeepReadValueMapDecorator(this, new ReadableValueMap(this.dbObject));
         } else if ( type == ModifiableValueMap.class ) {
             this.dbObject = this.provider.getUpdatedDBObject(this.resourcePath, this.dbObject);
-            return (AdapterType) new ChangeableValueMap(this);
+            return (AdapterType) new DeepReadValueMapDecorator(this, new ChangeableValueMap(this));
         }
 
         return super.adaptTo(type);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.