incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r599443 - in /incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling: scripting/ servlet/ slingservlets/
Date Thu, 29 Nov 2007 13:58:02 GMT
Author: bdelacretaz
Date: Thu Nov 29 05:58:01 2007
New Revision: 599443

URL: http://svn.apache.org/viewvc?rev=599443&view=rev
Log:
SLING-109, adaptations for Resource API changes. Also made JCR Session available in request
attributes, for easier access

Modified:
    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/servlet/MicroslingMainServlet.java
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxGetServlet.java
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java

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=599443&r1=599442&r2=599443&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
Thu Nov 29 05:58:01 2007
@@ -160,19 +160,9 @@
     public SlingScript resolveScriptInternal(
             final SlingHttpServletRequest request) throws RepositoryException, SlingException
{
 
-        final Resource r = request.getResource();
-
-        // ensure repository access
-        if (!(r instanceof NodeProvider)) {
-            return null;
-        }
-
-        final Session s = ((NodeProvider) r).getNode().getSession();
+        final Resource r = request.getResource(); 
+        final Session s = (Session)request.getAttribute(Session.class.getName());
         MicroslingScript result = null;
-
-        if (r == null) {
-            return null;
-        }
 
         String scriptFilename = scriptFilenameBuilder.buildScriptFilename(
             request.getMethod(),

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/servlet/MicroslingMainServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/servlet/MicroslingMainServlet.java?rev=599443&r1=599442&r2=599443&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/servlet/MicroslingMainServlet.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/servlet/MicroslingMainServlet.java
Thu Nov 29 05:58:01 2007
@@ -167,9 +167,11 @@
             return;
         }
 
+        // get a Session and make it available as a Request attribute
         Session session = authenticate(req);
+        req.setAttribute(Session.class.getName(), session);
+        
         try {
-
             MicroslingSlingHttpServletRequest request = new MicroslingSlingHttpServletRequest(
                 hReq, session, serviceLocator);
             MicroslingSlingHttpServletResponse response = new MicroslingSlingHttpServletResponse(

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxGetServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxGetServlet.java?rev=599443&r1=599442&r2=599443&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxGetServlet.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxGetServlet.java
Thu Nov 29 05:58:01 2007
@@ -87,18 +87,11 @@
     protected Map<String, Object> getSessionInfo(SlingHttpServletRequest request)
     throws RepositoryException, HttpStatusCodeException, SlingException {
         final Map<String, Object> result = new HashMap<String, Object>();
-
-        // TODO not very convenient way to get a Session...
-        final Resource root = request.getResourceResolver().getResource("/");
-        final Node rootNode = ((NodeProvider)root).getNode();
-        if(rootNode == null) {
-            throw new HttpStatusCodeException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Root
Node not found");
-        }
-        final Session s = rootNode.getSession();
-
+        
+        final Session s = (Session)request.getAttribute(Session.class.getName());
         result.put("workspace",s.getWorkspace().getName());
         result.put("userID",s.getUserID());
-
+        
         return result;
     }
 

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java?rev=599443&r1=599442&r2=599443&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java
Thu Nov 29 05:58:01 2007
@@ -102,13 +102,7 @@
                 s = currentNode.getSession();
             } else {
                 currentPath = SlingRequestPaths.getPathInfo(request);
-                // TODO not very convenient way to get a Session...
-                final Resource root = request.getResourceResolver().getResource("/");
-                final Node rootNode = ((NodeProvider)root).getNode();
-                if(rootNode == null) {
-                    throw new HttpStatusCodeException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Root
Node not found");
-                }
-                s = rootNode.getSession();
+                s = (Session)request.getAttribute(Session.class.getName());
             }
 
             final String [] pathsToDelete = request.getParameterValues(RP_DELETE_PATH);



Mime
View raw message