incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r586010 - in /incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling: api/ contenttype/ request/ resource/ scripting/ servlet/ slingservlets/
Date Thu, 18 Oct 2007 15:43:14 GMT
Author: bdelacretaz
Date: Thu Oct 18 08:43:13 2007
New Revision: 586010

URL: http://svn.apache.org/viewvc?rev=586010&view=rev
Log:
SLING-60 - make SlingRequestContext an api interface, and start ResourceResolver implementation

Added:
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestContext.java
  (with props)
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/MicroslingRequestContext.java
      - copied, changed from r585978, incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/SlingRequestContext.java
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java
      - copied, changed from r585978, incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/ResourceResolverFilter.java
Removed:
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/SlingRequestContext.java
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/ResourceResolverFilter.java
Modified:
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/contenttype/ResponseContentTypeResolverFilter.java
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/RhinoJavascriptServlet.java
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/SlingPostServlet.java
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/VelocityTemplatesServlet.java

Added: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestContext.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestContext.java?rev=586010&view=auto
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestContext.java
(added)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestContext.java
Thu Oct 18 08:43:13 2007
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.microsling.api;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.sling.microsling.etc.MissingRequestAttributeException;
+
+/** Provides Sling-specific information about the current Request.
+ *  An object implementing this interface must be stored as a 
+ *  request attribute using this interface's name as the attribute key,
+ *  and can be retrieved using the SlingRequestContext.Accessor class. 
+ */
+public interface SlingRequestContext {
+
+    public static class Accessor {
+        public static SlingRequestContext getSlingRequestContext(HttpServletRequest req)

+        throws MissingRequestAttributeException {
+            final String REQ_ATTR_NAME = SlingRequestContext.class.getName();
+            final SlingRequestContext ctx = (SlingRequestContext)req.getAttribute(REQ_ATTR_NAME);
+            if(ctx == null) {
+                throw new MissingRequestAttributeException(REQ_ATTR_NAME);
+            }
+            return ctx;
+        }
+    }
+
+    /** Acquire a JCR Session if not done yet, and return it */
+    Session getSession() throws RepositoryException;
+
+    /** Get the Resource that the current Request processes, null if not found */
+    Resource getResource() throws Exception;
+
+    /** TODO does this really belong here? */
+    void setResponseContentType(String responseContentType);
+    
+    /** TODO see the real Sling, this could have several possible values */ 
+    String getResponseContentType();
+
+    /** Return the SlingRequestPathInfo for this request: selectors, extension, suffix, etc.
*/
+    SlingRequestPathInfo getRequestPathInfo();
+
+    /** Return the map of request parameters */
+    RequestParameterMap getRequestParameterMap();
+}

Propchange: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestContext.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/contenttype/ResponseContentTypeResolverFilter.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/contenttype/ResponseContentTypeResolverFilter.java?rev=586010&r1=586009&r2=586010&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/contenttype/ResponseContentTypeResolverFilter.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/contenttype/ResponseContentTypeResolverFilter.java
Thu Oct 18 08:43:13 2007
@@ -7,8 +7,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.sling.microsling.api.SlingRequestContext;
 import org.apache.sling.microsling.api.helpers.AbstractFilter;
-import org.apache.sling.microsling.request.SlingRequestContext;
 
 public class ResponseContentTypeResolverFilter extends AbstractFilter {
 
@@ -21,7 +21,7 @@
             HttpServletResponse response, FilterChain filterChain)
             throws IOException, ServletException {
 
-        final SlingRequestContext ctx = SlingRequestContext.getFromRequest(request);
+        final SlingRequestContext ctx = SlingRequestContext.Accessor.getSlingRequestContext(request);
 
         String file = "dummy." + ctx.getRequestPathInfo().getExtension();
         final String contentType = getFilterConfig().getServletContext().getMimeType(file);

Copied: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/MicroslingRequestContext.java
(from r585978, incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/SlingRequestContext.java)
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/MicroslingRequestContext.java?p2=incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/MicroslingRequestContext.java&p1=incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/SlingRequestContext.java&r1=585978&r2=586010&rev=586010&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/SlingRequestContext.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/MicroslingRequestContext.java
Thu Oct 18 08:43:13 2007
@@ -27,14 +27,15 @@
 
 import org.apache.sling.microsling.api.RequestParameterMap;
 import org.apache.sling.microsling.api.Resource;
+import org.apache.sling.microsling.api.SlingRequestContext;
 import org.apache.sling.microsling.api.SlingRequestPathInfo;
 import org.apache.sling.microsling.api.exceptions.SlingException;
-import org.apache.sling.microsling.etc.MissingRequestAttributeException;
 import org.apache.sling.microsling.request.helpers.SlingRequestParameterMap;
 import org.apache.sling.microsling.request.helpers.SlingRequestPathInfoParser;
+import org.apache.sling.microsling.resource.MicroslingResourceResolver;
 
 /** Additional Request-based info used by for SlingServlets */
-public class SlingRequestContext {
+public class MicroslingRequestContext implements SlingRequestContext {
 
     private Session session;
     private String responseContentType;
@@ -42,30 +43,20 @@
     private final Repository repository;
     private Resource resource;
     private final SlingRequestPathInfoParser requestPathInfo;
+    private final HttpServletRequest request;
     private RequestParameterMap parameterMap;
 
-    public static final String REQ_ATTR_NAME = SlingRequestContext.class.getName();
-
-    /** Get the SlingRequestContext from req */
-    public static SlingRequestContext getFromRequest(HttpServletRequest req) throws MissingRequestAttributeException
{
-        final SlingRequestContext ctx = (SlingRequestContext)req.getAttribute(REQ_ATTR_NAME);
-        if(ctx == null) {
-            throw new MissingRequestAttributeException(REQ_ATTR_NAME);
-        }
-        return ctx;
-    }
-
-    /** TODO parse the request to extract extension, selectors, etc. */
-    public SlingRequestContext(ServletContext sctx,ServletRequest servletRequest) throws
ServletException {
+    /** Build a MicroslingRequestContext and add it to the request attributes */
+    public MicroslingRequestContext(ServletContext sctx,ServletRequest servletRequest) throws
ServletException {
         this.servletContext = sctx;
 
         if( !(servletRequest instanceof HttpServletRequest) ) {
             throw new ServletException("SlingRequestContext requires an HttpServletRequest");
         }
-        HttpServletRequest req = (HttpServletRequest)servletRequest;
+        request = (HttpServletRequest)servletRequest;
 
         // Store this into the request attributes
-        req.setAttribute(REQ_ATTR_NAME,this);
+        request.setAttribute(SlingRequestContext.class.getName(),this);
 
         // Access our Repository
         final String repoAttr = Repository.class.getName();
@@ -75,11 +66,11 @@
         }
 
         // Parse request URI
-        requestPathInfo = new SlingRequestPathInfoParser(req.getPathInfo());
+        requestPathInfo = new SlingRequestPathInfoParser(request.getPathInfo());
 
         // load the request parameter map
         // this can be done lazily when we keep the request here
-        parameterMap = new SlingRequestParameterMap(req);
+        parameterMap = new SlingRequestParameterMap(request);
     }
 
     /** Acquire a JCR Session if not done yet, and return it */
@@ -90,12 +81,13 @@
         return session;
     }
 
-    public Resource getResource() {
+    public Resource getResource() throws Exception {
+        if(resource==null) {
+            // TODO use ServiceLocator here?
+            resource = new MicroslingResourceResolver().getResource(request);
+            // TODO initialize SlingRequestPathInfo from resource here
+        }
         return resource;
-    }
-
-    public void setResource(Resource resource) {
-        this.resource = resource;
     }
 
     public void setResponseContentType(String responseContentType) {

Copied: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java
(from r585978, incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/ResourceResolverFilter.java)
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java?p2=incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java&p1=incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/ResourceResolverFilter.java&r1=585978&r2=586010&rev=586010&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/ResourceResolverFilter.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java
Thu Oct 18 08:43:13 2007
@@ -16,46 +16,25 @@
  */
 package org.apache.sling.microsling.resource;
 
-import java.io.IOException;
-
-import javax.jcr.RepositoryException;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
 import org.apache.sling.microsling.api.Resource;
-import org.apache.sling.microsling.api.helpers.AbstractFilter;
-import org.apache.sling.microsling.request.SlingRequestContext;
+import org.apache.sling.microsling.api.ResourceResolver;
+import org.apache.sling.microsling.api.SlingRequestContext;
 
 /** A RequestFilter that selects the Resource to process */
-public class ResourceResolverFilter extends AbstractFilter {
-
-    @Override
-    protected void init() {
-        // no further initialization
-    }
-
-    @Override
-    protected void doFilter(HttpServletRequest request,
-            HttpServletResponse response, FilterChain filterChain)
-            throws IOException, ServletException {
-
-        final SlingRequestContext ctx = SlingRequestContext.getFromRequest(request);
+public class MicroslingResourceResolver implements ResourceResolver {
 
+    public Resource getResource(HttpServletRequest request) throws Exception {
+        final SlingRequestContext ctx = SlingRequestContext.Accessor.getSlingRequestContext(request);
+        Resource result = null;
+        
         // TODO support OCM-mapped objects as well
-        try {
-            final String contentPath = ctx.getRequestPathInfo().getContentPath();
-            if (ctx.getSession().itemExists(contentPath)) {
-                Resource r = new JcrNodeResource(ctx.getSession(),
-                    contentPath);
-                ctx.setResource(r);
-            }
-        } catch (RepositoryException re) {
-            throw new ServletException(re.getMessage(), re);
+        final String contentPath = ctx.getRequestPathInfo().getContentPath();
+        if (ctx.getSession().itemExists(contentPath)) {
+            result = new JcrNodeResource(ctx.getSession(),contentPath);
         }
-
-        filterChain.doFilter(request, response);
+        
+        return result;
     }
-
 }

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java?rev=586010&r1=586009&r2=586010&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
Thu Oct 18 08:43:13 2007
@@ -22,7 +22,8 @@
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.sling.microsling.api.Resource;
-import org.apache.sling.microsling.request.SlingRequestContext;
+import org.apache.sling.microsling.api.SlingRequestContext;
+import org.apache.sling.microsling.request.MicroslingRequestContext;
 import org.apache.sling.microsling.scripting.helpers.ScriptFilenameBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -52,7 +53,7 @@
      */
     public Node resolveScript(HttpServletRequest req,String scriptExtension) throws Exception
{
 
-        final SlingRequestContext ctx = SlingRequestContext.getFromRequest(req);
+        final SlingRequestContext ctx = SlingRequestContext.Accessor.getSlingRequestContext(req);
         final Resource r = ctx.getResource();
         final Session s = ctx.getSession();
         Node result = null;

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java?rev=586010&r1=586009&r2=586010&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java
Thu Oct 18 08:43:13 2007
@@ -34,8 +34,7 @@
 import org.apache.sling.microsling.api.exceptions.HttpStatusCodeException;
 import org.apache.sling.microsling.contenttype.ResponseContentTypeResolverFilter;
 import org.apache.sling.microsling.etc.HttpConstants;
-import org.apache.sling.microsling.request.SlingRequestContext;
-import org.apache.sling.microsling.resource.ResourceResolverFilter;
+import org.apache.sling.microsling.request.MicroslingRequestContext;
 import org.apache.sling.microsling.slingservlets.DefaultSlingServlet;
 import org.apache.sling.microsling.slingservlets.RhinoJavascriptServlet;
 import org.apache.sling.microsling.slingservlets.SlingPostServlet;
@@ -60,7 +59,6 @@
 
         // TODO use OSGi to setup this list
         filterChain = new MicroSlingFilterHelper(this);
-        addFilter(new ResourceResolverFilter());
         addFilter(new ResponseContentTypeResolverFilter());
 
         try {
@@ -83,7 +81,7 @@
             throws ServletException, IOException {
 
         // our filters might need the SlingRequestContext to store info in it
-        new SlingRequestContext(getServletContext(),req);
+        new MicroslingRequestContext(getServletContext(),req);
         filterChain.service(req, resp);
     }
 

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java?rev=586010&r1=586009&r2=586010&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
Thu Oct 18 08:43:13 2007
@@ -28,9 +28,9 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.sling.microsling.api.SlingRequestContext;
 import org.apache.sling.microsling.api.exceptions.HttpStatusCodeException;
 import org.apache.sling.microsling.etc.AbstractSlingServlet;
-import org.apache.sling.microsling.request.SlingRequestContext;
 
 /**
  * The default SlingServlet, used if no other SlingServlet wants to process the
@@ -43,7 +43,7 @@
             throws Exception {
         resp.setContentType("text/plain");
 
-        final SlingRequestContext ctx = SlingRequestContext.getFromRequest(req);
+        final SlingRequestContext ctx = SlingRequestContext.Accessor.getSlingRequestContext(req);
         if (ctx.getResource() == null) {
             throw new HttpStatusCodeException(404, "Resource not found: "
                 + req.getPathInfo());

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/RhinoJavascriptServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/RhinoJavascriptServlet.java?rev=586010&r1=586009&r2=586010&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/RhinoJavascriptServlet.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/RhinoJavascriptServlet.java
Thu Oct 18 08:43:13 2007
@@ -26,8 +26,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.sling.microsling.api.SlingRequestContext;
 import org.apache.sling.microsling.etc.AbstractSlingServlet;
-import org.apache.sling.microsling.request.SlingRequestContext;
 import org.apache.sling.microsling.scripting.FileNodeRequestAttribute;
 import org.apache.sling.microsling.scripting.SlingScriptResolver;
 import org.apache.sling.microsling.scripting.helpers.EspReader;
@@ -88,7 +88,7 @@
     /** Called by the doX methods to handle HTTP request method X */
     protected void processRequest(HttpServletRequest req,
             HttpServletResponse resp) throws Exception {
-        final SlingRequestContext ctx = SlingRequestContext.getFromRequest(req);
+        final SlingRequestContext ctx = SlingRequestContext.Accessor.getSlingRequestContext(req);
 
         // get the script that was revolved by canProcess
         final FileNodeRequestAttribute script = FileNodeRequestAttribute.getFromRequest(req);

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/SlingPostServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/SlingPostServlet.java?rev=586010&r1=586009&r2=586010&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/SlingPostServlet.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/SlingPostServlet.java
Thu Oct 18 08:43:13 2007
@@ -24,8 +24,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.sling.microsling.api.SlingRequestContext;
 import org.apache.sling.microsling.etc.AbstractSlingServlet;
-import org.apache.sling.microsling.request.SlingRequestContext;
 
 /** Handle POST to create nodes easily over HTTP.
  */
@@ -36,7 +36,7 @@
     
     @Override
     public void doPost(HttpServletRequest req, HttpServletResponse resp) throws Exception
{
-        final SlingRequestContext ctx = SlingRequestContext.getFromRequest(req);
+        final SlingRequestContext ctx = SlingRequestContext.Accessor.getSlingRequestContext(req);
         
         // Create or update node under current path
         final String nodePath = ctx.getRequestPathInfo().getContentPath();

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/VelocityTemplatesServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/VelocityTemplatesServlet.java?rev=586010&r1=586009&r2=586010&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/VelocityTemplatesServlet.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/VelocityTemplatesServlet.java
Thu Oct 18 08:43:13 2007
@@ -25,9 +25,9 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.sling.microsling.api.Resource;
+import org.apache.sling.microsling.api.SlingRequestContext;
 import org.apache.sling.microsling.etc.AbstractSlingServlet;
 import org.apache.sling.microsling.etc.HttpConstants;
-import org.apache.sling.microsling.request.SlingRequestContext;
 import org.apache.sling.microsling.scripting.FileNodeRequestAttribute;
 import org.apache.sling.microsling.scripting.SlingScriptResolver;
 import org.apache.velocity.VelocityContext;
@@ -65,7 +65,7 @@
 
     @Override
     public void doGet(HttpServletRequest req, HttpServletResponse resp) throws Exception
{
-        final SlingRequestContext ctx = SlingRequestContext.getFromRequest(req);
+        final SlingRequestContext ctx = SlingRequestContext.Accessor.getSlingRequestContext(req);
         
         // get the script that was revolved by canProcess
         final FileNodeRequestAttribute script = FileNodeRequestAttribute.getFromRequest(req);
@@ -75,7 +75,7 @@
         final VelocityContext c = new VelocityContext();
         final Resource r =  ctx.getResource();
         c.put("resource", r);
-        c.put("slingContext", SlingRequestContext.getFromRequest(req));
+        c.put("slingContext", ctx);
         if(r!=null && (r.getItem() instanceof Node)) {
             c.put("node", (Node)r.getItem());
         }



Mime
View raw message