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:12 UTC
[sling-org-apache-sling-mongodb] 24/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 cca81f8cebe4768e044f9579694bc5036d499f91
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Mar 16 09:42:06 2014 +0000
SLING-3451 : Support for deep reads from a value map
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1578011 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/sling/mongodb/impl/MongoDBResource.java | 3 ++-
.../org/apache/sling/mongodb/impl/ReadableValueMap.java | 17 +++++++++--------
2 files changed, 11 insertions(+), 9 deletions(-)
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 5bae7fa..a45335b 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.DeepReadModifiableValueMapDecorator;
import org.apache.sling.api.wrappers.DeepReadValueMapDecorator;
import com.mongodb.DBObject;
@@ -122,7 +123,7 @@ public class MongoDBResource extends AbstractResource {
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 DeepReadValueMapDecorator(this, new ChangeableValueMap(this));
+ return (AdapterType) new DeepReadModifiableValueMapDecorator(this, new ChangeableValueMap(this));
}
return super.adaptTo(type);
diff --git a/src/main/java/org/apache/sling/mongodb/impl/ReadableValueMap.java b/src/main/java/org/apache/sling/mongodb/impl/ReadableValueMap.java
index a363591..f3eee76 100644
--- a/src/main/java/org/apache/sling/mongodb/impl/ReadableValueMap.java
+++ b/src/main/java/org/apache/sling/mongodb/impl/ReadableValueMap.java
@@ -38,17 +38,18 @@ public class ReadableValueMap implements ValueMap {
}
protected void createValueMap(final DBObject dbObject) {
- final Map<String, Object> map = new HashMap<String, Object>();
if (dbObject == null) {
this.valueMap = Collections.<String, Object> emptyMap();
- }
- for(final String key : dbObject.keySet()) {
- final String name = MongoDBResourceProvider.keyToPropName(key);
- if ( name != null ) {
- map.put(key, dbObject.get(name));
+ } else {
+ final Map<String, Object> map = new HashMap<String, Object>();
+ for(final String key : dbObject.keySet()) {
+ final String name = MongoDBResourceProvider.keyToPropName(key);
+ if ( name != null ) {
+ map.put(key, dbObject.get(name));
+ }
}
+ this.valueMap = Collections.unmodifiableMap(map);
}
- this.valueMap = Collections.unmodifiableMap(map);
}
/**
@@ -204,7 +205,7 @@ public class ReadableValueMap implements ValueMap {
/**
* Converts the object to an array of the given type
- * @param obj tje object or object array
+ * @param obj the object or object array
* @param type the component type of the array
* @return and array of type T
*/
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.