Author: justin
Date: Fri Jun 3 18:24:40 2011
New Revision: 1131133
URL: http://svn.apache.org/viewvc?rev=1131133&view=rev
Log:
SLING-2093 - applying patch to get partial aliasing working
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=1131133&r1=1131132&r2=1131133&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
Fri Jun 3 18:24:40 2011
@@ -634,21 +634,21 @@ public class JcrResourceResolver
StringBuilder buf = new StringBuilder();
Resource current = res.getResourceResolver().getResource("/");
for (String name: segments) {
- current = current.getChild(name);
- if (current == null) {
+ Resource child = current.getChild(name);
+ if (child == null) {
LOGGER.warn("map: could not load child resource {}/{}
for alias mapping.", buf, name);
- buf = new StringBuilder(res.getPath());
- break;
- }
- String alias = getProperty(current, PROP_ALIAS);
- if (alias == null || alias.length() == 0) {
- alias = name;
+ current = new
NonExistingResource(res.getResourceResolver(), current.getPath() + "/" + name);
+ buf.append('/').append(name);
+ } else {
+ String alias = getProperty(child, PROP_ALIAS);
+ if (alias == null || alias.length() == 0) {
+ alias = name;
+ }
+ buf.append('/').append(alias);
+ current = child;
}
- buf.append('/').append(alias);
- }
- if (buf.length() == 0) {
- buf.append('/');
}
+
// reappend the resolutionPathInfo
if (resolutionPathInfo != null) {
buf.append(resolutionPathInfo);
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=1131133&r1=1131132&r2=1131133&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
Fri Jun 3 18:24:40 2011
@@ -1871,11 +1871,10 @@ public class JcrResourceResolverTest ext
AccessControlUtil.replaceAccessControlEntry(session,
grandchild.getPath(), testUserPrincipal, new String[] { "jcr:all" }, null,
null, "first");
session.save();
- // expect /child/grandchild due to parent node not being
+ // expect /child/enkel due to parent node not being
// visible to the test user and no parent due to mapping
// the rootPath onto root
- // TODO - get partial aliases to work, i.e. this should be
/child/enkel
- String pathEnkel = "/child/grandchild";
+ String pathEnkel = "/child/enkel";
String mappedEnkel = testUserResolver.map(grandchild.getPath());
assertEquals(pathEnkel, mappedEnkel);