sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1657561 - in /sling/whiteboard/bdelacretaz/multisling2015: cdtenants/src/main/java/org/apache/sling/ms2015/cdtenants/ cdtenants/src/main/java/org/apache/sling/ms2015/cdtenants/impl/ resolver/src/main/java/org/apache/sling/servlets/resolver...
Date Thu, 05 Feb 2015 13:10:07 GMT
Author: bdelacretaz
Date: Thu Feb  5 13:10:07 2015
New Revision: 1657561

URL: http://svn.apache.org/r1657561
Log:
SLING-4386 - enable default Sling servlets by adding /libs to the search path but with /libs/sling
exec path restriction

Modified:
    sling/whiteboard/bdelacretaz/multisling2015/cdtenants/src/main/java/org/apache/sling/ms2015/cdtenants/ContentDrivenTenant.java
    sling/whiteboard/bdelacretaz/multisling2015/cdtenants/src/main/java/org/apache/sling/ms2015/cdtenants/impl/ContentDrivenTenantImpl.java
    sling/whiteboard/bdelacretaz/multisling2015/resolver/src/main/java/org/apache/sling/servlets/resolver/multitenant/MultitenantServletResolver.java
    sling/whiteboard/bdelacretaz/multisling2015/test-content/src/main/resources/SLING-CONTENT/tenants/example.com.json

Modified: sling/whiteboard/bdelacretaz/multisling2015/cdtenants/src/main/java/org/apache/sling/ms2015/cdtenants/ContentDrivenTenant.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/multisling2015/cdtenants/src/main/java/org/apache/sling/ms2015/cdtenants/ContentDrivenTenant.java?rev=1657561&r1=1657560&r2=1657561&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/multisling2015/cdtenants/src/main/java/org/apache/sling/ms2015/cdtenants/ContentDrivenTenant.java
(original)
+++ sling/whiteboard/bdelacretaz/multisling2015/cdtenants/src/main/java/org/apache/sling/ms2015/cdtenants/ContentDrivenTenant.java
Thu Feb  5 13:10:07 2015
@@ -25,4 +25,5 @@ package org.apache.sling.ms2015.cdtenant
 public interface ContentDrivenTenant {
     String getId();
     String [] getSearchPath();
+    String [] getExecutionPath();
 }

Modified: sling/whiteboard/bdelacretaz/multisling2015/cdtenants/src/main/java/org/apache/sling/ms2015/cdtenants/impl/ContentDrivenTenantImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/multisling2015/cdtenants/src/main/java/org/apache/sling/ms2015/cdtenants/impl/ContentDrivenTenantImpl.java?rev=1657561&r1=1657560&r2=1657561&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/multisling2015/cdtenants/src/main/java/org/apache/sling/ms2015/cdtenants/impl/ContentDrivenTenantImpl.java
(original)
+++ sling/whiteboard/bdelacretaz/multisling2015/cdtenants/src/main/java/org/apache/sling/ms2015/cdtenants/impl/ContentDrivenTenantImpl.java
Thu Feb  5 13:10:07 2015
@@ -22,14 +22,19 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ValueMap;
 import org.apache.sling.ms2015.cdtenants.ContentDrivenTenant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /** Adapt a Resource found under our content root to a Tenant, based
  *  on the content path.  
  */
 public class ContentDrivenTenantImpl implements ContentDrivenTenant {
 
+    private final Logger log = LoggerFactory.getLogger(getClass());
+    
     private final String id;
     private final String [] searchPath;
+    private final String [] executionPath;
     
     // TODO should be configurable
     public static final String TENANTS_ROOT_PATH = "/tenants";
@@ -38,10 +43,6 @@ public class ContentDrivenTenantImpl imp
     public static final String SEARCH_PATH = "searchPath";
     public static final String EXEC_PATH = "executionPath";
     
-    public static final String TENANT_PATH_PROP = "sling.tenant.path";
-    public static final String TENANT_SEARCH_PATH_PROP = "sling.tenant.search.path";
-    public static final String TENANT_EXEC_PATH_PROP = "sling.tenant.execution.path";
-    
     ContentDrivenTenantImpl(String id, ResourceResolver tenantResourceResolver) {
         this.id = id;
         
@@ -49,19 +50,22 @@ public class ContentDrivenTenantImpl imp
         // TODO should be cached
         final String tenantPath = TENANTS_ROOT_PATH + "/" + id + "/" + SLING_TENANT;
         String [] p = {};
+        String [] e = {};
         final Resource r = tenantResourceResolver.resolve(tenantPath);
         if(r != null) {
             final ValueMap props = r.adaptTo(ValueMap.class);
             if(props != null) {
-                p = normalizeSearchPath(props.get(SEARCH_PATH, String[].class));
-                
+                p = normalizePath(props.get(SEARCH_PATH, String[].class));
+                e = normalizePath(props.get(EXEC_PATH, String[].class));
             }
         }
         
         this.searchPath = p;
+        this.executionPath = (e == null || e.length == 0 ? null : e);
+        log.debug("{} created", this);
     }
     
-    static String [] normalizeSearchPath(String [] path) {
+    static String [] normalizePath(String [] path) {
         for(int i=0 ; i < path.length; i++) {
             if(!path[i].endsWith("/")) {
                 path[i] += "/";
@@ -85,6 +89,7 @@ public class ContentDrivenTenantImpl imp
         sb.append(getClass().getSimpleName());
         sb.append(", id=").append(id);
         dumpPath(sb, "search path", searchPath);
+        dumpPath(sb, "execution path", executionPath);
         return sb.toString();
     }
     
@@ -92,6 +97,10 @@ public class ContentDrivenTenantImpl imp
         return searchPath;
     }
     
+    public String [] getExecutionPath() {
+        return executionPath;
+    }
+    
     public String getId() {
         return id;
     }

Modified: sling/whiteboard/bdelacretaz/multisling2015/resolver/src/main/java/org/apache/sling/servlets/resolver/multitenant/MultitenantServletResolver.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/multisling2015/resolver/src/main/java/org/apache/sling/servlets/resolver/multitenant/MultitenantServletResolver.java?rev=1657561&r1=1657560&r2=1657561&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/multisling2015/resolver/src/main/java/org/apache/sling/servlets/resolver/multitenant/MultitenantServletResolver.java
(original)
+++ sling/whiteboard/bdelacretaz/multisling2015/resolver/src/main/java/org/apache/sling/servlets/resolver/multitenant/MultitenantServletResolver.java
Thu Feb  5 13:10:07 2015
@@ -66,7 +66,7 @@ public class MultitenantServletResolver
         final ResourceResolver scriptResolver = resource.getResourceResolver();
         
         Servlet result = null;
-        final ResourceCollector rc = ResourceCollector.create(request,  t.getSearchPath(),
defaultExtensions);
+        final ResourceCollector rc = ResourceCollector.create(request,  t.getExecutionPath(),
defaultExtensions);
         
         // For now, simply return the first servlet found
         // TODO handle OptingServlets, refactor code from SlingServletResolver
@@ -81,7 +81,7 @@ public class MultitenantServletResolver
             }
         }
         
-        rpt.log("Resolved servlet: {0}", result.toString());
+        rpt.log("Resolved servlet: {0}", result);
         return result;
     }   
 }
\ No newline at end of file

Modified: sling/whiteboard/bdelacretaz/multisling2015/test-content/src/main/resources/SLING-CONTENT/tenants/example.com.json
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/multisling2015/test-content/src/main/resources/SLING-CONTENT/tenants/example.com.json?rev=1657561&r1=1657560&r2=1657561&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/multisling2015/test-content/src/main/resources/SLING-CONTENT/tenants/example.com.json
(original)
+++ sling/whiteboard/bdelacretaz/multisling2015/test-content/src/main/resources/SLING-CONTENT/tenants/example.com.json
Thu Feb  5 13:10:07 2015
@@ -2,15 +2,27 @@
     "jcr:primaryType" : "nt:unstructured",
     "sling:tenant" : {
         "searchPath" : [
+            "/libs",
             "/modules/blog/v42/scripts",
             "/tenants/example.com/sling:tenant/scripts"
+        ],
+        "executionPath" : [
+            "/libs/sling",
+            "/modules",
+            "/tenants/example.com/sling:tenant/scripts"
         ]
     },
     "subsite" : {
         "sling:tenant" : {
             "searchPath" : [
+                "/libs",
                 "/modules/blog/v43/scripts",
                 "/tenants/example.com/subsite/sling:tenant/scripts"
+            ],
+            "executionPath" : [
+                "/libs/sling",
+                "/modules",
+                "/tenants/example.com/sling:tenant/scripts"
             ]
         }
     }



Mime
View raw message