Author: jvazquez
Date: Thu Feb 19 09:17:04 2009
New Revision: 745785
URL: http://svn.apache.org/viewvc?rev=745785&view=rev
Log:
SlingGenerator resolving an nt:file resource (test.xml)
Modified:
incubator/sling/whiteboard/jvazquez/org.apache.sling.scripting.xproc/src/main/java/org/apache/sling/cocoon/SlingGenerator.java
incubator/sling/whiteboard/jvazquez/org.apache.sling.scripting.xproc/src/main/resources/SLING-INF/content/xpl-sample/pipelines.json
Modified:
incubator/sling/whiteboard/jvazquez/org.apache.sling.scripting.xproc/src/main/java/org/apache/sling/cocoon/SlingGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/sling/whiteboard/jvazquez/org.apache.sling.scripting.xproc/src/main/java/org/apache/sling/cocoon/SlingGenerator.java?rev=745785&r1=745784&r2=745785&view=diff
==============================================================================
---
incubator/sling/whiteboard/jvazquez/org.apache.sling.scripting.xproc/src/main/java/org/apache/sling/cocoon/SlingGenerator.java
(original)
+++
incubator/sling/whiteboard/jvazquez/org.apache.sling.scripting.xproc/src/main/java/org/apache/sling/cocoon/SlingGenerator.java
Thu Feb 19 09:17:04 2009
@@ -19,15 +19,12 @@
package org.apache.sling.cocoon;
import java.io.InputStream;
-import java.net.URL;
-
-import javax.servlet.RequestDispatcher;
+import java.util.Map;
import org.apache.cocoon.pipeline.component.sax.AbstractGenerator;
import org.apache.cocoon.pipeline.util.XMLUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
-import org.apache.sling.api.request.RequestDispatcherOptions;
import org.apache.sling.api.resource.Resource;
public class SlingGenerator extends AbstractGenerator {
@@ -48,17 +45,13 @@
}
}
+ @SuppressWarnings("unchecked")
private InputStream genXml() throws Exception {
- return null;
-// Resource resource = request.getResource();
-// RequestDispatcherOptions options = new
RequestDispatcherOptions();
-// options.setForceResourceType("sling/xpl/sample/data");
-// RequestDispatcher dispatcher =
request.getRequestDispatcher(resource, options);
-// dispatcher.include(request, response);
-//// resource =
request.getResourceResolver().resolve(resource.getPath() + ".xml");
-// resource =
request.getResourceResolver().resolve("/xpl-sample/pipelines/test_pipeline.xml");
-// URL source = resource.adaptTo(URL.class);
-// return source.openConnection().getInputStream();
+ Resource resource = request.getResource();
+ Map props = resource.adaptTo(Map.class);
+ String absPathGen = props.get("sling:datasource").toString();
+ Resource genResource =
request.getResourceResolver().resolve(absPathGen);
+ return genResource.adaptTo(InputStream.class);
}
}
Modified:
incubator/sling/whiteboard/jvazquez/org.apache.sling.scripting.xproc/src/main/resources/SLING-INF/content/xpl-sample/pipelines.json
URL:
http://svn.apache.org/viewvc/incubator/sling/whiteboard/jvazquez/org.apache.sling.scripting.xproc/src/main/resources/SLING-INF/content/xpl-sample/pipelines.json?rev=745785&r1=745784&r2=745785&view=diff
==============================================================================
---
incubator/sling/whiteboard/jvazquez/org.apache.sling.scripting.xproc/src/main/resources/SLING-INF/content/xpl-sample/pipelines.json
(original)
+++
incubator/sling/whiteboard/jvazquez/org.apache.sling.scripting.xproc/src/main/resources/SLING-INF/content/xpl-sample/pipelines.json
Thu Feb 19 09:17:04 2009
@@ -3,6 +3,7 @@
"jcr:primaryType":"nt:unstructured",
"test_pipeline": {
"title": "test_pipeline",
- "sling:resourceType": "sling/xpl/sample"
+ "sling:resourceType": "sling/xpl/sample",
+ "sling:datasource": "/xpl-sample/test.xml"
}
}
\ No newline at end of file