incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1185732 - in /sling/trunk/bundles/jcr/resource/src: main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java
Date Tue, 18 Oct 2011 16:02:40 GMT
Author: cziegeler
Date: Tue Oct 18 16:02:39 2011
New Revision: 1185732

URL: http://svn.apache.org/viewvc?rev=1185732&view=rev
Log:
SLING-2246 : Wrong mapping for nodes having sling:alias property. Apply patch from Antonio
Sanso

Modified:
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java?rev=1185732&r1=1185731&r2=1185732&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
Tue Oct 18 16:02:39 2011
@@ -645,7 +645,7 @@ public class JcrResourceResolver
             String path = res.getPath();
             while ( path != null ) {
                 String alias = null;
-                if ( current != null ) {
+                if ( current != null && !path.endsWith("jcr:content")) {
                     alias = getProperty(current, PROP_ALIAS);
                 }
                 if (alias == null || alias.length() == 0) {

Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java?rev=1185732&r1=1185731&r2=1185732&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java
Tue Oct 18 16:02:39 2011
@@ -1726,7 +1726,52 @@ public class JcrResourceResolverTest ext
         mapped = resResolver.map(child.getPath() + selExt);
         assertEquals(path, mapped);
     }
+    
+    public void testMapResourceAlias() throws Exception {
+    	// define an alias for the rootPath
+        String alias = "testAlias";
+        rootNode.setProperty(JcrResourceResolver.PROP_ALIAS, alias);
+        session.save();
+    	
+    	String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
+                + "/" + alias); 
+        String mapped = resResolver.map(rootNode.getPath());
+        assertEquals(path, mapped);
+        Node child = rootNode.addNode("child");
+        session.save();
+        
+        path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
+                + "/" + alias+"/child");
+        mapped = resResolver.map(child.getPath());
+        assertEquals(path, mapped);
+     }
 
+    public void testMapResourceAliasJcrContent() throws Exception {
+        // define an alias for the rootPath in the jcr:content child node
+        String alias = "testAlias";
+        Node content = rootNode.addNode("jcr:content", "nt:unstructured");
+        content.setProperty(JcrResourceResolver.PROP_ALIAS, alias);
+        session.save();
+        
+        String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
+                + "/" + alias); 
+        String mapped = resResolver.map(rootNode.getPath());
+        assertEquals(path, mapped);
+        
+        path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
+                + "/" + alias+"/_jcr_content"); 
+        mapped = resResolver.map(content.getPath());
+        assertEquals(path, mapped);
+        
+        Node child = content.addNode("child");
+        session.save();
+        
+        path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
+                + "/" + alias+"/_jcr_content/child");
+        mapped = resResolver.map(child.getPath());
+        assertEquals(path, mapped);
+    }
+    
     public void test_resolve() throws Exception {
 
         Node child = rootNode.addNode("child");



Mime
View raw message