incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1130844 - /sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
Date Thu, 02 Jun 2011 22:05:40 GMT
Author: justin
Date: Thu Jun  2 22:05:40 2011
New Revision: 1130844

URL: http://svn.apache.org/viewvc?rev=1130844&view=rev
Log:
 SLING-2095 - extracting workspace name from path if it is present

Modified:
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.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=1130844&r1=1130843&r2=1130844&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
Thu Jun  2 22:05:40 2011
@@ -329,22 +329,34 @@ public class JcrResourceResolver
     public Resource resolve(HttpServletRequest request, String absPath) {
         checkClosed();
 
+        String workspaceName = null;
+
         // make sure abspath is not null and is absolute
         if (absPath == null) {
             absPath = "/";
         } else if (!absPath.startsWith("/")) {
-            absPath = "/" + absPath;
+            if (useMultiWorkspaces) {
+                final int wsSepPos = absPath.indexOf(":/");
+                if (wsSepPos != -1) {
+                    workspaceName = absPath.substring(0, wsSepPos);
+                    absPath = absPath.substring(wsSepPos + 1);
+                } else {
+                    absPath = "/" + absPath;
+                }
+            } else {
+                absPath = "/" + absPath;
+            }
         }
 
         // check for special namespace prefix treatment
         absPath = unmangleNamespaces(absPath);
-
-        String workspaceName = null;
         if (useMultiWorkspaces) {
-            // check for workspace info
-            workspaceName = (request == null ? null :
-                (String)request.getAttribute(ResourceResolver.REQUEST_ATTR_WORKSPACE_INFO));
-            if ( workspaceName != null && !workspaceName.equals(getSession().getWorkspace().getName()))
{
+            if (workspaceName == null) {
+                // check for workspace info from request
+                workspaceName = (request == null ? null :
+                    (String)request.getAttribute(ResourceResolver.REQUEST_ATTR_WORKSPACE_INFO));
+            }
+            if (workspaceName != null && !workspaceName.equals(getSession().getWorkspace().getName()))
{
                 LOGGER.debug("Delegating resolving to resolver for workspace {}", workspaceName);
                 try {
                     final ResourceResolver wsResolver = getResolverForWorkspace(workspaceName);



Mime
View raw message