sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sseif...@apache.org
Subject svn commit: r1680744 - in /sling/trunk/contrib/nosql/generic/src: main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlResourceProvider.java test/java/org/apache/sling/nosql/generic/resource/impl/AbstractNoSqlResourceProviderRootTest.java
Date Thu, 21 May 2015 07:02:41 GMT
Author: sseifert
Date: Thu May 21 07:02:40 2015
New Revision: 1680744

URL: http://svn.apache.org/r1680744
Log:
SLING-4381 disallow storing data in root resource

Modified:
    sling/trunk/contrib/nosql/generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlResourceProvider.java
    sling/trunk/contrib/nosql/generic/src/test/java/org/apache/sling/nosql/generic/resource/impl/AbstractNoSqlResourceProviderRootTest.java

Modified: sling/trunk/contrib/nosql/generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/nosql/generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlResourceProvider.java?rev=1680744&r1=1680743&r2=1680744&view=diff
==============================================================================
--- sling/trunk/contrib/nosql/generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlResourceProvider.java
(original)
+++ sling/trunk/contrib/nosql/generic/src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlResourceProvider.java
Thu May 21 07:02:40 2015
@@ -194,6 +194,9 @@ public class NoSqlResourceProvider imple
                notifyRemoved(path);
             }
             for (NoSqlData item : changedResources.values()) {
+                if (ROOT_PATH.equals(item.getPath())) {
+                    throw new PersistenceException("Unable to store resource at {}" + item.getPath(),
null, item.getPath(), null);
+                }
                 boolean created = adapter.store(item);
                 if (created) {
                     notifyAdded(item.getPath());

Modified: sling/trunk/contrib/nosql/generic/src/test/java/org/apache/sling/nosql/generic/resource/impl/AbstractNoSqlResourceProviderRootTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/nosql/generic/src/test/java/org/apache/sling/nosql/generic/resource/impl/AbstractNoSqlResourceProviderRootTest.java?rev=1680744&r1=1680743&r2=1680744&view=diff
==============================================================================
--- sling/trunk/contrib/nosql/generic/src/test/java/org/apache/sling/nosql/generic/resource/impl/AbstractNoSqlResourceProviderRootTest.java
(original)
+++ sling/trunk/contrib/nosql/generic/src/test/java/org/apache/sling/nosql/generic/resource/impl/AbstractNoSqlResourceProviderRootTest.java
Thu May 21 07:02:40 2015
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertTrue;
 
 import org.apache.jackrabbit.JcrConstants;
+import org.apache.sling.api.resource.ModifiableValueMap;
 import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceUtil;
@@ -75,5 +76,19 @@ public abstract class AbstractNoSqlResou
         
         context.resourceResolver().delete(test);
     }
+    
+    @Test(expected = PersistenceException.class)
+    public void testDeleteRootPath() throws PersistenceException {
+        Resource root = context.resourceResolver().getResource("/");
+        context.resourceResolver().delete(root);
+    }
+
+    @Test(expected = Throwable.class)
+    public void testUpdateRootPath() throws PersistenceException {
+        Resource root = context.resourceResolver().getResource("/");
+        ModifiableValueMap props = root.adaptTo(ModifiableValueMap.class);
+        props.put("prop1", "value1");
+        context.resourceResolver().commit();
+    }
 
 }



Mime
View raw message