sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sseif...@apache.org
Subject svn commit: r1680104 - in /sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic: pom.xml src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlResource.java src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlValueMap.java
Date Mon, 18 May 2015 21:17:21 GMT
Author: sseifert
Date: Mon May 18 21:17:20 2015
New Revision: 1680104

URL: http://svn.apache.org/r1680104
Log:
switch to DeepReadValueMapDecorator

Modified:
    sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/pom.xml
    sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlResource.java
    sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlValueMap.java

Modified: sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/pom.xml?rev=1680104&r1=1680103&r2=1680104&view=diff
==============================================================================
--- sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/pom.xml (original)
+++ sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/pom.xml Mon May 18 21:17:20 2015
@@ -26,9 +26,8 @@
         <version>22</version>
     </parent>
 
-    <groupId>org.apache.sling</groupId>
-    <artifactId>org.apache.sling.nosql-generic</artifactId>
-    <version>0.0.1-SNAPSHOT</version>
+    <artifactId>org.apache.sling.nosql.generic</artifactId>
+    <version>0.1.0-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Generic NoSQL Resource Provider</name>

Modified: sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlResource.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlResource.java?rev=1680104&r1=1680103&r2=1680104&view=diff
==============================================================================
--- sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlResource.java
(original)
+++ sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlResource.java
Mon May 18 21:17:20 2015
@@ -26,6 +26,8 @@ import org.apache.sling.api.resource.Mod
 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 org.apache.sling.nosql.generic.adapter.NoSqlData;
 
 /**
@@ -66,8 +68,11 @@ public class NoSqlResource extends Abstr
     @SuppressWarnings("unchecked")
     @Override
     public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
-        if (type == ValueMap.class || type == Map.class || type == ModifiableValueMap.class)
{
-            return (AdapterType)new NoSqlValueMap(this, data.getProperties());
+        if (type == ValueMap.class || type == Map.class) {
+            return (AdapterType)new DeepReadValueMapDecorator(this, new NoSqlValueMap(data.getProperties()));
+        }
+        if (type == ModifiableValueMap.class) {
+            return (AdapterType)new DeepReadModifiableValueMapDecorator(this, new NoSqlValueMap(data.getProperties()));
         }
         return super.adaptTo(type);
     }

Modified: sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlValueMap.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlValueMap.java?rev=1680104&r1=1680103&r2=1680104&view=diff
==============================================================================
--- sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlValueMap.java
(original)
+++ sling/whiteboard/sseifert/SLING-4381_nosql/nosql-generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlValueMap.java
Mon May 18 21:17:20 2015
@@ -34,8 +34,6 @@ import javax.xml.bind.DatatypeConverter;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.sling.api.resource.ModifiableValueMap;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.api.wrappers.ValueMapDecorator;
 
 /**
@@ -45,28 +43,14 @@ import org.apache.sling.api.wrappers.Val
  */
 class NoSqlValueMap extends ValueMapDecorator implements ModifiableValueMap {
     
-    private final Resource resource;
-    
-    public NoSqlValueMap(Resource resource, Map<String,Object> map) {
+    public NoSqlValueMap(Map<String,Object> map) {
         super(convertForWriteAll(map));
-        this.resource = resource;
     }
 
     @SuppressWarnings("unchecked")
     @Override
     public <T> T get(String name, Class<T> type) {
         
-        // check for deep path access
-        int slashPos = name.lastIndexOf('/');
-        if (slashPos >= 0) {
-            String resourcePath = "./" + name.substring(0, slashPos);
-            String propertyName = name.substring(slashPos + 1);
-            Resource childResource = resource.getChild(resourcePath);
-            if (childResource!=null) {
-                return ResourceUtil.getValueMap(childResource).get(propertyName, type);
-            }
-        }
-        
         if (type == Calendar.class) {
             Date date = get(name, Date.class);
             if (date != null) {



Mime
View raw message