incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r591357 - in /incubator/sling/trunk/microsling/microsling-core/src: main/java/org/apache/sling/microsling/resource/ main/java/org/apache/sling/microsling/scripting/ main/java/org/apache/sling/microsling/scripting/helpers/ main/java/org/apac...
Date Fri, 02 Nov 2007 15:17:03 GMT
Author: fmeschbe
Date: Fri Nov  2 08:17:01 2007
New Revision: 591357

URL: http://svn.apache.org/viewvc?rev=591357&view=rev
Log:
SLING-88 Use plain primary node type as resource type if none is set
   in the property. Conversion to a script path is handled by the
   ScriptFilenameBuilder on behalf of the MicroslingScriptResolver.
   In addition the resource type property value (or the primary node
   type) are not converted to lowercase any more.

Modified:
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/MicroslingScriptResolver.java
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/helpers/ScriptFilenameBuilder.java
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/servlet/MicroslingServletResolver.java
    incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/NodetypeRenderingTest.java

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java?rev=591357&r1=591356&r2=591357&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
Fri Nov  2 08:17:01 2007
@@ -36,8 +36,6 @@
      */
     public static final String SLING_RESOURCE_TYPE_PROPERTY = "slingResourceType";
 
-    public static final String NODE_TYPE_RT_PREFIX = "NODETYPES/";
-
     JcrNodeResource(javax.jcr.Session s,String path) throws RepositoryException {
         node = (Node)s.getItem(path);
         this.path = node.getPath();
@@ -89,18 +87,13 @@
         String result = null;
 
         if(node.hasProperty(SLING_RESOURCE_TYPE_PROPERTY)) {
-            result = node.getProperty(SLING_RESOURCE_TYPE_PROPERTY).getValue().getString().toLowerCase().trim();
+            result = node.getProperty(SLING_RESOURCE_TYPE_PROPERTY).getValue().getString();
         }
 
         if(result==null || result.length() == 0) {
-            result = NODE_TYPE_RT_PREFIX + filterName(node.getPrimaryNodeType().getName());
+            result = node.getPrimaryNodeType().getName();
         }
 
         return result;
-    }
-
-    /** Filter a node type name so that it can be used in a resource type value */
-    public static String filterName(String name) {
-        return name.toLowerCase().replaceAll("\\:","/");
     }
 }

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/MicroslingScriptResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/MicroslingScriptResolver.java?rev=591357&r1=591356&r2=591357&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/MicroslingScriptResolver.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/MicroslingScriptResolver.java
Fri Nov  2 08:17:01 2007
@@ -66,8 +66,6 @@
 
     private static final Logger log = LoggerFactory.getLogger(MicroslingScriptResolver.class);
 
-    public static final String SCRIPT_BASE_PATH = "/sling/scripts";
-
     /**
      * jcr:encoding
      */
@@ -169,7 +167,7 @@
             request.getMethod(),
             request.getRequestPathInfo().getSelectorString(),
             request.getResponseContentType(), "*");
-        String scriptPath = SCRIPT_BASE_PATH + "/" + r.getResourceType();
+        String scriptPath = scriptFilenameBuilder.buildScriptPath(r);
 
         // SLING-72: if the scriptfilename contains a relative path, move that
         // to the scriptPath and make the scriptFilename a direct child pattern

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/helpers/ScriptFilenameBuilder.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/helpers/ScriptFilenameBuilder.java?rev=591357&r1=591356&r2=591357&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/helpers/ScriptFilenameBuilder.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/helpers/ScriptFilenameBuilder.java
Fri Nov  2 08:17:01 2007
@@ -18,6 +18,7 @@
  */
 package org.apache.sling.microsling.scripting.helpers;
 
+import org.apache.sling.api.resource.Resource;
 import org.apache.sling.microsling.helpers.constants.HttpConstants;
 
 /** Builds the names of script files based on the current input:
@@ -36,6 +37,8 @@
  */
 public class ScriptFilenameBuilder {
 
+    public static final String SCRIPT_BASE_PATH = "/sling/scripts";
+
     /** @return a name like "html.js" or "print/a4/html.vlt" or "POST.js" */
     public String buildScriptFilename(String methodName,String selectors,String contentType,String
scriptExtension) {
         final StringBuffer sb = new StringBuffer();
@@ -79,4 +82,12 @@
         return sb.toString();
     }
 
+    /** Returns the script root path constructed from the {@link #SCRIPT_BASE_PATH}
+     * and the resource type, where all backslashes and colons are replaced by
+     * forward slashes.
+     */
+    public String buildScriptPath(Resource resource) {
+        String typePath = resource.getResourceType().replaceAll("\\:","/");
+        return SCRIPT_BASE_PATH + "/" + typePath;
+    }
 }

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/servlet/MicroslingServletResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/servlet/MicroslingServletResolver.java?rev=591357&r1=591356&r2=591357&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/servlet/MicroslingServletResolver.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/servlet/MicroslingServletResolver.java
Fri Nov  2 08:17:01 2007
@@ -56,8 +56,7 @@
         this.servletContext = servletContext;
         this.servlets = new HashMap<String, Servlet>();
 
-        // TODO use a utility class to map nt:file to the magic NODETYPES path
-        addServlet("NODETYPES/nt/file", new StreamServlet());
+        addServlet("nt:file", new StreamServlet());
 
         defaultSlingServlet = new DefaultSlingServlet();
         ServletConfig config = new MicroslingServletConfig(

Modified: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/NodetypeRenderingTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/NodetypeRenderingTest.java?rev=591357&r1=591356&r2=591357&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/NodetypeRenderingTest.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/NodetypeRenderingTest.java
Fri Nov  2 08:17:01 2007
@@ -20,7 +20,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
-/** Test creating a Node and rendering it using scripts in 
+/** Test creating a Node and rendering it using scripts in
  *  various supported languages, using nodetype-based
  *  script resolution
  */
@@ -29,31 +29,31 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        
+
         // set test values
         testText = "This is a test " + System.currentTimeMillis();
-        
+
         // create the test node, under a path that's specific to this class to allow collisions
         final String url = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "." + System.currentTimeMillis()
+ ".sling";
         final Map<String,String> props = new HashMap<String,String>();
         props.put("text", testText);
         displayUrl = testClient.createNode(url, props);
-        
+
         // the rendering script goes under /sling/scripts in the repository
-        scriptPath = "/sling/scripts/NODETYPES/nt/unstructured";
+        scriptPath = "/sling/scripts/nt/unstructured";
         testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
     }
-    
+
     public void testWithoutScriptTxt() throws IOException {
         final String content = getContent(displayUrl + ".txt", CONTENT_TYPE_PLAIN);
         assertTrue("Content includes PlainTextRendererServlet marker",content.contains("dumped
by PlainTextRendererServlet"));
     }
-    
+
     public void testWithoutScriptHtml() throws IOException {
         final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
         assertTrue("Content includes DefaultHtmlRendererServlet marker",content.contains("dumped
by DefaultHtmlRendererServlet"));
     }
-    
+
     public void testEspHtml() throws IOException {
         final String toDelete = uploadTestScript("rendering-test.esp","html.esp");
         try {
@@ -64,7 +64,7 @@
             testClient.delete(toDelete);
         }
     }
-    
+
     public void testEspXml() throws IOException {
         final String toDelete = uploadTestScript("rendering-test.esp","xml.esp");
         try {
@@ -75,7 +75,7 @@
             testClient.delete(toDelete);
         }
     }
-    
+
     public void testEspPlain() throws IOException {
         final String toDelete = uploadTestScript("rendering-test.esp","plain.esp");
         try {
@@ -86,7 +86,7 @@
             testClient.delete(toDelete);
         }
     }
-    
+
     public void testVltHtml() throws IOException {
         final String toDelete = uploadTestScript("rendering-test.vlt","html.vlt");
         try {
@@ -97,7 +97,7 @@
             testClient.delete(toDelete);
         }
     }
-    
+
     public void testJsHtml() throws IOException {
         final String toDelete = uploadTestScript("rendering-test.js","html.js");
         try {
@@ -108,7 +108,7 @@
             testClient.delete(toDelete);
         }
     }
-    
+
     public void testFtlHtml() throws IOException {
         final String toDelete = uploadTestScript("rendering-test.ftl","html.ftl");
         try {



Mime
View raw message